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(); } }
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"); } } }
//private static System.Threading.Timer timer; public static XLant.XLVirtualCabinet.BondResult IndexEmail(Outlook.MailItem email, string folder) { try { XLMain.Client selectClient = new XLMain.Client(); selectClient = GetClient(email); //Add CRMID to email for later use. UpdateParameter("CrmID", selectClient.crmID, email); //Collect data for indexing XLMain.Staff user = XLMain.Staff.StaffFromUser(Environment.UserName); string docPath = TempSave(email); string docDate = DateTime.Now.ToString("dd/MM/yyyy"); //take a guess at the status string status = ""; string desc = email.Subject; if (folder.Contains("Inbox")) { status = "External"; docDate = CheckDate(email.ReceivedTime); } else if (folder.Contains("Sent")) { status = "Sent"; docDate = CheckDate(email.SentOn); } else { status = "Draft"; docDate = CheckDate(DateTime.Now); } if (XLantRibbon.staff.Count == 0) { XLantRibbon.staff = XLMain.Staff.AllStaff(); } VCForm indexForm = new VCForm(user, selectClient, docPath, desc, status, docDate, "blank", XLantRibbon.staff); indexForm.ShowDialog(); //collect result from form XLVirtualCabinet.BondResult outcome = indexForm.outcome; //add client to recent list AddClienttoRecent(selectClient); return(outcome); } catch (Exception ex) { MessageBox.Show("Unable to index e-mail"); XLtools.LogException("IndexEmail", ex.ToString()); return(null); } }
private void IndexBtn_Click(object sender, EventArgs e) { string folder = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\XLant\\temp\\"; string tempPath = folder + "temp.msg"; email.SaveAs(tempPath); string cabinet = XLVirtualCabinet.FileStore(client.office, client.department); string clientStr = client.clientcode + " - " + client.name; string status = ""; if (email.ReceivedTime != null) { status = "External"; } else if (email.SentOn != null) { status = "Sent"; } else { status = "Draft"; } 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(tempPath, cabinet, clientStr, status, toBe.name, section, desc); //close the dialog in any event. this.Close(); }
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; string toBeActionedBy = null; if (ToBeActionDDL.SelectedValue == null) { toBeActionedBy = ""; } else { XLMain.EntityCouplet toBe = (XLMain.EntityCouplet)ToBeActionDDL.SelectedItem; toBeActionedBy = toBe.name; } //collect information from the two optional ddls use whether they are visible or not to acsertain whether //to include them - They may not be visible but still hold data. XLVirtualCabinet.IndexPair list1Data = new XLVirtualCabinet.IndexPair(); XLVirtualCabinet.IndexPair list2Data = new XLVirtualCabinet.IndexPair(); if (ListDDL1.Visible) { list1Data.index = list1.index; list1Data.value = ListDDL1.Text; } if (ListDDL2.Visible) { list2Data.index = list2.index; list2Data.value = ListDDL2.Text; } string desc = DescTB.Text; string section = ""; section = FileSectionDDL.SelectedItem.ToString(); //Launch the index process and collect the result outcome = XLVirtualCabinet.IndexDocument(fullPath, cabinet, clientStr, status, toBeActionedBy, section, desc, docDate, list1Data, list2Data); this.Close(); }
public static void IndexAttachments(Outlook.MailItem email) { if (email.Attachments.Count > 0) { XLVirtualCabinet.BondResult outcome = new XLVirtualCabinet.BondResult(); string fileid = ""; string docPath = ""; XLVirtualCabinet.FileInfo info = new XLVirtualCabinet.FileInfo(); for (int i = 1; i <= email.Attachments.Count; i++) { string folder = XLtools.TempPath(); if (i == 1) { email.Attachments[i].SaveAsFile(folder + email.Attachments[i].FileName); XLMain.Client selectClient = GetClient(email); //Collect data for indexing XLMain.Staff user = XLMain.Staff.StaffFromUser(Environment.UserName); docPath = folder + email.Attachments[i].FileName; string docDate = DateTime.Now.ToString("dd/MM/yyyy"); string status = "External"; string desc = email.Attachments[i].FileName; if (XLantRibbon.staff.Count == 0) { XLantRibbon.staff = XLMain.Staff.AllStaff(); } VCForm indexForm = new VCForm(user, selectClient, docPath, desc, status, docDate, "blank", XLantRibbon.staff); indexForm.ShowDialog(); //collect result from form outcome = indexForm.outcome; //get the details of the file. fileid = Regex.Match(outcome.StandardOutput, @"\d+").ToString(); info = XLVirtualCabinet.FileIndex(fileid); //add client to recent list AddClienttoRecent(selectClient); } else { //save the next file email.Attachments[i].SaveAsFile(folder + email.Attachments[i].FileName); docPath = folder + email.Attachments[i].FileName; foreach (XLVirtualCabinet.IndexPair pair in info.Indexes) { if (pair.index.ToUpper() == "INDEX03") { string d = email.Attachments[i].FileName; //generate form for the description to be altered SingleDataCaptureForm myForm = new SingleDataCaptureForm("Input Description", "Enter Description", d); myForm.ShowDialog(); if (myForm.result == DialogResult.Cancel) { continue; } else { pair.value = myForm.data; } } } outcome = XLVirtualCabinet.IndexDocument(docPath, info); } } MessageBox.Show("All Attachments Saved"); } }
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()); } }
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()); } }