private void butOK_Click(object sender, System.EventArgs e) { registrationKey.RegKey = textKey.Text; registrationKey.Note = textNote.Text; RegistrationKeys.Update(registrationKey); DialogResult = DialogResult.OK; }
private void FormBugSubmission_Load(object sender, EventArgs e) { try { RegistrationKey key = RegistrationKeys.GetByKey(_subCur.RegKey); _patCur = Patients.GetPat(key.PatNum); } catch (Exception ex) { ex.DoNothing(); _patCur = new Patient(); //Just in case, needed mostly for debug. } labelName.Text = _patCur?.GetNameLF() ?? ""; labelDateTime.Text = POut.DateT(_subCur.SubmissionDateTime); labelVersion.Text = _subCur.TryGetPrefValue(PrefName.ProgramVersion, "0.0.0.0"); labelHashNum.Text = POut.Long(_subCur.BugSubmissionHashNum); if (_subCur.BugId != 0) //Already associated to a bug { _bug = Bugs.GetOne(_subCur.BugId); butAddViewBug.Text = "View Bug"; } if (_bug != null) { _listLinks = JobLinks.GetForType(JobLinkType.Bug, _bug.BugId); if (_listLinks.Count == 1) { butAddViewJob.Text = "View Job"; } } Dictionary <string, Patient> dictPats = new Dictionary <string, Patient>(); dictPats.Add(_subCur.RegKey, _patCur); bugSubmissionControl.RefreshData(dictPats, -1, null); //New selelction, refresh control data. bugSubmissionControl.RefreshView(_subCur); }
///<summary>Reloads all data for form.</summary> private void RefreshData() { _listHashes = BugSubmissionHashes.GetMany(datePicker.GetDateTimeFrom(), datePicker.GetDateTimeTo()); _dictBugSubsByHashNum = BugSubmissions.GetForHashNums(_listHashes.Select(x => x.BugSubmissionHashNum).ToList()); _dictBugs = Bugs.GetMany(_listHashes.Select(x => x.BugId).Where(x => x != 0).ToList()).ToDictionary(key => key.BugId); _dictPatients = RegistrationKeys.GetPatientsByKeys(_dictBugSubsByHashNum.Values.SelectMany(x => x.Select(y => y.RegKey)).ToList()); }
private void FillGrid() { Cursor.Current = Cursors.WaitCursor; TableRegKeys = RegistrationKeys.GetAllWithoutCharges(); Cursor.Current = Cursors.Default; gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn("PatNum", 60); gridMain.Columns.Add(col); col = new ODGridColumn("RegKey", 140); gridMain.Columns.Add(col); col = new ODGridColumn("Family", 200); gridMain.Columns.Add(col); //col=new ODGridColumn("Repeating Charge",150); //gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; for (int i = 0; i < TableRegKeys.Rows.Count; i++) { row = new ODGridRow(); row.Cells.Add(TableRegKeys.Rows[i]["PatNum"].ToString()); row.Cells.Add(TableRegKeys.Rows[i]["RegKey"].ToString()); row.Cells.Add(TableRegKeys.Rows[i]["LName"].ToString() + ", " + TableRegKeys.Rows[i]["FName"].ToString()); //row.Cells.Add(table.Rows[i]["dateStop"].ToString()); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
private void FillGrid() { table = RegistrationKeys.GetAllWithoutCharges(); gridMain.BeginUpdate(); gridMain.Columns.Clear(); ODGridColumn col = new ODGridColumn("Family", 160); gridMain.Columns.Add(col); col = new ODGridColumn("RegKey", 140); gridMain.Columns.Add(col); col = new ODGridColumn("Repeating Charge", 150); gridMain.Columns.Add(col); gridMain.Rows.Clear(); ODGridRow row; for (int i = 0; i < table.Rows.Count; i++) { row = new ODGridRow(); row.Cells.Add(table.Rows[i]["family"].ToString()); row.Cells.Add(table.Rows[i]["RegKey"].ToString()); row.Cells.Add(table.Rows[i]["dateStop"].ToString()); gridMain.Rows.Add(row); } gridMain.EndUpdate(); }
private void butOK_Click(object sender, System.EventArgs e) { if (textDateStarted.errorProvider1.GetError(textDateStarted) != "" || textDateDisabled.errorProvider1.GetError(textDateDisabled) != "" || textDateEnded.errorProvider1.GetError(textDateEnded) != "" ) { MsgBox.Show(this, "Please fix data entry errors first."); return; } try { PIn.Int(textVotesAllotted.Text); } catch { MsgBox.Show(this, "Votes Allotted is invalid."); return; } //RegKey.RegKey=textKey.Text;//It's read only. RegKey.DateStarted = PIn.Date(textDateStarted.Text); RegKey.DateDisabled = PIn.Date(textDateDisabled.Text); RegKey.DateEnded = PIn.Date(textDateEnded.Text); RegKey.IsFreeVersion = checkFree.Checked; RegKey.IsOnlyForTesting = checkTesting.Checked; RegKey.IsResellerCustomer = checkResellerCustomer.Checked; //RegKey.UsesServerVersion=checkServerVersion.Checked; RegKey.VotesAllotted = PIn.Int(textVotesAllotted.Text); RegKey.Note = textNote.Text; RegKey.HasEarlyAccess = checkEarlyAccess.Checked; RegistrationKeys.Update(RegKey); DialogResult = DialogResult.OK; }
private void butDelete_Click(object sender, EventArgs e) { try{ RegistrationKeys.Delete(RegKey.RegistrationKeyNum); } catch (ApplicationException ex) { MessageBox.Show(ex.Message); } Close(); }
private void gridSubs_CellClick(object sender, UI.ODGridClickEventArgs e) { butAddJob.Text = "Add Job"; //Always reset if (e.Row == -1 || gridSubs.SelectedIndices.Length != 1) { bugSubmissionControl.ClearCustomerInfo(); _subCur = null; labelDateTime.Text = ""; labelHashNum.Text = ""; bugSubmissionControl.SetTextDevNoteEnabled(false); return; } bugSubmissionControl.SetTextDevNoteEnabled(true); _subCur = ((List <BugSubmission>)gridSubs.ListGridRows[e.Row].Tag)[0]; if (_dictPatients.ContainsKey(_subCur.RegKey)) { _patCur = _dictPatients[_subCur.RegKey]; } else { try { RegistrationKey key = RegistrationKeys.GetByKey(_subCur.RegKey); _patCur = Patients.GetPat(key.PatNum); } catch (Exception ex) { ex.DoNothing(); _patCur = new Patient(); //Just in case, needed mostly for debug. } _dictPatients.Add(_subCur.RegKey, _patCur); } List <BugSubmission> listSubs = _listAllSubs; if (comboGrouping.SelectedIndex.In(1, 2, 3, 4, 5)) { listSubs = ((List <BugSubmission>)gridSubs.ListGridRows[gridSubs.GetSelectedIndex()].Tag); } butAddJob.Tag = null; bugSubmissionControl.RefreshData(_dictPatients, comboGrouping.SelectedIndex, listSubs); //New selelction, refresh control data. bugSubmissionControl.RefreshView(_subCur); labelDateTime.Text = POut.DateT(_subCur.SubmissionDateTime); labelHashNum.Text = POut.Long(_subCur.BugSubmissionHashNum); if (_subCur.BugId != 0) { List <JobLink> listJobLink = _listJobLinks.Where(x => x.FKey == _subCur.BugId).ToList(); if (listJobLink.Count == 1) { butAddJob.Text = "View Job"; butAddJob.Tag = listJobLink.First(); } } if (_viewMode.In(FormBugSubmissionMode.SelectionMode, FormBugSubmissionMode.ValidationMode)) { butAddJob.Text = "OK"; } }
private void butMoveTo_Click(object sender, EventArgs e) { FormPatientSelect form = new FormPatientSelect(); if (form.ShowDialog() != DialogResult.OK) { return; } RegKey.PatNum = form.SelectedPatNum; RegistrationKeys.Update(RegKey); MessageBox.Show("Registration key moved successfully"); DialogResult = DialogResult.OK; //Chart module grid will refresh after closing this form, showing that the key is no longer in the ptinfo grid of the chart. }
///<summary>When sub is set, fills customer group box with various information. ///When null, clears all fields.</summary> private void SetCustomerInfo(BugSubmission sub = null) { if (sub == null) { textStack.Text = ""; //Also clear any submission specific fields. labelCustomerNum.Text = ""; labelCustomerName.Text = ""; labelCustomerState.Text = ""; labelCustomerPhone.Text = ""; labelSubNum.Text = ""; labelLastCall.Text = ""; FillOfficeInfoGrid(null); butGoToAccount.Enabled = false; butBugTask.Enabled = false; return; } try { if (_patCur == null) { RegistrationKey key = RegistrationKeys.GetByKey(sub.RegKey); _patCur = Patients.GetPat(key.PatNum); if (_patCur == null) { return; //Should not happen. } } labelCustomerNum.Text = _patCur.PatNum.ToString(); labelCustomerName.Text = _patCur.GetNameLF(); labelCustomerState.Text = _patCur.State; labelCustomerPhone.Text = _patCur.WkPhone; labelSubNum.Text = POut.Long(sub.BugSubmissionNum); labelLastCall.Text = Commlogs.GetDateTimeOfLastEntryForPat(_patCur.PatNum).ToString(); } catch (Exception ex) { ex.DoNothing(); } butGoToAccount.Enabled = true; butBugTask.Enabled = true; }
private void butDelete_Click(object sender, EventArgs e) { //Only Jordan should be able to delete resellers. if (!Security.IsAuthorized(Permissions.SecurityAdmin)) { return; } //Do not let the reseller be deleted if they have customers in their list. if (Resellers.HasActiveResellerCustomers(ResellerCur)) { MsgBox.Show(this, "This reseller cannot be deleted until all active services are removed from their customers. This should be done using the reseller portal."); return; } if (!MsgBox.Show(this, MsgBoxButtons.YesNo, "This will update PatStatus to inactive and set every registartion key's stop date.\r\nContinue?")) { return; } Patient patOld = Patients.GetPat(ResellerCur.PatNum); Patient patCur = patOld.Copy(); patCur.PatStatus = PatientStatus.Inactive; Patients.Update(patCur, patOld); RegistrationKey[] regKeys = RegistrationKeys.GetForPatient(patCur.PatNum); for (int i = 0; i < regKeys.Length; i++) { DateTime dateTimeNow = MiscData.GetNowDateTime(); if (regKeys[i].DateEnded.Year > 1880 && regKeys[i].DateEnded < dateTimeNow) { continue; //Key already ended. Nothing to do. } regKeys[i].DateEnded = MiscData.GetNowDateTime(); RegistrationKeys.Update(regKeys[i]); } Resellers.Delete(ResellerCur.ResellerNum); DialogResult = DialogResult.OK; }
private void FillSubGrid(bool isRefreshNeeded = false, string grouping95 = "") { List <string> listSelectedVersions = listVersionsFilter.SelectedItems.OfType <string>().ToList(); if (listSelectedVersions.Contains("All")) { listSelectedVersions.Clear(); } if (isRefreshNeeded && listSelectedVersions.IsNullOrEmpty()) { if (!MsgBox.Show(MsgBoxButtons.YesNo, "All bug submissions are going to be downloaded...\r\nAre you sure about this?")) { return; } } Action loadingProgress = null; Cursor = Cursors.WaitCursor; #region gridSubs columns gridSubs.BeginUpdate(); gridSubs.ListGridColumns.Clear(); gridSubs.ListGridColumns.Add(new GridColumn("Submitter", 140)); gridSubs.ListGridColumns.Add(new GridColumn("Vers.", 55, GridSortingStrategy.VersionNumber)); if (comboGrouping.SelectedIndex == 0) //Group by 'None' { gridSubs.ListGridColumns.Add(new GridColumn("DateTime", 75, GridSortingStrategy.DateParse)); } else { gridSubs.ListGridColumns.Add(new GridColumn("#", 30, HorizontalAlignment.Right, GridSortingStrategy.AmountParse)); } gridSubs.ListGridColumns.Add(new GridColumn("Flag", 50, HorizontalAlignment.Center)); gridSubs.ListGridColumns.Add(new GridColumn("Msg Text", 0)); gridSubs.AllowSortingByColumn = true; gridSubs.ListGridRows.Clear(); #endregion bugSubmissionControl.ClearCustomerInfo(); bugSubmissionControl.SetTextDevNoteEnabled(false); if (isRefreshNeeded) { loadingProgress = ODProgress.Show(ODEventType.BugSubmission, typeof(BugSubmissionEvent), Lan.g(this, "Refreshing Data") + "..."); #region Refresh Logic if (_viewMode.In(FormBugSubmissionMode.ViewOnly, FormBugSubmissionMode.ValidationMode)) { _listAllSubs = ListViewedSubs; } else { BugSubmissionEvent.Fire(ODEventType.BugSubmission, Lan.g(this, "Refreshing Data: Bugs")); _listAllSubs = BugSubmissions.GetAllInRange(dateRangePicker.GetDateTimeFrom(), dateRangePicker.GetDateTimeTo(), listSelectedVersions); } try { BugSubmissionEvent.Fire(ODEventType.BugSubmission, Lan.g(this, "Refreshing Data: Patients")); _dictPatients = RegistrationKeys.GetPatientsByKeys(_listAllSubs.Select(x => x.RegKey).ToList()); } catch (Exception e) { e.DoNothing(); _dictPatients = new Dictionary <string, Patient>(); } BugSubmissionEvent.Fire(ODEventType.BugSubmission, Lan.g(this, "Refreshing Data: JobLinks")); _listJobLinks = JobLinks.GetManyForType(JobLinkType.Bug, _listAllSubs.Select(x => x.BugId).Where(x => x != 0).Distinct().ToList()); #endregion } #region Filter Logic BugSubmissionEvent.Fire(ODEventType.BugSubmission, "Filtering Data"); List <BugSubmission> listFilteredSubs = null; List <string> listSelectedRegKeys = comboRegKeys.ListSelectedItems.Select(x => (string)x).ToList(); if (listSelectedRegKeys.Contains("All")) { listSelectedRegKeys.Clear(); } List <string> listStackFilters = textStackFilter.Text.Split(',') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => x.ToLower()).ToList(); List <string> listPatNumFilters = textPatNums.Text.Split(',') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => x.ToLower()).ToList(); _listAllSubs.ForEach(x => x.TagCustom = null); List <string> listCategoryFilters = textCategoryFilters.Text.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); string msgText = textMsgText.Text; string devNoteFilter = textDevNoteFilter.Text; DateTime dateTimeFrom = dateRangePicker.GetDateTimeFrom(); DateTime dateTimeTo = dateRangePicker.GetDateTimeTo(); //Filter the list of all bug submissions and then order it by program version and submission date time so that the grouping is predictable. listFilteredSubs = _listAllSubs.Where(x => PassesFilterValidation(x, listCategoryFilters, listSelectedRegKeys, listStackFilters, listPatNumFilters, listSelectedVersions, grouping95, msgText, devNoteFilter, dateTimeFrom, dateTimeTo) ) .OrderByDescending(x => new Version(x.ProgramVersion)) .ThenByDescending(x => x.SubmissionDateTime) .ToList(); if (isRefreshNeeded) { FillPatNameFilter(_listAllSubs); } #endregion #region Grouping Logic List <BugSubmission> listGridSubmissions = new List <BugSubmission>(); BugSubmissionEvent.Fire(ODEventType.BugSubmission, "Grouping Data"); switch (comboGrouping.SelectedIndex) { case 0: #region None foreach (BugSubmission bugSubmission in listFilteredSubs) { AddGroupedSubsToGridSubs(listGridSubmissions, new List <BugSubmission>() { bugSubmission }); } listShowHideOptions.SetSelected(3, false); //Deselect 'None' _minGroupingCount = -1; butAddJob.Enabled = true; #endregion break; case 1: #region RegKey/Ver/Stack listFilteredSubs.GroupBy(x => new { x.BugId, x.RegKey, x.ProgramVersion, x.ExceptionMessageText, x.ExceptionStackTrace }) .ToDictionary(x => x.Key, x => x.ToList()) .ForEach(x => AddGroupedSubsToGridSubs(listGridSubmissions, x.Value)); butAddJob.Enabled = true; #endregion break; case 2: #region StackTrace listFilteredSubs.GroupBy(x => new { x.BugId, x.ExceptionMessageText, x.ExceptionStackTrace }) .ToDictionary(x => x.Key, x => x.ToList()) .ForEach(x => AddGroupedSubsToGridSubs(listGridSubmissions, x.Value)); butAddJob.Enabled = true; #endregion break; case 3: #region 95% //At this point all bugSubmissions in listFilteredSubs is at least a 95% match. Group them all together in a single row. AddGroupedSubsToGridSubs(listGridSubmissions, listFilteredSubs); butAddJob.Enabled = true; #endregion break; case 4: #region StackSig listFilteredSubs.GroupBy(x => new { x.BugId, x.ExceptionMessageText, x.OdStackSignature }) .ToDictionary(x => x.Key, x => x.ToList()) .ForEach(x => AddGroupedSubsToGridSubs(listGridSubmissions, x.Value)); butAddJob.Enabled = false; //Can not add jobs in this mode. #endregion break; case 5: #region StackSimple listFilteredSubs.GroupBy(x => new { x.BugId, x.ExceptionMessageText, x.SimplifiedStackTrace }) .ToDictionary(x => x.Key, x => x.ToList()) .ForEach(x => AddGroupedSubsToGridSubs(listGridSubmissions, x.Value)); butAddJob.Enabled = false; //Can not add jobs in this mode. #endregion break; case 6: #region Hash listFilteredSubs.GroupBy(x => new { x.BugId, x.BugSubmissionHashNum }) .ToDictionary(x => x.Key, x => x.ToList()) .ForEach(x => AddGroupedSubsToGridSubs(listGridSubmissions, x.Value)); butAddJob.Enabled = false; //Can not add jobs in this mode. #endregion break; } if (_minGroupingCount > 0) { listGridSubmissions.RemoveAll(x => (x.TagCustom as List <BugSubmission>).Count < _minGroupingCount); } #endregion #region Sorting Logic BugSubmissionEvent.Fire(ODEventType.BugSubmission, "Sorting Data"); switch (comboSortBy.SelectedIndex) { case 0: listGridSubmissions = listGridSubmissions.OrderByDescending(x => new Version(x.ProgramVersion)) .ThenByDescending(x => GetGroupCount(x)) .ThenByDescending(x => x.SubmissionDateTime).ToList(); break; } #endregion #region Fill gridSubs BugSubmissionEvent.Fire(ODEventType.BugSubmission, "Filling Grid"); foreach (BugSubmission sub in listGridSubmissions) { gridSubs.ListGridRows.Add(GetODGridRowForSub(sub)); } gridSubs.EndUpdate(); #endregion loadingProgress?.Invoke(); Cursor = Cursors.Default; }
private void butDelete_Click(object sender, EventArgs e) { RegistrationKeys.Delete(registrationKey); Close(); }
///<summary>When sub is set, fills customer group box with various information. ///When null, clears all fields.</summary> private void SetCustomerInfo(BugSubmission sub = null, bool refreshGrid = true) { if (sub == null) { textStack.Text = ""; //Also clear any submission specific fields. labelCustomerNum.Text = ""; labelCustomerName.Text = ""; labelCustomerState.Text = ""; labelCustomerPhone.Text = ""; labelSubNum.Text = ""; labelLastCall.Text = ""; FillOfficeInfoGrid(null); gridCustomerSubs.BeginUpdate(); gridCustomerSubs.Rows.Clear(); gridCustomerSubs.EndUpdate(); butGoToAccount.Enabled = false; butBugTask.Enabled = false; return; } try { if (_dictPatients.ContainsKey(sub.RegKey)) { _patCur = _dictPatients[sub.RegKey]; } else { RegistrationKey key = RegistrationKeys.GetByKey(sub.RegKey); _patCur = Patients.GetPat(key.PatNum); if (_patCur == null) { return; //Should not happen. } _dictPatients.Add(sub.RegKey, _patCur); } labelCustomerNum.Text = _patCur.PatNum.ToString(); labelCustomerName.Text = _patCur.GetNameLF(); labelCustomerState.Text = _patCur.State; labelCustomerPhone.Text = _patCur.WkPhone; labelSubNum.Text = POut.Long(sub.BugSubmissionNum); labelLastCall.Text = Commlogs.GetDateTimeOfLastEntryForPat(_patCur.PatNum).ToString(); } catch (Exception ex) { ex.DoNothing(); } if (!refreshGrid) { return; } switch (comboGrouping.SelectedIndex) { case 0: #region None gridCustomerSubs.Title = "Customer Submissions"; gridCustomerSubs.BeginUpdate(); gridCustomerSubs.Columns.Clear(); gridCustomerSubs.Columns.Add(new ODGridColumn("Version", 100, HorizontalAlignment.Center)); gridCustomerSubs.Columns.Add(new ODGridColumn("Count", 50, HorizontalAlignment.Center)); gridCustomerSubs.Rows.Clear(); Dictionary <string, List <BugSubmission> > dictCustomerSubVersions = _listAllSubs .Where(x => x.RegKey == sub.RegKey) .GroupBy(x => x.Info.DictPrefValues[PrefName.ProgramVersion]) .ToDictionary(x => x.Key, x => x.DistinctBy(y => y.ExceptionStackTrace).ToList()); foreach (KeyValuePair <string, List <BugSubmission> > pair in dictCustomerSubVersions) { gridCustomerSubs.Rows.Add(new ODGridRow(pair.Key, pair.Value.Count.ToString())); } gridCustomerSubs.EndUpdate(); #endregion break; case 1: case 2: case 3: #region Customer, Stacktrace, 95% List <BugSubmission> listSubGroup = ((List <BugSubmission>)gridSubs.Rows[gridSubs.GetSelectedIndex()].Tag); gridCustomerSubs.Title = "Grouped Submissions"; gridCustomerSubs.BeginUpdate(); gridCustomerSubs.Columns.Clear(); gridCustomerSubs.Columns.Add(new ODGridColumn("Vers.", 55, HorizontalAlignment.Center)); gridCustomerSubs.Columns.Add(new ODGridColumn("RegKey", 140, HorizontalAlignment.Center)); gridCustomerSubs.Rows.Clear(); listSubGroup.ForEach(x => { ODGridRow row = new ODGridRow(x.Info.DictPrefValues[PrefName.ProgramVersion], x.RegKey); row.Tag = x; gridCustomerSubs.Rows.Add(row); }); gridCustomerSubs.EndUpdate(); #endregion break; } butGoToAccount.Enabled = true; butBugTask.Enabled = true; }
private void FillSubGrid(bool isRefreshNeeded = false) { SetCustomerInfo(); if (isRefreshNeeded) { if (_viewMode.In(FormBugSubmissionMode.ViewOnly, FormBugSubmissionMode.ValidationMode)) { _listAllSubs = ListViewedSubs; } else { _listAllSubs = BugSubmissions.GetAllInRange(dateRangePicker.GetDateTimeFrom(), dateRangePicker.GetDateTimeTo()); } try { _dictPatients = RegistrationKeys.GetPatientsByKeys(_listAllSubs.Select(x => x.RegKey).ToList()); } catch (Exception e) { e.DoNothing(); _dictPatients = new Dictionary <string, Patient>(); } } gridSubs.BeginUpdate(); gridSubs.Columns.Clear(); gridSubs.Columns.Add(new ODGridColumn("Reg Key", 140)); gridSubs.Columns.Add(new ODGridColumn("Vers.", 55, GridSortingStrategy.VersionNumber)); if (comboGrouping.SelectedIndex == 0) //None { gridSubs.Columns.Add(new ODGridColumn("DateTime", 75, GridSortingStrategy.DateParse)); } else { gridSubs.Columns.Add(new ODGridColumn("Count", 75, GridSortingStrategy.AmountParse)); } gridSubs.Columns.Add(new ODGridColumn("HasBug", 50, HorizontalAlignment.Center)); gridSubs.Columns.Add(new ODGridColumn("Msg Text", 300)); gridSubs.AllowSortingByColumn = true; List <string> listSelectedVersions = comboVersions.ListSelectedItems.Select(x => (string)x).ToList(); if (listSelectedVersions.Contains("All")) { listSelectedVersions.Clear(); } List <string> listSelectedRegKeys = comboRegKeys.ListSelectedItems.Select(x => (string)x).ToList(); if (listSelectedRegKeys.Contains("All")) { listSelectedRegKeys.Clear(); } List <string> listStackFilters = textStackFilter.Text.Split(',') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => x.ToLower()).ToList(); List <string> listPatNumFilters = textPatNums.Text.Split(',') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => x.ToLower()).ToList(); gridSubs.Rows.Clear(); _listAllSubs.ForEach(x => x.TagOD = null); List <BugSubmission> listFilteredSubs = _listAllSubs.Where(x => PassesFilterValidation(x, listSelectedRegKeys, listStackFilters, listPatNumFilters, listSelectedVersions) ).ToList(); foreach (BugSubmission sub in listFilteredSubs) { ODGridRow row = new ODGridRow(); row.Cells.Add(sub.RegKey); row.Cells.Add(sub.Info.DictPrefValues[PrefName.ProgramVersion]); List <BugSubmission> listPreviousRows; List <BugSubmission> listGroupedSubs; List <string> listProgVersions; switch (comboGrouping.SelectedIndex) { case 0: #region None row.Cells.Add(sub.SubmissionDateTime.ToString().Replace('\r', ' ')); row.Tag = new List <BugSubmission>() { sub }; //Tag is a specific bugSubmission #endregion break; case 1: #region Customer //Take previously proccessed rows and see if we have already handled the grouping. listPreviousRows = listFilteredSubs.Take(listFilteredSubs.IndexOf(sub)).ToList(); if (listPreviousRows.Any(x => x.RegKey == sub.RegKey && x.Info.DictPrefValues[PrefName.ProgramVersion] == sub.Info.DictPrefValues[PrefName.ProgramVersion] && x.ExceptionStackTrace == sub.ExceptionStackTrace && x.BugId == sub.BugId)) { //Skip adding rows that have already been added when grouping continue; } listGroupedSubs = listFilteredSubs.FindAll(x => x.RegKey == sub.RegKey && x.Info.DictPrefValues[PrefName.ProgramVersion] == sub.Info.DictPrefValues[PrefName.ProgramVersion] && x.ExceptionStackTrace == sub.ExceptionStackTrace && x.BugId == sub.BugId); row.Cells.Add(listGroupedSubs.Count.ToString()); //row.Cells[1].Text=string.Join(",",listGroupedSubs.Select(x => x.Info.DictPrefValues[PrefName.ProgramVersion]).ToList()); listProgVersions = listGroupedSubs.Select(x => x.Info.DictPrefValues[PrefName.ProgramVersion]).Distinct().ToList(); if (listProgVersions.Count > 1) { row.Cells[1].Text = listProgVersions.Select(x => new Version(x)).Max().ToString(); } else { row.Cells[1].Text = listProgVersions.First(); } row.Tag = listGroupedSubs; //Tag is a list of bugSubmissions #endregion break; case 2: #region StackTrace //Take previously proccessed rows and see if we have already handled the grouping. listPreviousRows = listFilteredSubs.Take(listFilteredSubs.IndexOf(sub)).ToList(); if (listPreviousRows.Any(x => x.ExceptionStackTrace == sub.ExceptionStackTrace && x.BugId == sub.BugId)) { //Skip adding rows that have already been added when grouping continue; } listGroupedSubs = listFilteredSubs.FindAll(x => x.ExceptionStackTrace == sub.ExceptionStackTrace && x.BugId == sub.BugId); row.Cells.Add(listGroupedSubs.Count.ToString()); listProgVersions = listGroupedSubs.Select(x => x.Info.DictPrefValues[PrefName.ProgramVersion]).Distinct().ToList(); if (listProgVersions.Count > 1) { row.Cells[1].Text = listProgVersions.Select(x => new Version(x)).Max().ToString(); } else { row.Cells[1].Text = listProgVersions.First(); } row.Tag = listGroupedSubs; //Tag is a list of bugSubmissions #endregion break; case 3: #region 95% //if(sub.TagOD!=null) { // continue; //} //listGroupedSubs=listFilteredSubs.FindAll(x => x.BugId==sub.BugId // &&x.TagOD==null // &&CalculateSimilarity(x.ExceptionMessageText,sub.ExceptionMessageText)>95 // &&(x==sub||CalculateSimilarity(x.ExceptionStackTrace,sub.ExceptionStackTrace)>95)); //listGroupedSubs.ForEach(x => x.TagOD=true); //row.Cells.Add(listGroupedSubs.Count.ToString()); //listProgVersions=listGroupedSubs.Select(x => x.Info.DictPrefValues[PrefName.ProgramVersion]).Distinct().ToList(); //if(listProgVersions.Count>1) { // row.Cells[1].Text=listProgVersions.Select(x => new Version(x)).Max().ToString(); //} //else { // row.Cells[1].Text=listProgVersions.First(); //} //row.Tag=listGroupedSubs;//Tag is a list of bugSubmissions #endregion break; } row.Cells.Add(sub.BugId == 0 ? "" : "X"); row.Cells.Add(sub.ExceptionMessageText); gridSubs.Rows.Add(row); } gridSubs.EndUpdate(); gridSubs.SortForced(1, false); //Sort by Version column if (isRefreshNeeded) { FillVersionsFilter(); FillRegKeyFilter(); } }
private void FillSubGrid(bool isRefreshNeeded = false, string grouping95 = "") { Action loadingProgress = null; Cursor = Cursors.WaitCursor; bugSubmissionControl.ClearCustomerInfo(); bugSubmissionControl.SetTextDevNoteEnabled(false); if (isRefreshNeeded) { loadingProgress = ODProgressOld.ShowProgressStatus("FormBugSubmissions", this, Lan.g(this, "Refreshing Data") + "...", false); #region Refresh Logic if (_viewMode.In(FormBugSubmissionMode.ViewOnly, FormBugSubmissionMode.ValidationMode)) { _listAllSubs = ListViewedSubs; } else { _listAllSubs = BugSubmissions.GetAllInRange(dateRangePicker.GetDateTimeFrom(), dateRangePicker.GetDateTimeTo()); } try { _dictPatients = RegistrationKeys.GetPatientsByKeys(_listAllSubs.Select(x => x.RegKey).ToList()); } catch (Exception e) { e.DoNothing(); _dictPatients = new Dictionary <string, Patient>(); } #endregion } gridSubs.BeginUpdate(); #region gridSubs columns gridSubs.Columns.Clear(); gridSubs.Columns.Add(new ODGridColumn("Submitter", 140)); gridSubs.Columns.Add(new ODGridColumn("Vers.", 55, GridSortingStrategy.VersionNumber)); if (comboGrouping.SelectedIndex == 0) //Group by 'None' { gridSubs.Columns.Add(new ODGridColumn("DateTime", 75, GridSortingStrategy.DateParse)); } else { gridSubs.Columns.Add(new ODGridColumn("Count", 75, GridSortingStrategy.AmountParse)); } gridSubs.Columns.Add(new ODGridColumn("HasBug", 50, HorizontalAlignment.Center)); gridSubs.Columns.Add(new ODGridColumn("Msg Text", 300)); gridSubs.AllowSortingByColumn = true; #endregion #region Filter Logic ODEvent.Fire(new ODEventArgs("FormBugSubmissions", "Filtering Data")); List <string> listSelectedVersions = comboVersions.ListSelectedItems.Select(x => (string)x).ToList(); if (listSelectedVersions.Contains("All")) { listSelectedVersions.Clear(); } List <string> listSelectedRegKeys = comboRegKeys.ListSelectedItems.Select(x => (string)x).ToList(); if (listSelectedRegKeys.Contains("All")) { listSelectedRegKeys.Clear(); } List <string> listStackFilters = textStackFilter.Text.Split(',') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => x.ToLower()).ToList(); List <string> listPatNumFilters = textPatNums.Text.Split(',') .Where(x => !string.IsNullOrWhiteSpace(x)) .Select(x => x.ToLower()).ToList(); _listAllSubs.ForEach(x => x.TagOD = null); List <BugSubmission> listFilteredSubs = _listAllSubs.Where(x => PassesFilterValidation(x, listSelectedRegKeys, listStackFilters, listPatNumFilters, listSelectedVersions, grouping95) ).ToList(); if (isRefreshNeeded) { FillVersionsFilter(listFilteredSubs); FillRegKeyFilter(listFilteredSubs); } #endregion #region Grouping Logic List <BugSubmission> listGroupedSubs; int index = 0; List <BugSubmission> listGridSubmissions = new List <BugSubmission>(); foreach (BugSubmission sub in listFilteredSubs) { ODEvent.Fire(new ODEventArgs("FormBugSubmissions", "Grouping Data: " + POut.Double(((double)index++ / (double)listFilteredSubs.Count) * 100) + "%")); if (sub.TagOD != null) { continue; } switch (comboGrouping.SelectedIndex) { case 0: #region None sub.TagOD = new List <BugSubmission>() { sub }; //Tag is a specific bugSubmission listGridSubmissions.Add(sub.Copy()); #endregion break; case 1: #region RegKey/Ver/Stack listGroupedSubs = listFilteredSubs.FindAll(x => x.TagOD == null && x.RegKey == sub.RegKey && x.Info.DictPrefValues[PrefName.ProgramVersion] == sub.Info.DictPrefValues[PrefName.ProgramVersion] && x.ExceptionStackTrace == sub.ExceptionStackTrace && x.BugId == sub.BugId); if (listGroupedSubs.Count == 0) { continue; } listGroupedSubs = listGroupedSubs.OrderByDescending(x => new Version(x.Info.DictPrefValues[PrefName.ProgramVersion])) .ThenByDescending(x => x.SubmissionDateTime).ToList(); listGroupedSubs.ForEach(x => x.TagOD = true); //So we don't considered previously handled submissions. listGroupedSubs.First().TagOD = listGroupedSubs; //First element is what is shown in grid, still wont be considered again. listGridSubmissions.Add(listGroupedSubs.First().Copy()); #endregion break; case 2: #region StackTrace listGroupedSubs = listFilteredSubs.FindAll(x => x.TagOD == null && x.ExceptionStackTrace == sub.ExceptionStackTrace && x.BugId == sub.BugId); if (listGroupedSubs.Count == 0) { continue; } listGroupedSubs = listGroupedSubs.OrderByDescending(x => new Version(x.Info.DictPrefValues[PrefName.ProgramVersion])) .ThenByDescending(x => x.SubmissionDateTime).ToList(); listGroupedSubs.ForEach(x => x.TagOD = true); //So we don't considered previously handled submissions. listGroupedSubs.First().TagOD = listGroupedSubs; //First element is what is shown in grid, still wont be considered again. listGridSubmissions.Add(listGroupedSubs.First().Copy()); #endregion break; case 3: #region 95% //At this point all bugSubmissions in listFilteredSubs is at least a 95% match. Group them all together in a single row. listGroupedSubs = listFilteredSubs; listGroupedSubs = listGroupedSubs.OrderByDescending(x => new Version(x.Info.DictPrefValues[PrefName.ProgramVersion])) .ThenByDescending(x => x.SubmissionDateTime).ToList(); listGroupedSubs.ForEach(x => x.TagOD = true); //So we don't considered previously handled submissions. listGroupedSubs.First().TagOD = listGroupedSubs; //First element is what is shown in grid, still wont be considered again. listGridSubmissions.Add(listGroupedSubs.First().Copy()); #endregion break; } } #endregion #region Sorting Logic ODEvent.Fire(new ODEventArgs("FormBugSubmissions", "Sorting Data")); switch (comboSortBy.SelectedIndex) { case 0: listGridSubmissions = listGridSubmissions.OrderByDescending(x => new Version(x.Info.DictPrefValues[PrefName.ProgramVersion])) .ThenByDescending(x => GetGroupCount(x)) .ThenByDescending(x => x.SubmissionDateTime).ToList(); break; } #endregion #region Fill gridSubs gridSubs.Rows.Clear(); index = 0; foreach (BugSubmission sub in listGridSubmissions) { ODEvent.Fire(new ODEventArgs("FormBugSubmissions", "Filling Grid: " + POut.Double(((double)index++ / (double)listFilteredSubs.Count) * 100) + "%")); gridSubs.Rows.Add(GetODGridRowForSub(sub)); } gridSubs.EndUpdate(); #endregion try { loadingProgress?.Invoke(); //When this function executes quickly this can fail rarely, fail silently because of WaitCursor. } catch (Exception ex) { ex.DoNothing(); } Cursor = Cursors.Default; }