コード例 #1
0
        public List <GetSpecResultResponseDTO> Spec_GetSpec(string midSiteId, List <string> partNoList, string cutting = "")
        {
            DateTime requestStartTime           = DateTime.Now;
            List <GetSpecResultResponseDTO> dto = new List <GetSpecResultResponseDTO>();
            string postData     = "";
            string responseJson = "";

            try
            {
                postData     = PrivateSpecMethod.SetDefaultPostData(new GetSpecInput(partNoList, midSiteId, cutting), SpecSystem_apiid, SpecSystem_apikey);
                responseJson = AOCC_ApiHelper.ToPostAPI_withArray(GetSpecURL_URL, postData);

                oLogService.InsertExternalAPILog(MethodBase.GetCurrentMethod().Name, requestStartTime, DateTime.Now, GetSpecURL_URL, "", postData, responseJson);

                JObject jObj = JObject.Parse(responseJson);

                if (jObj == null)
                {
                    throw new Exception("Spec System Error : " + jObj["message"].Value <string>());
                }
                if (jObj["result"].Value <int>() == 1)
                {
                    throw new Exception("Spec System Error : " + jObj["message"].Value <string>());
                }

                foreach (var partNo in partNoList)
                {
                    JToken tmpSku = jObj["skus"][partNo];
                    if (jObj["skus"][partNo]["status"].Value <int>() == 0)
                    {
                        continue;                                                  //測試用先關閉判斷
                    }
                    var skuData = JsonConvert.DeserializeObject <SpecPartResponseDTO>(JsonConvert.SerializeObject(tmpSku));

                    dto.Add(new GetSpecResultResponseDTO()
                    {
                        Part_no = partNo,
                        Obj     = skuData
                    });
                }
            }
            catch (Exception ex)
            {
                oLogService.InsertExternalApiErrorLog(MethodBase.GetCurrentMethod().Name, GetSpecURL_URL, postData, responseJson, ex.Message);
            }
            return(dto);
        }
コード例 #2
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        public JObject Product_gettagInfo(string siteid, List <string> product_id_list)
        {
            JObject dto         = new JObject();
            var     startTime   = DateTime.Now;
            var     endTime     = DateTime.Now;
            string  strJsonData = "";

            strPostData  = "";
            strPostData += "apiid=" + this.ProductSystem_apiid;
            strPostData += "&apikey=" + this.ProductSystem_apikey;

            try
            {
                strPostData += "&siteid=" + siteid;

                foreach (var product_id in product_id_list)
                {
                    strPostData += "&product_id=" + product_id;
                }

                startTime = DateTime.Now;

                strJsonData = AOCC_ApiHelper.ToPostAPI_withArray(this.Product_GettagInfo_Url, strPostData);

                dto = JsonConvert.DeserializeObject <JObject>(strJsonData);

                if (dto["status"].ToString() == "1")
                {
                    return(null);
                }
                if (dto["data"].ToList().Count == 0)
                {
                    return(null);
                }

                oLogService.InsertExternalAPILog(MethodBase.GetCurrentMethod().Name, startTime, DateTime.Now, Product_GettagInfo_Url, "", strPostData, strJsonData);
            }
            catch (Exception ex)
            {
                oLogService.InsertExternalApiErrorLog(MethodBase.GetCurrentMethod().Name, Product_GettagInfo_Url, strPostData, strJsonData, ex.Message);
            }
            return(dto);
        }