private static void AddAirsCat() { string errMess; int errCode = 0; var shExpCats = sh.ExpCtgs(out errCode, out errMess); AlohaFly.DataExtension.DataCatalogsSingleton.Instance.DataCatalogsFill(); foreach (var airc in AlohaFly.DataExtension.DataCatalogsSingleton.Instance.AirCompanies.Where(a => a.SHId < 80)) { if (!shExpCats.ListExpCtgs.Select(a => a.Name).Contains(airc.Name.Trim())) { bool res = sh.AddExpCtgs(airc.Name.Trim(), out errCode, out errMess); shExpCats = sh.ExpCtgs(out errCode, out errMess); } if (shExpCats.ListExpCtgs.Any(a => a.Name == airc.Name.Trim())) { airc.SHId = shExpCats.ListExpCtgs.FirstOrDefault(a => a.Name == airc.Name.Trim()).Rid; AlohaFly.DBProvider.Client.UpdateAirCompany(airc); } } foreach (var p in AlohaFly.DataExtension.DataCatalogsSingleton.Instance.Payments.Where(a => a.ToGo && a.SHId < 80)) { if (!shExpCats.ListExpCtgs.Select(a => a.Name).Contains(p.Name)) { bool res = sh.AddExpCtgs(p.Name, out errCode, out errMess); shExpCats = sh.ExpCtgs(out errCode, out errMess); } if (shExpCats.ListExpCtgs.Any(a => a.Name == p.Name)) { p.SHId = shExpCats.ListExpCtgs.FirstOrDefault(a => a.Name == p.Name).Rid; AlohaFly.DBProvider.Client.UpdatePayment(p); } } }
private static bool AddAirCompany(AirCompany airc, out string ErrMesssage) { try { logger.Debug($"AddAirCompany Order {airc.Name}"); ErrMesssage = ""; var shExpCats = sh.ExpCtgs(out int errCode, out string errMess); if (!shExpCats.ListExpCtgs.Select(a => a.Name).Contains(airc.Name.Trim())) { bool res = sh.AddExpCtgs(airc.Name.Trim(), out errCode, out errMess); if (!res) { ErrMesssage = "Не могу добавить авиакомпанию" + Environment.NewLine + errMess + Environment.NewLine; return(false); } shExpCats = sh.ExpCtgs(out errCode, out errMess); } if (shExpCats.ListExpCtgs.Any(a => a.Name == airc.Name.Trim())) { airc.SHId = shExpCats.ListExpCtgs.FirstOrDefault(a => a.Name == airc.Name.Trim()).Rid; DBProvider.Client.UpdateAirCompany(airc); logger.Debug($"AddAirCompany ok {airc.Name}"); return(true); } else { ErrMesssage = "Не могу добавить авиакомпанию" + Environment.NewLine; return(false); } } catch (Exception e) { logger.Error($"AddAirCompany error {airc.Name} " + e.Message); ErrMesssage = "Ошибка при добавлении авиакомпании" + Environment.NewLine + e.Message + Environment.NewLine; return(false); } }