internal async Task Initialize() { IsInitialized = false; Debug.Write($"ダウンロードリクエストの復元を開始"); // キャッシュリクエストファイルのアクセサーを初期化 var videoSaveFolder = await HohoemaApp.GetApplicationLocalDataFolder(); _CacheRequestedItemsFileAccessor = new FileAccessor <IList <NicoVideoCacheRequest> >(videoSaveFolder, CACHE_REQUESTED_FILENAME); // ダウンロード待機中のアイテムを復元 await RestoreCacheRequestedItems(); // ダウンロードバックグラウンドタスクの情報を復元 await RestoreBackgroundDownloadTask(); IsInitialized = true; // ダウンロードリクエストされたものが削除済み動画だった場合に対応 // 削除されたDLリクエストを反映 await SaveDownloadRequestItems(); await TryNextCacheRequestedVideoDownload(); }
public void RepairAll() { _fileAccessor = new FileAccessor(_sourceFolder, null); var allXmlFileList = _fileAccessor.ListFiles("*." + _fileExtension, _sourceFolder, allDirectories: true).ToList(); List <string> needRepairXmlFileList = new List <string>(); List <string> msdnUrlList = new List <string>(); int modifyFileCounter = 0; for (int i = 0; i < allXmlFileList.Count(); i++) { var xmlFile = allXmlFileList[i]; if (RepairFile(xmlFile.AbsolutePath)) { modifyFileCounter++; } if (modifyFileCounter >= _batchSize) { break; } } string message = $"Repair done, Total file:{allXmlFileList.Count()}, updated file:{modifyFileCounter}"; WriteLine(message); logMessages.Add(message); }
public void WriteLog(String log) { if (!Enabled) { return; } //Debug.WriteLine(log); Fi.Tech.FireAndForget(async() => { await Task.Yield(); if (EnableConsoleLogging) { Console.Error.WriteLine(log); } List <String> Lines = new List <String>(); lock (this) { log = Regex.Replace(log, @"\s+", " "); String line = DateTime.Now.ToString("HH:mm:ss - ") + log; Lines.AddRange(logLinesCache); Lines.Add(line); logLinesCache.Clear(); } FileAccessor.AppendAllLines( Filename.Value, Lines ); }); }
public void CannotAccessDeletedFile() { ulong volumeSerial; FileId fileId; string path = GetFullPath("F"); using (FileStream fs = File.Create(path)) { volumeSerial = FileUtilities.GetVolumeSerialNumberByHandle(fs.SafeFileHandle); fileId = FileUtilities.ReadFileUsnByHandle(fs.SafeFileHandle).Value.FileId; } File.Delete(path); VolumeMap map = CreateMapOfAllLocalVolumes(); using (FileAccessor accessor = map.CreateFileAccessor()) { SafeFileHandle handle; FileAccessor.OpenFileByIdResult openResult = accessor.TryOpenFileById( volumeSerial, fileId, FileDesiredAccess.GenericRead, FileShare.ReadWrite, FileFlagsAndAttributes.None, out handle); using (handle) { XAssert.AreEqual(FileAccessor.OpenFileByIdResult.FailedToFindFile, openResult); XAssert.IsNull(handle); } } }
public static void Initialize() { var fileAccessor = new FileAccessor(SettingPath); TiltDistribution = (from e in fileAccessor.Read() select double.Parse(e[1])).ToList(); }
public async Task <ApiMessage> CreateFile(FileEntry fileEntry) { return(await ApiMessage.Wrap(async() => { await FileAccessor.Add(fileEntry); })); }
public async Task <IFeedGroup> AddFeedGroup(string label) { var folder = await GetFeedGroupFolder(); var feedStreamDataFolder = await GetFeedStreamDataFolder(); var feedGroup = new FeedGroup2(label); var fileAccessor = new FileAccessor <FeedGroup2>(folder, label + ".json"); feedGroup.HohoemaApp = this.HohoemaApp; feedGroup.FeedManager = this; FeedGroupDict.Add(feedGroup, fileAccessor); var itemId = feedGroup.Id.ToString(); var streamFileAccessor = new FileAccessor <List <FeedItem> >(feedStreamDataFolder, $"{itemId}.json"); FeedStreamFileAccessors.Add(feedGroup.Id, streamFileAccessor); _FeedGroupUpdaters.Add(feedGroup, HohoemaApp.BackgroundUpdater.RegistrationBackgroundUpdateScheduleHandler( feedGroup, feedGroup.Label, nameof(FeedGroup), label: $"FeedGroup:{feedGroup.Label}") ); await SaveOne(feedGroup); return(feedGroup); }
/// <summary> /// Creates an instance of <see cref="FileContentTableAccessorWin"/> /// </summary> /// <param name="volumeMap">Volume map.</param> public FileContentTableAccessorWin(VolumeMap volumeMap) { Contract.Requires(volumeMap != null); m_volumeMap = volumeMap; m_fileAccessor = m_volumeMap.CreateFileAccessor(); }
private static void Verify2(string tempFile, SerializationEngine serializer, IReadOnlyList <TestClass> list) { using (var data = new FileAccessor(tempFile)) { var lFile = new LowLevelAppendOnlyFile(data); var file = new GenericAppendOnlyFile <TestClass>(lFile, serializer); var records = file.ReadFrom(0).ToList(); // fails even when sorting the lists //list = list.OrderBy(it => it.Name).ToList(); //records = records.OrderBy(it => it.Name).ToList(); // verify that the index is built correctly for (var i = 0; i < COUNT; i++) { var r = records[i]; if (r.Name != list[i].Name) { throw new Exception($"Verify2: Expected [{list[i].Name}] but was [{r.Name}]."); } if (r.Address != list[i].Address) { throw new Exception($"Verify2: Expected [{list[i].Address}] but was [{r.Address}]."); } } } }
public static Result OpenFile(this FileSystemClient fs, out FileHandle handle, IFile file, OpenMode mode) { var accessor = new FileAccessor(fs, ref file, null, mode); handle = new FileHandle(accessor); return(Result.Success); }
public override void OnInspectorGUI() { EditorGUILayout.BeginVertical(); // EditorGUILayout.Space(); EditorGUILayout.LabelField("Map Size:", map.mapSize.x + "x" + map.mapSize.y); // EditorGUILayout.Space(); EditorGUILayout.LabelField( "Map Items:", EditorStyle.guiMessageStyle ); // var oldItems = map.mapItems; itemList.DoLayoutList(); serializedObject.ApplyModifiedProperties(); if (oldItems != map.mapItems) { LoadGemItemSpritesAsCache(); UpdateCalculations(); NewBrush(); } if (GUILayout.Button("Save Map Items")) { FileAccessor.WriteData(map.SaveItems(), "Save Gem Items", ReadPostName() + "_items.txt", "txt"); } if (GUILayout.Button("Load Map Items")) { map.LoadItems(FileAccessor.ReadTextFromFile("Load Gem Items", "txt")); } // if (map.mapItems.Count == 0) { EditorGUILayout.HelpBox( "You have not selected a texture 2D yet.", MessageType.Warning ); } else { EditorGUILayout.Space(); EditorGUILayout.Space(); EditorGUILayout.LabelField("Gem Size:", map.itemSize.x + "x" + map.itemSize.y); EditorGUILayout.LabelField("Grid Size In Units:", map.gridSize.x + "x" + map.gridSize.y); EditorGUILayout.LabelField("Pixels To Units:", map.pixelsToUnits.ToString()); UpdateBrush(map.currentItemBrush); } EditorGUILayout.EndVertical(); }
public async void TestException() { await Assert.ThrowsAsync <NotImplementedException>(async() => { await FileAccessor.RunAction("file", () => LongRunningTask(() => { throw new NotImplementedException(); }, 10)); }); }
public static void Start(string[] args) { var opt = new CommandLineOptions(); if (opt.Parse(args)) { _xmlDataFolder = opt.XmlPath; _docsetFolder = opt.DocsetPath; _outFolder = opt.OutFolder; _moniker = opt.Moniker; _logFile = opt.LogFilePath; } if (string.IsNullOrEmpty(_xmlDataFolder)) { WriteLine("xml path can't be null!"); return; } if (!Directory.Exists(_docsetFolder)) { WriteLine($"docset path '{_docsetFolder}' not exist"); return; } if (string.IsNullOrEmpty(opt.LogFilePath)) { _logFile = "log.txt"; } if (!string.IsNullOrEmpty(opt.Moniker)) { _monikers = opt.Moniker.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToHashSet(); } (_repoRootFolder, _fallbackRepoRootFolder) = ECMALoader.GetRepoRootBySubPath(_xmlDataFolder); _fileAccessor = new FileAccessor(_repoRootFolder, _fallbackRepoRootFolder); WriteLine(string.Format("xml path:'{0}'", _xmlDataFolder)); WriteLine(string.Format("docset path:'{0}'", _docsetFolder)); WriteLine(string.Format("out path:'{0}'", _outFolder)); WriteLine(string.Format("root path:'{0}'", _repoRootFolder)); try { StartGenerate(); } catch (Exception ex) { OPSLogger.LogSystemError(LogCode.ECMA2Yaml_InternalError, null, ex.ToString()); } finally { OPSLogger.Flush(_logFile); } }
public static void Main(string[] args) { Console.Error.WriteLine("uex started..."); List <string> listFileNames = new List <string>(); string outputFileName = "output.uex"; bool foundFileName = false; for (int i = 0; i < args.Length; i++) { if (args[i].StartsWith("/") && !foundFileName) { if (args[i].StartsWith("/out:")) { outputFileName = args[i].Substring(5); } } else { // is file name foundFileName = true; listFileNames.Add(args[i]); } } PackageObjectModel ue = new PackageObjectModel(); OpenDocumentDataFormat odf = new OpenDocumentDataFormat(); System.Text.StringBuilder sb = new System.Text.StringBuilder(); int totalInstances = 0; string exefilename = System.Environment.GetCommandLineArgs()[0]; string workingdir = System.IO.Path.GetDirectoryName(exefilename); for (int i = 0; i < listFileNames.Count; i++) { string relpath = listFileNames[i]; if (relpath.StartsWith(workingdir)) { relpath = relpath.Substring(workingdir.Length); } relpath = "Content/" + relpath; byte[] filedata = System.IO.File.ReadAllBytes(listFileNames[i]); ue.FileSystem.AddFile(relpath, filedata); } FileAccessor faout = new FileAccessor(outputFileName, true, true); Document.Save(ue, odf, faout); Console.Error.WriteLine("uex written to {0}!", outputFileName); }
public void ConversionLog(String log) { if (!Enabled) { return; } try { FileAccessor.AppendAllLines( Filename, new String[] { DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss - ") + log }); } catch (Exception) { } }
public async Task<bool> LoadFeedStream(FileAccessor<List<FeedItem>> fileAccessor) { try { var items = await fileAccessor.Load(); this.FeedItems = items ?? new List<FeedItem>(); return true; } catch { return false; } }
public void BDadosLogDropLines() { if (!Enabled) { return; } try { FileAccessor.AppendAllLines( Filename, new String[] { "", "", "" }); } catch (Exception) { } }
/// <summary> /// ユーザーIDに基づいたユーザー設定を0.4.0以降のユーザー設定として移行します。 /// すでに0.4.0環境のユーザー設定が存在する場合や /// ユーザーIDに基づいたユーザー設定が存在しない場合は何もしません。 /// 読み込みに成功するとUserSettingsが上書き更新されます。 /// ユーザーIDに基づいたユーザー設定はフォルダごと削除されます。 /// </summary> /// <param name="userId"></param> /// <returns></returns> public async Task MigrateLegacyUserSettings(string userId) { var folder = await ApplicationData.Current.LocalFolder.TryGetItemAsync(userId) as StorageFolder; if (folder != null) { var fileAccessor = new FileAccessor <CacheSettings>(ApplicationData.Current.LocalFolder, HohoemaUserSettings.CacheSettingsFileName); if (false == await fileAccessor.ExistFile()) { await MoveFiles(folder, ApplicationData.Current.LocalFolder); await LoadUserSettings(); } } }
public void CanAccessMultipleFilesById() { var fileIdAndVolumeSerialPairs = new List <Tuple <FileId, ulong> >(); for (int i = 0; i < 3; i++) { string path = GetFullPath("F" + i); using (FileStream fs = File.Create(path)) { fs.WriteByte((byte)i); ulong volumeSerial = FileUtilities.GetVolumeSerialNumberByHandle(fs.SafeFileHandle); FileId fileId = FileUtilities.ReadFileUsnByHandle(fs.SafeFileHandle).Value.FileId; fileIdAndVolumeSerialPairs.Add(Tuple.Create(fileId, volumeSerial)); } } VolumeMap map = CreateMapOfAllLocalVolumes(); using (FileAccessor accessor = map.CreateFileAccessor()) { for (int i = 0; i < fileIdAndVolumeSerialPairs.Count; i++) { Tuple <FileId, ulong> fileIdAndVolumeSerial = fileIdAndVolumeSerialPairs[i]; SafeFileHandle handle; FileAccessor.OpenFileByIdResult openResult = accessor.TryOpenFileById( fileIdAndVolumeSerial.Item2, fileIdAndVolumeSerial.Item1, FileDesiredAccess.GenericRead, FileShare.ReadWrite, FileFlagsAndAttributes.None, out handle); using (handle) { XAssert.AreEqual(openResult, FileAccessor.OpenFileByIdResult.Succeeded); XAssert.IsNotNull(handle); using (var fileStream = new FileStream(handle, FileAccess.Read)) { XAssert.AreEqual(i, fileStream.ReadByte()); } } } } }
private static void Generate2(string tempFile, SerializationEngine serializer, IReadOnlyList <TestClass> list, Action <Action <int> > loop) { Console.WriteLine($"Using {tempFile}"); using (var data = new FileAccessor(tempFile)) { CreateAndProcessFile(data, serializer, list, loop); } // close and reopen the file (rebuilds the index) ShowTimeIncludingOpsPerSec("rebuild index", () => { using (var data = new FileAccessor(tempFile)) { var lFile = new LowLevelAppendOnlyFile(data); } }); }
public LocalMylist CreatePlaylist(string id, string name) { var sortIndex = _Playlists.Count > 0 ? _Playlists.Max(x => x.SortIndex) + 1 : 0; var playlist = new LocalMylist(id, name) { HohoemaPlaylist = this, SortIndex = sortIndex }; var playlistFileAccessor = new FileAccessor <LocalMylist>(PlaylistsSaveFolder, playlist.Name + ".json"); _PlaylistFileAccessorMap.Add(playlist.Id, playlistFileAccessor); _Playlists.Add(playlist); playlistFileAccessor.Save(playlist).ConfigureAwait(false); return(playlist); }
private void _parseAllClassDefinitions(string[] paths) { foreach (var path in paths) { var fileAccessor = new FileAccessor(path); var reader = ServiceLocator.Container.GetInstance <IReader>(fileAccessor.Data); var d2ODefUnpacker = new D2OClassDefinitionUnpacker(); d2ODefUnpacker.Unpack(reader); if (_constants.Debug) { _logger.Log(LogType.Debug, Path.GetFileName(path) + $" unpacked successfully with {d2ODefUnpacker.Unpacked.Count} class definitions"); } _definitions.AddRange(d2ODefUnpacker.Unpacked); _files.Add(new D2OFile(fileAccessor, d2ODefUnpacker)); } }
public async Task <ActionResult> DownloadFile() { var path = Request.QueryString.ToString().TrimStart('?'); var accessor = await FileAccessor.Create(path, User); if (!accessor.IsAllowed()) { return(new UnauthorizedResult()); } if (accessor.Blob.IsMedia()) { return(await RangeFileContentResult.From(accessor.Blob)); } else { return(await File(accessor.Blob)); } }
static void Main(string[] args) { var fileAccessor = new FileAccessor(); var parsingService = new FileParsingService(); var writer = new JsonFileWriter(); Console.WriteLine("Please enter the full path to the input CSV file:"); var inputPath = Console.ReadLine(); Console.WriteLine("Please enter the full path for the output JSON file:"); var outputPath = Console.ReadLine(); var lines = fileAccessor.ReadFile(inputPath); if (lines == null) { Console.WriteLine($"Was not able to read {inputPath}"); return; } var dto = parsingService.Parse(lines); if (dto == null) { Console.WriteLine($"Error parsing file: {inputPath}"); return; } var wasSuccessful = writer.WriteFileAsJson(outputPath, dto); if (wasSuccessful) { Console.WriteLine($"Successfully wrote the JSON to {outputPath}"); } else { Console.WriteLine($"Failed to write the JSON to {outputPath}"); } Console.ReadLine(); }
public ITask CreateRenderBms() { return(Build("BMS to WAV", task => { var files = GetInputFiles(task); if (!files.Any()) { task.Message = "No input files."; return false; } var options = new ChartRendererOptions { UseSourceDataForSamples = true }; ParallelProgress(task, files, file => { using (var stream = OpenRead(task, file)) { var accessor = new FileAccessor(Path.GetDirectoryName(file.Name)); var commands = _bmsStreamReader.Read(stream); var resolved = _bmsRandomResolver.Resolve(commands); var decoded = _bmsDecoder.Decode(resolved); decoded.Chart.PopulateLinearOffsets(); var sounds = _bmsSoundLoader.Load(decoded.SoundMap, accessor); var rendered = _chartRenderer.Render(decoded.Chart.Events, sounds, options); var normalized = _audioDsp.Normalize(rendered, 1.0f, true); using (var outFile = OpenWriteSingle(task, file, i => $"{i}.render.wav")) { var riff = _riffPcm16SoundEncoder.Encode(normalized); _riffStreamWriter.Write(outFile, riff); outFile.Flush(); } } }); return true; })); }
public void TestParallel() { int hit = 0; Task task1 = FileAccessor.RunAction("onefile", () => LongRunningTask(() => { Assert.True(hit == 1); hit++; }, 100)); Task task2 = FileAccessor.RunAction("anotherfile", () => LongRunningTask(() => { Assert.True(hit == 0); hit++; }, 10)); Task.WaitAll(task1, task2); Assert.True(hit == 2); }
public FileHandle OpenFile(string path, OpenMode mode) { FindFileSystem(path.AsSpan(), out FileSystemAccessor fileSystem, out ReadOnlySpan <char> subPath) .ThrowIfFailure(); FileHandle handle; if (IsEnabledAccessLog() && fileSystem.IsAccessLogEnabled) { TimeSpan startTime = Time.GetCurrent(); FileAccessor file = fileSystem.OpenFile(subPath.ToString(), mode); handle = new FileHandle(file); TimeSpan endTime = Time.GetCurrent(); OutputAccessLog(startTime, endTime, handle, $", path: \"{path}\", open_mode: {mode}"); } else { FileAccessor file = fileSystem.OpenFile(subPath.ToString(), mode); handle = new FileHandle(file); } return(handle); }
public async Task Load(IReadOnlyList <StorageFile> files) { var feedGroupFolder = await GetFeedGroupFolder(); var feedStreamDataFolder = await GetFeedStreamDataFolder(); var legacyFeedSettingsFolder = await HohoemaApp.GetFeedSettingsFolder(); foreach (var file in files) { if (file.FileType == ".json") { var fileName = file.Name; var fileAccessor = new FileAccessor <FeedGroup2>(feedGroupFolder, fileName); try { var item = await fileAccessor.Load(FeedGroupSerializerSettings); bool isLoadFromLegacyFile = false; if (item == null) { var legacyFeedGroupFileAccessor = new FileAccessor <FeedGroup>(legacyFeedSettingsFolder, fileName); var item_legacy = await legacyFeedGroupFileAccessor.Load(FeedGroupSerializerSettings); if (item_legacy != null) { item = new FeedGroup2(item_legacy); isLoadFromLegacyFile = true; } } if (item != null) { item.HohoemaApp = this.HohoemaApp; item.FeedManager = this; FeedGroupDict.Add(item, fileAccessor); var itemId = item.Id.ToString(); var streamFileAccessor = new FileAccessor <List <FeedItem> >(feedStreamDataFolder, $"{itemId}.json"); FeedStreamFileAccessors.Add(item.Id, streamFileAccessor); await item.LoadFeedStream(streamFileAccessor); // 古いファイルは新しいフォーマットで上書きして消しておく if (isLoadFromLegacyFile) { await SaveOne(item, isSkipSyncRoaming : true); } // FeedGroupの更新処理情報を構築 _FeedGroupUpdaters.Add(item, HohoemaApp.BackgroundUpdater.RegistrationBackgroundUpdateScheduleHandler( item, item.Label, nameof(FeedGroup), label: $"FeedGroup:{item.Label}") ); Debug.WriteLine($"FeedManager: [Sucesss] load {item.Label}"); } else { Debug.WriteLine($"FeedManager: [?] .json but not FeedGroup file < {fileName}"); } } catch { Debug.WriteLine($"FeedManager: [Failed] load {file.Path}"); } } } }
private String GetPartyFileNameFromUser(FileAccessor fileAccessor) { var open = new System.Windows.Forms.OpenFileDialog(); open.InitialDirectory = fileAccessor.SaveDirectory; var result = open.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) return String.Empty; if (String.IsNullOrEmpty(open.FileName)) { System.Windows.MessageBox.Show("Empty file name. Cannot open the file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return String.Empty; } return open.FileName; }
public FileAccessorWrap(FileAccessor fileAccessor) { this.fileAccessor = fileAccessor; }
public ECMALoader(FileAccessor fileAccessor) { _fileAccessor = fileAccessor; FallbackFiles = new ConcurrentBag <string>(); }
public static void Run( string xmlDirectory, string outputDirectory, string fallbackXmlDirectory = null, string fallbackOutputDirectory = null, Action <LogItem> logWriter = null, string logContentBaseDirectory = null, string sourceMapFilePath = null, string publicGitRepoUrl = null, string publicGitBranch = null, ECMA2YamlRepoConfig config = null) { if (xmlDirectory == null) { throw new ArgumentNullException(xmlDirectory); } if (!Directory.Exists(xmlDirectory)) { throw new DirectoryNotFoundException($"{nameof(xmlDirectory)} {xmlDirectory} does not exist."); } if (outputDirectory == null) { throw new ArgumentNullException(outputDirectory); } if (!string.IsNullOrEmpty(fallbackXmlDirectory)) { if (!Directory.Exists(fallbackXmlDirectory)) { throw new DirectoryNotFoundException($"{nameof(fallbackXmlDirectory)} {fallbackXmlDirectory} does not exist."); } if (string.IsNullOrEmpty(fallbackOutputDirectory)) { throw new ArgumentNullException(fallbackOutputDirectory, $"{nameof(fallbackOutputDirectory)} cannot be empty if {nameof(fallbackXmlDirectory)} is present."); } } if (!string.IsNullOrEmpty(logContentBaseDirectory)) { OPSLogger.PathTrimPrefix = logContentBaseDirectory.NormalizePath().AppendDirectorySeparator(); } if (!string.IsNullOrEmpty(fallbackXmlDirectory)) { OPSLogger.FallbackPathTrimPrefix = fallbackXmlDirectory.NormalizePath().AppendDirectorySeparator(); } if (logWriter != null) { OPSLogger.WriteLogCallback = logWriter; } var fileAccessor = new FileAccessor(xmlDirectory, fallbackXmlDirectory); ECMALoader loader = new ECMALoader(fileAccessor); Console.WriteLine("Loading ECMAXML files..."); var store = loader.LoadFolder(""); if (store == null) { return; } Console.WriteLine("Building loaded files..."); Console.WriteLine($"ECMA2YamlRepoConfig:{JsonConvert.SerializeObject(config)}"); store.UWPMode = config?.UWP ?? false; store.Build(); if (!string.IsNullOrEmpty(publicGitRepoUrl) && !string.IsNullOrEmpty(publicGitBranch)) { store.TranlateContentSourceMeta(publicGitRepoUrl, publicGitBranch); } else { Console.WriteLine("Not enough information, unable to generate git url related metadata. -publicRepo {0}, -publicBranch {1}", publicGitRepoUrl, publicGitBranch); } var xmlYamlFileMapping = SDPYamlGenerator.Generate(store, outputDirectory, flatten: config?.Flatten ?? true, withVersioning: true); if (loader.FallbackFiles != null && loader.FallbackFiles.Any() && !string.IsNullOrEmpty(fallbackOutputDirectory)) { if (!Directory.Exists(fallbackOutputDirectory)) { Directory.CreateDirectory(fallbackOutputDirectory); } foreach (var fallbackFile in loader.FallbackFiles) { if (xmlYamlFileMapping.TryGetValue(fallbackFile, out var originalYamls)) { foreach (var originalYaml in originalYamls) { var newYaml = originalYaml.Replace(outputDirectory, fallbackOutputDirectory); File.Copy(originalYaml, newYaml, overwrite: true); File.Delete(originalYaml); } xmlYamlFileMapping.Remove(fallbackFile); } } } if (!string.IsNullOrEmpty(sourceMapFilePath)) { WriteYamlXMLFileMap(sourceMapFilePath, xmlYamlFileMapping); } var toc = SDPTOCGenerator.Generate(store); var tocOutputDirectory = string.IsNullOrEmpty(config?.BatchId) ? outputDirectory : Path.Combine(outputDirectory, config.BatchId); if (!Directory.Exists(tocOutputDirectory)) { Directory.CreateDirectory(tocOutputDirectory); } YamlUtility.Serialize(Path.Combine(tocOutputDirectory, "toc.yml"), toc, "YamlMime:TableOfContent"); }
private void Load(Object sender, RoutedEventArgs e) { fileAccessor = SetupFileAccessor(); var party = SetupParty(fileAccessor); partyViewModel = new PartyViewModel(party); Title = GetVersion(); DataContext = partyViewModel; round = 0; }
private String SaveNewParty(FileAccessor fileAccessor) { var save = new System.Windows.Forms.SaveFileDialog(); save.InitialDirectory = fileAccessor.SaveDirectory; var result = save.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) return String.Empty; if (String.IsNullOrEmpty(save.FileName)) { System.Windows.MessageBox.Show("Empty file name. Cannot open the file.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); return String.Empty; } return save.FileName; }
private IEnumerable<ActionParticipant> SetupParty(FileAccessor fileAccessor) { var result = System.Windows.MessageBox.Show("Load a party?", "Load?", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { var partyFileName = GetPartyFileNameFromUser(fileAccessor); return fileAccessor.LoadParty(partyFileName); } else { var partyFileName = SaveNewParty(fileAccessor); if (String.IsNullOrEmpty(partyFileName)) { System.Windows.MessageBox.Show("No party file selected. Cannot continue operations. Closing program.", "Error: No Party File to Auto Save To", MessageBoxButton.OK); Close(); } var party = new List<ActionParticipant>(); fileAccessor.SaveParty(party, partyFileName); return party; } }