--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-04-08 15:31:44 -07:00
6 changed files with 72 additions and 23 deletions

View File

@@ -10,7 +10,7 @@ using Orchard.Recipes.Models;
namespace Orchard.Recipes.Services {
public class RecipeJournalManager : IRecipeJournal {
private readonly IStorageProvider _storageProvider;
private readonly string _recipeJournalFolder = "RecipeJournal" + Path.DirectorySeparatorChar;
private const string RecipeJournalFolder = "RecipeJournal";
private const string WebConfig =
@"
<configuration>
@@ -92,10 +92,10 @@ namespace Orchard.Recipes.Services {
private IStorageFile GetJournalFile(string executionId) {
IStorageFile journalFile;
var journalPath = Path.Combine(_recipeJournalFolder, executionId);
var journalPath = _storageProvider.Combine(RecipeJournalFolder, executionId);
try {
if (_storageProvider.TryCreateFolder(_recipeJournalFolder)) {
var webConfigPath = Path.Combine(_recipeJournalFolder, "web.config");
if (_storageProvider.TryCreateFolder(RecipeJournalFolder)) {
var webConfigPath = _storageProvider.Combine(RecipeJournalFolder, "web.config");
var webConfigFile = _storageProvider.CreateFile(webConfigPath);
WriteWebConfig(webConfigFile);
}
@@ -121,10 +121,9 @@ namespace Orchard.Recipes.Services {
private static void WriteJournal(IStorageFile journalFile, XElement journal) {
string content = journal.ToString();
using (var stream = journalFile.OpenWrite()) {
using (var stream = journalFile.CreateFile()) {
using (var tw = new StreamWriter(stream)) {
tw.Write(content);
stream.SetLength(stream.Position);
}
}
}