private void cmdRunUnusedAnalyse_Click(object sender, System.EventArgs e) { try { if (_IsLoading.Value) { return; } using (var locker = new BoolLocker(ref _IsLoading)) { using (var projectOpenLocker = new BoolLocker(ref Consts.Consts.DontShowCheckTaskOnStartup)) { var inProgressUserControl = new ucMessageBox("Traitement en cours"); using (var inProgressForm = new frmUserControl(inProgressUserControl, "Recherche des tables inutilisées", false, false)) { inProgressForm.TopMost = true; inProgressForm.Show(); inProgressForm.Refresh(); var projectService = _Application.ServiceManager.GetService <IProjectService>(); var activeProject = projectService.ActiveProject; var result = new List <string>(); //Récupération de la liste des tables settings var settingsDatatable = activeProject.GetTableSettingsList(); settingsDatatable.AddRange(activeProject.GetControlTableNameList()); //récupération de la liste des tables var searchProcess = new SearchRuleProcess(activeProject); foreach (var tableItem in activeProject.DataTables.Enum()) { //ignore les tables de settings if (settingsDatatable.Exists(x => x == tableItem.InvariantName)) { continue; } if (!searchProcess.GetSearchResult("DwLookup" + tableItem.InvariantName).IsNotNullAndNotEmpty()) { result.Add(tableItem.DisplayName); } } dgvUnusedTable.DataSource = result.Enum().Select(x => TableView.ConvertTo(x)).Enum().ToList(); dgvUnusedTable.FormatColumns <TableView>("FR"); MessageBox.Show("{0} tables sont inutilisées sur {1} tables".FormatString(result.Count, activeProject.DataTables.Count())); } } } } catch (Exception ex) { ex.ShowInMessageBox(); } }
private void cmdRunUnusedVariable_Click(object sender, System.EventArgs e) { try { if (_IsLoading.Value) { return; } using (var locker = new BoolLocker(ref _IsLoading)) { using (var projectOpenLocker = new BoolLocker(ref Consts.Consts.DontShowCheckTaskOnStartup)) { var projectService = _Application.ServiceManager.GetService <IProjectService>(); var activeProject = projectService.ActiveProject; var inProgressUserControl = new ucMessageBox("Traitement en cours"); using (var inProgressForm = new frmUserControl(inProgressUserControl, "Recherches des variables inutilisés", false, false)) { inProgressForm.TopMost = true; inProgressForm.Show(); inProgressForm.Refresh(); var result = new List <string>(); //récupération de la liste des tables var searchProcess = new SearchRuleProcess(activeProject); foreach (var variableItem in activeProject.Variables.GetVariables().Enum()) { if (!searchProcess.GetSearchResult(variableItem.Name).IsNotNullAndNotEmpty()) { result.Add(variableItem.Name); } } dgvUnusedVariables.DataSource = result.Enum().Select(x => VariableView.ConvertTo(x)).Enum().ToList(); dgvUnusedVariables.FormatColumns <VariableView>("FR"); MessageBox.Show("{0} paramètres sont inutilisés sur {1} paramètres".FormatString(result.Count, activeProject.Variables.GetVariables().Enum().Count())); } } } } catch (Exception ex) { ex.ShowInMessageBox(); } }