public static IEnumerable <int> GetSoftwareIDsBySoftMaker(int idSoftMaker) { return(from softwareRow in FilterRows(SoftwareDataModel.GetInstance().Select()) join softVersionRow in FilterRows(SoftVersionsDataModel.GetInstance().Select()) on softwareRow.Field <int>("ID Software") equals softVersionRow.Field <int>("ID Software") where softwareRow.Field <int>("ID SoftMaker") == idSoftMaker select softVersionRow.Field <int>("ID Version")); }
public override void LoadData() { dataGridView.AutoGenerateColumns = false; DockAreas = WeifenLuo.WinFormsUI.Docking.DockAreas.Document; _softVersions = SoftVersionsDataModel.GetInstance(); // Дожидаемся дозагрузки данных, если это необходимо _softVersions.Select(); _vSoftVersions = new BindingSource { DataMember = "SoftVersions", Filter = StaticFilter }; if (!string.IsNullOrEmpty(StaticFilter) && !String.IsNullOrEmpty(DynamicFilter)) { _vSoftVersions.Filter += " AND "; } _vSoftVersions.Filter += DynamicFilter; _vSoftVersions.DataSource = DataSetManager.DataSet; if (ParentRow != null && ParentType == ParentTypeEnum.Software) { Text = string.Format(CultureInfo.InvariantCulture, "Версии ПО №{0}", ParentRow["ID Software"]); } else { throw new ViewportException("Неизвестный тип родительского объекта"); } //Инициируем колонки snapshot-модели for (var i = 0; i < _softVersions.Select().Columns.Count; i++) { _snapshotSoftVersions.Columns.Add(new DataColumn(_softVersions.Select().Columns[i].ColumnName, _softVersions.Select().Columns[i].DataType)); } //Загружаем данные snapshot-модели из original-view for (var i = 0; i < _vSoftVersions.Count; i++) { _snapshotSoftVersions.Rows.Add(DataRowViewToArray(((DataRowView)_vSoftVersions[i]))); } _vSnapshotSoftVersions = new BindingSource { DataSource = _snapshotSoftVersions }; _vSnapshotSoftVersions.CurrentItemChanged += VSnapshotVersionsCurrentItemChanged; dataGridView.DataSource = _vSnapshotSoftVersions; idVersion.DataPropertyName = "ID Version"; idSoftware.DataPropertyName = "ID Software"; Version.DataPropertyName = "Version"; dataGridView.DataBindings.DefaultDataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged; dataGridView.CellValidated += dataGridView_CellValidated; //События изменения данных для проверки соответствия реальным данным в модели dataGridView.CellValueChanged += dataGridView_CellValueChanged; //Синхронизация данных исходные->текущие _softVersions.Select().RowChanged += SoftLicKeysViewport_RowChanged; _softVersions.Select().RowDeleting += SoftLicKeysViewport_RowDeleting; _softVersions.Select().RowDeleted += SoftLicKeysViewport_RowDeleted; }
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); }
public static IEnumerable <int> GetLicenseIDsByCondition(Func <DataRow, bool> condition, EntityType entity) { var software = FilterRows(SoftwareDataModel.GetInstance().Select()); var softVersions = FilterRows(SoftVersionsDataModel.GetInstance().Select()); var departments = from departmentsRow in FilterRows(DepartmentsDataModel.GetInstance().SelectVisibleDepartments()) where departmentsRow.Field <bool>("AllowSelect") select departmentsRow.Field <int>("ID Department"); var licenses = from licensesRow in FilterRows(SoftLicensesDataModel.GetInstance().Select()) where departments.Contains(licensesRow.Field <int>("ID Department")) select licensesRow; var result = from softwareRow in software join softVersionRow in softVersions on softwareRow.Field <int>("ID Software") equals softVersionRow.Field <int>("ID Software") join licensesRow in licenses on softVersionRow.Field <int>("ID Version") equals licensesRow.Field <int>("ID Version") where entity == EntityType.Software ? condition(softwareRow) : entity == EntityType.SoftVersion ? condition(softVersionRow) : entity == EntityType.License && condition(licensesRow) select licensesRow.Field <int>("ID License"); return(result); }
protected override void Calculate(object sender, System.ComponentModel.DoWorkEventArgs e) { DmLoadState = DataModelLoadState.Loading; if (e == null) { throw new DataModelException("Не передана ссылка на объект DoWorkEventArgs в классе CalcDataModelSoftwareConcat"); } var config = (CalcAsyncConfig)e.Argument; // Фильтруем удаленные строки IEnumerable <DataRow> software; IEnumerable <DataRow> versions; if (config.Entity == EntityType.Software) { software = DataModelHelper.FilterRows(SoftwareDataModel.GetInstance().Select(), config.Entity, config.IdObject); versions = DataModelHelper.FilterRows(SoftVersionsDataModel.GetInstance().Select(), config.Entity, config.IdObject); } else if (config.Entity == EntityType.SoftVersion) { software = DataModelHelper.FilterRows(SoftwareDataModel.GetInstance().Select(), EntityType.Unknown, null); versions = DataModelHelper.FilterRows(SoftVersionsDataModel.GetInstance().Select(), config.Entity, config.IdObject); } else { software = DataModelHelper.FilterRows(SoftwareDataModel.GetInstance().Select(), EntityType.Unknown, null); versions = DataModelHelper.FilterRows(SoftVersionsDataModel.GetInstance().Select(), EntityType.Unknown, null); } // Вычисляем агрегационную информацию var result = from softwareRow in software join versionRow in versions on softwareRow.Field <int>("ID Software") equals versionRow.Field <int>("ID Software") select new { id_version = versionRow.Field <int>("ID Version"), id_software = versionRow.Field <int>("ID Software"), software = softwareRow.Field <string>("Software") + (versionRow.Field <string>("Version") == null ? "" : " " + versionRow.Field <string>("Version")) }; // Заполняем таблицу изменений var table = InitializeTable(); table.BeginLoadData(); result.ToList().ForEach(x => { table.Rows.Add(x.id_version, x.id_software, x.software); }); table.EndLoadData(); if (!DataSetManager.DataSet.Tables.Contains(TableName)) { DataSetManager.AddTable(table); } else { DataSetManager.DataSet.Merge(table); } // Возвращаем результат e.Result = table; }