示例#1
0
        private void OnMenuClick(object sender, EventArgs e)
        {
            //Event handler for mneu item clicked
            try {
                ToolStripDropDownItem menu = (ToolStripDropDownItem)sender;
                switch (menu.Text)
                {
                case MNU_NEW:
                    Issue.Action action = this.mIssue.Item(0);
                    dlgAction    dlgNA  = new dlgAction(action);
                    dlgNA.Font = this.Font;
                    if (dlgNA.ShowDialog(this) == DialogResult.OK)
                    {
                        //Add the action to the issue
                        this.mIssue.Add(action);
                    }
                    break;

                case MNU_PRINT:
                    WinPrinter2 wp  = new WinPrinter2("", this.txtAction.Font);
                    Issue       i   = this.mIssue;
                    string      doc = "Issue Type: \t" + i.Type + "\r\nSubject: \t\t" + i.Subject + "\r\nContact: \t\t" + i.Contact + "\r\n" + "\r\nCompany: \t" + i.Company + "\r\nStore#: \t\t" + i.StoreNumber.ToString() + "\r\nAgent#: \t" + i.AgentNumber + "\r\nZone: \t\t" + i.Zone;
                    doc += "\r\n\r\n\r\n" + i.GetAllActionComments();
                    wp.Print(i.Subject, doc, true);
                    break;

                case MNU_REFRESH: this.mIssue.Refresh(); break;

                case MNU_ARRANGEBYDATE: break;
                }
            }
            catch (Exception ex) { reportError(new ControlException("Unexpected error setting IssueInspector menu services.", ex)); }
        }
示例#2
0
        private void loadActions()
        {
            //Event handler for change in actions collection
            //Load actions for this issue
            this.lsvActions.Groups.Clear();
            this.lsvActions.Items.Clear();
            if (this.mIssue != null)
            {
                //Create action listitems sorted by date/time
                IssueDS actions = new IssueDS();
                actions.Merge(this.mIssue.Actions.ActionTable.Select("", "Created DESC"));
                for (int i = 0; i < actions.ActionTable.Rows.Count; i++)
                {
                    //Add attachment symbol as required
                    //Tag is used to enable attachement to newest action only
                    Issue.Action action = this.mIssue.Item(actions.ActionTable[i].ID);
                    ListViewItem item   = this.lsvActions.Items.Add(action.ID.ToString(), action.UserID, (action.Attachments.AttachmentTable.Rows.Count > 0 ? 0 : -1));
                    item.Tag = i.ToString();

                    //Assign to listitem group
                    DateTime created      = actions.ActionTable[i].Created;
                    bool     useYesterday = DateTime.Today.DayOfWeek != DayOfWeek.Monday;
                    if (created.CompareTo(DateTime.Today) >= 0)
                    {
                        this.lsvActions.Groups.Add("Today", "Today");
                        item.SubItems.Add(created.ToString("ddd HH:mm"));
                        item.Group = this.lsvActions.Groups["Today"];
                    }
                    else if (useYesterday && created.CompareTo(DateTime.Today.AddDays(-1)) >= 0)
                    {
                        this.lsvActions.Groups.Add("Yesterday", "Yesterday");
                        item.SubItems.Add(created.ToString("ddd HH:mm"));
                        item.Group = this.lsvActions.Groups["Yesterday"];
                    }
                    else if (created.CompareTo(DateTime.Today.AddDays(0 - DateTime.Today.DayOfWeek)) >= 0)
                    {
                        this.lsvActions.Groups.Add("This Week", "This Week");
                        item.SubItems.Add(created.ToString("ddd HH:mm"));
                        item.Group = this.lsvActions.Groups["This Week"];
                    }
                    else if (created.CompareTo(DateTime.Today.AddDays(0 - DateTime.Today.DayOfWeek - 7)) >= 0)
                    {
                        this.lsvActions.Groups.Add("Last Week", "Last Week");
                        item.SubItems.Add(created.ToString("ddd MM/dd HH:mm"));
                        item.Group = this.lsvActions.Groups["Last Week"];
                    }
                    else
                    {
                        this.lsvActions.Groups.Add("Other", "Other");
                        item.SubItems.Add(created.ToString("ddd MM/dd/yyyy HH:mm"));
                        item.Group = this.lsvActions.Groups["Other"];
                    }
                }
            }
            if (this.lsvActions.Items.Count > 0)
            {
                this.lsvActions.Items[0].Selected = true;
            }
            OnActionSelected(null, EventArgs.Empty);
        }
示例#3
0
 //Interface
 public dlgAction(Issue.Action action)
 {
     //Constructor
     try {
         InitializeComponent();
         this.btnOk.Text         = CMD_OK;
         this.btnCancel.Text     = CMD_CANCEL;
         this.btnSpellCheck.Text = CMD_SPELLCHECK;
         this.mAction            = action;
         this.Text = "Action (New) for " + this.mAction.Parent.Subject;
     }
     catch (Exception ex) { throw new ApplicationException("Unexpected error while creating new dlgAction instance.", ex); }
 }
示例#4
0
        private void OnDragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
            //Event handler for dropping onto the listview
            try {
                DataObject data = (DataObject)e.Data;
                if (data.GetDataPresent(DataFormats.FileDrop))
                {
                    //Local file
                    string[] names = (string[])data.GetData(DataFormats.FileDrop);
                    if (names.Length > 0)
                    {
                        //Save attachment
                        long             id         = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name);
                        Issue.Action     action     = this.mIssue.Item(id);
                        Issue.Attachment attachment = action.Item(0);
                        attachment.Filename = names[0];
                        attachment.Save();
                    }
                }
                else if (data.GetDataPresent("FileGroupDescriptor"))
                {
                    //Outlook attachment
                    //Set the position within the current stream to the beginning of the file name
                    //return the file name in the fileName variable
                    System.IO.MemoryStream stream = (System.IO.MemoryStream)data.GetData("FileGroupDescriptor");
                    stream.Seek(76, System.IO.SeekOrigin.Begin);
                    byte[] fileName = new byte[256];
                    stream.Read(fileName, 0, 256);
                    System.Text.Encoding encoding = System.Text.Encoding.ASCII;
                    string name = encoding.GetString(fileName);
                    name = name.TrimEnd('\0');

                    //Write the file content to a file under the same path of the exe file.
                    stream = (System.IO.MemoryStream)e.Data.GetData("FileContents");
                    System.IO.FileStream fs = new System.IO.FileStream(name, System.IO.FileMode.Create);
                    stream.WriteTo(fs);
                    fs.Close();

                    //Save attachment
                    long             id         = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name);
                    Issue.Action     action     = this.mIssue.Item(id);
                    Issue.Attachment attachment = action.Item(0);
                    attachment.Filename = name;
                    attachment.Save();
                }
            }
            catch (Exception ex) { reportError(ex); }
            finally { setUserServices(); }
        }
示例#5
0
        private void OnActionSelected(object sender, EventArgs e)
        {
            //Event handler for change in selected action
            try {
                this.txtAction.Text = "";
                this.lsvAttachments.Items.Clear();
                if (this.lsvActions.SelectedItems.Count > 0)
                {
                    //Show the selected action
                    long         actionID = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name);
                    Issue.Action action   = this.mIssue.Item(actionID);
                    if (action != null)
                    {
                        IssueDS actions = new IssueDS();
                        actions.Merge(this.mIssue.Actions.ActionTable.Select("Created <= '" + action.Created.AddSeconds(1) + "'", "Created DESC"));
                        int start = 0;
                        for (int i = 0; i < actions.ActionTable.Rows.Count; i++)
                        {
                            string header = actions.ActionTable[i].Created.ToString("f") + "     " + actions.ActionTable[i].UserID + ", " + Issue.Action.GetActionTypeName(actions.ActionTable[i].TypeID);
                            this.txtAction.AppendText(header);
                            this.txtAction.Select(start, header.Length);
                            this.txtAction.SelectionFont = new Font(this.txtAction.Font, FontStyle.Bold);
                            this.txtAction.AppendText("\r\n\r\n");
                            this.txtAction.AppendText(actions.ActionTable[i].Comment);
                            this.txtAction.AppendText("\r\n");
                            this.txtAction.AppendText("".PadRight(75, '-'));
                            this.txtAction.AppendText("\r\n");
                            start = this.txtAction.Text.Length;
                        }

                        //Show the attachments
                        IssueDS attachments = action.Attachments;
                        this.lsvAttachments.Items.Clear();
                        for (int i = 0; i < attachments.AttachmentTable.Rows.Count; i++)
                        {
                            string key  = attachments.AttachmentTable[i].ID.ToString();
                            string text = attachments.AttachmentTable[i].FileName.Trim();
                            this.lsvAttachments.Items.Add(text);
                        }
                        this.lsvAttachments.View = View.List;
                    }
                }
            }
            catch (Exception ex) { reportError(new ControlException("Unexpected error on change of selected issue action in the IssueInspector control.", ex)); }
            finally { setUserServices(); };
        }
示例#6
0
        private void OnToolbarItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            //Toolbar handler - forward to main menu handler
            long id = 0;

            Issue.Action     action     = null;
            Issue.Attachment attachment = null;
            try {
                //Get the current action
                id     = Convert.ToInt64(this.lsvActions.SelectedItems[0].Name);
                action = this.mIssue.Item(id);
                switch (e.ClickedItem.Name)
                {
                case "btnNew":  this.ctxActionsNew.PerformClick(); break;

                case "btnPrint": this.ctxActionsPrint.PerformClick();  break;

                case "btnRefresh": this.ctxRefresh.PerformClick(); break;

                case "btnOpen":
                    //Open the selected attachment
                    attachment = action.Item(this.lsvAttachments.SelectedItems[0].Text);
                    attachment.Open();
                    break;

                case "btnAttach":
                    //Save an attachment to the selected action
                    OpenFileDialog dlgOpen = new OpenFileDialog();
                    dlgOpen.AddExtension = true;
                    dlgOpen.Filter       = "All Files (*.*) | *.*";
                    dlgOpen.FilterIndex  = 0;
                    dlgOpen.Title        = "Select Attachment to Save...";
                    dlgOpen.FileName     = "";
                    if (dlgOpen.ShowDialog(this) == DialogResult.OK)
                    {
                        attachment          = action.Item(0);
                        attachment.Filename = dlgOpen.FileName;
                        attachment.Save();
                        OnActionSelected(null, EventArgs.Empty);
                    }
                    break;

                case "btnSend":
                    if (this.lsvActions.SelectedItems.Count > 0)
                    {
                        //Create new mail item
                        if (OutlookApp == null)
                        {
                            return;
                        }
                        Outlook.MailItem item = (Outlook.MailItem)OutlookApp.CreateItem(Outlook.OlItemType.olMailItem);
                        item.Subject = this._Issue.Subject;
                        item.Body    = action.Comment;
                        item.To      = EnterpriseFactory.GetContact(this._Issue.ContactID).Email;
                        item.Display(false);
                    }
                    break;
                }
            }
            catch (Exception ex) { reportError(new ControlException("Unexpected error in IssueInspector.", ex)); }
        }
示例#7
0
        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(); }
        }