Beispiel #1
0
        private void IndexBtn_Click(object sender, EventArgs e)
        {
            string fullPath  = docPath;
            string cabinet   = XLVirtualCabinet.FileStore(client.manager.office, client.department);
            string clientStr = client.clientcode + " - " + client.name;

            XLMain.Staff toBe    = (XLMain.Staff)ToBeActionDDL.SelectedItem;
            string       desc    = DescTB.Text;
            string       section = "";

            if (client.department != "INS")
            {
                section = "Correspondence";
            }
            else
            {
                section = FileSectionDDL.SelectedItem.ToString();
            }
            //Launch the index process and collect the result
            XLVirtualCabinet.BondResult outcome = XLVirtualCabinet.IndexDocument(fullPath, cabinet, clientStr, status, toBe.name, section, desc);

            if (outcome.ExitCode == 0)
            {
                XLDocument.EndDocument();
            }
            else
            {
                MessageBox.Show("Unable to index document, please index manually.  Error code: " + outcome.ExitCode.ToString() + "-" + outcome.StandardOutput.ToString());
            }
            //close the dialog in any event.
            this.Close();
        }
Beispiel #2
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());
            }
        }
Beispiel #3
0
        private void CreatePrettyPdf(string watermark = "", bool withAttachments = false)
        {
            try
            {
                List <Tuple <string, string> > selectedDocs = new List <Tuple <string, string> >();

                if (withAttachments)
                {
                    //get available documents
                    List <Tuple <string, string> > attachmentOptions = XLDocument.GetAttachmentFiles();
                    //ask user to check which ones they want
                    XLForms.Attachments attachmentsForm = new XLForms.Attachments(attachmentOptions);
                    attachmentsForm.ShowDialog();
                    selectedDocs = attachmentsForm.selectedDocuments;
                }

                //get the id for later use and before the original is closed.
                string fileID = XLDocument.GetFileID();
                //save the document as a pdf and get location
                string file     = XLDocument.CreatePdf();
                string fileName = XLDocument.currentDoc.Name.Substring(0, XLDocument.currentDoc.Name.LastIndexOf('.'));
                //close the original, it isn't required any more
                XLDocument.EndDocument();
                //add the header and get the location of the new combined file
                file = XLDocument.AddHeadertoPDF(file, watermark, fileName);
                //merge the attachments, if any selected
                if (selectedDocs.Count != 0)
                {
                    List <string> docs = new List <string>();
                    docs.Add(file);
                    foreach (Tuple <string, string> tuple in selectedDocs)
                    {
                        docs.Add(tuple.Item2);
                    }
                    file = XLDocument.AddAttachments(docs);
                }
                if (String.IsNullOrEmpty(fileID))
                {
                    string         finalLocation = "";
                    SaveFileDialog sDialog       = new SaveFileDialog();
                    sDialog.FileName   = "NewPdf.pdf";
                    sDialog.DefaultExt = ".pdf";
                    sDialog.Title      = "Save PDF as...";
                    if (sDialog.ShowDialog() == DialogResult.OK)
                    {
                        finalLocation = sDialog.FileName;
                    }

                    System.IO.File.Copy(file, finalLocation);
                }
                else
                {
                    //index the combined file using the data from the original
                    XLDocument.IndexPDFCopy(file, fileID);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Cancelled PDF Creation");
                XLtools.LogException("Word - PDFCreation", ex.Message);
            }
        }
Beispiel #4
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());
            }
        }