Example #1
0
 public void RefreshCandidatesStatuses()
 {
     CrossThreadUtility.InvokeControlAction <ComboBox>(cbStatus, cb =>
     {
         cb.Items.Clear();
         cb.Items.AddRange(m_candidatesStatuses);
     });
 }
Example #2
0
 public void RefreshRoles()
 {
     CrossThreadUtility.InvokeControlAction <ComboBox>(cbRole, cb =>
     {
         cb.Items.Clear();
         cb.Items.AddRange(m_roles);
     });
 }
Example #3
0
 public void RefreshAreas()
 {
     CrossThreadUtility.InvokeControlAction <TreeView>(tvAreas, tv =>
     {
         tv.Nodes.Clear();
         tv.Nodes.AddRange(m_areas.CloneNodes());
         tv.ExpandAll();
     });
 }
Example #4
0
 public void RefreshCreatedBy()
 {
     CrossThreadUtility.InvokeControlAction <ComboBox>(cbCreatedBy, cb =>
     {
         cb.DataSource    = new BindingSource(m_users, null);
         cb.DisplayMember = "Value";
         cb.ValueMember   = "Key";
     });
 }
Example #5
0
        private void candidatesWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled == true)
            {
            }
            else if (e.Error != null)
            {
                MessageBox.Show("Login failed, please try again\n\nError:" + e.Error.Message, "HunterCV");
            }
            else
            {
                var response = (CandidatesApiResponse)e.Result;

                m_TotalPages   = response.TotalPages;
                m_TotalRecords = response.TotalRows;

                m_candidates = new BindingList <Candidate>(response.Candidates.ToList());

                SetCandidatesInGridView();

                CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = false);

                if (this.CurrentCandidateForm != null)
                {
                    CrossThreadUtility.InvokeControlAction <DataGridView>(dataGridView1, dg =>
                    {
                        dg.ClearSelection();

                        if (this.GridRowSelectionType == GridRowSelectionTypes.First)
                        {
                            dg.Rows[0].Selected = true;
                        }
                        else
                        {
                            dg.Rows[dg.Rows.Count - 1].Selected = true;
                        }

                        this.CurrentCandidateForm.Candidate = dg.SelectedRows[0].DataBoundItem as Candidate;

                        this.CurrentCandidateForm.SetFormValues();
                        this.CurrentCandidateForm.SetFormTitle();
                        this.CurrentCandidateForm.LoadResumes();

                        CrossThreadUtility.InvokeControlAction <CandidateEditForm>(this.CurrentCandidateForm, form =>
                        {
                            form.Enabled = true;
                            this.CurrentCandidateForm = null;
                        });
                    });
                }
            }
        }
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (m_candidatesBindingSource.Count > 0)
            {
                MessageBox.Show("You can not delete this opening till You remove all candidates connected to this position", "HunterCV", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("Are You sure to permanently delete this opening from database ?", "HunterCV", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes)
            {
                button1.Enabled   = false;
                button2.Enabled   = false;
                btnDelete.Enabled = false;

                try
                {
                    BackgroundWorker worker = new BackgroundWorker();

                    worker.RunWorkerCompleted += (senders, es) =>
                    {
                        CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = false);

                        CrossThreadUtility.InvokeControlAction <MainRegion>(m_region, r =>
                        {
                            m_region.Positions.Remove(m_position);
                        });

                        Form form = MainRegion.GetForm(typeof(PositionsForm));

                        if (form is PositionsForm)
                        {
                            CrossThreadUtility.InvokeControlAction <PositionsForm>(((PositionsForm)form), f => f.DoSearch(-1));
                        }

                        CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());
                    };

                    worker.DoWork += (senders, es) =>
                    {
                        CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = true);

                        //remove from service
                        ServiceHelper.Delete(m_position);
                    };

                    worker.RunWorkerAsync();
                }
                catch (HttpRequestException)
                {
                }
            }
        }
Example #7
0
        private void ClearFilter()
        {
            CrossThreadUtility.InvokeControlAction <ComboBox>(cbRole, cb => cb.Text            = "");
            CrossThreadUtility.InvokeControlAction <CheckBox>(checkBox1, cb => cb.Checked      = false);
            CrossThreadUtility.InvokeControlAction <ComboBox>(cbStatus, cb => cb.SelectedIndex = -1);
            CrossThreadUtility.InvokeControlAction <TextBox>(tbNumber, cb =>
            {
                cb.Text = "";

                m_ignoreCheckedEvent = true;
                GetCheckedAreas(tvAreas.Nodes, true);
                m_ignoreCheckedEvent = false;
            });
        }
Example #8
0
        private void loadPage()
        {
            CrossThreadUtility.InvokeControlAction <DataGridView>(dg, dataGrid =>
            {
                var m_pagedCandidates = m_filteredPositions.Skip(m_CurrentPage * Properties.Settings.Default.PageSize)
                                        .Take(Properties.Settings.Default.PageSize);

                m_mainGridBindingSource            = new BindingSource();
                m_mainGridBindingSource.DataSource = new List <Position>(m_pagedCandidates);

                dataGrid.Columns.Clear();
                dataGrid.DataSource = m_mainGridBindingSource;
                if (m_filteredPositions.Count() > 0 && dataGrid.Columns.Count > 0)
                {
                    dataGrid.Columns[0].Visible  = false;
                    dataGrid.Columns[10].Visible = false;
                    dataGrid.Columns[11].Visible = false;
                }

                if (m_openMode == FormOpenMode.SearchAndSelect)
                {
                    dataGrid.ReadOnly = false;

                    for (int i = 0; i < dataGrid.ColumnCount; i++)
                    {
                        dataGrid.Columns[i].ReadOnly = true;
                    }

                    var col          = new System.Windows.Forms.DataGridViewCheckBoxColumn();
                    col.Width        = 30;
                    col.Frozen       = true;
                    col.DividerWidth = 3;
                    col.MinimumWidth = 30;
                    col.ReadOnly     = false;

                    dataGrid.Columns.Insert(0, col);
                }
                else
                {
                    dataGrid.ReadOnly = true;
                }
            });

            // Show Status
            CrossThreadUtility.InvokeControlAction <Label>(lblStatus, label => label.Text    = (m_CurrentPage + (m_TotalRecords > 0 ? 1 : 0)).ToString() + " / " + m_TotalPages.ToString());
            CrossThreadUtility.InvokeControlAction <Panel>(panelWait, panel => panel.Visible = false);
        }
Example #9
0
        // Occurs before the form region is displayed.
        // Use this.OutlookItem to get a reference to the current Outlook item.
        // Use this.OutlookFormRegion to get a reference to the form region.
        private void MainRegion_FormRegionShowing(object sender, System.EventArgs e)
        {
            try
            {
                var worker = new BackgroundWorker();

                worker.RunWorkerCompleted += (senders, es) =>
                {
                    //CrossThreadUtility.InvokeControlAction<Panel>(panelWait, p => p.Visible = false);
                };

                worker.DoWork += (senders, es) =>
                {
                    if (m_candidates == null && !roleWorker.IsBusy)
                    {
                        CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = true);
                        roleWorker.RunWorkerAsync();
                    }
                    else if (!roleWorker.IsBusy)
                    {
                        RefreshAreas();
                        RefreshRoles();
                        RefreshCandidatesStatuses();
                        RefreshCreatedBy();

                        Outlook.MailItem mailItem = (this.OutlookItem as Outlook.MailItem);

                        if (mailItem != null)
                        {
                            DoSearch(-1, mailItem.EntryID);
                        }
                    }
                    else
                    {
                        CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = true);
                    }
                };

                worker.RunWorkerAsync();
            }
            catch (Exception ex)
            {
                Logger.Error("Error:", ex);
            }
        }
Example #10
0
        private void SetCandidatesInGridView()
        {
            CrossThreadUtility.InvokeControlAction <DataGridView>(dataGridView1, dg =>
            {
                m_mainGridBindingSource            = new BindingSource();
                m_mainGridBindingSource.DataSource = new List <Candidate>(m_candidates);
                dg.Columns.Clear();
                dg.DataSource = m_mainGridBindingSource;
                if (m_candidates.Count() > 0 && dg.Columns.Count > 0)
                {
                    dg.Columns[0].Visible    = false;
                    dg.Columns[1].HeaderText = "#";
                    dg.Columns[1].Width      = 65;
                    dg.Columns[2].HeaderText = "Created by";
                    dg.Columns[7].Visible    = false;
                    dg.Columns[8].Visible    = false;
                    dg.Columns[9].Visible    = false;
                    dg.Columns[10].Visible   = false;
                    dg.Columns[11].Visible   = false;
                    dg.Columns[12].Visible   = false;
                    dg.Columns[18].Visible   = false;
                    dg.Columns[19].Visible   = false;
                    dg.Columns[20].Visible   = false;
                    dg.Columns[21].Visible   = false;
                    dg.Columns[22].Visible   = false;
                    dg.Columns[23].Visible   = false;
                    dg.Columns[24].Visible   = false;
                    dg.Columns[25].Visible   = false;
                    dg.Columns[26].Visible   = false;

                    DataGridViewImageColumn iconColumn = new DataGridViewImageColumn();
                    iconColumn.Name       = "StarredIcon";
                    iconColumn.HeaderText = "";
                    iconColumn.Width      = 35;
                    dg.Columns.Insert(0, iconColumn);
                }
            });

            // Show Status
            CrossThreadUtility.InvokeControlAction <Label>(lblStatus, label => label.Text    = (m_CurrentPage + (m_TotalRecords > 0 ? 1 : 0)).ToString() + " / " + m_TotalPages.ToString());
            CrossThreadUtility.InvokeControlAction <Panel>(panelWait, panel => panel.Visible = false);
        }
Example #11
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 0)
            {
                FavoritesIcons icn = (FavoritesIcons)Enum.Parse(typeof(FavoritesIcons), (string)dataGridView1.Rows[e.RowIndex].Cells["Starred"].Value ?? "Silver", true);

                if (icn == FavoritesIcons.Red)
                {
                    icn = FavoritesIcons.Silver;
                }
                else
                {
                    icn = (FavoritesIcons)(((int)icn) + 1);
                }

                var worker = new BackgroundWorker();

                panelWait.Visible = true;

                worker.DoWork += (ssender, es) =>
                {
                    ServiceHelper.UpdateFavorite((Candidate)dataGridView1.Rows[e.RowIndex].DataBoundItem, icn.ToString());
                };

                worker.RunWorkerCompleted += (ssender, es) =>
                {
                    CrossThreadUtility.InvokeControlAction <DataGridView>(dataGridView1, dg =>
                    {
                        dg.Rows[e.RowIndex].Cells["Starred"].Value = icn.ToString();
                        m_mainGridBindingSource.ResetBindings(true);
                    });

                    CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = false);
                };

                worker.RunWorkerAsync();
            }
        }
Example #12
0
        private void readingWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            try
            {
                string fileName = null;

                //cloudy document
                if (m_resume.IsCloudy)
                {
                    var getBytesWorker = new BackgroundWorker();

                    getBytesWorker.RunWorkerCompleted += (senders, es) =>
                    {
                        fileName = Path.Combine(System.IO.Path.GetTempPath(), m_resume.FileName);
                        System.IO.File.WriteAllBytes(fileName, (byte[])es.Result);

                        ScreeningDocument(fileName);
                    };

                    getBytesWorker.DoWork += (senders, es) =>
                    {
                        es.Result = ServiceHelper.GetResumeContent(m_resume.ResumeID);
                    };

                    getBytesWorker.RunWorkerAsync();
                }
                else
                {
                    ScreeningDocument(m_resume.FileName);
                }
            }
            catch
            {
                CrossThreadUtility.InvokeControlAction <ReadingResumeForm>(this, f => f.Close());
            }
        }
Example #13
0
        // This event handler deals with the results of the background operation.
        private void loginWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = false);
            CrossThreadUtility.InvokeControlAction <Button>(btnOK, b => b.Enabled    = true);

            if (e.Cancelled == true)
            {
            }
            else if (e.Error != null)
            {
                string errors = string.Empty;

                if (e.Error is AggregateException)
                {
                    var exception = (AggregateException)e.Error;

                    foreach (Exception ex in exception.InnerExceptions)
                    {
                        errors += "\n" + ex.ToString();
                    }
                }
                else
                {
                    errors = e.Error.ToString();
                }

                MessageBox.Show("Login failed, please try again\n\nError:" + errors, "HunterCV");
            }
            else
            {
                bool result = (bool)e.Result;

                if (result)
                {
                    try
                    {
                        MainRegion.WordApplication = new Microsoft.Office.Interop.Word.Application();
                    }
                    catch
                    {
                    }

                    CrossThreadUtility.InvokeControlAction <Form>(this, f =>
                    {
                        ServiceHelper.LastLogin = new LoginDetails
                        {
                            Username = tbUsername.Text,
                            Password = tbPassword.Text
                        };


                        if (cbRemember.Checked)
                        {
                            //save credentials if checkbox is on
                            Properties.Settings.Default.Username = tbUsername.Text;
                            Properties.Settings.Default.Password = tbPassword.Text;
                            Properties.Settings.Default.Save();
                        }

                        f.Close();
                    });
                }
                else
                {
                    MessageBox.Show("Login failed, please try again", "HunterCV");
                }
            }
        }
Example #14
0
        public void DoSearch(int columnIndex)
        {
            if (m_region.Positions == null)
            {
                return;
            }

            m_filteredPositions = (from l in m_region.Positions select l);

            List <String> areas = GetCheckedAreas(tvAreas.Nodes, false);

            if (areas.Count() > 0)
            {
                foreach (var area in areas)
                {
                    m_filteredPositions = m_filteredPositions.Where(p => p.PositionAreas != null && p.PositionAreas.Contains(area));
                }
            }

            if (m_openMode == FormOpenMode.SearchAndSelect)
            {
                m_filteredPositions = m_filteredPositions.Where(a => a.Status != "Manned");
            }
            else
            {
                if (!string.IsNullOrEmpty(cbStatus.Text))
                {
                    m_filteredPositions = m_filteredPositions.Where(a => a.Status == cbStatus.Text);
                }
            }

            if (!string.IsNullOrEmpty(cbCompany.Text))
            {
                m_filteredPositions = m_filteredPositions.Where(a => a.Company == cbCompany.Text);
            }

            CrossThreadUtility.InvokeControlAction <TextBox>(tbNumber, tb =>
            {
                if (!string.IsNullOrEmpty(tb.Text))
                {
                    bool parse;
                    int result;

                    parse = int.TryParse(tb.Text, out result);

                    if (parse)
                    {
                        m_filteredPositions = m_filteredPositions.Where(a => a.PositionNumber.Value == result);
                    }
                }
            });

            if (checkBox1.Checked)
            {
                DateTime start = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, 0, 0, 0);
                DateTime end   = new DateTime(dateTimePicker2.Value.Year, dateTimePicker2.Value.Month, dateTimePicker2.Value.Day, 23, 59, 59);

                m_filteredPositions = m_filteredPositions.Where(a => a.PublishedAt.Value >= start && a.PublishedAt.Value <= end);
            }

            m_TotalRecords = m_filteredPositions.Count();
            m_TotalPages   = m_TotalRecords / Properties.Settings.Default.PageSize + (m_TotalRecords % Properties.Settings.Default.PageSize > 0 ? 1 : 0);
            m_CurrentPage  = 0;

            if (columnIndex > 0 && dg.Columns[columnIndex].Name == "PositionNumber")
            {
                if (m_oldSortingIndex == columnIndex && m_oldSortingAscending)
                {
                    m_filteredPositions   = m_filteredPositions.OrderByDescending(p => p.PositionNumber);
                    m_oldSortingAscending = false;
                }
                else
                {
                    m_filteredPositions   = m_filteredPositions.OrderBy(p => p.PositionNumber);
                    m_oldSortingAscending = true;
                }

                m_oldSortingIndex = columnIndex;
            }

            if (columnIndex > 0 && dg.Columns[columnIndex].Name == "PublishedAt")
            {
                if (m_oldSortingIndex == columnIndex && m_oldSortingAscending)
                {
                    m_filteredPositions   = m_filteredPositions.OrderByDescending(p => p.PublishedAt);
                    m_oldSortingAscending = false;
                }
                else
                {
                    m_filteredPositions   = m_filteredPositions.OrderBy(p => p.PublishedAt);
                    m_oldSortingAscending = true;
                }

                m_oldSortingIndex = columnIndex;
            }

            if (columnIndex > 0 && dg.Columns[columnIndex].Name == "PositionTitle")
            {
                if (m_oldSortingIndex == columnIndex && m_oldSortingAscending)
                {
                    m_filteredPositions   = m_filteredPositions.OrderByDescending(p => p.PositionTitle);
                    m_oldSortingAscending = false;
                }
                else
                {
                    m_filteredPositions   = m_filteredPositions.OrderBy(p => p.PositionTitle);
                    m_oldSortingAscending = true;
                }

                m_oldSortingIndex = columnIndex;
            }

            if (columnIndex > 0 && dg.Columns[columnIndex].Name == "PositionDescription")
            {
                if (m_oldSortingIndex == columnIndex && m_oldSortingAscending)
                {
                    m_filteredPositions   = m_filteredPositions.OrderByDescending(p => p.PositionDescription);
                    m_oldSortingAscending = false;
                }
                else
                {
                    m_filteredPositions   = m_filteredPositions.OrderBy(p => p.PositionDescription);
                    m_oldSortingAscending = true;
                }

                m_oldSortingIndex = columnIndex;
            }

            if (columnIndex > 0 && dg.Columns[columnIndex].Name == "PositionAreas")
            {
                if (m_oldSortingIndex == columnIndex && m_oldSortingAscending)
                {
                    m_filteredPositions   = m_filteredPositions.OrderByDescending(p => p.PositionAreas);
                    m_oldSortingAscending = false;
                }
                else
                {
                    m_filteredPositions   = m_filteredPositions.OrderBy(p => p.PositionAreas);
                    m_oldSortingAscending = true;
                }

                m_oldSortingIndex = columnIndex;
            }

            if (columnIndex > 0 && dg.Columns[columnIndex].Name == "PositionRole")
            {
                if (m_oldSortingIndex == columnIndex && m_oldSortingAscending)
                {
                    m_filteredPositions   = m_filteredPositions.OrderByDescending(p => p.PositionRole);
                    m_oldSortingAscending = false;
                }
                else
                {
                    m_filteredPositions   = m_filteredPositions.OrderBy(p => p.PositionRole);
                    m_oldSortingAscending = true;
                }

                m_oldSortingIndex = columnIndex;
            }

            if (columnIndex > 0 && dg.Columns[columnIndex].Name == "Company")
            {
                if (m_oldSortingIndex == columnIndex && m_oldSortingAscending)
                {
                    m_filteredPositions   = m_filteredPositions.OrderByDescending(p => p.Company);
                    m_oldSortingAscending = false;
                }
                else
                {
                    m_filteredPositions   = m_filteredPositions.OrderBy(p => p.Company);
                    m_oldSortingAscending = true;
                }

                m_oldSortingIndex = columnIndex;
            }

            if (columnIndex > 0 && dg.Columns[columnIndex].Name == "Status")
            {
                if (m_oldSortingIndex == columnIndex && m_oldSortingAscending)
                {
                    m_filteredPositions   = m_filteredPositions.OrderByDescending(p => p.Status);
                    m_oldSortingAscending = false;
                }
                else
                {
                    m_filteredPositions   = m_filteredPositions.OrderBy(p => p.Status);
                    m_oldSortingAscending = true;
                }

                m_oldSortingIndex = columnIndex;
            }

            //m_mainGridBindingSource = new BindingSource();
            //m_mainGridBindingSource.DataSource = new List<Position>(m_filteredPositions);

            //dg.Columns.Clear();
            //dg.DataSource = m_mainGridBindingSource;

            //if (m_filteredPositions.Count() > 0)
            //{
            //    dg.Columns[0].Visible = false;
            //    dg.Columns[10].Visible = false;
            //    dg.Columns[11].Visible = false;
            //}
            if (m_openMode == FormOpenMode.SearchAndSelect)
            {
                btnContinue.Enabled = true;
            }

            loadPage();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bool blValidTitle = ValidateTitle();

            if (!blValidTitle)
            {
                return;
            }

            panelWait.Visible = true;
            button1.Enabled   = false;

            this.m_position.PositionAreas = GetNodesPath(tvAreas.Nodes, null);

            //exists
            if (!m_position.IsNew)
            {
                var saveWorker = new BackgroundWorker();

                saveWorker.RunWorkerCompleted += (senders, es) =>
                {
                    CrossThreadUtility.InvokeControlAction <MainRegion>(m_region, m => m.Positions.Add(m_position));

                    CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());
                };

                saveWorker.DoWork += (senders, es) =>
                {
                    try
                    {
                        if (!es.Cancel)
                        {
                            ServiceHelper.Update(m_position);
                        }
                    }
                    finally
                    {
                    }
                };

                saveWorker.RunWorkerAsync();
            }
            else
            {
                //new

                var saveWorker = new BackgroundWorker();

                saveWorker.RunWorkerCompleted += (senders, es) =>
                {
                    if (es.Error != null)
                    {
                        if (es.Error is LicenseException)
                        {
                            CrossThreadUtility.InvokeControlAction <Form>(this, f =>
                            {
                                MessageBox.Show(this, "Sorry, but this license type does not allow more entities of those types", "HunterCV", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                                f.Close();
                            });
                        }
                    }
                    else
                    {
                        m_position.IsNew = false;

                        CrossThreadUtility.InvokeControlAction <MainRegion>(m_region, m => m.Positions.Add(m_position));

                        Form form = MainRegion.GetForm(typeof(PositionsForm));

                        if (form is PositionsForm)
                        {
                            CrossThreadUtility.InvokeControlAction <PositionsForm>(((PositionsForm)form), f => f.DoSearch(-1));
                        }


                        CrossThreadUtility.InvokeControlAction <Form>(this, f => f.Close());
                    }
                };



                saveWorker.DoWork += (senders, es) =>
                {
                    try
                    {
                        if (!es.Cancel)
                        {
                            ServiceHelper.Add(m_position);
                        }
                    }
                    finally
                    {
                    }
                };

                saveWorker.RunWorkerAsync();
            }
        }
Example #16
0
        private void ScreeningDocument(string fileName)
        {
            FileInfo fi = new FileInfo(fileName);

            try
            {
                if (fi.Exists)
                {
                    switch (fi.Extension)
                    {
                    //case ".pdf":
                    //    PDFParser parser = new PDFParser();

                    //    string pdfContent;

                    //    bool extracted = parser.ExtractText(m_filePath, out pdfContent);

                    //    if (extracted && !string.IsNullOrEmpty( pdfContent.Trim()) )
                    //    {
                    //        this.ReadingResult.Add("Content", pdfContent);
                    //        this.ReadingResult.Add("Mobile1", GetPDFRegularExpression(pdfContent.Replace(" ",""), @"0(5[012345678]|6[47]){1}(\s)?(\-)?(\s)?[^0\D]{1}\d{6}"));
                    //        this.ReadingResult.Add("Phone1", GetPDFRegularExpression(pdfContent.Replace(" ", ""), @"0(5[012345678]|6[47]){1}(\s)?(\-)?(\s)?[^0\D]{1}\d{6}"));
                    //    }

                    //    break;
                    case ".doc":
                    case ".docx":
                    case ".rtf":
                        Object objMissing = Type.Missing;
                        Object objTrue    = true;
                        Object objFalse   = true;

                        //Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
                        if (MainRegion.WordApplication != null)
                        {
                            Object name = fileName;
                            Object confirmConversions = false;

                            Microsoft.Office.Interop.Word.Document doc = MainRegion.WordApplication.Documents.Open(
                                ref name, ref confirmConversions,
                                ref objMissing, ref objMissing, ref objMissing, ref objMissing,
                                ref objMissing, ref objMissing, ref objMissing, ref objMissing,
                                ref objMissing, ref objMissing, ref objMissing, ref objMissing,
                                ref objMissing, ref objMissing
                                );

                            if (Properties.Settings.Default.AddMSCompanyLogo &&
                                !string.IsNullOrEmpty(Properties.Settings.Default.MSLogoFilePath) &&
                                File.Exists(Properties.Settings.Default.MSLogoFilePath))
                            {
                                foreach (Microsoft.Office.Interop.Word.Section wordSection in doc.Content.Sections)
                                {
                                    wordSection.Headers[Microsoft.Office.Interop.Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage]
                                    .Range.InlineShapes.AddPicture(Properties.Settings.Default.MSLogoFilePath);
                                }
                            }

                            doc.Save();

                            if (!m_previewOnly)
                            {
                                this.ReadingResult.Add("Content", doc.Content.Text);

                                if (!string.IsNullOrEmpty(m_region.Settings.Where(p => p.Key == "MSWordMobile1WildCards").Single().Value))
                                {
                                    this.ReadingResult.Add("MSWordMobile1WildCards", GetMSWordWildCard(doc, "<" + m_region.Settings.Where(p => p.Key == "MSWordMobile1WildCards").Single().Value + ">"));
                                }

                                if (!string.IsNullOrEmpty(m_region.Settings.Where(p => p.Key == "MSWordMobile2WildCards").Single().Value))
                                {
                                    this.ReadingResult.Add("MSWordMobile2WildCards", GetMSWordWildCard(doc, "<" + m_region.Settings.Where(p => p.Key == "MSWordMobile2WildCards").Single().Value + ">"));
                                }

                                if (!string.IsNullOrEmpty(m_region.Settings.Where(p => p.Key == "MSWordPhone1WildCards").Single().Value))
                                {
                                    this.ReadingResult.Add("MSWordPhone1WildCards", GetMSWordWildCard(doc, "<" + m_region.Settings.Where(p => p.Key == "MSWordPhone1WildCards").Single().Value + ">"));
                                }

                                if (!string.IsNullOrEmpty(m_region.Settings.Where(p => p.Key == "MSWordPhone2WildCards").Single().Value))
                                {
                                    this.ReadingResult.Add("MSWordPhone2WildCards", GetMSWordWildCard(doc, "<" + m_region.Settings.Where(p => p.Key == "MSWordPhone2WildCards").Single().Value + ">"));
                                }
                            }

                            FileInfo htmlFile = new FileInfo(fileName.ToLower().Replace(new FileInfo(fileName).Extension, ".html"));

                            object oFileName = (object)htmlFile.FullName;

                            object oFormat            = Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML;
                            object oCompatibilityMode = Microsoft.Office.Interop.Word.WdCompatibilityMode.wdWord2007;    //.wdFormatHTML;

                            doc.SaveAs2(ref oFileName, ref oFormat, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing,
                                        ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing, ref objMissing);

                            doc.Close(objMissing, objMissing, objMissing);
                            //app.Quit(ref objMissing, ref objMissing, ref objMissing);

                            this.ReadingResult.Add("HtmlPreviewFileName", htmlFile.FullName);

                            doc = null;
                            //GC.Collect(); // force final cleanup!
                            //GC.WaitForPendingFinalizers();
                        }

                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Fatal(m_resume, ex);
            }
            finally
            {
                CrossThreadUtility.InvokeControlAction <ReadingResumeForm>(this, f => f.Close());
            }
        }
Example #17
0
        private void candidatesWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            CrossThreadUtility.InvokeControlAction <Panel>(panelWait, p => p.Visible = true);

            CandidatesApiRequest request = new CandidatesApiRequest();

            request.PageSize   = Properties.Settings.Default.PageSize;
            request.PageNumber = m_CurrentPage;

            if (e.Argument != null)
            {
                request.FilterMailEntryId = (string)e.Argument;
            }

            IEnumerable <String> areas = null;

            CrossThreadUtility.InvokeControlAction <TreeView>(tvAreas, tree =>
            {
                areas = GetCheckedAreas(tree.Nodes, false).ToArray <string>();
            });

            request.FilterStarredBlue = MainRegion.FilterFavorites["Blue"];
            request.FilterStarredGold = MainRegion.FilterFavorites["Gold"];
            request.FilterStarredRed  = MainRegion.FilterFavorites["Red"];

            if (areas.Count() > 0)
            {
                request.FilterAreas = areas.Aggregate((i, j) => i + "," + j);
            }

            if (!string.IsNullOrEmpty(tbName.Text))
            {
                request.FilterFullName = tbName.Text.Trim();
            }

            CrossThreadUtility.InvokeControlAction <ComboBox>(cbCreatedBy, cb =>
            {
                if (!string.IsNullOrEmpty(cb.Text))
                {
                    request.FilterCreatedBy = (string)cb.SelectedValue;
                }
            });

            CrossThreadUtility.InvokeControlAction <ComboBox>(cbRole, cb =>
            {
                if (!string.IsNullOrEmpty(cb.Text))
                {
                    request.FilterRole = cb.Text;
                }
            });

            CrossThreadUtility.InvokeControlAction <ComboBox>(cbStatus, cb =>
            {
                if (!string.IsNullOrEmpty(cb.Text))
                {
                    request.FilterStatus = cb.Text;
                }
            });

            CrossThreadUtility.InvokeControlAction <TextBox>(tbNumber, tb =>
            {
                if (!string.IsNullOrEmpty(tb.Text))
                {
                    bool parse;
                    int result;

                    parse = int.TryParse(tb.Text, out result);

                    if (parse)
                    {
                        request.FilterCandidateNumber = result;
                    }
                }
            });
            CrossThreadUtility.InvokeControlAction <CheckBox>(checkBox1, cb =>
            {
                if (cb.Checked)
                {
                    DateTime start = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day, 0, 0, 0);
                    DateTime end   = new DateTime(dateTimePicker2.Value.Year, dateTimePicker2.Value.Month, dateTimePicker2.Value.Day, 23, 59, 59);

                    request.FilterRegistrationStartDate = start.Ticks;
                    request.FilterRegistrationEndDate   = end.Ticks;
                }
            });

            CrossThreadUtility.InvokeControlAction <DataGridView>(dataGridView1, dg =>
            {
                if (m_oldSortingIndex > -1)
                {
                    request.SortField = dg.Columns[m_oldSortingIndex].Name.Replace("Icon", string.Empty);
                }
                else
                {
                    request.SortField = "CandidateNumber";
                }

                request.SortType = m_oldSortingAscending ? 2 : 1;
            });

            e.Result = ServiceHelper.SearchCandidates(request);
        }
Example #18
0
        // This event handler deals with the results of the background operation.
        private void m_retrieveWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            //panelWait.Visible = false;

            if (e.Cancelled == true)
            {
            }
            else if (e.Error != null)
            {
                MessageBox.Show("Login failed, please try again\n\nError:" + e.Error.Message, "HunterCV");
            }
            else
            {
                m_roleId = ((UserData)e.Result).roleId;

                var license = ((UserData)e.Result).license;

                if (license == Role.FreeLicenseGuid)
                {
                    m_license = LicenseType.Free;
                }
                else if (license == Role.StandardLicenseGuid)
                {
                    m_license = LicenseType.Standard;
                }
                else if (license == Role.PremiumLicenseGuid)
                {
                    m_license = LicenseType.Premium;
                }
                else
                {
                    m_license = LicenseType.Free;
                }


                m_positions = new BindingList <Position>(((UserData)e.Result).positions.ToList());


                //parse areas
                var             docAreas      = XDocument.Parse(((UserData)e.Result).areas);
                var             elementsAreas = docAreas.Root.Elements();
                List <TreeNode> xAreas        = new List <TreeNode>();

                foreach (XElement root in elementsAreas)
                {
                    xAreas.AddRange(GetNodes(new TreeNode((string)root.Attribute("title")), root));
                }

                m_areas = xAreas.ToArray();

                //parse companies
                var docCompanies = XDocument.Parse(((UserData)e.Result).companies);
                m_companies = docCompanies.Root.Elements();
                //var elementsCompanies = docCompanies.Root.Elements();
                //List<TreeNode> xCompany = new List<TreeNode>();

                //foreach (XElement root in elementsCompanies)
                //{
                //    xCompany.AddRange(GetNodes(new TreeNode((string)root.Attribute("title")), root));
                //}

                //m_companies = xCompany.ToArray();

                //parse roles
                var           docRoles      = XDocument.Parse(((UserData)e.Result).roles);
                var           elementsRoles = docRoles.Root.Elements();
                List <string> xRole         = new List <string>();

                foreach (XElement root in elementsRoles)
                {
                    xRole.Add((string)root.Attribute("title"));
                }

                m_roles = xRole.ToArray();


                //parse candidates statuses
                var           docCandidatesStatuses      = XDocument.Parse(((UserData)e.Result).candidatesStatuses);
                var           elementsCandidatesStatuses = docCandidatesStatuses.Root.Elements();
                List <string> xCandidatesStatus          = new List <string>();

                foreach (XElement root in elementsCandidatesStatuses)
                {
                    xCandidatesStatus.Add((string)root.Attribute("title"));
                }

                m_candidatesStatuses = xCandidatesStatus.ToArray();

                //parse positions statuses
                var           docPositionsStatuses      = XDocument.Parse(((UserData)e.Result).positionsStatuses);
                var           elementsPositionsStatuses = docPositionsStatuses.Root.Elements();
                List <string> xPositionsStatus          = new List <string>();

                foreach (XElement root in elementsPositionsStatuses)
                {
                    xPositionsStatus.Add((string)root.Attribute("title"));
                }

                m_positionsStatuses = xPositionsStatus.ToArray();

                //parse settings
                var docSettings      = XDocument.Parse(((UserData)e.Result).settings);
                var elementsSettings = docSettings.Root.Elements();
                m_Settings = new List <KeyValuePair <string, string> >();

                foreach (XElement root in elementsSettings)
                {
                    m_Settings.Add(new KeyValuePair <string, string>((string)root.Attribute("title"), (string)root.Attribute("value")));
                }

                //parse mail templates
                m_templates = new List <MailTemplate>(((UserData)e.Result).templates);

                m_users = ((UserData)e.Result).users;

                foreach (Microsoft.Office.Tools.Outlook.IFormRegion formRegion
                         in Globals.FormRegions)
                {
                    if (formRegion is MainRegion)
                    {
                        MainRegion region = (MainRegion)formRegion;
                        region.RefreshAreas();
                        region.RefreshRoles();
                        region.RefreshCandidatesStatuses();
                        region.RefreshCreatedBy();
                        region.DoSearch(-1, null);

                        CrossThreadUtility.InvokeControlAction <Panel>(region.panelWait, panel =>
                        {
                            panel.Visible = false;
                        });
                    }
                }
            }
        }