private void button4_Click_1(object sender, RibbonControlEventArgs e)
        {
            WindowFormRegionCollection formRegions =
                Globals.FormRegions
                [Globals.ThisAddIn.Application.ActiveExplorer()];

            if (!ServiceHelper.IsLoggedIn)
            {
                using (LoginForm frmLogin = new LoginForm())
                {
                    frmLogin.ShowDialog();
                    return;
                }
            }

            if (formRegions.MainRegion.IsRoleWorkerBusy || formRegions.MainRegion.IsCandidatesWorkerBusy)
            {
                return;
            }

            Guid guid = Guid.NewGuid();

            Candidate newCandidate = new Candidate();

            newCandidate.Username           = ServiceHelper.LastLogin.Username;
            newCandidate.RegistrationDate   = DateTime.Today;
            newCandidate.CandidateID        = guid;
            newCandidate.CandidatePositions = new List <CandidatePosition>();

            newCandidate.Status = "Classification";

            CandidateEditForm form = new CandidateEditForm(true, formRegions.MainRegion, newCandidate);

            form.Show();
        }
Example #2
0
 private void dataGridView1_MouseDoubleClick(object sender, MouseEventArgs e)
 {
     if (dataGridView1.SelectedRows.Count > 0)
     {
         Candidate         item = dataGridView1.SelectedRows[0].DataBoundItem as Candidate;
         CandidateEditForm form = new CandidateEditForm(this, item);
         form.Show(this);
     }
 }
Example #3
0
        private void dataGridView1_DragDrop(object sender, DragEventArgs e)
        {
            string[] fileNames = null;

            Guid guid = Guid.NewGuid();

            try
            {
                if (e.Data.GetDataPresent(DataFormats.FileDrop, false) == true)
                {
                    fileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
                    // handle each file passed as needed
                    foreach (string fileName in fileNames)
                    {
                        // do what you are going to do with each filename
                    }
                }
                else if (e.Data.GetDataPresent("FileGroupDescriptor"))
                {
                    Stream fileStream          = (Stream)e.Data.GetData("FileGroupDescriptor");
                    byte[] fileGroupDescriptor = new byte[fileStream.Length];
                    fileStream.Read(fileGroupDescriptor, 0, fileGroupDescriptor.Length);
                    fileStream.Close();
                    System.Text.StringBuilder fileName = new System.Text.StringBuilder("");
                    for (int i = 76; i < fileGroupDescriptor.Length; i++)
                    {
                        if (fileGroupDescriptor[i] != 0)
                        {
                            fileName.Append(Convert.ToChar(fileGroupDescriptor[i]));
                        }
                    }

                    fileName = fileName.Replace("?", "_");

                    string tempPath = System.IO.Path.GetTempPath();

                    // put the zip file into the temp directory
                    string theFile = Path.Combine(tempPath, "resume." + fileName.ToString().Split('.')[fileName.ToString().Split('.').Length - 1]);

                    FileInfo fi = new FileInfo(theFile);

                    int file_rescue = 1;

                    while (fi.Exists)
                    {
                        theFile = Path.Combine(tempPath, string.Format("resume({0}).", file_rescue) + fileName.ToString().Split('.')[fileName.ToString().Split('.').Length - 1]);
                        fi      = new FileInfo(theFile);
                        file_rescue++;
                    }

                    // get the actual raw file into memory
                    MemoryStream ms = (MemoryStream)e.Data.GetData(
                        "FileContents", true);
                    // allocate enough bytes to hold the raw data
                    byte[] fileBytes = new byte[ms.Length];
                    // set starting position at first byte and read in the raw data
                    ms.Position = 0;
                    ms.Read(fileBytes, 0, (int)ms.Length);
                    // create a file and save the raw zip file to it
                    FileStream fs = new FileStream(theFile, FileMode.Create);
                    fs.Write(fileBytes, 0, (int)fileBytes.Length);

                    fs.Close();  // close the file

                    FileInfo tempFile = new FileInfo(theFile);

                    // always good to make sure we actually created the file
                    if (tempFile.Exists == true)
                    {
                        Outlook.MailItem mailItem =
                            (this.OutlookItem as Outlook.MailItem);

                        Candidate newCandidate = new Candidate();
                        newCandidate.Username           = ServiceHelper.LastLogin.Username;
                        newCandidate.RegistrationDate   = mailItem.SentOn;
                        newCandidate.MailEntryID        = mailItem.EntryID;
                        newCandidate.CandidateID        = guid;
                        newCandidate.ResumePath         = tempFile.FullName;
                        newCandidate.EMailAddress       = mailItem.SenderEmailAddress;
                        newCandidate.CandidatePositions = new List <CandidatePosition>();

                        string[] senderarr = mailItem.SenderName.Split(' ');

                        if (senderarr.Length > 1)
                        {
                            newCandidate.FirstName = senderarr[0];
                            newCandidate.LastName  = senderarr.Skip(1).Aggregate((i, j) => i + " " + j);
                        }
                        else
                        {
                            newCandidate.FirstName = senderarr[0];
                        }

                        newCandidate.Status = "Classification";

                        CandidateEditForm form = new CandidateEditForm(true, this, newCandidate, mailItem);
                        form.Show(this);
                    }
                    else
                    {
                        Trace.WriteLine("File was not created!");
                    }
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Error in DragDrop function: " + ex.Message);

                // don't use MessageBox here - Outlook or Explorer is waiting !
            }
        }