コード例 #1
0
        public void Run(Newegg.Oversea.Framework.JobConsole.Client.JobContext context)
        {
            string baseUrl      = System.Configuration.ConfigurationManager.AppSettings["RestFulBaseUrl"];
            string languageCode = System.Configuration.ConfigurationManager.AppSettings["LanguageCode"];

            ECCentral.Job.Utility.RestClient client = new ECCentral.Job.Utility.RestClient(baseUrl, languageCode);
            client.Timeout = 100000;
            string companyCode = System.Configuration.ConfigurationManager.AppSettings["CompanyCode"];

            companyCode = companyCode == null ? null : (companyCode.Trim() == String.Empty ? null : companyCode.Trim());

            ECCentral.Job.Utility.RestServiceError error;

            List <WaitDeclareSO> waitDeclareSOList = new List <WaitDeclareSO>();

            client.Query <List <WaitDeclareSO> >("/SO/Job/GetWaitDeclareSO", out waitDeclareSOList, out error);
            if (waitDeclareSOList != null && waitDeclareSOList.Count > 0)
            {
                int totalDeclareCnt = waitDeclareSOList.Count;
                int successCnt      = 0;
                int failCnt         = 0;
                waitDeclareSOList = waitDeclareSOList.FindAll(m => !string.IsNullOrWhiteSpace(m.TrackingNumber));
                foreach (var item in waitDeclareSOList)
                {
                    bool bResult = false;
                    client.Query("/SO/Job/DeclareSO", item, out bResult, out error);

                    if (error != null)
                    {
                        string errorMessage = "";
                        foreach (var errItem in error.Faults)
                        {
                            errorMessage = errItem.ErrorDescription;
                        }
                        throw new Exception(error.StatusDescription + errorMessage);
                    }
                    if (bResult)
                    {
                        successCnt++;
                    }
                    else
                    {
                        failCnt++;
                    }
                }
                context.Message = string.Format("总申报数量:{0},成功数量:{1},失败数量:{2}", totalDeclareCnt, successCnt, failCnt);
            }
            else
            {
                context.Message = "总申报数量:0";
            }
        }
コード例 #2
0
        public void Run(JobContext context)
        {
            string baseUrl      = System.Configuration.ConfigurationManager.AppSettings["RestFulBaseUrl"];
            string languageCode = System.Configuration.ConfigurationManager.AppSettings["LanguageCode"];

            ECCentral.Job.Utility.RestClient client = new ECCentral.Job.Utility.RestClient(baseUrl, languageCode);
            client.Timeout = 100000;
            string companyCode = System.Configuration.ConfigurationManager.AppSettings["CompanyCode"];

            companyCode = companyCode == null ? null : (companyCode.Trim() == String.Empty ? null : companyCode.Trim());
            int Cnt = int.Parse(System.Configuration.ConfigurationManager.AppSettings["SigleCount"]);

            ECCentral.Job.Utility.RestServiceError error;


            List <string> trackingNumberList = new List <string>();

            client.Query <List <string> >("/SO/Job/GetWaitingFinishShippingList", ExpressType.KD100, out trackingNumberList, out error);
            if (trackingNumberList != null && trackingNumberList.Count > 0)
            {
                trackingNumberList = trackingNumberList.FindAll(m => !string.IsNullOrWhiteSpace(m));
                for (int i = 0; i < trackingNumberList.Count; i = i + Cnt)
                {
                    List <string> currHandleList = new List <string>();
                    int           thisCnt        = i + Cnt;
                    for (int j = i; j < thisCnt; j++)
                    {
                        if (j >= trackingNumberList.Count)
                        {
                            break;
                        }
                        currHandleList.Add(trackingNumberList[j]);
                    }
                    object obj = new object();
                    client.Query("/SO/Job/QueryTracking", new ExpressQueryEntity()
                    {
                        Type = ExpressType.KD100, TrackingNumberList = trackingNumberList
                    }, out obj, out error);
                    //if (error != null)
                    //{
                    //    ECCentral.Job.Utility.Logger.WriteLog("Service:" + error.ToString(), "ECCentral.Job.SO.KD100Express");
                    //}
                }
            }
        }
コード例 #3
0
ファイル: Processor.cs プロジェクト: sanlonezhang/ql
        public void Run(JobContext context)
        {
            string baseUrl      = System.Configuration.ConfigurationManager.AppSettings["RestFulBaseUrl"];
            string languageCode = System.Configuration.ConfigurationManager.AppSettings["LanguageCode"];

            ECCentral.Job.Utility.RestClient client = new ECCentral.Job.Utility.RestClient(baseUrl, languageCode);
            client.Timeout = 100000;
            string companyCode = System.Configuration.ConfigurationManager.AppSettings["CompanyCode"];

            companyCode = companyCode == null ? null : (companyCode.Trim() == String.Empty ? null : companyCode.Trim());

            List <WaitDeclareProduct> productList = new List <WaitDeclareProduct>();

            ECCentral.Job.Utility.RestServiceError error;
            #region 获取审核通过的商品,进行提交商检操作
            client.Query <List <WaitDeclareProduct> >("/SO/Job/GetEntryAuditSucess", out productList, out error);
            if (productList != null && productList.Count > 0)
            {
                for (int i = 0; i < productList.Count; i += 10)
                {
                    client.Update("/SO/Job/MarkInInspection", productList.Skip(i).Take(10).ToList(), out error);
                    if (error != null)
                    {
                        string errorMessage = "商品申请商检:";
                        foreach (var errItem in error.Faults)
                        {
                            errorMessage += errItem.ErrorDescription;
                        }
                        context.Message += errorMessage + "\r\n";
                    }
                }
            }
            else
            {
                context.Message += "商品申请商检数量:0" + "\r\n";
            }
            #endregion
            #region 获取商检中的商品,进行商检通过操作
            client.Query <List <WaitDeclareProduct> >("/SO/Job/GetInInspectionProduct", out productList, out error);
            if (productList != null && productList.Count > 0)
            {
                for (int i = 0; i < productList.Count; i += 10)
                {
                    client.Update("/SO/Job/MarkSuccessInspection", productList.Skip(i).Take(10).ToList(), out error);
                    if (error != null)
                    {
                        string errorMessage = "商品通过商检:";
                        foreach (var errItem in error.Faults)
                        {
                            errorMessage += errItem.ErrorDescription;
                        }
                        context.Message += errorMessage + "\r\n";
                    }
                }
            }
            else
            {
                context.Message += "商品通过商检数量:0" + "\r\n";
            }
            #endregion
            #region 获取商检通过的商品,进行报关申请
            client.Query <List <WaitDeclareProduct> >("/SO/Job/GetWaitDeclareProduct", out productList, out error);
            if (productList != null && productList.Count > 0)
            {
                var group      = productList.GroupBy(t => t.MerchantSysNo);
                var enumerator = group.GetEnumerator();
                while (enumerator.MoveNext())
                {
                    var pList           = enumerator.Current.ToList();
                    int totalDeclareCnt = pList.Count;
                    int successCnt      = 0;
                    int failCnt         = 0;
                    for (int i = 0; i < pList.Count; i += 10)
                    {
                        DeclareProductResult bResult;
                        var data = pList.Skip(i).Take(10).ToList();
                        client.Query("/SO/Job/DeclareProduct", data, out bResult, out error);
                        if (error != null)
                        {
                            string errorMessage = "商品申请报关:";
                            foreach (var errItem in error.Faults)
                            {
                                errorMessage += errItem.ErrorDescription;
                            }
                            context.Message += errorMessage + "\r\n";
                        }
                        if (bResult.Success)
                        {
                            successCnt += data.Count;
                        }
                        else
                        {
                            failCnt += data.Count;
                        }
                        context.Message += bResult.Message + "\r\n";
                    }
                    context.Message += string.Format("商家【{3}】商品总申报数量:{0},成功数量:{1},失败数量:{2}", totalDeclareCnt, successCnt, failCnt, enumerator.Current.FirstOrDefault().MerchantSysNo) + "\r\n";
                }
            }
            else
            {
                context.Message += "商品总申报数量:0" + "\r\n";
            }
            #endregion
        }