public List <string> DownloadOutToDB(string StrserviceUrl, string Strdbhost, string Strappkey, string Strappscret, string Strtoken)
        {
            List <string> returnList = new List <string>();

            for (int i = -100; i < 0; i++)
            {
                bool   isSuccess = false;
                string strJson   = string.Empty;
                while (isSuccess != true)
                {
                    EdbLib edb = new EdbLib(StrserviceUrl, Strdbhost, Strappkey, Strappscret, Strtoken);
                    Dictionary <String, String> @params = edb.edbGetCommonParams("edbInStoreGet");
                    @params["type"]       = "1";
                    @params["date_type"]  = "制单日期create_time";
                    @params["begin_time"] = DateTime.Now.AddDays(i).ToShortDateString();
                    @params["end_time"]   = DateTime.Now.AddDays(i + 1).ToShortDateString();
                    @params["page_no"]    = "1";
                    @params["page_size"]  = "1000";

                    strJson = edb.edbRequstPost(@params, out isSuccess);
                    edb     = null;
                }

                if (strJson != string.Empty)
                {
                    returnList = JsonToStockObject(strJson, returnList);
                }
            }
            return(returnList);
        }
        private List <Item> LoadInfo(string date_type, string begin_time, string end_time, string order_status, string StrserviceUrl, string Strdbhost, string Strappkey, string Strappscret, string Strtoken)
        {
            List <Item> lItems    = new List <Item>();
            bool        isSuccess = false;
            string      strJson   = string.Empty;

            while (isSuccess != true)
            {
                EdbLib edb = new EdbLib(StrserviceUrl, Strdbhost, Strappkey, Strappscret, Strtoken);
                Dictionary <String, String> @params = edb.edbGetCommonParams("edbTradeGet");
                if (date_type != "")
                {
                    @params["date_type"] = date_type;
                }
                @params["begin_time"]   = begin_time;
                @params["end_time"]     = end_time;
                @params["order_status"] = order_status;
                @params["page_no"]      = "1";
                @params["page_size"]    = page_size;
                strJson = edb.edbRequstPost(@params, out isSuccess);
                edb     = null;
            }

            if (strJson != string.Empty)
            {
                JObject jo  = (JObject)JsonConvert.DeserializeObject(strJson);
                JArray  arr = (JArray)jo["Success"]["items"]["item"];
                foreach (JObject j in arr)
                {
                    lItems.Add(GetItem(j));
                }
            }

            return(lItems);
        }
        /// <summary>
        /// 下载当天退货单信息
        /// </summary>
        public void DownloadReturnToDB(string StrserviceUrl, string Strdbhost, string Strappkey, string Strappscret, string Strtoken)
        {
            ConfigHelper config = new ConfigHelper();
            string       strdt1 = config.ReadValueByKey(ConfigurationFile.AppConfig, "退货到货日期");

            if (strdt1 != null)
            {
                DateTime dt1 = Convert.ToDateTime(strdt1);
                if (dt1 < DateTime.Now)
                {
                    for (int i = 1; i <= 24; i++)
                    {
                        DateTime dt2 = dt1.AddHours(1);
                        if (dt2 > DateTime.Now)
                        {
                            break;
                        }
                        bool   isSuccess = false;
                        string strJson   = string.Empty;
                        while (isSuccess != true)
                        {
                            EdbLib edb = new EdbLib(StrserviceUrl, Strdbhost, Strappkey, Strappscret, Strtoken);
                            Dictionary <String, String> @params = edb.edbGetCommonParams("edbTradReturnGet");
                            @params["date_type"]  = "退货到货日期";
                            @params["start_time"] = dt1.ToString();
                            @params["end_time"]   = dt2.ToString();
                            @params["page_no"]    = "1";
                            @params["page_size"]  = "1000";

                            strJson = edb.edbRequstPost(@params, out isSuccess);
                            edb     = null;
                        }

                        if (strJson != string.Empty)
                        {
                            List <Edb_RETURNSTOCK> lco = JsonToObject(strJson);
                            ObjectToData(lco);
                        }
                        dt1 = dt2;
                    }
                    if (dt1 > DateTime.Now)
                    {
                        dt1 = DateTime.Now;
                    }
                    config.UpdateOrCreateAppSetting(ConfigurationFile.AppConfig, "退货到货日期", dt1.ToString());
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// 导入分布式调拨出库单到E店宝出库单
        /// </summary>
        /// <returns></returns>
        public string AddStockOut(string StrserviceUrl, string Strdbhost, string Strappkey, string Strappscret, string Strtoken)
        {
            string strJson = string.Empty;

            if (isExists() == true)
            {
                bool isSuccess = false;

                while (isSuccess != true)
                {
                    EdbLib edb = new EdbLib(StrserviceUrl, Strdbhost, Strappkey, Strappscret, Strtoken);
                    Dictionary <String, String> @params = edb.edbGetCommonParams("edbOutStoreAdd");
                    StringBuilder builder = new StringBuilder();
                    builder.Append("<info>");
                    List <string> BillNos = new List <string>();
                    builder = GetCentaur_OutStorageList(builder, out BillNos);
                    builder.Append("<product_info>");
                    foreach (string BillNo in BillNos)
                    {
                        builder = GetOutStorage_ItemList(builder, BillNo);
                    }
                    builder.Append("</product_info>");
                    builder.Append("</info>");
                    @params["xmlValues"] = builder.ToString();

                    strJson = edb.edbRequstPost(@params, out isSuccess);
                    edb     = null;
                }

                if (strJson != string.Empty)
                {
                    UpdateSTKTRANSFEROUT(strJson);
                }
            }
            LogHelper.WriteLog(strcon, "Edb_STKTRANSFEROUT_DAL", "ResultJsonData", "", strJson);
            return(strJson);
        }
        private void LoadInfo(string date_type, string begin_time, string end_time, string order_status, string StrserviceUrl, string Strdbhost, string Strappkey, string Strappscret, string Strtoken)
        {
            bool   isSuccess = false;
            string strJson   = string.Empty;

            while (isSuccess != true)
            {
                EdbLib edb = new EdbLib(StrserviceUrl, Strdbhost, Strappkey, Strappscret, Strtoken);
                Dictionary <String, String> @params = edb.edbGetCommonParams("edbTradeGet");
                if (date_type != "")
                {
                    @params["date_type"] = date_type;
                }
                @params["begin_time"]   = begin_time;
                @params["end_time"]     = end_time;
                @params["order_status"] = order_status;
                @params["page_no"]      = "1";
                @params["page_size"]    = page_size;
                LogHelper.WriteFileLog(typeof(Edb_OUTSTOCK_DAL), begin_time + "|" + end_time);
                strJson = edb.edbRequstPost(@params, out isSuccess);
                edb     = null;
            }

            if (strJson != string.Empty)
            {
                try
                {
                    JObject jo            = (JObject)JsonConvert.DeserializeObject(strJson);
                    JArray  arr           = (JArray)jo["Success"]["items"]["item"];
                    int     total_results = int.Parse(jo["Success"]["total_results"].ToString());
                    if (total_results > 0)
                    {
                        DateTime dt   = DateTime.Parse(begin_time);
                        JArray   narr = arr;
                        JArray   j    = null;
                        for (int x = arr.Count - 1; x >= 0; x--)
                        {
                            JObject obj = (JObject)arr[x];
                            if (total_results == int.Parse(page_size))
                            {
                                string delivery_time = obj["delivery_time"].ToString();
                                if (dt < DateTime.Parse(delivery_time))
                                {
                                    dt = DateTime.Parse(delivery_time);
                                }
                            }
                            if (IsExists(obj["tid"].ToString()) == false)
                            {
                                if (j != null)
                                {
                                    //j.Merge((JArray)obj["tid_item"]);
                                    foreach (JObject job in (JArray)obj["tid_item"])
                                    {
                                        j.Add(job);
                                    }
                                }
                                else
                                {
                                    j = (JArray)obj["tid_item"];
                                }
                                obj.Remove("tid_item");
                            }
                            else
                            {
                                arr.Remove(obj);
                            }
                        }
                        if (arr != null && j != null)
                        {
                            DataTable d1 = GetDataTable(JsonToDataTable(arr.ToString()), dtTrade);
                            SqlBulkCopyInsert("tb_Trade", d1);
                            DataTable d2 = GetDataTable(JsonToDataTable(j.ToString()), dtTradeEntry);
                            SqlBulkCopyInsert("tb_TradeEntry", d2);
                        }
                        StringToDB(begin_time, end_time, true);
                        if (total_results == int.Parse(page_size) && dt < DateTime.Parse(end_time) && dt > DateTime.Parse(begin_time))
                        {
                            LoadInfo(date_type, dt.ToString("yyyy-MM-dd HH:mm:ss"), end_time, order_status, StrserviceUrl, Strdbhost, Strappkey, Strappscret, Strtoken);
                        }
                    }
                    else
                    {
                        StringToDB(begin_time, end_time, true);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteFileLog(typeof(Edb_OUTSTOCK_DAL), ex);
                    LogHelper.WriteFileLog(typeof(Edb_OUTSTOCK_DAL), strJson);
                }
            }
            else
            {
                StringToDB(begin_time, end_time, false);
            }
        }