private void MainForm_Load(object sender, EventArgs e) { UserDomain user = null; if (LicenseSoftwareSettings.UseLdap) { user = UserDomain.Current; } if (user == null) { toolStripLabelHelloUser.Text = ""; } else { toolStripLabelHelloUser.Text = @"Здравствуйте, " + user.DisplayName; } //Загружаем права пользователя AccessControl.LoadPriveleges(); if (AccessControl.HasNoPriveleges()) { MessageBox.Show(@"У вас нет прав на использование данного приложения", @"Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); Application.Exit(); return; } //Инициируем начальные параметры CallbackUpdater DataModelsCallbackUpdater.GetInstance().Initialize(); //Загружаем данные в асинхронном режиме PreLoadData(); //Обновляем состояние главного меню MainMenuStateUpdate(); if (string.IsNullOrEmpty(_computerNameCommandLineArg)) { return; } var device = DataModelHelper.FilterRows(DevicesDataModel.GetInstance().Select()) .FirstOrDefault(r => r.Field <string>("Device Name").Contains(_computerNameCommandLineArg)); if (device == null) { return; } var viewport = ViewportFactory.CreateViewport(this, ViewportType.InstallationsViewport); viewport.DynamicFilter = string.Format("[ID Computer] = {0}", device.Field <int>("ID Device")); if (((IMenuController)viewport).CanLoadData()) { ((IMenuController)viewport).LoadData(); } AddViewport(viewport); ChangeMainMenuState(); StatusBarStateUpdate(); ChangeViewportsSelectProprty(); }
public static IEnumerable <int> GetComputerIDsByDepartment(int idDepartment) { var childDepartments = from department in FilterRows(DepartmentsDataModel.GetInstance().Select()) where department.Field <int?>("ID Parent Department") == idDepartment select department.Field <int>("ID Department"); var computers = childDepartments.SelectMany(GetComputerIDsByDepartment); return(computers.Concat(from computerRow in FilterRows(DevicesDataModel.GetInstance().Select()) where computerRow.Field <int>("ID Department") == idDepartment select computerRow.Field <int>("ID Device"))); }
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); }
private void checkBoxComputerEnable_CheckedChanged(object sender, EventArgs e) { if (comboBoxComputer.DataSource == null) { _devices = DevicesDataModel.GetInstance(); _devices.Select(); _vDevices = new BindingSource { DataMember = "Devices", DataSource = DataSetManager.DataSet, Filter = DepartmentFilter() }; comboBoxComputer.DataSource = _vDevices; comboBoxComputer.ValueMember = "ID Device"; comboBoxComputer.DisplayMember = "Device Name"; } comboBoxComputer.Enabled = checkBoxComputerEnable.Checked; }
internal override string GetFilter() { var filter = ""; IEnumerable <int> includedLicensesIds = null; if (checkBoxSoftwareNameEnable.Checked && (comboBoxSoftwareName.SelectedValue != null)) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => row.Field <int>("ID Version") == (int)comboBoxSoftwareName.SelectedValue, Entities.EntityType.SoftVersion); includedLicensesIds = DataModelHelper.Intersect(null, ids); } if (checkBoxSoftwareMakerEnable.Checked && (comboBoxSoftwareMaker.SelectedValue != null)) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => row.Field <int>("ID SoftMaker") == (int)comboBoxSoftwareMaker.SelectedValue, Entities.EntityType.Software); includedLicensesIds = DataModelHelper.Intersect(includedLicensesIds, ids); } if (checkBoxSoftwareTypeEnable.Checked && (comboBoxSoftwareType.SelectedValue != null)) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => row.Field <int>("ID SoftType") == (int)comboBoxSoftwareType.SelectedValue, Entities.EntityType.Software); includedLicensesIds = DataModelHelper.Intersect(includedLicensesIds, ids); } if (checkBoxSupplierEnable.Checked && (comboBoxSupplierID.SelectedValue != null)) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => row.Field <int>("ID Supplier") == (int)comboBoxSupplierID.SelectedValue, Entities.EntityType.License); includedLicensesIds = DataModelHelper.Intersect(includedLicensesIds, ids); } if (checkBoxLicTypeEnable.Checked && (comboBoxLicType.SelectedValue != null)) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => row.Field <int>("ID LicType") == (int)comboBoxLicType.SelectedValue, Entities.EntityType.License); includedLicensesIds = DataModelHelper.Intersect(includedLicensesIds, ids); } if (checkBoxLicDocTypeEnable.Checked && (comboBoxLicDocType.SelectedValue != null)) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => row.Field <int>("ID DocType") == (int)comboBoxLicDocType.SelectedValue, Entities.EntityType.License); includedLicensesIds = DataModelHelper.Intersect(includedLicensesIds, ids); } if (checkBoxDepartmentLicEnable.Checked && (comboBoxDepartmentLicID.SelectedValue != null)) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => DataModelHelper.GetDepartmentSubunits((int)comboBoxDepartmentLicID.SelectedValue).Union( new List <int> { (int)comboBoxDepartmentLicID.SelectedValue }).Contains( row.Field <int>("ID Department")), Entities.EntityType.License); includedLicensesIds = DataModelHelper.Intersect(includedLicensesIds, ids); } if (checkBoxDocNumberEnable.Checked && !string.IsNullOrEmpty(textBoxDocNumber.Text.Trim())) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => row.Field <string>("DocNumber").ToUpper(CultureInfo.InvariantCulture) .Contains(textBoxDocNumber.Text.Trim().ToUpper(CultureInfo.InvariantCulture)), Entities.EntityType.License); includedLicensesIds = DataModelHelper.Intersect(includedLicensesIds, ids); } if (checkBoxExpireLicenseDateEnable.Checked) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => { if (row.Field <DateTime?>("ExpireLicenseDate") == null) { return(false); } switch (comboBoxOpExpireLicenseDate.SelectedItem.ToString()) { case "=": return(row.Field <DateTime>("ExpireLicenseDate") == dateTimePickerExpireLicenseDate.Value); case "≥": return(row.Field <DateTime>("ExpireLicenseDate") >= dateTimePickerExpireLicenseDate.Value); case "≤": return(row.Field <DateTime>("ExpireLicenseDate") <= dateTimePickerExpireLicenseDate.Value); } return(false); }, Entities.EntityType.License); includedLicensesIds = DataModelHelper.Intersect(includedLicensesIds, ids); } if (checkBoxBuyLicenseDateEnable.Checked) { var ids = DataModelHelper.GetLicenseIDsByCondition( row => { if (row.Field <DateTime?>("BuyLicenseDate") == null) { return(false); } switch (comboBoxOpBuyLicenseDate.SelectedItem.ToString()) { case "=": return(row.Field <DateTime>("BuyLicenseDate") == dateTimePickerBuyLicenseDate.Value); case "≥": return(row.Field <DateTime>("BuyLicenseDate") >= dateTimePickerBuyLicenseDate.Value); case "≤": return(row.Field <DateTime>("BuyLicenseDate") <= dateTimePickerBuyLicenseDate.Value); } return(false); }, Entities.EntityType.License); includedLicensesIds = DataModelHelper.Intersect(includedLicensesIds, ids); } var allowedDepartments = from departmentsRow in DataModelHelper.FilterRows(DepartmentsDataModel.GetInstance().SelectVisibleDepartments()) where departmentsRow.Field <bool>("AllowSelect") select departmentsRow.Field <int>("ID Department"); var allowedComputers = from devicesRow in DataModelHelper.FilterRows(DevicesDataModel.GetInstance().Select()) join depRow in allowedDepartments on devicesRow.Field <int>("ID Department") equals depRow select devicesRow.Field <int>("ID Device"); if (!string.IsNullOrEmpty(filter.Trim())) { filter += " AND "; } filter += "[ID Computer] IN (0"; foreach (var id in allowedComputers) { filter += id.ToString(CultureInfo.InvariantCulture) + ","; } filter = filter.TrimEnd(',') + ")"; if (checkBoxInstallDateEnable.Checked) { if (!string.IsNullOrEmpty(filter.Trim())) { filter += " AND "; } filter += string.Format(CultureInfo.InvariantCulture, "InstallationDate {0} #{1}#", ConvertDisplayEqExprToSql( comboBoxOpInstallDate.SelectedItem.ToString()), dateTimePickerInstallDate.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)); } if (checkBoxInstallatorEnable.Checked && (comboBoxInstallator.SelectedValue != null)) { if (!string.IsNullOrEmpty(filter.Trim())) { filter += " AND "; } filter += string.Format(CultureInfo.InvariantCulture, "[ID Installator] = '{0}'", comboBoxInstallator.SelectedValue); } if (checkBoxLicKeyEnable.Checked && (comboBoxLicKey.SelectedValue != null)) { if (!string.IsNullOrEmpty(filter.Trim())) { filter += " AND "; } filter += string.Format(CultureInfo.InvariantCulture, "[ID LicenseKey] = '{0}'", comboBoxLicKey.SelectedValue); } if (checkBoxComputerEnable.Checked && (comboBoxComputer.SelectedValue != null)) { if (!string.IsNullOrEmpty(filter.Trim())) { filter += " AND "; } filter += string.Format(CultureInfo.InvariantCulture, "[ID Computer] = '{0}'", comboBoxComputer.SelectedValue); } if (checkBoxInvNumEnable.Checked && (comboBoxInvNum.SelectedValue != null)) { if (!string.IsNullOrEmpty(filter.Trim())) { filter += " AND "; } filter += string.Format(CultureInfo.InvariantCulture, "[ID Computer] = '{0}'", comboBoxInvNum.SelectedValue); } if (checkBoxSerialNumEnable.Checked && (comboBoxSerialNum.SelectedValue != null)) { if (!string.IsNullOrEmpty(filter.Trim())) { filter += " AND "; } filter += string.Format(CultureInfo.InvariantCulture, "[ID Computer] = '{0}'", comboBoxSerialNum.SelectedValue); } if (checkBoxDepartmentInstallEnable.Checked && (comboBoxDepartmentInstallID.SelectedValue != null)) { var computerIds = DataModelHelper.GetComputerIDsByDepartment((int)comboBoxDepartmentInstallID.SelectedValue); if (!string.IsNullOrEmpty(filter.Trim())) { filter += " AND "; } filter += "[ID Computer] IN (0"; foreach (var id in computerIds) { filter += id.ToString(CultureInfo.InvariantCulture) + ","; } filter = filter.TrimEnd(',') + ")"; } if (includedLicensesIds != null) { if (!string.IsNullOrEmpty(filter.Trim())) { filter += " AND "; } filter += "[ID License] IN (0"; foreach (var id in includedLicensesIds) { filter += id.ToString(CultureInfo.InvariantCulture) + ","; } filter = filter.TrimEnd(',') + ")"; } return(filter); }