public async void PostToIon()
        {
            IonReponse     result         = new IonReponse();
            JArray         items          = new JArray();
            PackController packController = new PackController();
            string         url            = Constant.ION_SKU_ENTERPRISE_URL_SOUTH;

            items = this.Create_ModelSku();
            DataTable dtToken = DAL.GetNewToken();

            if (dtToken.Rows.Count > 0)
            {
                token   = dtToken.Rows[0]["AccessToken"].ToString();
                endTime = DateTime.Parse(dtToken.Rows[0]["EndTime"].ToString());
            }
            foreach (JObject item in items)
            {
                DateTime now     = DateTime.Now;
                int      resDate = DateTime.Compare(endTime, now);
                if (resDate < 0 || resDate == 0)
                {
                    dtToken = DAL.GetNewToken();
                    if (dtToken.Rows.Count > 0)
                    {
                        token   = dtToken.Rows[0]["AccessToken"].ToString();
                        endTime = DateTime.Parse(dtToken.Rows[0]["EndTime"].ToString());
                    }
                }
                System.Threading.Thread.Sleep(3000);
                string category = "Sku_Interprise_South";
                string sku_code = item.GetValue("sku").ToString().Trim();
                sku_code = DAL.GetString(sku_code, 8);

                bool checkPack = await packController.PostPack_ToIon_South(token, sku_code, "NEW");

                //if (checkPack)
                //{
                result = await ClientHttpController.Post(item, url, token);

                if (!result.check)
                {
                    result.RecordResultAPI(category, sku_code);
                    continue;
                }
                else
                {
                    this.PostToIon_Warehouse(item, token, sku_code);
                }

                //}
                //else
                //{
                //    DAL.UpdateStatus(sku_code, "ERROR_PACK", "SKU_SOUTH");
                //    continue;
                //}
            }
        }
Beispiel #2
0
        public async void PostToIon(string token)
        {
            IonReponse     result         = new IonReponse();
            JArray         items          = new JArray();
            PackController packController = new PackController();
            string         url            = Constant.ION_SKU_ENTERPRISE_URL_NORTH;

            //string url = Constant.ION_SKU_ENTERPRISE_URL;
            items = this.Create_ModelSku();

            foreach (JObject item in items)
            {
                string category = "Sku_Interprise_North";
                string sku_code = item.GetValue("sku").ToString().Trim();

                bool checkPack = await packController.PostPack_ToIon(token, sku_code);

                if (checkPack)
                {
                    result = await ClientHttpController.Post(item, url, token);

                    if (!result.check)
                    {
                        this.HandleError(result, sku_code, category);
                        continue;
                    }
                    else
                    {
                        this.PostToIon_Warehouse(item, token, sku_code);
                    }
                }
                else
                {
                    continue;
                }
            }
        }