示例#1
0
        private void IndexBtn_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                XLDocument.currentDoc.Save();

                //populate description
                string desc = XLDocument.ReadParameter("DocType");
                desc += " to ";
                desc += XLDocument.ReadBookmark("Addressee");
                string        str    = XLDocument.ReadParameter("CRMid");
                XLMain.Client client = new XLMain.Client();
                if (str != "")
                {
                    client = XLMain.Client.FetchClient(str);
                }
                else
                {
                    ClientForm cForm = new ClientForm();
                    cForm.ShowDialog();
                    client = cForm.selectedClient;
                }
                XLMain.Staff writer   = new XLMain.Staff();
                string       writerID = XLDocument.ReadParameter("Sender");
                if (writerID == "")
                {
                    writer = XLMain.Staff.StaffFromUser(Environment.UserName);
                }
                else
                {
                    writer = XLMain.Staff.StaffFromUser(XLDocument.ReadParameter("Sender"));
                }

                VCForm myForm = new VCForm(writer, client, XLDocument.currentDoc.FullName, desc, XLDocument.ReadParameter("VCStatus"));
                myForm.ShowDialog();
                //collect result from form
                XLVirtualCabinet.BondResult outcome = myForm.outcome;

                if (outcome.ExitCode == 0)
                {
                    XLDocument.EndDocument();
                    xlTaskPane1.Dispose();
                }
                else
                {
                    MessageBox.Show("Unable to index document, please index manually.  Error code: " + outcome.ExitCode.ToString() + "-" + outcome.StandardOutput.ToString());
                }
                //close the dialog in any event.
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error calling the VC integration. Error code: " + ex.ToString());
                XLtools.LogException("IndexBtn", ex.ToString());
            }
        }
示例#2
0
 private void UpdateBookmarks(string docType)
 {
     try
     {
         //Build reference
         string ourRef = OurRef(client, sender, user);
         if (docType == "Letter")
         {
             XLDocument.UpdateBookmark("Address", addTB.Text);
             XLDocument.UpdateBookmark("Salutation", SalutationTb.Text);
             XLDocument.UpdateBookmark("Subject", SubjectTB.Text);
             XLDocument.UpdateBookmark("Date", DateTB.Value.Date.ToString("d MMMM yyyy"));
             XLDocument.UpdateBookmark("Date2", DateTB.Value.Date.ToString("d MMMM yyyy"));
             XLDocument.UpdateBookmark("Addressee", AddresseeTB.Text);
             XLDocument.UpdateBookmark("Addressee2", AddresseeTB.Text);
             DeploySignature(client, sender, AddresseeTB.Text);
             XLDocument.UpdateBookmark("OurRef", ourRef, 0);
         }
         else if (docType == "Fax")
         {
             XLDocument.UpdateBookmark("Subject", SubjectTB.Text);
             XLDocument.UpdateBookmark("Client", client.name);
             XLDocument.UpdateBookmark("Date", DateTB.Value.Date.ToString("d MMMM yyyy"));
             XLDocument.UpdateBookmark("Date2", DateTB.Value.Date.ToString("d MMMM yyyy"));
             XLDocument.UpdateBookmark("Addressee", AddresseeTB.Text);
             XLDocument.UpdateBookmark("Addressee2", AddresseeTB.Text);
             DeploySignature(client, sender, AddresseeTB.Text);
             XLDocument.UpdateBookmark("Sender2", sender.name);
             XLDocument.UpdateBookmark("Fax", FaxTB.Text);
             XLDocument.UpdateBookmark("OurRef", ourRef, 0);
         }
         else if (docType == "FileNote")
         {
             XLDocument.UpdateBookmark("Subject", SubjectTB.Text, 1);
             XLDocument.UpdateBookmark("Date", DateTB.Value.Date.ToString("d MMMM yyyy"));
             XLDocument.UpdateBookmark("Date2", DateTB.Value.Date.ToString("d MMMM yyyy"));
             XLDocument.UpdateBookmark("Sender", sender.name, 1);
             XLDocument.UpdateBookmark("ClientStr", XLDocument.ReadParameter("ClientStr"));
             XLDocument.UpdateBookmark("OurRef", ourRef, 1);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Unable to update bookmarks");
         XLtools.LogException("TaskPane-UpdateBookmarks", ex.ToString());
     }
 }
        public ForwardForm()
        {
            InitializeComponent();
            this.CenterToParent();
            XLMain.Client client = new XLMain.Client();
            XLMain.Staff  staff  = new XLMain.Staff();

            //populate To Be Actioned by
            staff = XLMain.Staff.StaffFromUser(XLDocument.ReadParameter("Sender"));
            string str = XLDocument.ReadParameter("CRMid");

            client = XLMain.Client.FetchClient(str);

            //populate the sender
            List <XLMain.Staff> users = new List <XLMain.Staff>();

            users = XLMain.Staff.AllStaff();

            //place current and connected users at the top of the list, could remove them elsewhere but seems no point
            if (staff != null)
            {
                users.Insert(0, staff);
            }
            if (client.partner != null)
            {
                users.Insert(1, client.partner);
            }
            if (client.manager != null)
            {
                users.Insert(2, client.manager);
            }

            //users.Insert(3, client.other);  Other not yet part of client
            ToBeActionDDL.DataSource    = users;
            ToBeActionDDL.DisplayMember = "name";
            ToBeActionDDL.ValueMember   = "crmID";
            if (staff != null)
            {
                ToBeActionDDL.SelectedItem = staff;
            }
        }
        private void PaneRefresh()
        {
            System.Data.DataTable t = new System.Data.DataTable();
            t.Columns.Add("User");
            t.Columns.Add("Grade");
            t.Columns.Add("Date");
            t.Columns.Add("Signature");
            dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
            dataGridView1.Width = 325;

            for (int i = 0; i < 10; i++)
            {
                //add to grid

                string str = XLDocument.ReadParameter("Sign" + i.ToString());
                if (!String.IsNullOrEmpty(str))
                {
                    DataRow  r      = t.NewRow();
                    string[] sArray = str.Split(new Char[] { ';' });
                    r["User"]  = sArray[0];
                    r["Grade"] = sArray[1];
                    r["Date"]  = sArray[2];
                    //handle old 3 item entries
                    if (sArray.Length > 3)
                    {
                        r["Signature"] = sArray[3];
                    }
                    else
                    {
                        r["Signature"] = "";
                    }

                    t.Rows.Add(r);
                    dataGridView1.DataSource = t;
                }
            }
        }
示例#5
0
        private void button2_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                //get current user
                XLMain.Staff user = XLMain.Staff.StaffFromUser(Environment.UserName);
                //Build string and add to document
                string str = user.name + ";";
                str += user.grade + ";";
                str += DateTime.Now.ToString("d MMMM yyyy");
                XLDocument.InsertText(str.Replace(";", Environment.NewLine));

                //insert into document properties with added field
                str += ";" + user.name;
                for (int i = 0; i < 10; i++)
                {
                    string param = "Sign" + i;
                    string s     = XLDocument.ReadParameter(param);
                    if (s == "")
                    {
                        XLDocument.UpdateParameter(param, str);
                        break;
                    }
                    if (i == 10)
                    {
                        MessageBox.Show("Signature fields full");
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to add signature");
                XLtools.LogException("AddSignature", ex.ToString());
            }
        }
示例#6
0
        public static bool AddSignatureMetaData(XLMain.Staff user, XLMain.Staff sig)
        {
            try
            {
                //Add the meta data
                //Build string and add to document
                string str = user.name + ";";
                str += user.grade + ";";
                str += DateTime.Now.ToString("d MMMM yyyy");
                str += ";" + sig.name;
                //insert into document properties

                for (int i = 0; i < 10; i++)
                {
                    string param = "Sign" + i;
                    string s     = XLDocument.ReadParameter(param);
                    if (String.IsNullOrEmpty(s))
                    {
                        XLDocument.UpdateParameter(param, str);
                        break;
                    }
                    if (i == 10)
                    {
                        MessageBox.Show("Signature fields full");
                        break;
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to add signature metadata");
                XLtools.LogException("AddSignature", ex.ToString());
                return(false);
            }
        }
示例#7
0
        public XLTaskPane()
        {
            try
            {
                InitializeComponent();
                string str = XLDocument.ReadParameter("CRMid");
                docType = XLDocument.ReadParameter("DocType");

                client = XLMain.Client.FetchClient(str);
                //ClientIDLabel.Text = client.crmID;

                user  = XLMain.Staff.StaffFromUser(Environment.UserName);
                users = XLtools.StaffList(user, client, false, true);

                SenderDDL.DataSource    = users;
                SenderDDL.DisplayMember = "name";
                SenderDDL.ValueMember   = "crmID";
                SenderDDL.SelectedItem  = user;
                sender = user;
                XLDocument.UpdateParameter("Sender", sender.username);

                if (client != null)
                {
                    //set basic client info
                    string clientStr = client.clientcode + " - " + client.name;
                    ClientLbl.Text = clientStr;
                    SubjectTB.Text = client.name;
                    string fileStore = XLVirtualCabinet.FileStore(client.manager.office, client.department);
                    XLDocument.UpdateParameter("Cabinet", fileStore);
                    XLDocument.UpdateParameter("ClientStr", clientStr);

                    //Deal with salutations
                    if (client.salutations != null)
                    {
                        SalDDL.DataSource    = client.salutations;
                        SalDDL.DisplayMember = "Salutation";
                        SalDDL.ValueMember   = "Addressee";
                        sal = (XLMain.Salutation)SalDDL.SelectedItem;
                        if (sal != null)
                        {
                            AddresseeTB.Text  = sal.addressee;
                            SalutationTb.Text = sal.salutation;
                        }
                    }

                    //Add the appropriate header
                    XLDocument.Header clientHeader = XLDocument.MapHeader(client.office, client.department);


                    //Set up depending on whether it is insolvency or not
                    if (client.department == "INS")
                    {
                        //Deal with when calling ddl
                        WhencallingDDL.DataSource    = users;
                        WhencallingDDL.DisplayMember = "name";
                        WhencallingDDL.ValueMember   = "crmID";
                        WhenCallingCheck.Checked     = true;
                        SubjectTB.Text = XLInsol.GetSubject(client.crmID);
                    }
                    else
                    {
                        FAOBCheck.Checked        = true;
                        PandCCheck.Checked       = true;
                        WhenCallingCheck.Checked = false;
                    }

                    //Deal with addresses or fax no as appropriate
                    if (docType == "Letter")
                    {
                        if (client.addresses != null)
                        {
                            allAddresses               = client.addresses;
                            addressesDDL.DataSource    = allAddresses;
                            addressesDDL.DisplayMember = "address1";
                            addressesDDL.ValueMember   = "addressBlock";
                            add = (XLMain.Address)addressesDDL.SelectedItem;
                            if (add != null)
                            {
                                if (client.IsIndividual)
                                {
                                    addTB.Text = add.addressBlock;
                                }
                                else
                                {
                                    addTB.Text = client.name + Environment.NewLine + add.addressBlock;
                                }
                            }
                        }
                        if (clientHeader != null)
                        {
                            try
                            {
                                XLDocument.DeployHeader(clientHeader);
                            }
                            catch
                            {
                                MessageBox.Show("Unable to map header automatically." + Environment.NewLine + "Please run the Header/Footer menu.");
                            }
                        }
                    }
                    else if (docType == "Fax")
                    {
                        XLMain.Number fax = XLMain.Number.GetNumber(client.crmID, "Fax");
                        if (fax != null)
                        {
                            FaxTB.Text = fax.number;
                        }
                        if (clientHeader != null)
                        {
                            try
                            {
                                XLDocument.DeployHeader(clientHeader);
                            }
                            catch
                            {
                                MessageBox.Show("Unable to map header automatically." + Environment.NewLine + "Please run the Header/Footer menu.");
                            }
                        }
                    }

                    //set status
                    XLDocument.ChangeStatus("Draft");

                    //Alter fields dependant on doc type;
                    SetVisibility(docType);

                    if (client.department == "INS")
                    {
                        WhencallingDDL.Visible = true;
                        IPSContactBtn.Visible  = true;
                    }

                    //Update bookmarks dependant on doc type
                    UpdateBookmarks(docType);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to open taskpane");
                XLtools.LogException("TaskPane", ex.ToString());
            }
        }
示例#8
0
        private void ApproveBtn_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                Microsoft.Office.Interop.Word._Application app = Globals.ThisAddIn.Application;

                XLDocument.ChangeStatus("Approved");
                XLMain.Client client = null;
                string        fileID = XLDocument.GetFileID();
                if (String.IsNullOrEmpty(fileID))
                {
                    return;
                }

                if (XLDocument.ReadParameter("CRMid") != null)
                {
                    client = XLMain.Client.FetchClient(XLDocument.ReadParameter("CRMid"));
                }
                else
                {
                    //if the document param doesn't exist get the index data from VC
                    client = XLVirtualCabinet.GetClientFromIndex(fileID);
                }
                XLMain.Staff writer   = new XLMain.Staff();
                string       writerID = XLDocument.ReadParameter("Sender");
                if (writerID == "")
                {
                    writer = XLMain.Staff.StaffFromUser(Environment.UserName);
                }
                else
                {
                    writer = XLMain.Staff.StaffFromUser(XLDocument.ReadParameter("Sender"));
                }
                StaffSelectForm myForm = new XLForms.StaffSelectForm(client, writer);
                myForm.ShowDialog();
                XLMain.EntityCouplet staff = myForm.selectedStaff;

                if (myForm.DialogResult == DialogResult.OK)
                {
                    if (staff == null)
                    {
                        //make blank if no staff selected
                        staff.name = "";
                    }
                    string commandfileloc = "";
                    if (XLDocument.ReadBookmark("Date") == "")
                    {
                        commandfileloc = XLVirtualCabinet.Reindex(fileID, staff.name, XLDocument.ReadParameter("VCStatus"));
                    }
                    else
                    {
                        string docDate = XLDocument.ReadBookmark("Date");
                        commandfileloc = XLVirtualCabinet.Reindex(fileID, staff.name, XLDocument.ReadParameter("VCStatus"), docDate);
                    }
                    XLVirtualCabinet.BondResult result = XLVirtualCabinet.LaunchCabi(commandfileloc, true);
                    if (result.ExitCode != 0)
                    {
                        MessageBox.Show("Reindex failed please complete manually");
                    }
                    else
                    {
                        app.ActiveDocument.Save();
                        app.ActiveWindow.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to approve document");
                XLtools.LogException("ApproveBtn", ex.ToString());
            }
        }
示例#9
0
        private void ForwardBtn_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                XLMain.Client client = null;
                string        fileID = XLDocument.GetFileID();
                if (String.IsNullOrEmpty(fileID))
                {
                    return;
                }

                if (XLDocument.ReadParameter("CRMid") != null)
                {
                    client = XLMain.Client.FetchClient(XLDocument.ReadParameter("CRMid"));
                }
                else
                {
                    //if the document param doesn't exist get the index data from VC
                    client = XLVirtualCabinet.GetClientFromIndex(fileID);
                }

                XLMain.Staff writer   = new XLMain.Staff();
                string       writerID = XLDocument.ReadParameter("Sender");
                if (writerID == "")
                {
                    writer = XLMain.Staff.StaffFromUser(Environment.UserName);
                }
                else
                {
                    writer = XLMain.Staff.StaffFromUser(XLDocument.ReadParameter("Sender"));
                }
                StaffSelectForm myForm = new StaffSelectForm(client, writer);
                myForm.ShowDialog();
                XLMain.EntityCouplet staff = myForm.selectedStaff;

                string commandfileloc = "";
                if (XLDocument.ReadBookmark("Date") == "")
                {
                    commandfileloc = XLVirtualCabinet.Reindex(XLDocument.GetFileID(), staff.name);
                }
                else
                {
                    string docDate = XLDocument.ReadBookmark("Date");
                    commandfileloc = XLVirtualCabinet.Reindex(XLDocument.GetFileID(), staff.name, docDate: docDate);
                }

                //MessageBox.Show(commandfileloc);
                XLVirtualCabinet.BondResult result = XLVirtualCabinet.LaunchCabi(commandfileloc, true);
                if (result.ExitCode != 0)
                {
                    MessageBox.Show("Reindex failed please complete manually.");
                }
                else
                {
                    XLDocument.EndDocument();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to forward document");
                XLtools.LogException("ForwardBtn", ex.ToString());
            }
        }