Beispiel #1
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);
     }
 }
Beispiel #2
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);
            }
        }
        public static void MultiQuickIndex(Outlook.MailItem email, string folder)
        {
            try
            {
                XLant.XLVirtualCabinet.BondResult outcome = IndexEmail(email, folder);
                // As the filing has been successfull, get the FileId returned from Bond via the Standard Output
                if (outcome.ExitCode == 0)
                {
                    string fileid = Regex.Match(outcome.StandardOutput, @"\d+").ToString();
                    XLVirtualCabinet.FileInfo info = XLVirtualCabinet.FileIndex(fileid);
                    DialogResult result            = MessageBox.Show("Do you want to index another copy", "Index", MessageBoxButtons.YesNo);
                    while (result == DialogResult.Yes)
                    {
                        XLForms.ClientForm myForm = new ClientForm();
                        myForm.ShowDialog();
                        XLMain.Client client = myForm.selectedClient;
                        //update the cabinet based on the new client
                        string cabinet = XLVirtualCabinet.FileStore(client.manager.office, client.department);
                        info.Cabinet = cabinet;
                        //update the client field
                        foreach (XLVirtualCabinet.IndexPair pair in info.Indexes)
                        {
                            if (pair.index == "INDEX02")
                            {
                                pair.value = client.clientcode + " - " + client.name;
                            }
                        }
                        outcome = XLVirtualCabinet.IndexDocument(outcome.DocPath, info);

                        if (outcome.ExitCode == 0)
                        {
                            result = MessageBox.Show("Do you want to index another copy", "Index", MessageBoxButtons.YesNo);
                            continue;
                        }
                        else
                        {
                            MessageBox.Show("Unable to index document, please index manually.  Error code: " + outcome.ExitCode.ToString() + "-" + outcome.StandardOutput.ToString());
                            break;
                        }
                    }
                    //update the tick box and category
                    UpdateVCTick(email);
                    //delete email from temp directory
                    if (File.Exists(outcome.DocPath))
                    {
                        File.Delete(outcome.DocPath);
                    }
                }
                else
                {
                    Exception e = new Exception("Unable to index");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Unable to index email");
                XLtools.LogException("MultiQuickIndex", ex.ToString());
            }
        }
        public static void IndexPDFCopy(string filestring, string origFileID)
        {
            try
            {
                //get the info of the original file
                XLVirtualCabinet.FileInfo   fileInfo = XLVirtualCabinet.FileIndex(origFileID);
                XLVirtualCabinet.BondResult result   = XLVirtualCabinet.IndexDocument(filestring, fileInfo);

                if (result.ExitCode != 0)
                {
                    MessageBox.Show("Unable to index pdf, please index manually.  Error code: " + result.ExitCode.ToString() + "-" + result.StandardOutput.ToString());
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Unable to index pdf document" + filestring);
                XLtools.LogException("IndexPDFCopy", e.ToString());
            }
        }
        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");
            }
        }