private void LoadPreviousDiary() { String lastOpened = Properties.Settings.Default.LastOpenedLifeLog; if (!String.IsNullOrWhiteSpace(lastOpened) && new FileInfo(lastOpened).Exists) { Diary Previous = new Diary(lastOpened); //check if real by looking it it was between now and the year 2015 //This software didnt existed before 2016. Do not adjust this number otherwise this feature will break on old files if (Previous.CreationDate.CompareTo(DateTime.Now) < 0 && Previous.CreationDate.CompareTo(new DateTime(2015,01,01)) > 0) { //open it when all checks out OpenDiary = Previous; ExceptionlessClient.Default.SubmitLog("Loaded previous Diary"); } } }
public void NewFile() { //TODO: Check if the currently open one got saved ExceptionlessClient.Default.SubmitFeatureUsage(nameof(NewFile)); OpenDiary = new Diary {CreationDate = DateTime.UtcNow}; OnPropertyChanged(nameof(OpenDiary)); }
/// <summary> /// Load Diary from Harddrive /// </summary> /// <param name="Path">Path to specify where to load from. Will use "PathToDiaryFile" if not set.</param> /// <exception cref="FileNotFoundException">The file cannot be found. </exception> /// <exception cref="DirectoryNotFoundException">The specified path is invalid, such as being on an unmapped drive. </exception> /// <exception cref="IOException"><paramref name="path" /> includes an incorrect or invalid syntax for file name, directory name, or volume label. </exception> public void Load(String Path = null) { if (Path == null) Path = PathToDiaryFile; else PathToDiaryFile = Path; XmlSerializer serializer = new XmlSerializer(typeof(Diary)); using (StreamReader reader = new StreamReader(Path)) { Diary LoadedDiary = new Diary(); LoadedDiary = (Diary)serializer.Deserialize(reader); //TODO: This can be done better //"this = LoadedDiary" is illegal CreationDate = LoadedDiary.CreationDate; PathToDiaryFile = LoadedDiary.PathToDiaryFile; AllEntries = LoadedDiary.AllEntries; } ExceptionlessClient.Default.CreateLog("Diary loaded"); }