public static void Persist(AccountGroups groups) { foreach (var group in groups.Groups) { Persist(group); } var guids = groups.Groups.Select(g => g.Guid); var files = Directory.EnumerateFiles("data"); var toDelete = files .Where(f => !guids.Contains(Guid.Parse(Path.GetFileName(f)))); foreach (var f in toDelete) { File.Delete(f); } }
public static AccountGroups Load() { var groups = new AccountGroups(); if (!Directory.Exists("data")) { return(groups); } foreach (var path in Directory.EnumerateFiles("data")) { AccountGroup g = Load(path); groups.Groups.Add(g); } return(groups); }
public string Validate(List <Entity <string, PMProjectRate, PMProject> > data1, List <Entity <string, PMTaskRate, PMTask> > data2, List <Entity <int?, PMAccountGroupRate, PMAccountGroup> > data3, List <Entity <int?, PMItemRate, InventoryItem> > data4, List <Entity <int?, PMEmployeeRate, BAccount> > data5) { string errors = null; StringBuilder sb = new StringBuilder(); foreach (Entity <string, PMProjectRate, PMProject> i1 in data1) { foreach (Entity <string, PMTaskRate, PMTask> i2 in data2) { foreach (Entity <int?, PMAccountGroupRate, PMAccountGroup> i3 in data3) { foreach (Entity <int?, PMItemRate, InventoryItem> i4 in data4) { foreach (Entity <int?, PMEmployeeRate, BAccount> i5 in data5) { bool isDuplicate = true; if (i1.Key != null && !Projects.ContainsKey(i1.Key.ToUpper().Trim())) { isDuplicate = false; continue; } if (i2.Key != null && !Tasks.ContainsKey(i2.Key.ToUpper().Trim())) { isDuplicate = false; continue; } if (i3.Key != null && !AccountGroups.ContainsKey(i3.Key)) { isDuplicate = false; continue; } if (i4.Key != null && !Inventory.ContainsKey(i4.Key)) { isDuplicate = false; continue; } if (i5.Key != null && !Employees.ContainsKey(i5.Key)) { isDuplicate = false; continue; } if (isDuplicate) { bool hasError = false; if (i1.Key != null) { sb.AppendFormat("{0}:{1}, ", PXMessages.LocalizeNoPrefix(Messages.Project), i1.Key); hasError = true; } if (i2.Key != null) { sb.AppendFormat("{0}:{1}, ", PXMessages.LocalizeNoPrefix(Messages.ProjectTask), i2.Key); hasError = true; } if (i3.Key != null) { sb.AppendFormat("{0}:{1}, ", PXMessages.LocalizeNoPrefix(Messages.AccountGroup), i3.Object.GroupCD); hasError = true; } if (i4.Key != null) { sb.AppendFormat("{0}:{1}, ", PXMessages.LocalizeNoPrefix(IN.Messages.InventoryItem), i4.Object.InventoryCD); hasError = true; } if (i5.Key != null) { sb.AppendFormat("{0}:{1}, ", PXMessages.LocalizeNoPrefix(EP.Messages.Employee), i5.Object.AcctCD); hasError = true; } if (hasError) { sb.AppendLine(""); } } } } } } } if (sb.Length > 0) { errors = string.Format("{0} = {1} ", PXMessages.LocalizeNoPrefix(Messages.RateCode), RateCode) + sb.ToString(); } return(errors); }