public ModulesGetPageDTO Modules_GetPage(string pageid, string dataRowId = "") { ModulesGetPageDTO dto = new ModulesGetPageDTO(); postData.Clear(); postData.Add("apiid", ModulesSystem_apiid); postData.Add("apikey", ModulesSystem_apikey); try { postData.Add("pageid", pageid); if (!string.IsNullOrWhiteSpace(dataRowId)) { postData.Add("dataRowId", dataRowId); } string strResponseJsonData = AOCC_ApiHelper.SendPostRequest(Modules_GetPageURL, postData); dto = JsonConvert.DeserializeObject <ModulesGetPageDTO>(strResponseJsonData); } catch (Exception ex) { oLogService.InsertExternalApiErrorLog(MethodBase.GetCurrentMethod().Name, Modules_GetPageURL, postData, dto, ex.Message); } return(dto); }
public Get_SimpleSmResult WTB_Get_PIDSimpleSmInfoEC(string midSiteId, string ISOwebsite, List <string> productId) { Get_SimpleSmResult result = new Get_SimpleSmResult(); var requestData = new List <Get_PIDSimpleSmObjRequest>(); requestData.Add(new Get_PIDSimpleSmObjRequest() { websiteid = midSiteId, ISOwebsite = ISOwebsite, pid = productId }); string responseJsonStr = ""; string responseXML = ""; try { string strPostData = JsonConvert.SerializeObject(requestData); var header = new WtbHeader() { apiId = this.WhereToBuySystem_apiid, apikey = WhereToBuySystem_apikey }; var body = new WtbBody_Get_WTB() { Data = strPostData }; string strHeader = AOCC_ApiHelper.SetXMLString(header); string strBody = AOCC_ApiHelper.SetXMLString(body, true, "Get_PIDSimpleSmInfoEC"); DateTime requestStartTime = DateTime.Now; responseXML = AOCC_ApiHelper.ToPostSoapRequestWithXML(WTB_Host, strHeader, strBody); responseJsonStr = AOCC_ApiHelper.GetXmlStringData(responseXML, "Get_PIDSimpleSmInfoECResult"); var tmpResult = JsonConvert.DeserializeObject <Get_SimpleSmResponseResult>(responseJsonStr); oLogService.InsertExternalAPILog(MethodBase.GetCurrentMethod().Name, requestStartTime, DateTime.Now, Get_WTB_Url, "", $"strHeader : {strHeader}; strBody : {strBody}", responseJsonStr); if (tmpResult != null && tmpResult.Status == "1") { throw new Exception("WTB System Error : " + tmpResult.Message); } if (tmpResult != null && tmpResult.Status == "0") { result = tmpResult.lists; } } catch (Exception ex) { oLogService.InsertExternalApiErrorLog(MethodBase.GetCurrentMethod().Name, Get_WTB_Url, responseXML, responseJsonStr, ex.Message); } return(result); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public GetAwardListResponseRoot Award_GetAwardList(string productId, string area = "", string productLineId = "", string awardDateS = "", string awardDateE = "") { DateTime requestStartTime = DateTime.Now; GetAwardListResponseRoot result = new GetAwardListResponseRoot(); string xmlResponseString = ""; string responseString = ""; try { string strPostData = ""; strPostData += "apiid=" + AwardSystem_apiid; strPostData += "&apikey=" + AwardSystem_apikey; strPostData += "&productId=" + productId; if (!string.IsNullOrWhiteSpace(productLineId)) { strPostData += "&productLineId=" + productLineId; } if (!string.IsNullOrWhiteSpace(awardDateS)) { strPostData += "&awardDateS=" + HttpUtility.UrlEncode(awardDateS); } if (!string.IsNullOrWhiteSpace(awardDateE)) { strPostData += "&awardDateE=" + HttpUtility.UrlEncode(awardDateE); } if (!string.IsNullOrWhiteSpace(area)) { strPostData += "&area=" + area; } xmlResponseString = AOCC_ApiHelper.SendRequest($"{GetAwardList_Url}?{strPostData}"); responseString = AOCC_ApiHelper.GetXmlStringData(xmlResponseString); result = JsonConvert.DeserializeObject <GetAwardListResponseRoot>(responseString); if (result.Status == "1") { throw new Exception("Award System Error : " + result.Message); } oLogService.InsertExternalAPILog(MethodBase.GetCurrentMethod().Name, requestStartTime, DateTime.Now, GetAwardList_Url, "", strPostData, responseString); } catch (Exception ex) { oLogService.InsertExternalApiErrorLog(MethodBase.GetCurrentMethod().Name, GetAwardList_Url, strPostData, responseString, ex.Message); } return(result); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public List <Get_WtbResponseObj> WTB_Get_WTB(string website, string type, List <string> partNo) { DateTime requestStartTime = DateTime.Now; Get_WtbRootResponseResult result = new Get_WtbRootResponseResult(); var requestData = new List <Get_WtbObjRequest>(); requestData.Add(new Get_WtbObjRequest() { website = website, type = type, sku_member = partNo }); string responseJsonStr = ""; string responseXML = ""; try { string strPostData = JsonConvert.SerializeObject(requestData); var header = new WtbHeader() { apiId = this.WhereToBuySystem_apiid, apikey = WhereToBuySystem_apikey }; var body = new WtbBody_Get_WTB() { Data = strPostData }; string strHeader = AOCC_ApiHelper.SetXMLString(header); string strBody = AOCC_ApiHelper.SetXMLString(body, true, "Get_WTB"); responseXML = AOCC_ApiHelper.ToPostSoapRequestWithXML(WTB_Host, strHeader, strBody); responseJsonStr = AOCC_ApiHelper.GetXmlStringData(responseXML, "Get_WTBResult"); result = JsonConvert.DeserializeObject <List <Get_WtbRootResponseResult> >(responseJsonStr)?.FirstOrDefault(); if (result != null) { if (result.Status == "1") { throw new Exception("WTB System Error : " + result.Message); } oLogService.InsertExternalAPILog(MethodBase.GetCurrentMethod().Name, requestStartTime, DateTime.Now, Get_WTB_Url, "", $"strHeader : {strHeader}; strBody : {strBody}", responseJsonStr); } } catch (Exception ex) { oLogService.InsertExternalApiErrorLog(MethodBase.GetCurrentMethod().Name, Get_WTB_Url, responseXML, responseJsonStr, ex.Message); } return(result.lists); }
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); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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); }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //tagtype 搜尋模式 ( 0 = TAG搜尋 , 1 = 含該TAG的同義字 , 2 = 含該TAG的翻譯字 , 3 = 含該TAG的同義字+翻譯字 ) public RogSpecFiltersApiRootObj RogSpecFiltersAPI(int website, string tagid, string productline, string tagtype = "3") { RogSpecFiltersApiRootObj dto = new RogSpecFiltersApiRootObj(); postData.Clear(); postData.Add("apiid", RogSpecFiltersApi_apiid); postData.Add("apikey", RogSpecFiltersApi_apikey); try { postData.Add("website", website); postData.Add("tagid", tagid); postData.Add("productline", productline); postData.Add("tagtype", tagtype); string strJsonData = AOCC_ApiHelper.SendPostRequest(RogSpecFiltersApi_Url, postData); dto = JsonConvert.DeserializeObject <RogSpecFiltersApiRootObj>(strJsonData); } catch (Exception ex) { oLogService.InsertExternalApiErrorLog(MethodBase.GetCurrentMethod().Name, RogSpecFiltersApi_Url, postData, dto, ex.Message); } return(dto); }