protected override void Calculate(object sender, System.ComponentModel.DoWorkEventArgs e) { DmLoadState = DataModelLoadState.Loading; if (e == null) { throw new DataModelException("Не передана ссылка на объект DoWorkEventArgs в классе CalcDataModelLicensesConcat"); } var config = (CalcAsyncConfig)e.Argument; // Фильтруем удаленные строки var licenses = DataModelHelper.FilterRows(SoftLicensesDataModel.GetInstance().Select(), config.Entity, config.IdObject); var licKeys = DataModelHelper.FilterRows(SoftLicKeysDataModel.GetInstance().Select(), config.Entity, config.IdObject); // Вычисляем агрегационную информацию var result = from licensesRow in licenses join licKeyRow in licKeys on licensesRow.Field <int>("ID License") equals licKeyRow.Field <int>("ID License") select new { id_lickey = licKeyRow.Field <int>("ID LicenseKey"), id_license = licensesRow.Field <int>("ID License"), lickey = string.Format("{0} (в/н лицензии: {1}; срок действия: №{2} от {3})", licKeyRow.Field <string>("LicKey"), licensesRow.Field <int>("ID License"), licensesRow.Field <string>("DocNumber") ?? "б/н", licensesRow.Field <DateTime>("BuyLicenseDate").ToString("dd.MM.yyyy", CultureInfo.InvariantCulture) + (licensesRow.Field <DateTime?>("ExpireLicenseDate") == null ? " (бессрочно)" : " по " + licensesRow.Field <DateTime>("ExpireLicenseDate").ToString("dd.MM.yyyy", CultureInfo.InvariantCulture)) ) }; // Заполняем таблицу изменений var table = InitializeTable(); table.BeginLoadData(); result.ToList().ForEach(x => { table.Rows.Add(x.id_lickey, x.id_license, x.lickey); }); table.EndLoadData(); if (!DataSetManager.DataSet.Tables.Contains(TableName)) { DataSetManager.AddTable(table); } else { DataSetManager.DataSet.Merge(table); } // Возвращаем результат e.Result = table; }
private void PreLoadData() { toolStripProgressBar.Maximum = 13; DepartmentsDataModel.GetInstance(toolStripProgressBar, 1); DevicesDataModel.GetInstance(toolStripProgressBar, 1); SoftwareDataModel.GetInstance(toolStripProgressBar, 1); SoftVersionsDataModel.GetInstance(toolStripProgressBar, 1); SoftInstallationsDataModel.GetInstance(toolStripProgressBar, 1); SoftInstallatorsDataModel.GetInstance(toolStripProgressBar, 1); SoftLicDocTypesDataModel.GetInstance(toolStripProgressBar, 1); SoftLicensesDataModel.GetInstance(toolStripProgressBar, 1); SoftLicKeysDataModel.GetInstance(toolStripProgressBar, 1); SoftLicTypesDataModel.GetInstance(toolStripProgressBar, 1); SoftMakersDataModel.GetInstance(toolStripProgressBar, 1); SoftSuppliersDataModel.GetInstance(toolStripProgressBar, 1); SoftTypesDataModel.GetInstance(toolStripProgressBar, 1); }