private static void AssessExtensionInfo(CountryConfigFacade ccf, DataConfigFacade dcf, string extensionId, string offOn, ref Dictionary <string, List <string> > switchInfo) { Dictionary <string, List <string> > dataSwitches = new Dictionary <string, List <string> >(); foreach (DataConfig.PolicySwitchRow polSwitch in from e in dcf.GetDataConfig().PolicySwitch where e.SwitchablePolicyID == extensionId select e) { if (polSwitch.Value != offOn) { continue; } if (!dataSwitches.ContainsKey(polSwitch.DataBaseID)) { dataSwitches.Add(polSwitch.DataBaseID, new List <string>()); } dataSwitches[polSwitch.DataBaseID].Add(polSwitch.SystemID); } foreach (var dataSwitch in dataSwitches) { DataConfig.DataBaseRow dataRow = dcf.GetDataBaseRow(dataSwitch.Key); if (dataRow == null) { continue; } string sumDataSwitches = dataRow.Name + ":"; foreach (string sysId in dataSwitch.Value) { CountryConfig.SystemRow sysRow = ccf.GetSystemRowByID(sysId); if (sysRow == null) { continue; } sumDataSwitches += sysRow.Name + ","; } if (!switchInfo.ContainsKey(extensionId)) { switchInfo.Add(extensionId, new List <string>()); } switchInfo[extensionId].Add(RVItem_Base.TrimEnd(sumDataSwitches)); } }
private void EM3_WriteLog() { List <RunLogger.RunInfo> runInfoList = new List <RunLogger.RunInfo>(); foreach (Run run in _runs) { // some info needs to be looked up in country-files string country = run._contentConfig[TAGS.EM2CONFIG_COUNTRY_FILE]; if (country.ToLower().EndsWith(".xml")) { country = country.Substring(0, country.Length - 4); } CountryConfigFacade ccf = CountryAdministrator.GetCountryConfigFacade(country); DataConfigFacade dcf = CountryAdministrator.GetDataConfigFacade(country); string sysID = (from e in run._contentConfig where e.Key.StartsWith(TAGS.EM2CONFIG_SYSTEM_ID) select e.Value).FirstOrDefault(); // SYSTEM_ID is followed by a GUID string dataID = run._contentConfig[TAGS.EM2CONFIG_DATASET_ID]; if (!EM_AppContext.Instance._runExeViaLib && run._process != null) { run.em3RunInfo.duration = new RunLogger.Duration(run._process.StartTime, run._process.ExitTime); run.em3RunInfo.finishStatus = run._processStatus == Run._processStatus_Finished ? RunLogger.RunInfo.FINISH_STATUS.finished : RunLogger.RunInfo.FINISH_STATUS.aborted; } run.em3RunInfo.systemName = ccf.GetSystemRowByID(sysID).Name; run.em3RunInfo.ExtractAddonSystemNames(run._contentConfig, TAGS.EM2CONFIG_ADDON); run.em3RunInfo.databaseName = dcf.GetDataBaseRow(dataID).Name; run.em3RunInfo.currency = run._contentConfig.ContainsKey(TAGS.EM2CONFIG_EXCHANGE_RATE_DATE) ? DefPar.Value.EURO : ccf.GetSystemRowByID(sysID).CurrencyOutput; // config contains entry EXCHANGE_RATE_DATE only if "All Output in €" is checked run.em3RunInfo.exchangeRate = GetExchangeRate(run, country, ccf.GetSystemRowByID(sysID).Name); run.em3RunInfo.ExtractExtensionSwitches(run._contentConfig, TAGS.EM2CONFIG_POLICY_SWITCH); string runOutputPath = run._contentConfig.GetOrEmpty(TAGS.EM2CONFIG_OUTPUTPATH); if (!string.IsNullOrEmpty(runOutputPath) && !EMPath.IsSamePath(runOutputPath, _outputPath)) { run.em3RunInfo.nonDefaultOutputPath = runOutputPath; } runInfoList.Add(run.em3RunInfo); } new RunLogger(EM_AppContext.Instance.GetProjectName(), runInfoList).TxtWriteEMLog(_outputPath); string GetExchangeRate(Run run, string country, string sysName) { ExchangeRatesConfigFacade excf = EM_AppContext.Instance.GetExchangeRatesConfigFacade(false); if (excf == null) { return(Dialogs.ConfigureSystemsForm.DEFAULT_EXCHANGE_RATE); } foreach (ExchangeRatesConfig.ExchangeRatesRow exRate in excf.GetExchangeRates(country)) { if (!exRate.ValidFor.ToLower().Trim().EndsWith(sysName.ToLower()) && !exRate.ValidFor.ToLower().Contains(sysName.ToLower() + ",")) { continue; } string date = run._contentConfig.ContainsKey(TAGS.EM2CONFIG_EXCHANGE_RATE_DATE) && run._contentConfig[TAGS.EM2CONFIG_EXCHANGE_RATE_DATE].ToLower() != "default" ? run._contentConfig[TAGS.EM2CONFIG_EXCHANGE_RATE_DATE].ToLower() : exRate.Default.ToLower(); double value = 1.0; if (date.StartsWith("june")) { value = exRate.June30; } else if (date.StartsWith("year")) { value = exRate.YearAverage; } else if (date.StartsWith("first")) { value = exRate.FirstSemester; } else if (date.StartsWith("second")) { value = exRate.SecondSemester; } return(value.ToString()); } return(Dialogs.ConfigureSystemsForm.DEFAULT_EXCHANGE_RATE); } }
internal override void PerformAction() { ConfigureDataForm configureDataForm = new ConfigureDataForm(_countryShortName); //firstly provide dialog with the information it needs to display (i.e. info on datasets and available system-dataset combinations) ... foreach (CountryConfig.SystemRow systemRow in CountryAdministrator.GetCountryConfigFacade(_countryShortName).GetSystemRows().OrderBy(s => long.Parse(s.Order))) { configureDataForm._systemInfo.Add(systemRow.ID, systemRow.Name); } foreach (DataConfig.DataBaseRow dataBaseRow in _dataConfigFacade.GetDataBaseRows()) { ConfigureDataForm.RowTag rowTag = new ConfigureDataForm.RowTag(); rowTag.ID = dataBaseRow.ID; rowTag.Name = dataBaseRow.Name; rowTag.Comment = dataBaseRow.Comment; rowTag.YearCollection = dataBaseRow.YearCollection; rowTag.YearInc = dataBaseRow.YearInc; rowTag.Currency = dataBaseRow.Currency; rowTag.FilePath = dataBaseRow.FilePath; rowTag.DecimalSign = dataBaseRow.DecimalSign; rowTag.Private = dataBaseRow.Private; rowTag.UseCommonDefault = dataBaseRow.UseCommonDefault; rowTag.ReadXVariables = string.IsNullOrEmpty(dataBaseRow.ReadXVariables) ? DefPar.Value.NO : dataBaseRow.ReadXVariables; rowTag.IsCommonDefaultNull = dataBaseRow.IsUseCommonDefaultNull(); rowTag.ListStringOutVar = dataBaseRow.ListStringOutVar; rowTag.IndirectTaxTableYear = dataBaseRow.IndirectTaxTableYear; foreach (DataConfig.DBSystemConfigRow dbSystemConfigRow in _dataConfigFacade.GetDBSystemConfigRows(dataBaseRow.ID)) { ConfigureDataForm.CellTag cellTag = new ConfigureDataForm.CellTag(); cellTag.SystemID = dbSystemConfigRow.SystemID; cellTag.UseDefault = dbSystemConfigRow.UseDefault; cellTag.UseCommonDefault = dbSystemConfigRow.UseCommonDefault; cellTag.Uprate = dbSystemConfigRow.Uprate; cellTag.BestMatch = dbSystemConfigRow.BestMatch; rowTag.CellTags.Add(dbSystemConfigRow.SystemID, cellTag); } configureDataForm._dataBaseInfo.Add(rowTag); } //... then show the dialog ... if (configureDataForm.ShowDialog() == System.Windows.Forms.DialogResult.Cancel) { _actionIsCanceled = true; return; } //... finally store the modified information List <DataConfig.DataBaseRow> dataBaseRowsToDelete = new List <DataConfig.DataBaseRow>(); List <DataConfig.DBSystemConfigRow> dbSystemConfigRowsToDelete = new List <DataConfig.DBSystemConfigRow>(); foreach (ConfigureDataForm.RowTag dataBaseInfo in configureDataForm._dataBaseInfo) { DataConfig.DataBaseRow dataBaseRow = _dataConfigFacade.GetDataBaseRow(dataBaseInfo.ID); if (dataBaseInfo.ChangeState == ConfigureDataForm.ChangeStates.removed) { dataBaseRowsToDelete.Add(dataBaseRow); continue; } if (dataBaseInfo.ChangeState == ConfigureDataForm.ChangeStates.added) { dataBaseRow = _dataConfigFacade.AddDataBaseRow(dataBaseInfo.Name, dataBaseInfo.FilePath); _datasetAdded = true; } if (dataBaseInfo.ChangeState != ConfigureDataForm.ChangeStates.unchanged) { dataBaseRow.ID = dataBaseInfo.ID; dataBaseRow.Name = dataBaseInfo.Name; dataBaseRow.Comment = dataBaseInfo.Comment; dataBaseRow.YearCollection = dataBaseInfo.YearCollection; dataBaseRow.YearInc = dataBaseInfo.YearInc; dataBaseRow.Currency = dataBaseInfo.Currency; dataBaseRow.FilePath = dataBaseInfo.FilePath; dataBaseRow.DecimalSign = dataBaseInfo.DecimalSign; dataBaseRow.Private = dataBaseInfo.Private; dataBaseRow.UseCommonDefault = dataBaseInfo.UseCommonDefault; dataBaseRow.ReadXVariables = dataBaseInfo.ReadXVariables; dataBaseRow.ListStringOutVar = dataBaseInfo.ListStringOutVar; dataBaseRow.IndirectTaxTableYear = dataBaseInfo.IndirectTaxTableYear; } foreach (ConfigureDataForm.CellTag dbSystemCombination in dataBaseInfo.CellTags.Values) { DataConfig.DBSystemConfigRow dbSystemConfigRow = _dataConfigFacade.GetDBSystemConfigRow(dataBaseInfo.ID, dbSystemCombination.SystemID); if (dbSystemCombination.ChangeState == ConfigureDataForm.ChangeStates.removed) { dbSystemConfigRowsToDelete.Add(dbSystemConfigRow); continue; } if (dbSystemCombination.ChangeState == ConfigureDataForm.ChangeStates.added) { dbSystemConfigRow = _dataConfigFacade.AddDBSystemConfigRow(dbSystemCombination.SystemID, CountryAdministrator.GetCountryConfigFacade(_countryShortName).GetSystemRowByID(dbSystemCombination.SystemID).Name, dataBaseRow); } if (dbSystemCombination.ChangeState != ConfigureDataForm.ChangeStates.unchanged) { dbSystemConfigRow.SystemID = dbSystemCombination.SystemID; dbSystemConfigRow.UseDefault = dbSystemCombination.UseDefault; dbSystemConfigRow.UseCommonDefault = dbSystemCombination.UseCommonDefault; dbSystemConfigRow.Uprate = dbSystemCombination.Uprate; dbSystemConfigRow.BestMatch = dbSystemCombination.BestMatch; } } } foreach (DataConfig.DataBaseRow dataBaseRowToDelete in dataBaseRowsToDelete) { dataBaseRowToDelete.Delete(); } foreach (DataConfig.DBSystemConfigRow dbSystemConfigRowToDelete in dbSystemConfigRowsToDelete) { dbSystemConfigRowToDelete.Delete(); } }