Пример #1
0
        private void UpdateRefBtn_Click(object sender, RibbonControlEventArgs e)
        {
            string fileID = XLDocument.GetFileID();

            if (fileID == DateTime.Now.ToString("yyyy-MM-dd"))
            {
                MessageBox.Show("Unable to find FileID.  If the document has not yet been placed in VC click First Index.");
            }
            else
            {
                string ourRef = XLDocument.ReadBookmark("OurRef");
                //check to see if bookmark exists, if not just insert date.
                if (String.IsNullOrEmpty(ourRef))
                {
                    XLDocument.InsertText(fileID);
                }
                else
                {
                    ourRef += @"/" + fileID;
                    XLDocument.UpdateBookmark("OurRef", ourRef);
                }
            }
        }
Пример #2
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);
            }
        }
Пример #3
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());
            }
        }
Пример #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());
            }
        }