private void updateWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            panelWait.Invoke((MethodInvoker) delegate
            {
                panelWait.Visible = false;
            });

            if (e.Cancelled == true)
            {
            }
            else if (e.Error != null)
            {
                LoginForm form = new LoginForm();
                form.ShowDialog(this);

                if (ServiceHelper.IsLoggedIn)
                {
                    updateWorker.RunWorkerAsync();
                }
                else
                {
                    return;
                }
            }
            else
            {
                m_region.Areas = tvAreas.Nodes.CloneNodes();
                m_region.RefreshAreas();

                this.Close();
            }
        }
Пример #2
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;
                        });
                    }
                }
            }
        }