示例#1
0
        /// <summary>
        ///搜索结束、 解析json,分析公司资源状态
        /// </summary>
        /// <param name="jsons"></param>
        public void AnalyzeCompany(object jsons)
        {
            string json = (string)jsons;

            Console.WriteLine(json);
            try
            {
                CustomerListClass customer = JsonConvert.DeserializeObject <CustomerListClass>(json);
                string            err      = customer.errorMsg; //搜索错误信息
                                                                //判断这次请求验证码是否输入正确,正确的话展示结果,错误的提示重新输入

                if ((err != null && err.Equals("checkcode_error")) || (err != null && err.Equals("checkcode_need")))
                {
                    codeerr++;
                    //验证码错误,请求之后验证码要消失掉
                    this.Dispatcher.BeginInvoke((Action)(delegate()
                    {
                        //要执行的方法
                        if (codeerr <= 4)
                        {
                            getWinScript();
                            win.execScript("reloadcode();", "javascript");//刷新验证码
                            Thread thr = new Thread(() =>
                            {
                                //这里还可以处理些比较耗时的事情。
                                Thread.Sleep(2500);//延时2秒
                                this.Dispatcher.Invoke(new Action(() =>
                                {
                                    verfiyCode();//打码
                                }));
                            });
                            thr.Start();
                        }
                        else
                        {
                            MessageBox.Show("验证码错误次数过多!");
                            reshUi(1);
                        }
                    }));
                }
                else
                {
                    codeerr = 0;
                    //搜索成功
                    List <AllCustomerOpportunityListItem> AllCustomerOpportunityList = customer.allCustomerOpportunityList;
                    if (AllCustomerOpportunityList.Count == 0)
                    {
                        //没有查询到符合条件的客户
                        resourceRecord(resource, null, 0);
                    }
                    else if (customer.allCustomerLeadList.Count > 0)
                    {
                        //待分发
                        if (XunHuanTiaoRuc)
                        {
                            this.Dispatcher.BeginInvoke((Action)(delegate()
                            {
                                addresource(resource);
                            }));
                        }
                        Inquire();
                    }
                    else
                    {
                        List <AllCustomerOpportunityListItem> SeaCustomerOpportunityList = null;
                        int resourceNameDifferentCount = 0;
                        //存在资源
                        for (int i = 0; i < AllCustomerOpportunityList.Count; i++)
                        {
                            //1、先判断所有资源名称是否相同
                            AllCustomerOpportunityListItem item = AllCustomerOpportunityList[i];
                            if (item.companyName.Equals(resource))
                            {
                                //2、判断是否有在库中的资源,有在仓库的直接记录后开始下一条资源查询
                                if (item.productType.Equals("1") && item.depotOrSea.Equals("depot"))
                                {
                                    SeaCustomerOpportunityList = null;
                                    resourceNameDifferentCount = 0;
                                    if (XunHuanTiaoRuc)
                                    {
                                        this.Dispatcher.BeginInvoke((Action)(delegate()
                                        {
                                            addresource(resource);
                                        }));
                                    }
                                    Inquire();
                                    return;
                                }
                                else
                                {
                                    if (SeaCustomerOpportunityList == null)
                                    {
                                        SeaCustomerOpportunityList = new List <AllCustomerOpportunityListItem>();
                                    }
                                    SeaCustomerOpportunityList.Add(item);
                                }
                            }
                            else
                            {
                                //资源名称与搜索名称不同
                                resourceNameDifferentCount++;
                            }
                        }
                        if (resourceNameDifferentCount == AllCustomerOpportunityList.Count)
                        {
                            //4、所有资源名称都不正确
                            resourceRecord(resource, null, 1);
                        }
                        else
                        {
                            //3、所有资源都在公海,将信息记录
                            resourceRecord(resource, SeaCustomerOpportunityList[0], 2);
                        }
                        resourceNameDifferentCount = 0;
                        SeaCustomerOpportunityList = null;
                    }
                }
            }
            catch (Exception e)
            {
                string errorFiler = Directory.GetCurrentDirectory() + "\\errorlog.txt";//用户账号保存文件

                FileStream   fs = new FileStream(errorFiler, FileMode.OpenOrCreate);
                StreamWriter sw = new StreamWriter(fs);

                sw.WriteLine(json + "\n" + e.ToString());
                sw.Close();
                fs.Close();
                MessageBox.Show("提示:数据格式错误,请联系研发部!!");
            }
        }
示例#2
0
        /// <summary>
        ///搜索结束、 解析json,分析公司资源状态
        /// </summary>
        /// <param name="jsons"></param>
        private void AnalyzeCompany(object jsons)
        {
            string json = (string)jsons;

            try
            {
                CustomerListClass customer = JsonConvert.DeserializeObject <CustomerListClass>(json);
                string            err      = customer.errorMsg;//搜索错误信息

                //判断这次请求验证码是否输入正确,正确的话展示结果,错误的提示重新输入

                if ((err != null && err.Equals("checkcode_error")) || (err != null && err.Equals("checkcode_need")))
                {
                    codeerr++;
                    //验证码错误,请求之后验证码要消失掉
                    this.Dispatcher.BeginInvoke((Action)(delegate()
                    {
                        //要执行的方法
                        if (codeerr <= 4)
                        {
                            getWinScript();
                            win.execScript("reloadcode();", "javascript");//刷新验证码
                            Thread thr = new Thread(() =>
                            {
                                //这里还可以处理些比较耗时的事情。
                                Thread.Sleep(2000);//延时2秒
                                this.Dispatcher.Invoke(new Action(() =>
                                {
                                    verfiyCode();//打码
                                }));
                            });
                            thr.Start();
                        }
                        else
                        {
                            MessageBox.Show("验证码错误次数过多!");
                            reshUi(1);
                        }
                    }));
                }
                else
                {
                    codeerr = 0;
                    int resourceNameDifferentCount = 0;
                    //搜索成功
                    List <AllCustomerOpportunityListItem> AllCustomerOpportunityList = customer.allCustomerOpportunityList;
                    if (AllCustomerOpportunityList.Count > 0)
                    {
                        //存在资源
                        for (int i = 0; i < AllCustomerOpportunityList.Count; i++)
                        {
                            //1、先判断所有资源名称是否相同
                            AllCustomerOpportunityListItem item = AllCustomerOpportunityList[i];
                            if (item.companyName.Equals(resource))
                            {
                                //提示
                                resourceNameDifferentCount++;
                            }
                        }
                    }
                    if (resourceNameDifferentCount == 0)
                    {
                        this.Dispatcher.Invoke(new Action(() =>
                        {
                            addresource(resource);
                        }));

                        //要执行的方法
                        if (!clockstop)
                        {
                            InquireCompany();//循环
                        }
                    }
                    else
                    {
                        resourceNameDifferentCount = 0;
                        int a = 0X7FF;
                        int b = 1000;
                        Beep(a, b);

                        MessageBoxResult result = MessageBox.Show(resource + "   发现");
                        if (result == MessageBoxResult.OK)
                        {
                            //要执行的方法
                            if (!clockstop)
                            {
                                InquireCompany();//循环
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                string errorSaveFiler = Directory.GetCurrentDirectory() + "\\errorlog.txt";//用户账号保存文件
                try
                {
                    File.AppendAllText(errorSaveFiler, "\r\n" + DateTime.Now.ToString() + "      " + e.ToString());
                }
                catch
                {
                }
                MessageBox.Show("提示:数据格式改变,请联系研发部!!");
            }
        }