Exemplo n.º 1
0
        /// <summary>
        /// 资源记录,保存到excel
        /// </summary>
        /// <param name="resource">搜索的资源名称</param>
        /// <param name="item"></param>
        /// <param name="tag">0:没有资源 ;1:公司名称不符;2:公海 ;3:仓库</param>
        private void resourceRecord(string resource, AllCustomerOpportunityListItem item, int tag)
        {
            string result = "";

            switch (tag)
            {
            case 0:    //没有资源
                result = "没有搜索到这个资源";

                result = null;
                Inquire();
                break;

            case 1:    //公司名称不符
                result = "没有搜索到名称匹配资源";
                result = null;
                Inquire();
                break;

            case 2:    //公海
                this.Dispatcher.BeginInvoke((Action)(delegate()
                {
                    UsePickWebBrowser(item);
                }));

                break;

            case 3:    //仓库
                if (XunHuanTiaoRuc)
                {
                    this.Dispatcher.BeginInvoke((Action)(delegate()
                    {
                        addresource(resource);
                    }));
                }
                else
                {
                    result = "已在仓库";

                    result = null;
                }
                Inquire();
                break;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 使用挑入窗口
 /// </summary>
 private void UsePickWebBrowser(AllCustomerOpportunityListItem item)
 {
     pickurl = "https://crm.alibaba-inc.com/noah/opportunity/pickInfo.cxul?globalId=" + item.encryptGlobalId + "&from=leads&source=recommendHide";
     this.pickWebBrowser.Source = new Uri(pickurl);
 }
Exemplo n.º 3
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("提示:数据格式改变,请联系研发部!!");
            }
        }
Exemplo n.º 4
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("提示:数据格式错误,请联系研发部!!");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 资源记录,保存到excel
        /// </summary>
        /// <param name="resource">搜索的资源名称</param>
        /// <param name="item"></param>
        /// <param name="tag">0:没有资源 ;1:公司名称不符;2:公海 ;3:仓库</param>
        private void resourceRecord(string resource, AllCustomerOpportunityListItem item, int tag)
        {
            string result       = "";
            string globalId     = "";
            string orderArrived = "";
            string type         = "";
            string saler        = "";
            string time         = "";
            string organization = "";

            switch (tag)
            {
            case 0:    //没有资源
                result = "没有搜索到这个资源";
                break;

            case 1:    //公司名称不符
                result = "没有搜索到名称匹配资源";
                break;

            case 2:    //公海
                globalId     = item.globalId;
                orderArrived = "未到单";
                type         = "公海";
                time         = item.gmtlastOperate;
                organization = "公海";
                break;

            case 3:    //仓库
                globalId = item.globalId;
                if (item.orderArrived.Equals("n"))
                {
                    orderArrived = "未到单";
                }
                else if (item.orderArrived.Equals("y"))
                {
                    orderArrived = "已到单";
                }
                type         = "仓库中";
                saler        = item.ownerName;
                time         = item.gmtlastOperate;
                organization = item.orgFullNamePath;
                break;
            }
            ExcelOperation.WriteToExcel(1, excelPath, resource, result, globalId, orderArrived, type, saler, time, organization);
            result       = null;
            globalId     = null;
            orderArrived = null;
            type         = null;
            saler        = null;
            time         = null;
            organization = null;
            Thread.Sleep(RandomTime());//延时

            this.Dispatcher.BeginInvoke((Action)(delegate()
            {
                //要执行的方法
                if (!clockstop)
                {
                    InquireCompany();//循环
                }
            }));
        }