public void Refresh() { //Refresh this object try { //Get latest Issue issue = this.ID > 0 ? CRGFactory.GetIssue(this.ID) : null; if (issue != null) { //Updatable fields only this._ofd1datefrom = issue.OFD1FromDate; this._ofd1dateto = issue.OFD1ToDate; this._proid = issue.PROID; this.mActions.Clear(); this.mActions.Merge(issue.Actions); this.mAttachments.Clear(); this.mAttachments.Merge(issue.Attachments); } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { throw new ApplicationException("Unexpected error while refreshing issue.", ex); } finally { if (this.Changed != null) { this.Changed(this, EventArgs.Empty); } } }
private void OnGridSelectionChanged(object sender, Infragistics.Win.UltraWinGrid.AfterSelectChangeEventArgs e) { //Event handler for after selection changes this.Cursor = Cursors.WaitCursor; try { //Update the selected issue if not looking at another issue view this.mIssue = null; UltraGrid grid = (UltraGrid)sender; if (grid.Selected.Rows.Count > 0) { switch (this.cboView.Text) { case "Search Results": this.mIssue = CRGFactory.GetIssue(Convert.ToInt32(grid.Selected.Rows[0].Cells["ID"].Value)); break; case "Issue History": this.mIssue = CRGFactory.GetIssue(Convert.ToInt32(grid.Selected.Rows[0].Cells["ID"].Value)); break; default: this.mIssue = CRGFactory.GetIssue(Convert.ToInt32(grid.Selected.Rows[0].Cells["ID"].Value)); this.mIssueH = this.mIssue; break; } try { //Unbold viewed issues/actions grid.Selected.Rows[0].CellAppearance.FontData.Bold = DefaultableBoolean.False; int id = Convert.ToInt32(grid.Selected.Rows[0].Cells["ID"].Value); DateTime dt1 = Convert.ToDateTime(grid.Selected.Rows[0].Cells["LastActionCreated"].Value); if (this.mOldItems.ContainsKey(id)) { this.mOldItems[id] = dt1; } else { this.mOldItems.Add(id, dt1); } } catch { } } if (this.IssueSelected != null) { this.IssueSelected(this, EventArgs.Empty); } } catch { } finally { setUserServices(); this.Cursor = Cursors.Default; } }
private void OnMenuClick(object sender, System.EventArgs e) { //Event handler for menu selection Issue issue = null; try { ToolStripDropDownItem menu = (ToolStripDropDownItem)sender; switch (menu.Text) { case MNU_NEW: issue = CRGFactory.GetIssue(0); dlgIssue dlg = new dlgIssue(issue); dlg.Font = this.Font; if (dlg.ShowDialog() == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; if (issue.Save()) { for (int i = 0; i < this.grdIssues.Rows.Count; i++) { int id = Convert.ToInt32(this.grdIssues.Rows[i].Cells["ID"].Value); if (id == issue.ID) { this.grdIssues.Rows[i].Selected = true; this.grdIssues.DisplayLayout.Bands[0].Columns["LastActionCreated"].SortIndicator = SortIndicator.Descending; OnGridSelectionChanged(this.grdIssues, null); break; } } } } break; case MNU_OPEN: break; case MNU_SAVE: break; case MNU_SAVEAS: SaveFileDialog dlgSave = new SaveFileDialog(); dlgSave.AddExtension = true; dlgSave.Filter = "Export Files (*.xml) | *.xml | Excel Files (*.xls) | *.xls"; dlgSave.FilterIndex = 0; dlgSave.Title = "Save Issues As..."; dlgSave.FileName = ""; dlgSave.OverwritePrompt = true; if (dlgSave.ShowDialog(this) == DialogResult.OK) { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); if (dlgSave.FileName.EndsWith("xls")) { new Argix.ExcelFormat().Transform(this.mIssues, dlgSave.FileName); } else { this.mIssues.WriteXml(dlgSave.FileName, XmlWriteMode.WriteSchema); } } break; case MNU_SETUP: UltraGridPrinter.PageSettings(); break; case MNU_PRINT: UltraGridPrinter.Print(this.grdIssues, this.grdIssues.Text, true); break; case MNU_PREVIEW: UltraGridPrinter.PrintPreview(this.grdIssues, this.grdIssues.Text); break; case MNU_REFRESH: this.Cursor = Cursors.WaitCursor; this.mGridSvcIssues.CaptureState("ID"); switch (this.cboView.Text) { case "Search Results": break; case "Issue History": this.mIssueHistory.Clear(); this.mIssueHistory.Merge(CRGFactory.IssueHistory(this.mIssueH)); break; case "Draft Issues": break; default: DataSet ds = CRGFactory.GetIssues(); lock (this.mIssues) { this.mIssues.Clear(); this.mIssues.Merge(ds); } postIssueUpdates(); break; } this.mGridSvcIssues.RestoreState(); break; case MNU_REFRESHCACHE: EnterpriseFactory.RefreshCache(); CRGFactory.RefreshCache(); break; case MNU_AUTOREFRESHON: this.mnuCtxAutoRefreshOn.Checked = !this.mnuCtxAutoRefreshOn.Checked; if (this.mnuCtxAutoRefreshOn.Checked) { StartAuto(); } else { StopAuto(); } break; case MNU_CONTACTS: winContacts winC = new winContacts(); winC.Font = this.Font; winC.ShowDialog(); break; case MNU_PROPERTIES: break; } } catch (Exception ex) { reportError(ex); } finally { setUserServices(); this.Cursor = Cursors.Default; } }
public void OnFileAction(Office.IRibbonControl control) { //Event handler for view contacts clicked Outlook.Inspector insp = null; Outlook.MailItem m = null; Outlook.Attachments attachments = null; Issue issue = null; try { Tools.CustomTaskPane ctp = null; IssueSelector ie = null; Outlook.Inspector inspector = (Outlook.Inspector)control.Context; if (Globals.ThisAddIn.InspectorWrappers.ContainsKey(inspector)) { InspectorWrapper iw = Globals.ThisAddIn.InspectorWrappers[inspector]; ctp = iw.CustomTaskPane; if (ctp != null) { ie = (IssueSelector)ctp.Control; } } switch (control.Id) { case "btnNew": //Add the current outlook message as an issue action in a new issue //Show explorer if not visible ctp.Visible = true; //Get the current email item and any associated attachments insp = Globals.ThisAddIn.Application.ActiveInspector(); m = (Outlook.MailItem)insp.CurrentItem; attachments = m.Attachments; //Get a new issue; allow user interaction issue = CRGFactory.GetIssue(0); issue.Subject = m.Subject; issue.Actions.ActionTable[0].Comment = m.Body; if (new dlgIssue(issue).ShowDialog() == DialogResult.OK) { //Save (create) the new issue issue.Save(); if (ie != null) { ie.SelectedID = issue.ID; } } break; case "btnAdd": //Add the current outlook message as an issue action issue = ie != null ? ie.SelectedIssue : null; if (issue == null) { App.ReportError(new ApplicationException("Could not determine selected issue."), true, LogLevel.Error); } else { //Get the current email item and any associated attachments insp = Globals.ThisAddIn.Application.ActiveInspector(); m = (Outlook.MailItem)insp.CurrentItem; attachments = m.Attachments; //Get a new action and add attachments Issue.Action action = issue.Item(0); action.Comment = m.Body; foreach (Outlook.Attachment a in attachments) { Issue.Attachment attachment = action.Item(0); attachment.Filename = CRGFactory.TempFolder + a.FileName; action.Add(attachment); } //Allow user interaction if (new dlgAction(action).ShowDialog() == DialogResult.OK) { //Save selected attachments to TEMP dir foreach (Outlook.Attachment a in attachments) { try { if (action.Item(CRGFactory.TempFolder + a.FileName) != null) { a.SaveAsFile(CRGFactory.TempFolder + a.FileName); } } catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error while saving mail attachments to temporary storage; continuing...", ex), true, LogLevel.Error); } } //Save the action issue.Add(action); ie.SelectedID = issue.ID; } } break; } } catch (ApplicationException ex) { throw ex; } catch (Exception ex) { App.ReportError(new ApplicationException("Unexpected error while handling File actions in the Issue Mgt ribbon extension.", ex), true, LogLevel.Error); } finally { this.mRibbonUI.Invalidate(); } }