public void Add(Provider prov) { try { List<int> rel = pairs.Where(p => p.Item2 == prov.Id).Select(p => p.Item1).ToList(); rel.RemoveAll(p => provs.Contains(p)); provs.AddRange(rel); } catch (Exception ex) { Log.Error("Ошибка планирования обновления локальных прайсов в БД", ex); } }
List<Provider> GetProviderList() { List<Provider> result = new List<Provider>(); string filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ProviderFile); try { XmlDocument doc = new XmlDocument(); doc.Load(filename); foreach (XmlNode provnode in doc.SelectNodes("configuration/providers/provider_info")) { if (provnode.Attributes["enabled"] != null && provnode.Attributes["enabled"].Value == "0") continue; Provider prov = new Provider(); prov.Name = provnode.Attributes["name"].Value; prov.Id = int.Parse(provnode.Attributes["provider_id"].Value); prov.File = System.IO.Path.Combine(provnode.Attributes["file_path"].Value, provnode.Attributes["file_name"].Value); //if (!System.IO.File.Exists(prov.File)) // prov.File = null; result.Add(prov); } } catch (Exception ex) { Console.WriteLine("Не удалось прочитать файл " + ProviderFile + Environment.NewLine + ex.ToString()); return result; } return result; }
public void UpdateLoadDateTime(Provider prov) { queue.Enqueue(new Tuple<Func<Provider, bool>, Provider>(MyPriceLoader.UpdateLoadDateTime, prov)); }
private void SaveBKPrice(Provider provider) { if (Settings.Instance.BackupPriceFolder == null) return; try { if (!System.IO.File.Exists(provider.File)) { return; } string bkfolder = System.IO.Path.Combine(Settings.Instance.BackupPriceFolder, provider.Id.ToString()); if (!System.IO.Directory.Exists(bkfolder)) System.IO.Directory.CreateDirectory(bkfolder); DeleteOldFiles(bkfolder); System.IO.File.Copy(provider.File, System.IO.Path.Combine(bkfolder, System.IO.Path.GetFileNameWithoutExtension(provider.File) + "_" + DateTime.Now.ToString("yyyy-MM-dd-HH-mm", CultureInfo.InvariantCulture) + "." + System.IO.Path.GetExtension(provider.File))); } catch (Exception ex) { Log.Error("Не удалось создать копию прайса", ex); } }
public void Add(Provider prov) { queue.Enqueue(new Tuple<Func<Provider, bool>, Provider>(MyPriceLoader.Upload, prov)); }