コード例 #1
0
        private void ApproveBtn_Click(object sender, RibbonControlEventArgs e)
        {
            Outlook.MailItem email = ThisEmail();
            email.Save();
            XLMain.Client client = XLMain.Client.FetchClient(XLOutlook.ReadParameter("CrmID", email));
            XLMain.Staff  writer = XLMain.Staff.StaffFromUser(Environment.UserName);
            if (XLantRibbon.staff.Count == 0)
            {
                XLantRibbon.staff = XLMain.Staff.AllStaff();
            }
            StaffSelectForm myForm = new StaffSelectForm(client, writer, XLantRibbon.staff);

            myForm.ShowDialog();
            XLMain.EntityCouplet staff = myForm.selectedStaff;

            string commandfileloc = "";

            string fileId = XLOutlook.ReadParameter("VCFileID", email);

            commandfileloc = XLVirtualCabinet.Reindex(fileId, staff.name, status: "Approved", docDate: DateTime.Now.ToString("dd/MM/yyyy"));

            XLVirtualCabinet.BondResult result = XLVirtualCabinet.LaunchCabi(commandfileloc, true);
            if (result.ExitCode != 0)
            {
                MessageBox.Show("Reindex failed please complete manually.");
            }
            else
            {
                // Close the email in Outlook to prevent further changes that won't be saved to VC
                email.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olSave);
                // Delete the email from the Drafts folder in Outlook
//                email.Delete();
            }
        }
コード例 #2
0
 public static void CreateToDo(XLVirtualCabinet.FileInfo file)
 {
     try
     {
         if (ToDoFolder == null)
         {
             SetToDoFolder();
         }
         Outlook.TaskItem toDo = Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olTaskItem) as Outlook.TaskItem;
         string           desc = file.ClientString;
         desc           = desc + " - " + file.Description;
         toDo.Subject   = desc;
         toDo.StartDate = DateTime.Now;
         toDo.DueDate   = DateTime.Now.AddDays(1);
         //toDo.Body = file.FileID;
         XLOutlook.UpdateParameter(fileIdName, file.FileID, toDo);
         toDo.Move(ToDoFolder);
         toDo.Save();
     }
     catch (Exception ex)
     {
         XLant.XLtools.LogException("CreateToDo", ex.ToString());
         MessageBox.Show("Could not add To Do", "Add To Do", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
        public static void ReassignTask(Outlook.MailItem task)
        {
            //get the recipients of the assigned task
            string[] emails = XLOutlook.EmailAddresses(task);
            //we can only set one in VC so select the first one.
            string newUser = emails[0];

            //if the recipient is not one of us we aren't interested
            if (newUser.Contains("milsted-langdon.co.uk"))
            {
                string fileId = XLOutlook.ReadParameter("VCFileID", task);
                //assign the associated file to the new user
                //get the username from the e-mail address
                newUser = newUser.Substring(0, newUser.IndexOf('@'));
                XLMain.Staff staff = XLMain.Staff.StaffFromUser(newUser);
                //build a reindex command from the data
                string commandfileloc = "";
                commandfileloc = XLVirtualCabinet.Reindex(fileId, staff.name);
                //reindex
                XLVirtualCabinet.BondResult result = XLVirtualCabinet.LaunchCabi(commandfileloc, true, true);
                if (result.ExitCode != 0)
                {
                    //if the reindex is not successful then say so otherwise silence is golden.
                    MessageBox.Show("Reindex failed, possibly because you are offline, please reindex in VC");
                }
            }
        }
コード例 #4
0
 //strip out the VC property on receipt so that replies and forwards report correctly
 //redundant as the VC addin will only add it back
 public static void ItemSent(object item)
 {
     try
     {
         Outlook.MailItem       email      = (Outlook.MailItem)item;
         Outlook.ItemProperties properties = email.ItemProperties;
         Outlook.ItemProperty   property   = properties.Cast <Outlook.ItemProperty>().Where(c => c.Name == "In Virtual Cabinet").FirstOrDefault();
         string fileId = XLOutlook.ReadParameter("VCFileID", email);
         //Only if the e-mail is not a draft handled within VC
         //strip out the field
         if (property != null && (fileId == null || fileId == ""))
         {
             //MessageBox.Show(property.Name + ":" + property.Value);
             property.Delete();
             //MessageBox.Show("Deleted");
         }
         XLOutlook.UpdateParameter("VCFileID", "", email);
         //for testing purposes try it again to make sure it is gone
         //property = properties.Cast<Outlook.ItemProperty>().Where(c => c.Name == "In Virtual Cabinet").FirstOrDefault();
         //if (property == null)
         //{
         //    MessageBox.Show("Gone");
         //}
         //else
         //{
         //    MessageBox.Show(property.Name + ":" + property.Value);
         //}
     }
     catch (Exception ex)
     {
         XLtools.LogException("ItemSent", ex.ToString());
     }
 }
コード例 #5
0
        private void PromptTglBtn_Click(object sender, RibbonControlEventArgs e)
        {
            string docPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XLant\\personal.xml";
            //Update the settings file
            XDocument xPer     = XLtools.personalDoc();
            XElement  settings = xPer.Descendants("PersonalSettings").FirstOrDefault();
            string    prompt   = settings.Descendants("Prompt").FirstOrDefault().Value;

            if (PromptTglBtn.Checked)
            {
                //Update the settings file
                settings.Descendants("Prompt").FirstOrDefault().Value = "true";
                xPer.Save(docPath);
                XLOutlook.XLEventhandler(true);
                ExInternalCheck.Visible = true;
            }
            else
            {
                //Update the settings file
                settings.Descendants("Prompt").FirstOrDefault().Value = "false";
                xPer.Save(docPath);
                XLOutlook.XLEventhandler(false);
                ExInternalCheck.Visible = false;
            }
        }
コード例 #6
0
        private void XLantRibbon_Load(object sender, RibbonUIEventArgs e)
        {
            //Deal with the prompt issue
            string    docPath  = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\XLant\\personal.xml";
            XDocument xPer     = XLtools.personalDoc();
            XElement  settings = xPer.Descendants("PersonalSettings").FirstOrDefault();
            string    prompt   = "";

            if (settings.Descendants("Prompt").FirstOrDefault() == null)
            {
                settings.Add(new XElement("Prompt", "true"));
                xPer.Save(docPath);
            }
            else
            {
                prompt = settings.Descendants("Prompt").FirstOrDefault().Value;
            }

            //check the setting for prompt if it is not present or true then add handler
            if (prompt != "false")
            {
                XLOutlook.XLEventhandler(true);
                PromptTglBtn.Checked = true;
            }
            else
            {
                //don't need to stop the event handler, it hasn't yet been started
                PromptTglBtn.Checked = false;
            }

            if (prompt == "true")
            {
                //make the selection visible
                ExInternalCheck.Visible = true;
                //handle whether internal emails should be excluded
                if (settings.Descendants("Internal").FirstOrDefault() == null)
                {
                    settings.Add(new XElement("Internal", "false"));
                    xPer.Save(docPath);
                }

                if (settings.Descendants("Internal").FirstOrDefault().Value == "true")
                {
                    ExInternalCheck.Checked = true;
                    exInternal = true;
                }
                else
                {
                    ExInternal.Checked = false;
                    exInternal         = false;
                }
            }
            else
            {
                ExInternal.Visible = false;
            }
            //Handle the creation of the VC Folder
            //XLOutlook.CreateVCFolder();
        }
コード例 #7
0
        public static void CheckToDos()
        {
            try
            {
                List <string> newIds = new List <string>();
                //set user
                if (user == null)
                {
                    user = XLMain.Staff.StaffFromUser(Environment.UserName);
                }

                //get the current todos
                List <XLVirtualCabinet.FileInfo> newToDos = XLant.XLVirtualCabinet.GetToDos(user.name);

                //input the ids into an array for comparison with our existing list
                List <string> newtds = new List <string>();
                if (newToDos != null)
                {
                    foreach (XLVirtualCabinet.FileInfo i in newToDos)
                    {
                        //create a list of the ids for comparison
                        //with those already in the system
                        newtds.Add(i.FileID);
                    }
                }
                //get a list of the existing ids if not already filled
                if (ids == null)
                {
                    //build to dos
                    if (ToDoFolder == null)
                    {
                        SetToDoFolder();
                    }
                    foreach (Outlook.TaskItem item in ToDoFolder.Items)
                    {
                        string s = XLOutlook.ReadParameter(fileIdName, item);
                        MessageBox.Show(s);
                        ids.Add(s);
                    }
                }
                //compare the new with the old
                newIds = newtds.Except(ids).ToList();

                //where there are new ones create entries
                foreach (string id in newIds)
                {
                    //go and get the file details
                    XLVirtualCabinet.FileInfo item = XLVirtualCabinet.FileIndex(id);
                    //add to to dos
                    CreateToDo(item);
                }
                ///////////////////need to handle removal of things which have moved other than through XLant/////////////////////
            }
            catch (Exception ex)
            {
                XLant.XLtools.LogException("CheckToDos", ex.ToString());
                MessageBox.Show("Could not check To Dos", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #8
0
        private void MultiClientIndexBtn_Click(object sender, RibbonControlEventArgs e)
        {
            Outlook.MailItem email    = XLOutlook.GetSelectedEmail();
            Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
            string           path     = "";

            path = explorer.CurrentFolder.FolderPath;

            XLOutlook.MultiQuickIndex(email, path);
            explorer.CurrentFolder.CurrentView.Apply();
        }
コード例 #9
0
        private void IndexBtn_Click(object sender, RibbonControlEventArgs e)
        {
            Outlook.MailItem email    = ThisEmail();
            Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
            string           path     = "";

            path = explorer.CurrentFolder.FolderPath;

            XLOutlook.IndexEmail(email, path);
            email.Save();
            explorer.CurrentFolder.CurrentView.Apply();
        }
コード例 #10
0
        private void IndexBtn_Click(object sender, RibbonControlEventArgs e)
        {
            Outlook.MailItem email    = XLOutlook.GetSelectedEmail();
            Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
            string           path     = "";

            path = explorer.CurrentFolder.FolderPath;

            XLOutlook.QuickIndex(email, path);

            //see whether there are some new connections to be made
            string emails = XLOutlook.EmailAddressesStr(email);

            explorer.CurrentFolder.CurrentView.Apply();
        }
コード例 #11
0
 private void indexAttachmentsBtn_Click(object sender, RibbonControlEventArgs e)
 {
     Outlook.MailItem email = XLOutlook.GetSelectedEmail();
     XLOutlook.IndexAttachments(email);
 }
コード例 #12
0
 private void IndexAttachmentBtn_Click(object sender, RibbonControlEventArgs e)
 {
     Outlook.MailItem email = ThisEmail();
     XLOutlook.IndexAttachments(email);
 }
コード例 #13
0
        public static void OverwriteDraft(Outlook.MailItem email)
        {
            try
            {
                //get the fileID from the stored Parameter
                string fileId = XLOutlook.ReadParameter("VCFileID", email);

                //reindex the email to remove the to be actioned by and update status and doc date
                string commandfileloc = "";
                commandfileloc = XLVirtualCabinet.Reindex(fileId, status: "Sent", docDate: email.SentOn.ToString("dd/MM/yyyy"));

                XLVirtualCabinet.BondResult result = XLVirtualCabinet.LaunchCabi(commandfileloc, true);

                if (result.ExitCode != 0)
                {
                    MessageBox.Show("Reindex failed please complete manually.");
                }
                else
                {
                    //If reindex successful then continue
                    //create a commandfile to reopen the email in edit mode
                    string folderpath      = XLtools.TempPath();
                    string commandfilepath = "";
                    commandfilepath = folderpath + "\\" + (String.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now)) + ".bond";
                    StreamWriter commandfile = new StreamWriter(commandfilepath, false, System.Text.Encoding.Default);

                    commandfile.WriteLine("<<MODE=EDIT>>");
                    commandfile.WriteLine("<<INDEX01=" + fileId + ">>");
                    commandfile.WriteLine("<<OPENDOCUMENT=FALSE>>");
                    commandfile.Flush();
                    commandfile.Close();

                    // Call Bond to check out the document
                    result = XLVirtualCabinet.LaunchCabi(commandfilepath, false);
                    // Dispose of the command file object
                    commandfile.Dispose();

                    // Look for the file in the edited documents folder based on the FileId
                    List <string> msgfile    = new List <string>();
                    string[]      Files      = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Virtual Cabinet\\Edited documents");
                    int           FilesCount = Files.Length;

                    // Collect all the entries which match the fileID
                    for (int i = 0; i < FilesCount; i++)
                    {
                        string f = Files[i].ToString();

                        if (Path.GetFileName(f).StartsWith(fileId + "-"))
                        {
                            msgfile.Add(f);
                        }
                    }
                    //There should only be 1 if there are more something has gone wrong. We don't want to overwrite the wrong one so exit
                    if (msgfile.Count != 1)
                    {
                        Exception exception = new Exception("Unable to find the draft email message.");
                    }
                    else
                    {
                        // Delete the old version and save the sent email in the default MSG format
                        if (File.Exists(msgfile[0]))
                        {
                            File.Delete(msgfile[0]);
                        }
                        email.SaveAs(msgfile[0]);

                        // Create a command file to save the document as a new version based on the FileId
                        commandfilepath = folderpath + "\\" + (String.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now)) + ".bond";
                        commandfile     = new StreamWriter(commandfilepath, false, System.Text.Encoding.Default);
                        commandfile.WriteLine("<<MODE=SAVE>>");
                        commandfile.WriteLine("<<INDEX01=" + fileId + ">>");
                        commandfile.Flush();
                        commandfile.Close();

                        // Call Bond to save the email back to VC
                        result = XLVirtualCabinet.LaunchCabi(commandfilepath, false);
                        // Dispose of the command file object
                        commandfile.Dispose();
                        //update the tick box
                        UpdateVCTick(email);
                        //Mark email as saved.
                        email.UnRead = false;
                        //Close and save
                        email.Close(Outlook.OlInspectorClose.olSave);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to update e-mail");
                XLtools.LogException("OverwriteDraft", ex.ToString());
            }
        }
コード例 #14
0
 private void StartBtn_Click(object sender, RibbonControlEventArgs e)
 {
     XLOutlook.IndexDraft(ThisEmail());
 }
コード例 #15
0
        //this manages the process of promping and then indexing the email, if needed

        private static void SentItemIndexer(object item)
        {
            try
            {
                //convert the object to an email type
                Outlook.MailItem email = (Outlook.MailItem)item;
                //get the fileId if there is one
                string fileId = XLOutlook.ReadParameter("VCFileID", email);
                if (fileId != "")
                {
                    //if the fileId exists offer to overwrite the original
                    System.Threading.Thread.Sleep(5000);
                    //check whether the item is a task or not
                    //if (email.IsMarkedAsTask)
                    //{
                    //    //If it is reassign the to do based on the assingee
                    //    XLTask.ReassignTask(email);
                    //}
                    //else
                    //{

                    DialogResult response = MessageBox.Show("Do you want to Overwrite the existing draft email?", "Overwrite?", MessageBoxButtons.OKCancel);
                    if (response == DialogResult.OK)
                    {
                        XLOutlook.OverwriteDraft(email);
                    }
                    //}
                }
                else
                {
                    //otherwise consider indexing
                    //if user wants to exclude internal emails check that first.
                    if (XLantRibbon.exInternal)
                    {
                        //check whether it is internal only
                        string[] addresses = EmailAddresses(email);
                        //it includes the sender so 1 means there are no other external addresses
                        if (addresses.Count() == 1)
                        {
                            //The user wants to ignore internal e-mails and this one has no external parties so nothing
                            //to do
                            return;
                        }
                    }
                    //check whether conversation reference is turned on
                    if (!email.Body.Contains("VCID:"))
                    {
                        //otherwise continue
                        //get the subject line
                        string str = "";
                        if (email.Subject.Length > 30)
                        {
                            str = email.Subject.Substring(0, 30);
                        }
                        else
                        {
                            str = email.Subject;
                        }
                        //and ask the user whether they want to index
                        DialogResult response = MessageBox.Show("Do you want to index the email: " + str + "...?", "Quick Index?", MessageBoxButtons.OKCancel);
                        if (response == DialogResult.OK)
                        {
                            //if yes carryout indexing.
                            XLOutlook.QuickIndex(email, "Sent");
                        }
                    }
                }
                email.Save();
                emailsToIndex.Remove(email.EntryID);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to Index Item");
                XLtools.LogException("SentItemHandler", ex.ToString());
            }
        }
コード例 #16
0
 private void button1_Click(object sender, RibbonControlEventArgs e)
 {
     MessageBox.Show(XLOutlook.ReadParameter("VCFileID", ThisEmail()));
 }
コード例 #17
0
        public static void IndexDraft(Outlook.MailItem email)
        {
            try
            {
                XLant.XLVirtualCabinet.BondResult outcome = IndexEmail(email, "Draft");

                if (outcome.ExitCode != 0)
                {
                    MessageBox.Show("Unable to index document, please index manually.  Error code: " + outcome.ExitCode.ToString() + "-" + outcome.StandardOutput.ToString());
                }
                else
                {
                    UpdateVCTick(email);
                    // As the filing has been successfull, get the FileId returned from Bond via the Standard Output
                    string fileid          = Regex.Match(outcome.StandardOutput, @"\d+").ToString();
                    string folderpath      = XLtools.TempPath();
                    string commandfilepath = "";
                    commandfilepath = folderpath + "\\" + (String.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now)) + ".bond";
                    StreamWriter commandfile = new StreamWriter(commandfilepath, false, System.Text.Encoding.Default);

                    commandfile.WriteLine("<<MODE=EDIT>>");
                    commandfile.WriteLine("<<INDEX01=" + fileid + ">>");
                    commandfile.WriteLine("<<OPENDOCUMENT=FALSE>>");
                    commandfile.Flush();
                    commandfile.Close();

                    // Call Bond to check out the document
                    XLVirtualCabinet.BondResult result = XLVirtualCabinet.LaunchCabi(commandfilepath, false);
                    // Dispose of the command file object
                    commandfile.Dispose();

                    // Look for the file in the edited documents folder based on the FileId
                    List <string> msgfile    = new List <string>();
                    string[]      Files      = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Virtual Cabinet\\Edited documents");
                    int           FilesCount = Files.Length;

                    // Collect all the entries which match the fileID
                    for (int i = 0; i < FilesCount; i++)
                    {
                        string f = Files[i].ToString();

                        if (Path.GetFileName(f).StartsWith(fileid + "-"))
                        {
                            msgfile.Add(f);
                        }
                    }

                    if (msgfile.Count != 1)
                    {
                        Exception exception = new Exception("Unable to find the mail message.  Your file has been indexed but could not have the file ID added.");
                    }
                    else
                    {
                        // Add the Virtual Cabinet FileId to the Subject of the email (still open on screen)
                        // UserProperties and Custom Headers do not persist, so using something that does. Body could be another option.
                        XLOutlook.UpdateParameter("VCFileID", fileid, email);
                        //email.Subject = email.Subject + @" FileId:" + fileid.ToString();

                        // Save the MailItem
                        email.Save();

                        // Save the email in the default MSG format
                        if (File.Exists(msgfile[0]))
                        {
                            File.Delete(msgfile[0]);
                        }
                        email.SaveAs(msgfile[0]);

                        // Create a command file to save the document as a new version based on the FileId
                        commandfilepath = folderpath + "\\" + (String.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now)) + ".bond";
                        commandfile     = new StreamWriter(commandfilepath, false, System.Text.Encoding.Default);
                        commandfile.WriteLine("<<MODE=SAVE>>");
                        commandfile.WriteLine("<<INDEX01=" + fileid + ">>");
                        commandfile.Flush();
                        commandfile.Close();

                        // Call Bond to save the email back to VC
                        result = XLVirtualCabinet.LaunchCabi(commandfilepath, false);
                        // Dispose of the command file object
                        commandfile.Dispose();

                        // Close the email in Outlook to prevent further changes that won't be saved to VC
                        email.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olSave);

                        // Delete the email from the Drafts folder in Outlook
                        email.UnRead = false;
                        email.Delete();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to index draft email");
                XLtools.LogException("IndexDraft", ex.ToString());
            }
        }