internal static void UpdateCountryFiles(Dictionary <string, List <Tuple <string, string> > > changesCountryFiles, Form showWaitCursorForm = null) { try { if (showWaitCursorForm == null) { showWaitCursorForm = EM_AppContext.Instance.GetActiveCountryMainForm(); } showWaitCursorForm.Cursor = Cursors.WaitCursor; bool showOpenWarning = true; foreach (var ccChange in changesCountryFiles) { string country = ccChange.Key; EM_UI_MainForm ccMainForm = EM_AppContext.Instance.GetCountryMainForm(country); if (ccMainForm != null) { if (showOpenWarning) { switch (UserInfoHandler.GetInfo(country.ToUpper() + " is open." + Environment.NewLine + "Updating exchange rates requires a reset of the undo-functionality." + Environment.NewLine + "That means you will not be able to undo any of your changes so far." + Environment.NewLine + Environment.NewLine + "Do you still want to update exchange rates of " + country.ToUpper() + "?" + Environment.NewLine + Environment.NewLine + "(Press Cancel to not be requested with respect to further open countries.)", MessageBoxButtons.YesNoCancel)) { case DialogResult.No: continue; case DialogResult.Cancel: showOpenWarning = false; break; } } ccMainForm.GetUndoManager().Commit(); ccMainForm.GetUndoManager().Reset(); } CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); foreach (var change in ccChange.Value) { ccf.GetSystemRowByName(change.Item1).ExchangeRateEuro = change.Item2; } if (ccMainForm != null) { ccMainForm.GetUndoManager().Commit(); ccMainForm.GetUndoManager().Reset(); ccMainForm.WriteXml(); } else { CountryAdministrator.WriteXML(country); } } } catch (Exception) { } finally { showWaitCursorForm.Cursor = Cursors.Default; } }
internal static void SaveDirectXMLAction(EM_UI_MainForm mainForm) { string countryShortName = mainForm.GetCountryShortName(); CountryAdministrator.GetCountryConfigFacade(countryShortName).GetCountryConfig().AcceptChanges(); if (!CountryAdministrator.IsAddOn(countryShortName)) { CountryAdministrator.GetDataConfigFacade(countryShortName).GetDataConfig().AcceptChanges(); } mainForm.GetUndoManager().Reset(); //reset undo-manager with the drawback that actions up until now cannot be undone lock (EM_UI_MainForm._performActionLock) //to not get into conflict with auto-saving { CountryAdministrator.WriteXML(countryShortName); } }