예제 #1
0
        public void LoadData()
        {
            string k3ServerUrl = JsonUtils.ConvertObjectToString(this.View.Model.GetValue("F_HS_K3Server"));

            if (!string.IsNullOrWhiteSpace(k3ServerUrl) && k3ServerUrl.CompareTo("测试服务器") == 0)
            {
                k3ServerUrl = "http://10.2.0.150/k3cloud/";
            }
            else if (!string.IsNullOrWhiteSpace(k3ServerUrl) && k3ServerUrl.CompareTo("正式服务器") == 0)
            {
                k3ServerUrl = "http://10.2.0.150/k3cloud/";
            }

            string redisServerUrl = JsonUtils.ConvertObjectToString(this.View.Model.GetValue("F_HS_RedisServer"));

            if (!string.IsNullOrWhiteSpace(redisServerUrl) && redisServerUrl.CompareTo("测试服务器") == 0)
            {
                redisServerUrl = "10.2.0.150";
            }
            else if (!string.IsNullOrWhiteSpace(redisServerUrl) && redisServerUrl.CompareTo("正式服务器") == 0)
            {
                redisServerUrl = "221.120.177.22";
            }

            long   redsiDb = long.Parse(JsonUtils.ConvertObjectToString(this.View.Model.GetValue("F_HS_RedisDB")));
            string billNo  = JsonUtils.ConvertObjectToString(this.View.Model.GetValue("F_HS_BillNo"));
        }
예제 #2
0
        /// <summary>
        /// 根据字段名获取字段值
        /// </summary>
        /// <param name="fieldName"></param>
        /// <returns></returns>
        private string GetValue(string fieldName)
        {
            if (!string.IsNullOrWhiteSpace(fieldName))
            {
                return(JsonUtils.ConvertObjectToString(this.View.Model.GetValue(fieldName)));
            }

            return(null);
        }
예제 #3
0
 /// <summary>
 /// 获取发货通知单内码
 /// </summary>
 /// <param name="ctx"></param>
 /// <param name="FDelBillNo"></param>
 /// <returns></returns>
 private int GetFId(Context ctx, string FBillNo)
 {
     if (!string.IsNullOrWhiteSpace(FBillNo))
     {
         string sql = string.Format(@"/*dialect*/ select FID from {0} where FBillNo = '{1}'", HSTableConst.T_SAL_DELIVERYNOTICE, FBillNo);
         return(Convert.ToInt32(JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sql, "FID"))));
     }
     return(0);
 }
예제 #4
0
 /// <summary>
 /// 判断收款单是否已经关联了了销售订单
 /// </summary>
 /// <param name="saleOrderNo"></param>
 /// <returns></returns>
 private bool IsExistSaleOrderNo(string saleOrderNo)
 {
     if (!string.IsNullOrWhiteSpace(saleOrderNo))
     {
         string sql = string.Format(@"/*dialect*/ select FRECEIVEITEM from T_AR_RECEIVEBILLENTRY a 
                                                 inner join T_AR_RECEIVEBILL b on a.FID = b.FID
                                                 inner join T_SAL_ORDER c on c.FBILLNO = a.FRECEIVEITEM
                                                 where FRECEIVEITEM = '{0}'", saleOrderNo);
         return(string.IsNullOrWhiteSpace(JsonUtils.ConvertObjectToString(SQLUtils.GetObject(K3CloudContext, sql, "FRECEIVEITEM"))));
     }
     return(false);
 }
        /// <summary>
        /// 将需要同步的会员(用户)数据进行打包(单个客户)
        /// </summary>
        /// <param name="sourceData"></param>
        /// <param name="log"></param>
        /// <param name="operationType"></param>
        /// <returns></returns>
        public override JObject BuildSynchroDataJson(AbsSynchroDataInfo sourceData, SynchroLog log, SynOperationType operationType)
        {
            JObject root = new JObject();

            root.Add("NeedUpDateFields", new JArray(""));
            root.Add("IsDeleteEntry", "false");
            root.Add("SubSystemId", "");
            root.Add("IsVerifyBaseDataField", "true");

            if (operationType == SynOperationType.SAVE)
            {
                root.Add("Model", ConvertSynObjToJObj(sourceData, operationType));
                return(root);
            }
            //数据更新时的Json格式
            else
            {
                //更新单据时,表体信息必须填写明细表体的主键
                K3CustomerInfo custData = sourceData as K3CustomerInfo;
                string         sFCustId = string.Format(@"/*dialect*/ select FCUSTID from T_BD_CUSTOMER where FNumber = '{0}'", custData.FNumber);

                string sMainFCustId = string.Format(@"/*dialect*/ select FCUSTID from T_BD_CUSTOMER where FNumber = '{0}' and FUseOrgId != 1", custData.FNumber);
                int    subFCustId   = Convert.ToInt32(JsonUtils.ConvertObjectToString(SQLUtils.GetObject(this.K3CloudContext, sMainFCustId, "FCUSTID")));

                DynamicObjectCollection coll = SQLUtils.GetObjects(this.K3CloudContext, sFCustId);

                JArray model = new JArray();

                if (coll.Count > 0)
                {
                    foreach (var item in coll)
                    {
                        if (item["FCUSTID"] != null)
                        {
                            JObject baseData = ConvertSynObjToJObj(sourceData, operationType);
                            baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertObjectToString(item["FCUSTID"])));

                            if (subFCustId != Convert.ToInt32(JsonUtils.ConvertObjectToString(item["FCUSTID"])))
                            {
                                K3CustomerInfo soData = sourceData as K3CustomerInfo;
                                baseData = ConvertSynObjToJObj(soData, operationType);
                                baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertObjectToString(item["FCUSTID"])));
                            }
                            model.Add(baseData);
                        }
                    }
                }
                root.Add("Model", model);
                return(root);
            }
        }
예제 #6
0
        /// <summary>
        /// 解析json
        /// </summary>
        /// <param name="json"></param>
        /// <returns></returns>
        public static JArray GetResponseByJson(string json)
        {
            JArray jArr = null;

            if (!string.IsNullOrWhiteSpace(json))
            {
                JObject jObj = JObject.Parse(json);

                if (jObj.Property("Model") != null)
                {
                    jArr = JArray.Parse(JsonUtils.ConvertObjectToString(jObj["Model"]));
                }
            }
            return(jArr);
        }
예제 #7
0
        /// <summary>
        /// 根据调价单编码查询适用国家
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="billNo"></param>
        /// <returns></returns>
        private string GetApplicableState(Context ctx, string billNo)
        {
            string country = string.Empty;

            if (!string.IsNullOrEmpty(billNo))
            {
                string sql = string.Format(@"/*dialect*/ select d.FNUMBER from T_SAL_PRICELIST a
                                                          inner join T_SAL_BATCHADJUSTENTRY b on b.FPRICELISTID = a.FID
                                                          inner join T_SAL_BATCHADJUST c on c.FID = b.FID
                                                          inner join VW_BAS_ASSISTANTDATA_CountryName d on a.F_HS_APPLICABLESTATE = d.FCountry
                                                          where c.FBILLNO = '{0}'", billNo);
                country = JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sql, "FNUMBER"));
            }

            return(country);
        }
        public static List <K3CustomerInfo> BuildSynObjByCollection_(Context ctx, DynamicObjectCollection coll)
        {
            List <K3CustomerInfo> custs = null;
            K3CustomerInfo        cust  = null;

            if (coll != null)
            {
                if (coll.Count > 0)
                {
                    custs = new List <K3CustomerInfo>();
                    foreach (var item in coll)
                    {
                        cust = new K3CustomerInfo();

                        cust.FCreateOrgId = "100";
                        cust.FUseOrgId    = "100";

                        cust.FNumber    = JsonUtils.ConvertObjectToString(item["FNumber"]);
                        cust.FShortName = JsonUtils.ConvertObjectToString(item["FShortName"]);
                        cust.FName      = JsonUtils.ConvertObjectToString(item["FName"]);

                        if (string.IsNullOrWhiteSpace(cust.FName))
                        {
                            cust.FName = "None Name";
                        }

                        cust.FFCOUNTRY  = JsonUtils.ConvertObjectToString(item["FCOUNTRY"]).CompareTo("NULL") == 0 ? "US" : JsonUtils.ConvertObjectToString(item["FCOUNTRY"]);
                        cust.FAddress   = JsonUtils.ConvertObjectToString(item["FAddress"]);
                        cust.FZIP       = JsonUtils.ConvertObjectToString(item["FZIP"]);
                        cust.FTEL       = JsonUtils.ConvertObjectToString(item["FTEL"]);
                        cust.FSELLER    = JsonUtils.ConvertObjectToString(item["FSELLER"]);
                        cust.FSALDEPTID = JsonUtils.ConvertObjectToString(item["FSALDEPTID"]);

                        cust.FTaxType  = JsonUtils.ConvertObjectToString(item["FTaxType"]);
                        cust.FTaxRate  = JsonUtils.ConvertObjectToString(item["FTaxRate"]);
                        cust.FPriority = JsonUtils.ConvertObjectToString(item["FPriority"]);
                        cust.FIsTrade  = Convert.ToBoolean(Convert.ToInt32(JsonUtils.ConvertObjectToString(item["FIsTrade"])) == 1 ? true : false);

                        custs.Add(cust);
                    }
                }
            }
            return(custs);
        }
예제 #9
0
        /// <summary>
        /// 获取销售订单相关信息
        /// </summary>
        /// <param name="ctx"></param>
        /// <returns></returns>
        private AbsSynchroDataInfo GetK3Data(Context ctx)
        {
            AbsDataInfo order = new AbsDataInfo();

            order.F_HS_CheckBox = Convert.ToBoolean(this.View.Model.GetValue("F_HS_CheckBox"));

            DynamicObject source = this.View.Model.GetValue("F_HS_SaleOrderSource") as DynamicObject;
            string        sType  = SQLUtils.GetFieldValue(source, "FNumber");

            order.F_HS_SaleOrderSource = sType;
            this.SaleOrderSource       = sType;

            if (this.DataType.Equals(SynchroDataType.DropShippingSalOrder))
            {
                order.FDocumentStatus      = JsonUtils.ConvertObjectToString(this.View.Model.GetValue("FDocumentStatus"));
                order.F_HS_PaymentStatus   = JsonUtils.ConvertObjectToString(this.View.Model.GetValue("F_HS_PaymentStatus"));
                order.FCancelStatus        = JsonUtils.ConvertObjectToString(this.View.Model.GetValue("FCancelStatus"));
                order.F_HS_BalanceDeducted = Convert.ToBoolean(this.View.Model.GetValue("F_HS_BalanceDeducted"));

                DynamicObject cust   = this.View.Model.GetValue("F_HS_B2CCustId") as DynamicObject;
                string        custNo = SQLUtils.GetFieldValue(cust, "Number");

                decimal rateToUSA = Convert.ToDecimal(this.View.Model.GetValue("F_HS_RateToUSA"));
                order.FBillAmount = Convert.ToDecimal(this.View.Model.GetValue("FBillAmount")) / rateToUSA;

                decimal useUsdBalance = Math.Round(Convert.ToDecimal(this.View.Model.GetValue("F_HS_USDBalancePayments")), 2) / rateToUSA;
                order.F_HS_BalanceRechargeUSD = Math.Round(Convert.ToDecimal(this.View.Model.GetValue("F_HS_USDBalancePayments")), 2) / rateToUSA;
                decimal useCredit = Math.Round(Convert.ToDecimal(this.View.Model.GetValue("F_HS_USDBalancePayments")), 2) / rateToUSA;
                order.F_HS_CreditLineRechargeUSD = Math.Round(Convert.ToDecimal(this.View.Model.GetValue("F_HS_USDBalancePayments")), 2) / rateToUSA;

                decimal custBalance = Math.Round(LogHelper.GetCustBalance(ctx, custNo, "100.01"));
                decimal custCredit  = Math.Round(LogHelper.GetCustCreditLine(ctx, custNo, "F_HS_SurplusCreditUSD"));
                order.FCustBalanceAmount = custBalance + custCredit;
            }

            return(order);
        }
예제 #10
0
        private static List <DeliveryNotice> GetTrackingNumbers(Context ctx)
        {
            List <DeliveryNotice> noitces = null;
            DeliveryNotice        notice  = null;
            string sql = string.Format(@"/*dialect*/ select FBILLNO,F_HS_CARRYBILLNO from {0} where F_HS_DOCUMENTSTATUS = '{1}'", HSTableConst.HS_T_LogisticsInfo, LogisticsQuery.Query);
            DynamicObjectCollection coll = SQLUtils.GetObjects(ctx, sql);

            var group = from l in coll
                        group l by l["FBILLNO"]
                        into g
                        select g;

            if (group != null && group.Count() > 0)
            {
                noitces = new List <DeliveryNotice>();

                foreach (var g in group)
                {
                    notice = new DeliveryNotice();

                    if (g != null)
                    {
                        notice.FBillNo = JsonUtils.ConvertObjectToString(g.ElementAt(0)["FBILLNO"]);

                        foreach (var item in g)
                        {
                            DeliveryNoticeTraceEntry trace = new DeliveryNoticeTraceEntry();
                            trace.F_HS_CarryBillNO = JsonUtils.ConvertObjectToString(item["F_HS_CARRYBILLNO"]);
                            notice.TraceEntry.Add(trace);
                            noitces.Add(notice);
                        }
                    }
                }
            }

            return(noitces);
        }
예제 #11
0
        /// <summary>
        /// 根据返回结果获取不能保存成功的单据编号
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="json"></param>
        /// <param name="dataType"></param>
        /// <param name="index"></param>
        /// <returns></returns>
        public static string GetSynFailBillNo(Context ctx, string json, SynchroDataType dataType, int index)
        {
            JArray jArr   = GetResponseByJson(json);
            string number = null;

            if (jArr != null && jArr.Count() > 0)
            {
                if (dataType == SynchroDataType.Customer && index < jArr.Count())
                {
                    if (JObject.Parse(JsonUtils.ConvertObjectToString(jArr[index])).Property("FNumber") != null)
                    {
                        number = JsonUtils.ConvertObjectToString(jArr[index]["FNumber"]);
                    }
                    else if (JObject.Parse(JsonUtils.ConvertObjectToString(jArr[index])).Property("FCUSTID") != null)
                    {
                        int custId = Convert.ToInt32(JsonUtils.ConvertObjectToString(jArr[index]["FCUSTID"]));
                        number = SQLUtils.GetCustomerNo(ctx, custId);
                    }
                }
                else if (dataType == SynchroDataType.ReceiveBill && index < jArr.Count())
                {
                    if (JObject.Parse(JsonUtils.ConvertObjectToString(jArr[index])).Property("FRECEIVEBILLENTRY") != null)
                    {
                        number = JsonUtils.ConvertObjectToString(jArr[index]["FRECEIVEBILLENTRY"][0]["FRECEIVEITEM"]);
                    }
                }
                else
                {
                    if (JObject.Parse(JsonUtils.ConvertObjectToString(jArr[index])).Property("FBillNo") != null)
                    {
                        number = JsonUtils.ConvertObjectToString(jArr[index]["FBillNo"]);
                    }
                }
            }
            return(number);
        }
예제 #12
0
        /// <summary>
        /// 客户分配完后所做的操作,更新--提交--审核
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="sourceDatas"></param>
        /// <param name="operationType"></param>
        /// <returns></returns>
        public JObject BuildSyschroDataJsonForAfterAllot(Context ctx, List <AbsSynchroDataInfo> sourceDatas, SynOperationType operationType)
        {
            JObject root = null;

            if (operationType == SynOperationType.SAVE)
            {
                root = new JObject();
                root.Add("NeedUpDateFields", new JArray(""));
                root.Add("NeedReturnFields", new JArray("FNumber"));
                root.Add("IsDeleteEntry", "false");
                root.Add("SubSystemId", "");
                root.Add("IsVerifyBaseDataField", "true");


                root.Add("Model", ConvertSynObjToJObj(sourceDatas, operationType));
                return(root);
            }
            //数据更新时的Json格式
            else if (operationType == SynOperationType.UPDATE)
            {
                //更新单据时,表体信息必须填写明细表体的主键
                root = new JObject();

                root.Add("NeedUpDateFields", new JArray(""));
                root.Add("NeedReturnFields", new JArray("FNumber"));
                root.Add("IsDeleteEntry", "false");
                root.Add("SubSystemId", "");
                root.Add("IsVerifyBaseDataField", "true");

                if (sourceDatas != null)
                {
                    if (sourceDatas.Count > 0)
                    {
                        JArray model = new JArray();

                        for (int i = 0; i < sourceDatas.Count; i++)
                        {
                            K3CustomerInfo          custData = sourceDatas[i] as K3CustomerInfo;
                            string                  sFCustId = string.Format(@"/*dialect*/ select FCUSTID,FUseOrgId from T_BD_CUSTOMER where FNumber = '{0}' and FUseOrgId = {1}", custData.FNumber, ORGID);
                            DynamicObjectCollection coll     = SQLUtils.GetObjects(this.K3CloudContext, sFCustId);

                            if (coll.Count > 0)
                            {
                                foreach (var c in coll)
                                {
                                    if (c["FCUSTID"] != null)
                                    {
                                        JObject baseData = ConvertSynObjToJObj(sourceDatas[i], operationType);

                                        baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertObjectToString(c["FCUSTID"])));

                                        JObject FSELLER = new JObject();
                                        FSELLER.Add("FNumber", string.IsNullOrEmpty(custData.FSELLER) ? "NA" : custData.FSELLER);
                                        baseData.Add("FSELLER", FSELLER);

                                        JObject FSALDEPTID = new JObject();
                                        FSALDEPTID.Add("FNumber", string.IsNullOrEmpty(custData.FSALDEPTID) ? "BM000001" : custData.FSALDEPTID);
                                        baseData.Add("FSALDEPTID", FSALDEPTID);

                                        model.Add(baseData);
                                    }
                                }
                            }
                        }

                        root.Add("Model", model);
                        return(root);
                    }
                }
            }
            return(null);
        }
        /// <summary>
        /// 数据库查询的结果集封装成List<K3CustomerInfo>对象
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="coll"></param>
        /// <returns></returns>
        public static List <K3CustomerInfo> BuildSynObjByCollection(Context ctx, DynamicObjectCollection coll)
        {
            List <K3CustomerInfo> custs = null;
            K3CustomerInfo        cust  = null;

            if (coll != null)
            {
                if (coll.Count > 0)
                {
                    custs = new List <K3CustomerInfo>();
                    foreach (var item in coll)
                    {
                        cust = new K3CustomerInfo();

                        cust.FCreateOrgId = "100";
                        cust.FUseOrgId    = "100";

                        cust.FNumber    = JsonUtils.ConvertObjectToString(item["customers_id"]);
                        cust.FShortName = JsonUtils.ConvertObjectToString(item["customers_firstname"]);
                        cust.FName      = JsonUtils.ConvertObjectToString(item["customers_firstname"]) + " " +
                                          JsonUtils.ConvertObjectToString(item["customers_lastname"]);

                        if (string.IsNullOrWhiteSpace(cust.FName))
                        {
                            cust.FName = "None Name";
                        }

                        string sConutry = string.Format(@"/*dialect*/ select FNUMBER from VW_BAS_ASSISTANTDATA_CountryName
                                                                  where CountryName = '{0}'", JsonUtils.ConvertObjectToString(item["delivery_country"]));

                        cust.FFCOUNTRY = JsonUtils.ConvertObjectToString(item["delivery_country"]).CompareTo("NULL") == 0 ? "US" : JsonUtils.ConvertObjectToString(item["delivery_country"]);

                        string sProvincial = string.Format(@"/*dialect*/ select a.FNUMBER,b.FDATAVALUE from T_ECC_LOGISTICSAREADETAIL a
                                                                     inner join T_ECC_LOGISTICSAREADETAIL_L b
                                                                     on a.FDETAILID = b.FDETAILID
                                                                     where b.FDATAVALUE like N'%{0}%'", JsonUtils.ConvertObjectToString(item["entry_state"]));

                        cust.FAddress = JsonUtils.ConvertObjectToString(item["entry_street_address"]) + " " +
                                        JsonUtils.ConvertObjectToString(item["entry_city"]) + " " +
                                        JsonUtils.ConvertObjectToString(item["entry_state"]) + " " +
                                        JsonUtils.ConvertObjectToString(item["delivery_country"]);
                        cust.FZIP = JsonUtils.ConvertObjectToString(item["entry_postcode"]);

                        cust.FTEL = JsonUtils.ConvertObjectToString(item["customers_telephone"]);

                        string custLevel = JsonUtils.ConvertObjectToString(item["customers_whole"]);

                        cust.FGroup      = ServiceHelper.SetCustomerLevel(custLevel);
                        cust.FCustTypeId = ServiceHelper.SetCustomerLevel(custLevel);

                        cust.FTRADINGCURRID = "USD";


                        string sellerNo = JsonUtils.ConvertObjectToString(item["account_manager_id"]);
                        sellerNo     = sellerNo.CompareTo("null") == 0 ? "" : sellerNo;
                        cust.FSELLER = sellerNo;

                        string sDeptNo = string.Format(@"/*dialect*/   select b.FNUMBER from T_BD_STAFFTEMP	a 
                                            inner join T_BD_DEPARTMENT b on a.FDEPTID=b.FDEPTID
                                            inner join T_BD_STAFF c on a.FSTAFFID=c.FSTAFFID
                                            where c.FNUMBER='{0}'", cust.FSELLER);

                        cust.FSALDEPTID = JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sDeptNo, "FNUMBER"));


                        cust.FTaxType = "SFL02_SYS";
                        cust.FTaxRate = "SL04_SYS";


                        cust.FPriority = "1";
                        cust.FIsTrade  = true;

                        custs.Add(cust);
                    }
                }
            }
            return(custs);
        }
        /// <summary>
        /// 将需要同步的客户转化为JSON格式(客户集合)
        /// </summary>
        /// <param name="sourceDatas"></param>
        /// <param name="operationType"></param>
        /// <returns></returns>
        public override JObject BuildSynchroDataJsons(IEnumerable <AbsSynchroDataInfo> sourceDatas, SynOperationType operationType)
        {
            JObject root       = null;
            int     batchCount = BatchCount(sourceDatas);

            if (operationType == SynOperationType.SAVE)
            {
                root = new JObject();
                root.Add("NeedUpDateFields", new JArray(""));
                root.Add("NeedReturnFields", new JArray("FNumber"));
                root.Add("IsDeleteEntry", "false");
                root.Add("SubSystemId", "");
                root.Add("IsVerifyBaseDataField", "true");
                //root.Add("BatchCount", batchCount);

                root.Add("Model", ConvertSynObjToJObj(sourceDatas, operationType));
                return(root);
            }
            //数据更新时的Json格式
            else if (operationType == SynOperationType.UPDATE)
            {
                //更新单据时,表体信息必须填写明细表体的主键
                root = new JObject();

                root.Add("NeedUpDateFields", new JArray(""));
                root.Add("NeedReturnFields", new JArray("FNumber"));
                root.Add("IsDeleteEntry", "false");
                root.Add("SubSystemId", "");
                root.Add("IsVerifyBaseDataField", "true");
                root.Add("BatchCount", batchCount);

                if (sourceDatas != null)
                {
                    if (sourceDatas.Count() > 0)
                    {
                        JArray model = new JArray();

                        for (int i = 0; i < sourceDatas.Count(); i++)
                        {
                            K3CustomerInfo          custData = sourceDatas.ElementAt(i) as K3CustomerInfo;
                            string                  sFCustId = string.Format(@"/*dialect*/ select FCUSTID,FUseOrgId from T_BD_CUSTOMER where FNumber = '{0}'", custData.FNumber);
                            DynamicObjectCollection coll     = SQLUtils.GetObjects(this.K3CloudContext, sFCustId);

                            if (coll.Count > 0)
                            {
                                foreach (var c in coll)
                                {
                                    if (c["FCUSTID"] != null)
                                    {
                                        JObject baseData = ConvertSynObjToJObj(sourceDatas.ElementAt(i), operationType);
                                        //主组织记录
                                        if (Convert.ToInt32(JsonUtils.ConvertObjectToString(c["FUseOrgId"])) == 1)
                                        {
                                            //主组织记录中的销售员和销售部门不能被更新
                                            baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertObjectToString(c["FCUSTID"])));
                                            //baseData.Add("FT_BD_CUSTCONTACT", BuildK3CustContactJsons(custData));//客户地址信息
                                        }
                                        //else
                                        //{
                                        //    baseData.Add("FCUSTID", Convert.ToInt32(JsonUtils.ConvertJObjectToString(c["FCUSTID"])));
                                        //    JObject FSELLER = new JObject();
                                        //    FSELLER.Add("FNumber", custData.FSELLER);
                                        //    baseData.Add("FSELLER", FSELLER);

                                        //    JObject FSALDEPTID = new JObject();
                                        //    FSALDEPTID.Add("FNumber", custData.FSALDEPTID);
                                        //    baseData.Add("FSALDEPTID", FSALDEPTID);
                                        //}
                                        model.Add(baseData);
                                    }
                                }
                            }
                        }

                        root.Add("Model", model);
                        return(root);
                    }
                }
            }
            return(null);
        }
예제 #15
0
        private int GetPrimaryKey(Context ctx, string tableName, string fieldName)
        {
            string sql = string.Format(@"/*dialect*/ select MAX(" + fieldName + ") " + fieldName + " from {0} ", tableName);

            return(Convert.ToInt32(JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sql, fieldName))) + 1);
        }
예제 #16
0
        /// <summary>
        /// 数据库查询的结果集封装成List<K3CustomerInfo>对象
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="coll"></param>
        /// <returns></returns>
        public List <K3CustomerInfo> BuildSynObjByCollection(Context ctx, DynamicObjectCollection coll)
        {
            List <K3CustomerInfo> custs = null;
            K3CustomerInfo        cust  = null;

            if (coll != null)
            {
                if (coll.Count > 0)
                {
                    custs = new List <K3CustomerInfo>();
                    foreach (var item in coll)
                    {
                        cust = new K3CustomerInfo();

                        cust.FCreateOrgId = "100";
                        cust.FUseOrgId    = "100";

                        cust.FNumber    = SQLUtils.GetFieldValue(item, "FNumber");
                        cust.FShortName = SQLUtils.GetFieldValue(item, "FShortName");
                        cust.FName      = SQLUtils.GetFieldValue(item, "FName");

                        if (string.IsNullOrWhiteSpace(cust.FName))
                        {
                            cust.FName = "None Name";
                        }

                        string sConutry = string.Format(@"/*dialect*/ select FNUMBER from VW_BAS_ASSISTANTDATA_CountryName
                                                                  where FCountry = '{0}'", SQLUtils.GetFieldValue(item, "FCOUNTRY"));

                        cust.FFCOUNTRY = JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sConutry, "FNUMBER"));
                        cust.FAddress  = SQLUtils.GetFieldValue(item, "FAddress");

                        cust.FZIP = SQLUtils.GetFieldValue(item, "FZIP");
                        cust.FTEL = SQLUtils.GetFieldValue(item, "FTEL");
                        cust.F_HS_CustomerRegisteredMail = SQLUtils.GetFieldValue(item, "F_HS_CustomerRegisteredMail");
                        cust.FCustTypeId    = SQLUtils.GetCustTypeNo(ctx, item, "FCustTypeId");
                        cust.FTRADINGCURRID = SQLUtils.GetSettleCurrNo(ctx, item, "FTRADINGCURRID");

                        cust.FSELLER = string.IsNullOrWhiteSpace(SQLUtils.GetSellerNo(ctx, item, "FSELLER")) ? "NA" : SQLUtils.GetSellerNo(ctx, item, "FSELLER");

                        string sDeptNo = string.Format(@"/*dialect*/   select b.FNUMBER from T_BD_STAFFTEMP	a 
                                            inner join T_BD_DEPARTMENT b on a.FDEPTID=b.FDEPTID
                                            inner join T_BD_STAFF c on a.FSTAFFID=c.FSTAFFID
                                            where c.FNUMBER='{0}'", cust.FSELLER);

                        cust.FSALDEPTID                = JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sDeptNo, "FNUMBER"));
                        cust.F_HS_Grade                = SQLUtils.GetFieldValue(item, "F_HS_Grade");
                        cust.F_HS_SpecialDemand        = SQLUtils.GetFieldValue(item, "F_HS_SpecialDemand");
                        cust.F_HS_TaxNum               = SQLUtils.GetFieldValue(item, "F_HS_TaxNum");
                        cust.FPRICELISTID              = SQLUtils.GetFieldValue(item, "FPRICELISTID");
                        cust.F_HS_CustomerPurchaseMail = SQLUtils.GetFieldValue(item, "F_HS_CustomerPurchaseMail");

                        cust.FSETTLETYPEID = "JSFS01_SYS";
                        cust.FTaxType      = "SZ01_SYS";
                        cust.FTaxRate      = "SL04_SYS";

                        cust.FPriority      = "1";
                        cust.FRECEIVECURRID = "PRE001";

                        cust.FISCREDITCHECK = false;
                        cust.FIsTrade       = true;

                        custs.Add(cust);
                    }
                }
            }
            return(custs);
        }
예제 #17
0
        /// <summary>
        /// 获取发货通知单
        /// </summary>
        /// <returns></returns>
        private List <DeliveryNotice> GetDeliveryNotices(Context ctx)
        {
            DeliveryNotice        notice  = new DeliveryNotice();
            List <DeliveryNotice> notices = new List <DeliveryNotice>();

            List <string>           numbers = GetSelectedShipmentNos();
            DynamicObjectCollection coll    = GetObjects(ctx, numbers);

            var group = from c in coll
                        where c["FDelBillNo"] != null
                        group c by c["FDelBillNo"]
                        into g
                        select g;

            if (group != null && group.Count() > 0)
            {
                notices = new List <DeliveryNotice>();

                foreach (var item in group)
                {
                    if (item != null)
                    {
                        notice = new DeliveryNotice();

                        foreach (var obj in item)
                        {
                            if (obj != null)
                            {
                                notice.FShipmentBillNo.Add(SQLUtils.GetFieldValue(obj, "FShpBillNo"));
                            }
                        }

                        notice.FBillNo = SQLUtils.GetFieldValue(item.ElementAt(0), "FDelBillNo");

                        notice.F_HS_DeliveryName = SQLUtils.GetFieldValue(item.ElementAt(0), "F_HS_DeliveryName");
                        notice.F_HS_MobilePhone  = SQLUtils.GetFieldValue(item.ElementAt(0), "F_HS_MobilePhone");

                        notice.F_HS_DeliveryCity      = SQLUtils.GetFieldValue(item.ElementAt(0), "F_HS_DeliveryCity");
                        notice.F_HS_DeliveryProvinces = SQLUtils.GetFieldValue(item.ElementAt(0), "F_HS_DeliveryProvinces");

                        notice.F_HS_DeliveryAddress  = SQLUtils.GetFieldValue(item.ElementAt(0), "F_HS_DeliveryAddress");
                        notice.F_HS_RecipientCountry = SQLUtils.GetFieldValue(item.ElementAt(0), "F_HS_RecipientCountry");

                        notice.F_HS_PostCode = SQLUtils.GetFieldValue(item.ElementAt(0), "F_HS_PostCode");

                        notice.orderFin = new K3SaleOrderFinance();
                        notice.orderFin.FSettleCurrID = SQLUtils.GetFieldValue(item.ElementAt(0), "FSettleCurrID");
                        notice.orderFin.FBillAmount   = Convert.ToDecimal(JsonUtils.ConvertObjectToString(SQLUtils.GetFieldValue(item.ElementAt(0), "FBillAmount")));
                        notice.F_HS_ShippingMethod    = SQLUtils.GetFieldValue(item.ElementAt(0), "logisticsNo");
                        notice.F_HS_AllTotalWeight    = Convert.ToDecimal(SQLUtils.GetFieldValue(item.ElementAt(0), "F_HS_AllTotalWeight"));
                        notice.FDecAmount             = Convert.ToDecimal(SQLUtils.GetFieldValue(item.ElementAt(0), "FDecAmount"));

                        List <DynamicObject> entry = item.ToList();
                        SetDeliveryNoticeEntry(ctx, entry, notice);

                        Dimension dim = new Dimension();
                        dim.Length = SQLUtils.GetFieldValue(item.ElementAt(0), "FLENGTH");
                        dim.Width  = SQLUtils.GetFieldValue(item.ElementAt(0), "FWIDTH");
                        dim.Height = SQLUtils.GetFieldValue(item.ElementAt(0), "FHIGH");
                        dim.Units  = "CM";

                        Package pac = new Package();
                        pac.Weight    = Convert.ToDecimal(SQLUtils.GetFieldValue(item.ElementAt(0), "FBILLINGWEIGHT")) / 100;
                        pac.Units     = "KG";
                        pac.Dimension = dim;

                        notice.Packages.Add(pac);
                        notices.Add(notice);
                    }
                }
            }

            return(notices);
        }
예제 #18
0
        /// <summary>
        /// 提交请求后,服务端响应客户端信息
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="dataType"></param>
        /// <param name="operationType"></param>
        /// <param name="ret"></param>
        /// <returns></returns>
        public static HttpResponseResult Response(Context ctx, SynchroDataType dataType, SynOperationType operationType, string ret, string json = null)
        {
            HttpResponseResult          response = default(HttpResponseResult);
            Dictionary <string, string> dict     = new Dictionary <string, string>();

            string msg  = string.Empty;
            string last = string.Empty;

            if (!string.IsNullOrEmpty(ret))
            {
                response = new HttpResponseResult(dataType);

                JObject result = JObject.Parse(ret);

                if (result.Property("Result") != null)
                {
                    if (JObject.Parse(JsonUtils.ConvertObjectToString(result["Result"])).Property("ResponseStatus") != null)
                    {
                        response.Success = Convert.ToBoolean(JsonUtils.ConvertObjectToString(result["Result"]["ResponseStatus"]["IsSuccess"]));
                    }
                }

                if (response.Success == false)
                {
                    if (result.Property("Result") != null)
                    {
                        if (JObject.Parse(JsonUtils.ConvertObjectToString(result["Result"])).Property("ResponseStatus") != null)
                        {
                            JArray jArr = JArray.Parse(JsonUtils.ConvertObjectToString(result["Result"]["ResponseStatus"]["Errors"]));

                            if (jArr != null && jArr.Count() > 0)
                            {
                                string number = null;

                                for (int i = 0; i < jArr.Count(); i++)
                                {
                                    if (jArr[i]["DIndex"] != null)
                                    {
                                        int index = Convert.ToInt32(JsonUtils.ConvertObjectToString(jArr[i]["DIndex"]));
                                        number = GetSynFailBillNo(ctx, json, dataType, index);


                                        if (index > 0)
                                        {
                                            last = GetSynFailBillNo(ctx, json, dataType, index - 1);
                                        }
                                    }
                                    if (jArr[i]["FieldName"] != null)
                                    {
                                        if (!string.IsNullOrWhiteSpace(number))
                                        {
                                            if (i < jArr.Count() - 1)
                                            {
                                                response.Message += "编码为[" + number + "]:" + JsonUtils.ConvertObjectToString(jArr[i]["FieldName"]) + System.Environment.NewLine;
                                            }
                                            else if (i == jArr.Count() - 1)
                                            {
                                                response.Message += "编码为[" + number + "]:" + JsonUtils.ConvertObjectToString(jArr[i]["FieldName"]);
                                            }
                                        }
                                        else
                                        {
                                            if (i < jArr.Count() - 1)
                                            {
                                                response.Message += JsonUtils.ConvertObjectToString(jArr[i]["FieldName"]) + System.Environment.NewLine;
                                            }
                                            else if (i == jArr.Count() - 1)
                                            {
                                                response.Message += JsonUtils.ConvertObjectToString(jArr[i]["FieldName"]);
                                            }
                                        }
                                    }
                                    if (jArr[i]["Message"] != null)
                                    {
                                        if (!string.IsNullOrWhiteSpace(number))
                                        {
                                            if (i < jArr.Count() - 1)
                                            {
                                                response.Message += "编码为[" + number + "]:" + JsonUtils.ConvertObjectToString(jArr[i]["Message"]) + System.Environment.NewLine;
                                            }
                                            else if (i == jArr.Count() - 1)
                                            {
                                                response.Message += "编码为[" + number + "]:" + JsonUtils.ConvertObjectToString(jArr[i]["Message"]);
                                            }
                                        }
                                        else
                                        {
                                            if (i < jArr.Count() - 1)
                                            {
                                                response.Message += JsonUtils.ConvertObjectToString(jArr[i]["Message"]) + System.Environment.NewLine;
                                            }
                                            else if (i == jArr.Count() - 1)
                                            {
                                                response.Message += JsonUtils.ConvertObjectToString(jArr[i]["Message"]);
                                            }
                                        }
                                    }
                                }

                                if (!string.IsNullOrWhiteSpace(response.Message))
                                {
                                    LogUtils.WriteSynchroLog(ctx, dataType, operationType + "操作, Response返回的Json信息异常,异常信息:" + System.Environment.NewLine + response.Message);
                                }
                            }

                            response.ExceptionCode = JsonUtils.ConvertObjectToString(result["Result"]["ResponseStatus"]["ErrorCode"]);
                        }
                    }
                }

                if (result.Property("Result") != null)
                {
                    if (JObject.Parse(JsonUtils.ConvertObjectToString(result["Result"])).Property("Number") != null)
                    {
                        response.Source = JsonUtils.ConvertObjectToString(result["Result"]["Number"]);
                    }

                    if (JObject.Parse(JsonUtils.ConvertObjectToString(result["Result"])).Property("NeedReturnData") != null)
                    {
                        response.NeedReturnDatas = JArray.Parse(JsonUtils.ConvertObjectToString(result["Result"]["NeedReturnData"]));
                        response.ResultJson      = JsonUtils.ConvertObjectToString(result["Result"]["NeedReturnData"]);
                    }

                    if (JObject.Parse(JsonUtils.ConvertObjectToString(result["Result"])).Property("ResponseStatus") != null)
                    {
                        response.SuccessEntitys = JArray.Parse(JsonUtils.ConvertObjectToString(result["Result"]["ResponseStatus"]["SuccessEntitys"]));
                    }
                }
            }

            if (response != null)
            {
                if (response.Success == false || ret.StartsWith("Code"))
                {
                    LogUtils.WriteSynchroLog(ctx, dataType, "" + operationType + "操作, Response返回的Json信息异常,异常信息:" + ret);
                }
            }

            return(response);
        }
예제 #19
0
        public HttpResponseResult AfterAllot(Context ctx, List <K3CustomerInfo> custs)
        {
            HttpResponseResult result  = null;
            List <int>         pkIds   = new List <int>();
            List <string>      numbers = new List <string>();

            if (custs != null && custs.Count > 0)
            {
                numbers = new List <string>();

                foreach (var cust in custs)
                {
                    numbers.Add(cust.FNumber);
                    pkIds.Add(cust.FCUSTID);
                }
            }

            #region

            if (custs != null)
            {
                string FNumber = "";

                //分配成功后单据编码集合,做为查询从组织的内码的条件
                if (numbers != null && numbers.Count > 0)
                {
                    for (int i = 0; i < numbers.Count; i++)
                    {
                        if (i < numbers.Count - 1)
                        {
                            FNumber += "\'" + numbers[i] + "\',";
                        }
                        else if (i == numbers.Count - 1)
                        {
                            FNumber += "\'" + numbers[i] + "\'";
                        }
                    }
                }

                //根据单据编码集合查询出从组织的内码集合
                string sFCustId = string.Format(@"/*dialect*/ select FCUSTID,FNUMBER from T_BD_CUSTOMER where FNumber in ({0}) and FUSEORGID = {1}", FNumber, ORGID);
                DynamicObjectCollection   items = SQLUtils.GetObjects(ctx, sFCustId);
                List <AbsSynchroDataInfo> datas = new List <AbsSynchroDataInfo>();

                if (items != null && items.Count > 0)
                {
                    if (pkIds != null && pkIds.Count > 0)
                    {
                        pkIds.Clear();
                        foreach (var item in items)
                        {
                            pkIds.Add(Convert.ToInt32(JsonUtils.ConvertObjectToString(item["FCUSTID"])));
                        }
                    }


                    for (int i = 0; i < items.Count; i++)
                    {
                        if (JsonUtils.ConvertObjectToString(items[i]["FNUMBER"]).CompareTo(custs[i].FNumber) == 0)
                        {
                            custs[i].FCUSTID = Convert.ToInt32(JsonUtils.ConvertObjectToString(items[i]["FCUSTID"]));
                            AbsSynchroDataInfo data = custs[i] as AbsSynchroDataInfo;
                            datas.Add(data);
                        }
                    }

                    string json = BuildSyschroDataJsonForAfterAllot(ctx, datas, SynOperationType.UPDATE).ToString();
                    //更新单据
                    //result = InvokeWebApi.InvokeBatchSave(ctx, this.DataType, this.FormKey, json);

                    //numbers.Clear();
                    //if (result.Success == true)
                    //{
                    //    //单据提交
                    //    result = InvokeWebApi.InvokeBatchSubmit(ctx, this.DataType, FormKey, numbers, pkIds);

                    //    if (result != null && result.Success == true)
                    //    {
                    //        //单据审核
                    //        result = InvokeWebApi.InvokeBatchAudit(ctx, this.DataType, FormKey, numbers, pkIds);
                    //        pkIds.Clear();
                    //    }
                    //}
                }
            }

            #endregion
            return(result);
        }
예제 #20
0
        private int GetFEntryId(Context ctx, int FId)
        {
            string sql = string.Format(@"/*dialect*/ select FEntryID from {0} where FID = {1}", HSTableConst.HS_T_LogisTrack, FId);

            return(Convert.ToInt32(JsonUtils.ConvertObjectToString(SQLUtils.GetObject(ctx, sql, "FEntryID"))));
        }
예제 #21
0
        /// <summary>
        /// 筛选需要保存或更新的客户资料
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="srcDatas"></param>
        /// <returns></returns>
        public override Dictionary <SynOperationType, IEnumerable <AbsSynchroDataInfo> > EntityDataSource(Context ctx, IEnumerable <AbsSynchroDataInfo> srcDatas)
        {
            Dictionary <SynOperationType, IEnumerable <AbsSynchroDataInfo> > dict = new Dictionary <SynOperationType, IEnumerable <AbsSynchroDataInfo> >();


            List <AbsSynchroDataInfo> lstDiff = null;

            List <string> K3CustNos  = null;
            List <string> synCustNos = null;
            List <string> existNos   = null;

            #region

            string sql = string.Format(@"/*dialect*/ select distinct FNUMBER from T_BD_CUSTOMER");
            DynamicObjectCollection coll = SQLUtils.GetObjects(ctx, sql);

            if (coll != null && coll.Count > 0)
            {
                K3CustNos = new List <string>();
                foreach (var item in coll)
                {
                    K3CustNos.Add(JsonUtils.ConvertObjectToString(item["FNUMBER"]));
                }
                coll = null;
            }

            List <K3CustomerInfo> custs = ConvertAbsSynchroObject(srcDatas);

            if (custs != null && custs.Count > 0)
            {
                synCustNos = new List <string>();

                foreach (var cust in custs)
                {
                    synCustNos.Add(cust.FNumber);
                }
            }

            if (K3CustNos != null && K3CustNos.Count > 0)
            {
                existNos = K3CustNos.Intersect(synCustNos).ToList();
            }
            else
            {
                dict.Add(SynOperationType.SAVE, srcDatas);
                return(dict);
            }
            if (existNos != null)
            {
                var same = from c in custs
                           where existNos.Contains(c.FNumber)
                           select c;

                var diff = from c in custs
                           where existNos.Contains(c.FNumber) == false
                           select c;
                //if (same != null && same.Count() > 0)
                //{
                //    lstSame = same.ToList<AbsSynchroDataInfo>();
                //    if (lstSame != null && lstSame.Count > 0)
                //    {
                //        dict.Add(SynOperationType.UPDATE, lstSame);
                //    }
                //}

                if (diff != null && diff.Count() > 0)
                {
                    lstDiff = diff.ToList <AbsSynchroDataInfo>();

                    if (lstDiff != null && lstDiff.Count > 0)
                    {
                        dict.Add(SynOperationType.SAVE, lstDiff);
                    }
                }
            }
            return(dict);

            #endregion
        }