Пример #1
0
        /// <summary>
        /// 执行下载阿里订单计划
        /// </summary>
        /// <returns></returns>
        public bool ExecuteDownAliOrdersPlan()
        {
            int successCount = 0, total = 0;
            //获取阿里订单下载计划列表
            var list = AliOrderBusiness.BaseBusiness.GetAliOrderDownloadPlans();

            foreach (var item in list)
            {
                string error;

                //下载阿里打样订单
                var  gmtFentEnd = DateTime.Now.AddDays(1);
                bool flag       = AliOrderBusiness.DownFentOrders(item.FentSuccessEndTime, gmtFentEnd, item.Token, item.RefreshToken,
                                                                  item.UserID, item.ClientID, ref successCount, ref total, out error);

                //新增阿里打样订单下载日志
                AliOrderBusiness.BaseBusiness.AddAliOrderDownloadLog(EnumOrderType.ProofOrder, flag, AlibabaSdk.AliOrderDownType.Auto, item.FentSuccessEndTime, gmtFentEnd,
                                                                     successCount, total, item.ClientID, error);

                //添加服务日志
                string log = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "    ClientID:" + item.ClientID + " 下载打样订单结果:" + (flag ? "成功" : "失败") + " 成功订单数:" + successCount;
                if (!flag)
                {
                    log += "  失败原因:" + error;
                }
                WriteLog(log);


                //下载阿里大货订单列表
                var gmtBulkEnd = DateTime.Now.AddDays(1);
                flag = AliOrderBusiness.DownBulkOrders(item.BulkSuccessEndTime, gmtBulkEnd, item.Token, item.RefreshToken,
                                                       item.UserID, item.ClientID, ref successCount, ref total, out error);

                //新增阿里大货订单下载日志
                AliOrderBusiness.BaseBusiness.AddAliOrderDownloadLog(EnumOrderType.LargeOrder, flag, AlibabaSdk.AliOrderDownType.Auto, item.BulkSuccessEndTime, gmtBulkEnd,
                                                                     successCount, total, item.ClientID, error);

                //添加服务日志
                log = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "    ClientID:" + item.ClientID + " 下载大货订单结果:" + (flag ? "成功" : "失败") + "  成功订单数:" + successCount;
                if (!flag)
                {
                    log += "  失败原因:" + error;
                }
                WriteLog(log);
            }

            return(true);
        }
Пример #2
0
        public JsonResult DownAliOrders(int downOrderType, string startTime, string endTime)
        {
            int  result  = 0;
            bool flag    = false;
            bool canDown = true;

            if (canDown)
            {
                DateTime downStartTime = DateTime.Parse(startTime);
                DateTime downEndTime   = DateTime.Parse(endTime);
                downEndTime = downEndTime.AddDays(1);

                if ((downEndTime - downStartTime).TotalDays < 61)
                {
                    var plan = AliOrderBusiness.BaseBusiness.GetAliOrderDownloadPlanDetail(CurrentUser.ClientID);

                    if (plan != null)
                    {
                        int successCount = 0;
                        int total        = 0;

                        string token        = plan.Token;
                        string refreshToken = plan.RefreshToken;
                        string error;
                        if (downOrderType == 1)
                        {
                            flag = AliOrderBusiness.DownFentOrders(downStartTime, downEndTime, token, refreshToken, CurrentUser.UserID,
                                                                   CurrentUser.ClientID, ref successCount, ref total, out error, AlibabaSdk.AliOrderDownType.Hand);

                            //新增阿里打样订单下载日志
                            AliOrderBusiness.BaseBusiness.AddAliOrderDownloadLog(EnumOrderType.ProofOrder, flag, AlibabaSdk.AliOrderDownType.Hand, downStartTime, downEndTime,
                                                                                 successCount, total, error, plan.ClientID);
                        }
                        else
                        {
                            flag = AliOrderBusiness.DownBulkOrders(downStartTime, downEndTime, token, refreshToken, CurrentUser.UserID,
                                                                   CurrentUser.ClientID, ref successCount, ref total, out error, AlibabaSdk.AliOrderDownType.Hand);

                            //新增阿里大货订单下载日志
                            AliOrderBusiness.BaseBusiness.AddAliOrderDownloadLog(EnumOrderType.LargeOrder, flag, AlibabaSdk.AliOrderDownType.Hand, downStartTime, downEndTime,
                                                                                 successCount, total, error, plan.ClientID);
                        }

                        result = flag ? 1 : 0;

                        //拉取订单记录日期
                        if (flag)
                        {
                            LogBusiness.AddActionLog(IntFactoryEnum.EnumSystemType.Client, IntFactoryEnum.EnumLogObjectType.PullOrder, EnumLogType.Create, "", OperateIP, CurrentUser.ClientID);
                        }
                        JsonDictionary.Add("totalOrderCount", total);
                        JsonDictionary.Add("successOrderCount", successCount);

                        //if (flag)
                        //{
                        //    if (AliOrderBusiness.DownAliOrderLogs.ContainsKey(CurrentUser.ClientID))
                        //        AliOrderBusiness.DownAliOrderLogs[CurrentUser.ClientID] = DateTime.Now.AddHours(12);
                        //    else
                        //        AliOrderBusiness.DownAliOrderLogs.Add(CurrentUser.ClientID, DateTime.Now.AddHours(12));
                        //}
                    }
                    else
                    {
                        result = 2;
                    }
                }
                else
                {
                    result = 3;
                }
            }
            else
            {
                result = 4;
            }

            JsonDictionary.Add("result", result);

            return(new JsonResult
            {
                Data = JsonDictionary,
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }