/// <summary> /// Loads the configuration from the specified file. /// </summary> public bool Load(string fileName, out string errMsg) { try { SetToDefault(); if (!File.Exists(fileName)) { throw new FileNotFoundException(string.Format(CommonPhrases.NamedFileNotFound, fileName)); } XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fileName); foreach (XmlElement exportTargetElem in xmlDoc.DocumentElement.SelectNodes("ExportTarget")) { ExportTargetConfig exportTargetConfig = new ExportTargetConfig() { Parent = this }; exportTargetConfig.LoadFromXml(exportTargetElem); ExportTargets.Add(exportTargetConfig); } errMsg = ""; return(true); } catch (Exception ex) { errMsg = ModPhrases.LoadModSettingsError + ": " + ex.Message; return(false); } }
public CustomerPaymentsExportViewModel() { SelectedExportTarget.OnChange += (newValue) => DispatchPropertyChanged("SelectedExportTarget"); BeginDatetime.OnChange += (newValue) => DispatchPropertyChanged("BeginDatetime"); EndDatetime.OnChange += (newValue) => DispatchPropertyChanged("EndDatetime"); ExportCommand = new Command(DoExport); BeginDatetime.Value = DateTime.Now.DayBegin(); EndDatetime.Value = DateTime.Now.DayEnd(); SelectedExportTarget.Value = ExportTargets.FirstOrDefault(); }
public void ExportRule(Rule rule, ExportTargets target) { var dialog = new SaveFileDialog(); if (dialog.ShowDialog() != DialogResult.OK) { return; } using (var stream = new FileStream(dialog.FileName, FileMode.Create, FileAccess.ReadWrite)) { Globals.Exporters.First(e => e.Target == target).ExportRule(rule, stream); } }
/// <summary> /// Briefly validates the configuration. /// </summary> public bool Validate(out List <ExportTargetConfig> activeExportConfigs, out string errMsg) { activeExportConfigs = new List <ExportTargetConfig>(ExportTargets.Where(x => x.GeneralOptions.Active)); if (activeExportConfigs.Count <= 0) { errMsg = Localization.UseRussian ? "Отсутствуют активные цели экспорта." : "No active export targets."; return(false); } else if (ExportTargets.Distinct().Count() < ExportTargets.Count) { errMsg = Localization.UseRussian ? "Дублируются идентификаторы целей экспорта." : "Export target IDs are duplicated."; return(false); } else { errMsg = ""; return(true); } }