Beispiel #1
0
        public static async Task <IonReponse> Post(JObject model, string url, String token)
        {
            IonReponse result    = new IonReponse();
            var        tempModel = JsonConvert.DeserializeObject(model.ToString());

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            string URI        = string.Format(url, token);
            var    httpClient = new RestClient(URI);
            var    request    = new RestRequest(Method.POST);

            request.AddHeader("Content-Type", "application/json");
            request.AddParameter("application/json", tempModel, ParameterType.RequestBody);
            IRestResponse response = httpClient.Execute(request);

            if (response.IsSuccessful)
            {
                result.check   = true;
                result.message = response.Content.ToString();
            }
            else
            {
                result.check   = false;
                result.message = response.Content.ToString();
                result.errcode = response.StatusCode;
            }
            return(result);
        }
Beispiel #2
0
        public async void PostToIon_Warehouse(JObject model, string token, string sku)
        {
            IonReponse result  = new IonReponse();
            JArray     altSkus = new JArray();

            string url = Constant.ION_SKU_WAREHOUSE_URL_NORTH;

            // string url = Constant.ION_SKU_WAREHOUSE_URL;

            altSkus = this.Create_ModelAltSku(sku);

            model.Add("altSkus", altSkus);

            result = await ClientHttpController.Post(model, url, token);

            string category = "Sku_Warehouse_North";

            if (result.check)
            {
                this.Update_Satatus(sku, "OK", "SKU");
            }
            else
            {
                this.HandleError(result, sku, category);
            }
        }
Beispiel #3
0
 public void HandleError(IonReponse result, string sku, string type)
 {
     if (result.check == false)
     {
         result.RecordResultAPI(type, sku);
     }
 }
Beispiel #4
0
 public void HandleError(IonReponse result, string orderkey_mm, string type)
 {
     if (result.check == false)
     {
         result.RecordResultAPI(type, orderkey_mm);
     }
 }
Beispiel #5
0
        public async void PostToIon_South(string token)
        {
            IonReponse result = new IonReponse();
            JArray     Pos    = new JArray();

            string category1 = "PO";
            string category2 = "PODETAIL";
            string url       = Constant.ION_PO_URL;

            Pos = this.Create_ModelPo();

            foreach (JObject po in Pos)
            {
                var pokey_mm    = po.GetValue("externpokey").ToString().Trim();
                var pokey_infor = po.GetValue("pokey").ToString().Trim();
                var type        = po.GetValue("potype").ToString().Trim();
                result = await ClientHttpController.Post(po, url, token);

                if (result.check)
                {
                    this.Update_Satatus(pokey_mm, pokey_infor, category2);
                }
                else
                {
                    this.HandleError(result, pokey_mm, category1);
                }
            }
        }
Beispiel #6
0
        public async void PostToIon_South(string token)
        {
            IonReponse result = new IonReponse();
            JArray     jArray = new JArray();

            string category = "SO";
            string url      = Constant.ION_SO_URL;

            jArray = this.Create_ModelSO_South();

            foreach (JObject so in jArray)
            {
                var orderkey_mm    = so.GetValue("externorderkey").ToString().Trim();
                var orderkey_infor = so.GetValue("orderkey").ToString().Trim();

                result = await ClientHttpController.Post(so, url, token);

                if (result.check)
                {
                    this.Update_Satatus(orderkey_infor, orderkey_mm, category);
                }
                else
                {
                    this.HandleError(result, orderkey_mm, category);
                }
            }
        }
        public async void PostToIon_Warehouse(JObject model, string token, string sku)
        {
            IonReponse result  = new IonReponse();
            JArray     altSkus = new JArray();

            string url = Constant.ION_SKU_WAREHOUSE_URL_SOUTH;

            altSkus = this.Create_ModelAltSku(sku);

            model.Add("altSkus", altSkus);

            result = await ClientHttpController.Post(model, url, token);

            string category = "Sku_Warehouse_South";

            if (result.check)
            {
                DAL.UpdateStatus(sku, "OK", "SKU_SOUTH");
            }
            else
            {
                result.RecordResultAPI(category, sku);
                DAL.UpdateStatus(sku, "ERROR_WAREHOUSE", "SKU_SOUTH");
            }
        }
Beispiel #8
0
        public async Task <bool> PostPack_ToIon_South(string token, string sku, string type)
        {
            IonReponse result = new IonReponse();
            JObject    pack   = new JObject();

            string url = Constant.ION_PACK_URL_SOUTH;

            if (type == "NEW")
            {
                pack = this.Create_ModelPack_South(sku);
            }
            else
            {
                pack = this.Update_Model_South(sku);
            }


            result = await ClientHttpController.Post(pack, url, token);

            if (!result.check)
            {
                //result.RecordResultAPI(category, sku);
            }
            return(result.check);
        }
        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 #10
0
        public async void PostToIon_Xdock()
        {
            IonReponse result = new IonReponse();
            JArray     jArray = new JArray();

            string url      = Constant.ION_SO_URL_NORTH;
            string category = "XDOCK";

            jArray = this.Create_ModelSO_Xdock();

            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 so in jArray)
            {
                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);
                var orderkey_mm = so.GetValue("orderkey").ToString().Trim();
                var pokey_mm    = so.GetValue("pokey").ToString().Trim();

                orderkey_mm = DAL.GetString(orderkey_mm, 17);
                pokey_mm    = DAL.GetString(pokey_mm, 17);

                result = await ClientHttpController.Post(so, url, token);

                if (result.check)
                {
                    DAL.UpdateStatus(pokey_mm, orderkey_mm, category);
                }
                else
                {
                    result.RecordResultAPI("XDOCK_NORTH", orderkey_mm);
                }
            }
        }
Beispiel #11
0
        public async void PostToIon_North()
        {
            IonReponse result    = new IonReponse();
            JArray     suppliers = new JArray();

            string url = Constant.ION_SUPPLIER_URL_NORTH;

            suppliers = this.CreateModelSupplier("NORTH");

            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 supplier in suppliers)
            {
                DateTime now     = DateTime.Now;
                int      resDate = DateTime.Compare(endTime, now);

                if (resDate < 0 || resDate == 0)
                {
                    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 supplier_code = supplier.GetValue("storerkey").ToString().Trim();

                supplier_code = DAL.GetString(supplier_code, 6);

                string category = "Supplier_North";

                result = await ClientHttpController.Post(supplier, url, token);

                if (result.check)
                {
                    DAL.UpdateStatus(supplier_code, "OK", category);
                }
                else
                {
                    result.RecordResultAPI(category, supplier_code);
                }
            }
        }
        public async void PostToIon()
        {
            IonReponse result = new IonReponse();
            JArray     Pos    = new JArray();

            string category = "PO";
            string url      = Constant.ION_PO_URL_SOUTH;

            Pos = this.Create_ModelPo();
            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 po in Pos)
            {
                DateTime now     = DateTime.Now;
                int      resDate = DateTime.Compare(endTime, now);

                if (resDate < 0 || resDate == 0)
                {
                    if (dtToken.Rows.Count > 0)
                    {
                        token   = dtToken.Rows[0]["AccessToken"].ToString();
                        endTime = DateTime.Parse(dtToken.Rows[0]["EndTime"].ToString());
                    }
                }

                System.Threading.Thread.Sleep(3000);
                var pokey_mm    = po.GetValue("externpokey").ToString().Trim();
                var pokey_infor = po.GetValue("pokey").ToString().Trim();

                result = await ClientHttpController.Post(po, url, token);

                if (result.check)
                {
                    DAL.UpdateStatus(pokey_mm, pokey_infor, category);
                }
                else
                {
                    //DAL.UpdateStatus(pokey_mm, "ERROR", category);
                    result.RecordResultAPI("PO_SOUTH", pokey_mm);
                }
            }
        }
Beispiel #13
0
        public async void PostToIon()
        {
            IonReponse result = new IonReponse();
            JArray     asns   = new JArray();

            string category = "ASN_SOUTH";
            string url      = Constant.ION_ASN_URL_SOUTH;

            asns = this.Create_ModelAsn();
            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 asn in asns)
            {
                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);
                var pokey_mm = asn.GetValue("pokey").ToString().Trim();
                pokey_mm = DAL.GetString(pokey_mm, 17);
                var receiptkey = asn.GetValue("receiptkey").ToString().Trim();

                result = await ClientHttpController.Post(asn, url, token);

                if (result.check)
                {
                    DAL.UpdateStatus(pokey_mm, receiptkey, category);
                }
                else
                {
                    result.RecordResultAPI(category, pokey_mm);
                }
            }
        }
Beispiel #14
0
        public async Task <bool> PostPack_ToIon(string token, string sku)
        {
            IonReponse result = new IonReponse();
            JObject    pack   = new JObject();

            string url      = Constant.ION_PACK_URL_NORTH;
            string category = "Pack_North";

            pack   = this.Create_ModelPack(sku);
            result = await ClientHttpController.Post(pack, url, token);

            if (!result.check)
            {
                result.RecordResultAPI(category, sku);
            }
            return(result.check);
        }
Beispiel #15
0
        public async void Post_Update_Sku_Warehouse(JObject model, string token, string sku)
        {
            IonReponse result  = new IonReponse();
            JArray     altSkus = new JArray();

            string url = Constant.ION_SKU_WAREHOUSE_URL_NORTH;

            result = await ClientHttpController.Post(model, url, token);

            string category = "Update_Sku_Warehouse_North";

            if (result.check)
            {
                DAL.UpdateStatus(sku, "UPDATE", "SKU_NORTH");
            }
            else
            {
                result.RecordResultAPI(category, sku);
                DAL.UpdateStatus(sku, "ERROR_UPDATE_WAREHOUSE", "SKU_NORTH");
            }
        }
Beispiel #16
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;
                }
            }
        }