public static ObservableRangeCollection<ArticleProperty> ArticlePropertyListDeserialize(string property) { var ArtPropList = new ObservableRangeCollection<ArticleProperty>(); var ISD = new IsolatedStorageDeserializer<ObservableRangeCollection<ArticleProperty>>(); ArtPropList = ISD.XmlDeserialize(property, CurrentData.AppMode); if (ArtPropList == null) switch (property) { case "Income": ArtPropList = new ObservableRangeCollection<ArticleProperty> { new ArticleProperty("Зарплата",1), new ArticleProperty("Подработка",2), }; break; case "Outlay": ArtPropList = new ObservableRangeCollection<ArticleProperty> { new ArticleProperty("Продукты",-1), new ArticleProperty("За квартиру",-2), }; break; default: ArtPropList = new ObservableRangeCollection<ArticleProperty>(); break; } return ArtPropList; }
public static bool isRightPassword(string str) { var ISD = new IsolatedStorageDeserializer<UserData>(); UserData userData = ISD.XmlDeserialize("UserData"); if (GetSHA256Hash(str) == userData.Password) return true; else return false; }
public static bool IsSetPass() { var ISD = new IsolatedStorageDeserializer<UserData>(); UserData userData = ISD.XmlDeserialize("UserData"); try { if (userData.Password == "") return false; else return true; } catch (NullReferenceException) { return false; } }
private static void ArtSerialize(Article art) { IsolatedStorageDeserializer<List<Article>> ISD = new IsolatedStorageDeserializer<List<Article>>(); var articleList = new List<Article>(); IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication(); if (!storage.DirectoryExists(CurrentData.AppMode + "\\" + "Articles\\" + art.ADateTime.ToString("M.y"))) storage.CreateDirectory(CurrentData.AppMode + "\\" + "Articles\\" + art.ADateTime.ToString("M.y")); int id = 1; if (storage.FileExists(CurrentData.AppMode + "\\" + "Articles\\" + art.ADateTime.ToString("M.y") + "\\" + art.ADateTime.ToString("d.M.y") + ".xml")) { articleList = ISD.XmlDeserialize(art.ADateTime.ToString("d.M.y"), CurrentData.AppMode + "\\" + "Articles" + "\\" + art.ADateTime.ToString("M.y")); if (articleList == null) articleList = new List<Article>(); else id = SearchFreeID(articleList); } art.DateID = id; string property; if (art.IsIncome) property = "Income"; else property = "Outlay"; articleList.Add(art); AssignmentArticleAccountID(articleList); AssignmentArticleIncomeOrOutlayID(articleList, property); ISD.XmlSerialize(articleList, art.ADateTime.ToString("d.M.y"), true, CurrentData.AppMode + "\\" + "Articles" + "\\" + art.ADateTime.ToString("M.y")); }
public static void SetIncomeAndOutlayForNDays(int nDays) { //Необходимо проведение уточнения по количеству var ISD = new IsolatedStorageDeserializer<List<Article>>(); var lastOpList = ISD.XmlDeserialize(DateTime.Today.ToString("d.M.y"), CurrentData.AppMode + "\\" + "Articles" + "\\" + DateTime.Today.ToString("M.y")); if (lastOpList == null) lastOpList = new List<Article>(); for (int i = 1; i < (nDays + 1); i++) { var previouslyDayList = ISD.XmlDeserialize(DateTime.Now.AddDays(-i).ToString("d.M.y"), CurrentData.AppMode + "\\" + "Articles" + "\\" + DateTime.Now.AddDays(-i).ToString("M.y")); if (previouslyDayList != null && previouslyDayList.Count != 0) lastOpList.InsertRange(0, previouslyDayList); } for (int i = 0; i < lastOpList.Count; i++) if (lastOpList[i].NameID == 0) { lastOpList.RemoveAt(i); i--; } Dictionary<int, double> OutlayDict = new Dictionary<int, double>(); Dictionary<int, double> IncomeDict = new Dictionary<int, double>(); CreateDictionaties(lastOpList, OutlayDict, IncomeDict); foreach (ArticleProperty aP in CurrentData.ArtPropList("Income")) if (IncomeDict.ContainsKey(aP.ID)) aP.Summ = IncomeDict[aP.ID]; foreach (ArticleProperty aP in CurrentData.ArtPropList("Income")) if (OutlayDict.ContainsKey(aP.ID)) aP.Summ = OutlayDict[aP.ID]; }
public static void SetCurrentAccountsStatusToList(double n) { //Для отладки var ISD = new IsolatedStorageDeserializer<ObservableRangeCollection<AccountsObservableRangeCollection>>(); var listForDeserialize = new ObservableRangeCollection<AccountsObservableRangeCollection>(); listForDeserialize.Add(new AccountsObservableRangeCollection(CurrentData.ArtAccountList.AccountsList , (new AccountsObservableRangeCollection()).SetRecordDayStr((int)n))); ISD.XmlSerialize(listForDeserialize, DateTime.Today.AddDays(-(int)n).ToString("M.y"), true, CurrentData.AppMode + "\\" + "AccountStatuses"); }
public static void SetCurrentAccountsStatusToList() { //Решить проблему с годом(потом) var ISD = new IsolatedStorageDeserializer<ObservableRangeCollection<AccountsObservableRangeCollection>>(); CurrentData.ArtAccountList.SetRecordDayStr(); ISD.XmlSerialize(CurrentData.AccountsListsAtThisMonth, CurrentData.ArtAccountList.GetRecordDay().ToString("M.y") , true, CurrentData.AppMode + "\\" + "AccountStatuses"); }
public static ObservableRangeCollection<AccountsObservableRangeCollection> GetPreviouslyAccountsList(int monthNumberToPast = 0) { var ISD = new IsolatedStorageDeserializer<ObservableRangeCollection<AccountsObservableRangeCollection>>(); var PrevAccLists = ISD.XmlDeserialize(DateTime.Today.AddMonths(-monthNumberToPast).ToString("M.y"), CurrentData.AppMode + "\\" + "AccountStatuses"); if (PrevAccLists != null) return PrevAccLists; else return new ObservableRangeCollection<AccountsObservableRangeCollection>(); }
public static List<Article> GetLastOperations() { //Необходимо проведение уточнения по количеству int count = 15; var ISD = new IsolatedStorageDeserializer<List<Article>>(); var lastOpList = ISD.XmlDeserialize(DateTime.Today.ToString("d.M.y"), CurrentData.AppMode + "\\" + "Articles" + "\\" + DateTime.Today.ToString("M.y")); if (lastOpList == null) lastOpList = new List<Article>(); int n = -1; while (lastOpList.Count < count) { var previouslyDayList = ISD.XmlDeserialize(DateTime.Now.AddDays(n).ToString("d.M.y"), CurrentData.AppMode + "\\" + "Articles" + "\\" + DateTime.Now.AddDays(n).ToString("M.y")); if (previouslyDayList == null || previouslyDayList.Count == 0) break; lastOpList.InsertRange(0, previouslyDayList); n--; } for (int i = 0; i < lastOpList.Count; i++) if (lastOpList[i].NameID == 0) { lastOpList.RemoveAt(i); i--; } return lastOpList; }
public static void DeleteToDayArts() { var ISD = new IsolatedStorageDeserializer<List<Article>>(); var artList = ISD.XmlDeserialize(DateTime.Today.ToString("d.M.y"), CurrentData.AppMode + "\\" + "Articles" + "\\" + DateTime.Today.ToString("M.y")); if (artList == null) { artList = new List<Article>(); return; } foreach (Article a in artList) { AddSummToAccountProperty(- a.Number, a.IsIncome, a.AccountID); AddSummToIncomeOrOutlayProperty(- a.Number, a.IsIncome, a.NameID); } IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication(); if (!storage.DirectoryExists(CurrentData.AppMode + "\\" + "Articles\\" + DateTime.Today.ToString("M.y"))) storage.CreateDirectory(CurrentData.AppMode + "\\" + "Articles\\" + DateTime.Today.ToString("M.y")); if (storage.FileExists(CurrentData.AppMode + "\\" + "Articles\\" + DateTime.Today.ToString("M.y") + "\\" + DateTime.Today.ToString("d.M.y") + ".xml")) storage.DeleteFile(CurrentData.AppMode + "\\" + "Articles\\" + DateTime.Today.ToString("M.y") + "\\" + DateTime.Today.ToString("d.M.y") + ".xml"); CurrentData.LastOperationsList = new List<Article>(); }
public static void DeleteArt(Article a) { var ISD = new IsolatedStorageDeserializer<List<Article>>(); var artList = ISD.XmlDeserialize(a.ADateTime.ToString("d.M.y"), CurrentData.AppMode + "\\" + "Articles" + "\\" + a.ADateTime.ToString("M.y")); if (artList == null) artList = new List<Article>(); SearchAndRemoveArticle(artList, a); ISD.XmlSerialize(artList, a.ADateTime.ToString("d.M.y"), true, CurrentData.AppMode + "\\" + "Articles" + "\\" + a.ADateTime.ToString("M.y")); CurrentData.LastOperationsList = new List<Article>(); AddSummToAccountProperty(- a.Number, a.IsIncome, a.AccountID); AddSummToIncomeOrOutlayProperty(-a.Number, a.IsIncome, a.NameID); }
public static void ArticlePropertyListSerialize(string property, ObservableRangeCollection<ArticleProperty> ArtPropList) { var ISD = new IsolatedStorageDeserializer<ObservableRangeCollection<ArticleProperty>>(); ISD.XmlSerialize(ArtPropList, property, true, CurrentData.AppMode); }
public static void SaveNewPass(string str) { UserData userData = new UserData { Password = GetSHA256Hash(str) }; var ISD = new IsolatedStorageDeserializer<UserData>(); ISD.XmlSerialize(userData, "UserData", true); }
public static void DeletePass() { UserData userData = new UserData { Password = "" }; var ISD = new IsolatedStorageDeserializer<UserData>(); ISD.XmlSerialize(userData, "UserData", true); }