Exemple #1
0
        /// <summary>
        /// 同步成功日志
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="dataType"></param>
        /// <param name="errMessage"></param>
        /// <param name="isOk"></param>
        /// <param name="srcPKId"></param>
        /// <param name="billNo"></param>
        public static void WriteSynchroLog_Succ(Context ctx, SynchroDataType dataType, string errMessage, bool isOk = true, string srcPKId = "", string billNo = "")
        {
            lock (objLock)
            {
                if (errMessage.Length > 4000)
                {
                    errMessage = errMessage.Substring(0, 3999);
                }

                string insertSql = @" Insert Into HS_T_SynchroLog_Succ(FDataSourceType,FDataSourceId,FBILLNO,
                                        FSynchroTime,FIsSuccess,FErrInfor,FDataSourceTypeDesc,FHSOperateId) 
                                  Select @FDataSourceType as FDataSourceType,@FDataSourceId as FDataSourceId,@FBILLNO as FBILLNO,
                                        @FSynchroTime as FSynchroTime,@FIsSuccess as FIsSuccess,@FErrInfor as FErrInfor,
                                        @FDataSourceTypeDesc as FDataSourceTypeDesc,@FHSOperateId as FHSOperateId ";

                var para = new List <SqlParam>();
                para.Add(new SqlParam("@FDataSourceType", KDDbType.String, dataType.ToString()));
                para.Add(new SqlParam("@FDataSourceId", KDDbType.String, srcPKId));
                para.Add(new SqlParam("@FBILLNO", KDDbType.String, billNo));
                para.Add(new SqlParam("@FSynchroTime", KDDbType.DateTime, DateTime.Now));
                para.Add(new SqlParam("@FIsSuccess", KDDbType.String, isOk == true ? 1 : 0));
                para.Add(new SqlParam("@FErrInfor", KDDbType.String, errMessage));
                para.Add(new SqlParam("@FDataSourceTypeDesc", KDDbType.String, GetDataSourceTypeDesc(dataType)));
                para.Add(new SqlParam("@FHSOperateId", KDDbType.Int64, ctx.UserId));

                Kingdee.BOS.App.ServiceHelper.GetService <IDBService>().Execute(ctx, insertSql, para);
            }
        }
        /// <summary>
        /// 获取同步类的实例
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="assembly"></param>
        /// <param name="type"></param>
        /// <param name="dataType"></param>
        /// <returns></returns>
        private static List <T> GetSynchroClsInstance_ <T>(Assembly assembly, Type type, SynchroDataType dataType)
        {
            List <T> types = null;

            if (clsSynchroToHCType == null || clsSynchroToHCType.Count == 0)
            {
                CreateSynchroHCClsInstance <T>(assembly, type);
            }

            types = new List <T>();

            if (clsSynchroToHCType != null && clsSynchroToHCType.Count > 0)
            {
                foreach (var item in clsSynchroToHCType)
                {
                    if (item != null)
                    {
                        if (item.BaseType != null)
                        {
                            if (item.BaseType == type || item.BaseType.BaseType == type)
                            {
                                T x = (T)Activator.CreateInstance(item);

                                if (x != null)
                                {
                                    if (x.GetType() != null)
                                    {
                                        if (x.GetType().GetProperty("DataType") != null)
                                        {
                                            if (x.GetType().GetProperty("DataType").GetValue(x, null) != null)
                                            {
                                                if (dataType.ToString() == x.GetType().GetProperty("DataType").GetValue(x, null).ToString())
                                                {
                                                    types.Add(x);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }


            return(types);
        }
Exemple #3
0
        public static string GetDataSourceTypeDesc(SynchroDataType dataType)
        {
            switch (dataType)
            {
            case SynchroDataType.Inventroy:
                return("库存");

            case SynchroDataType.Customer:
                return("客户");

            case SynchroDataType.CustomerByExcel:
                return("客户(EXCEL)");

            case SynchroDataType.CustomerOrderQty:
                return("客户下单次数");

            case SynchroDataType.CustomerAddress:
                return("客户地址");

            case SynchroDataType.CustomerAddressByExcel:
                return("客户地址(EXCEL)");

            case SynchroDataType.SaleOrder:
                return("销售订单");

            case SynchroDataType.SaleOrderOffline:
                return("线下销售订单");

            case SynchroDataType.SaleOrderStatus:
                return("销售订单状态");

            case SynchroDataType.SalesOrderPayStatus:
                return("销售订单支付状态");

            case SynchroDataType.SaleOutStockBill:
                return("销售出库单");

            case SynchroDataType.UserLoin:
                return("用户登录");

            case SynchroDataType.DelCustomerAddress:
                return("删除客户地址");

            case SynchroDataType.Material:
                return("物料");

            case SynchroDataType.DownLoadListInfo:
                return("物料List信息");

            case SynchroDataType.DeliveryNoticeBill:
                return("发货通知单");

            case SynchroDataType.K3ToKuaiDi100:
                return("订阅快递100");

            case SynchroDataType.ImportLogis:
                return("上传运单号");

            case SynchroDataType.DeductIntegral:
                return("扣减积分");

            case SynchroDataType.UnDeductIntegral:
                return("反扣减积分");

            case SynchroDataType.ReceiveBill:
                return("收款单");

            case SynchroDataType.BatchAdjust:
                return("批量调价单");

            case SynchroDataType.OnTheWay:
                return("在途明细");

            default:
                return(dataType.ToString());
            }
        }
Exemple #4
0
        private HttpResponseResult SynchroDropShipping(SynchroDataType dataType)
        {
            HttpResponseResult result = null;
            SynchroService     cli    = new SynchroService();

            DropShippingInfo info = new DropShippingInfo();

            info.Token     = "HANDS-test";
            info.FCustId   = "107325";
            info.TimeStamp = TimeHelper.GetTimeStamp(DateTime.Now);

            info.SignMsg = EncryptUtil.MD5Encrypt(info.FCustId + info.TimeStamp, "DROPSHIPPING");

            switch (dataType)
            {
            case SynchroDataType.DropShippingSalOrder:
                info.DataType = dataType.ToString();
                List <DSSaleOrder>      orders  = null;
                DSSaleOrder             order   = null;
                List <DSSaleOrderEntry> entries = null;
                DSSaleOrderEntry        entry   = null;

                orders = new List <DSSaleOrder>();

                for (int i = 0; i < 5; i++)
                {
                    order = new DSSaleOrder();

                    order.FBillNo = i.ToString();
                    order.FDate   = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd hh:mm"));
                    order.F_HS_SaleOrderSource         = "DropShippingOrder";
                    order.F_HS_B2CCustId               = info.FCustId;
                    order.FSettleCurrId                = "USD";
                    order.F_HS_AmountDeclared          = 99.9M;
                    order.F_HS_FreightDeclared         = 88.8M;
                    order.F_HS_DeclaredCurrId          = "USD";
                    order.F_HS_DeclaredCurrId          = "USD";
                    order.F_HS_RecipientCountry        = "HR";
                    order.F_HS_DeliveryProvinces       = "Slavonija";
                    order.F_HS_DeliveryCity            = "Djakovo";
                    order.F_HS_DeliveryAddress         = "Marina Drzica 19";
                    order.F_HS_PostCode                = "31400";
                    order.F_HS_DeliveryName            = "Ljiljana Haas";
                    order.F_HS_MobilePhone             = "38763520647";
                    order.F_HS_DropShipDeliveryChannel = "SZ DHL(Solid), 2-8 business days";
                    order.F_HS_PlatformCustomerID      = "100";
                    order.F_HS_PlatformCustomerEmail   = "*****@*****.**";
                    entries = new List <DSSaleOrderEntry>();

                    for (int j = 0; j < 5; j++)
                    {
                        if (j == 0)
                        {
                            entry              = new DSSaleOrderEntry();
                            entry.FMaterialId  = "1000100084";
                            entry.FQTY         = 5M;
                            entry.F_HS_StockID = "301";
                            entry.F_HS_StockID = "DLC001";
                            entries.Add(entry);
                        }
                        if (j == 1)
                        {
                            entry              = new DSSaleOrderEntry();
                            entry.FMaterialId  = "1000100085";
                            entry.FQTY         = 5M;
                            entry.F_HS_StockID = "302";
                            entry.F_HS_StockID = "DLC003";
                            entries.Add(entry);
                        }

                        if (j == 2)
                        {
                            entry              = new DSSaleOrderEntry();
                            entry.FMaterialId  = "1000100086";
                            entry.FQTY         = 5M;
                            entry.F_HS_StockID = "303";
                            entry.F_HS_StockID = "DLC019";
                            entries.Add(entry);
                        }
                    }

                    order.OrderEntry = entries;
                    orders.Add(order);
                }

                info.SaleOrders = orders;
                break;

            case SynchroDataType.Inventroy:
            case SynchroDataType.ImportLogis:
                info.DataType = dataType.ToString();
                break;
            }

            string json = JsonConvert.SerializeObject(info);

            //string ret = cli.SynchroData(json);
            //result = JsonConvert.DeserializeObject<HttpResponseResult>(ret);

            result = RequestServices(json);

            if (result != null)
            {
                if (result.Success)
                {
                    this.View.ShowMessage(string.Format("同步{0}至{1}成功!", "DropShipping订单", "K3") + result.Message, Kingdee.BOS.Core.DynamicForm.MessageBoxType.Notice);
                }
                else
                {
                    this.View.ShowErrMessage("", string.Format("同步{0}至{1}失败!", "DropShipping订单", "K3") + result.Message, Kingdee.BOS.Core.DynamicForm.MessageBoxType.Error);
                }
            }
            else
            {
                this.View.ShowErrMessage("", string.Format("同步{0}至{1}失败!", "DropShipping订单", "K3"), Kingdee.BOS.Core.DynamicForm.MessageBoxType.Error);
            }

            return(result);
        }