// **************** END IMPORTENT!!!! IGNOR SSL ERRORS!!!! **************************** public string GetCustOrdersStatus(string dbName, string custName, string ordStatus) { IRestResponse response = null; string res = string.Empty; var uri = new Uri(ConfigurationManager.AppSettings["AppAPI"].ToString()); // Replace with your Service Root URL //string aline_one_data = CreateBaseFormData(rptData, exRPT, rdf, null, isNewRPT); try { var client = new RestClient(ConfigurationManager.AppSettings["AppAPI"].ToString() + dbName + "/ORDERS?$filter=CUSTNAME eq '" + custName + "' and (CURDATE gt " + DateTime.Now.AddMonths(-18).ToShortDateString() + ") and ORDSTATUSDES eq '" + ordStatus + "'"); // ("https://priority.metalicone.com/odata/priority/tabula.ini/metalic/ALINE_ONE"); var request = new RestRequest(Method.GET); request.AddHeader("postman-token", "fec359c7-7a6a-3c70-7095-a5ec2123a638"); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/json"); request.AddHeader("authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes((ConfigurationManager.AppSettings["AppAPI_U"].ToString() + ":" + (ConfigurationManager.AppSettings["AppAPI_P"].ToString()))))); //IRestResponse response = client.Execute(request); response = client.Execute(request); ResultAPI ra = CreateResultApi(response); res = TransformeResultToXml(response.Content); } catch (Exception ex) { AppLogger.log.Debug(AppLogger.CreateLogText("GetCustOrdersStatus", ex.Message)); AppLogger.log.Debug(AppLogger.CreateLogText("GetCustOrdersStatus", response.ErrorMessage), response.ErrorException); } return(res); }
public ResultAPI Call_PATCH_USER(string query) { IRestResponse response = null; //var uri = new Uri(ConfigurationManager.AppSettings["AppAPI"].ToString()); // Replace with your Service Root URL Uri uri = GetUri(); ResultAPI ra = null; try { System.Net.ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(AcceptAllCertifications); var client = new RestClient(ConfigurationManager.AppSettings["AppAPI"].ToString() + ConfigurationManager.AppSettings["Defult_DNAME"].ToString() + "/PHONEBOOK"); var request = new RestRequest(Method.PATCH); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/atom+xml"); request.AddHeader("authorization", "Basic " + Convert.ToBase64String(Encoding.ASCII.GetBytes((ConfigurationManager.AppSettings["AppAPI_U"].ToString() + ":" + (ConfigurationManager.AppSettings["AppAPI_P"].ToString()))))); request.AddHeader("content-type", "application/json"); request.AddParameter("application/json", query, ParameterType.RequestBody); response = client.Execute(request); ra = CreateResultApi(response); } catch (Exception ex) { AppLogger.log.Debug(AppLogger.CreateLogText("Call_PATCH_USER", ex.Message)); AppLogger.log.Debug(AppLogger.CreateLogText("Call_PATCH_USER", response.ErrorMessage), response.ErrorException); } return(ra); }
public string TestAPI() { IRestResponse response = null; string res = string.Empty; var uri = new Uri(ConfigurationManager.AppSettings["AppAPI"].ToString()); // Replace with your Service Root URL //string aline_one_data = CreateBaseFormData(rptData, exRPT, rdf, null, isNewRPT); try { //var client = new RestClient(ConfigurationManager.AppSettings["AppAPI"].ToString() + dbName + "/ALINE_ONE"); // ("https://priority.metalicone.com/odata/priority/tabula.ini/metalic/ALINE_ONE"); var client = new RestClient("https://priority.metalicone.com/odata/priority/tabula.ini/metalic/ALINE_ONE?%24filter=DOC%20eq%20907350"); var request = new RestRequest(Method.GET); request.AddHeader("postman-token", "fec359c7-7a6a-3c70-7095-a5ec2123a638"); request.AddHeader("cache-control", "no-cache"); request.AddHeader("content-type", "application/atom+xml"); request.AddHeader("authorization", "Basic cmVwb3J0YWxuZXc6cmVwb3J0YWwxOA=="); //IRestResponse response = client.Execute(request); response = client.Execute(request); res = TransformeResultToXml(response.Content); } catch (Exception ex) { AppLogger.log.Debug(AppLogger.CreateLogText("PriorityAPI", ex.Message)); AppLogger.log.Debug(AppLogger.CreateLogText("PriorityAPI", response.ErrorMessage), response.ErrorException); } return(res); }
private ResultAPI CreateResultApi(IRestResponse response) { ResultAPI res = new ResultAPI(); XmlDocument doc = new XmlDocument(); res.ResultStatus = response.StatusDescription; try { if ((res.ResultStatus.Equals("Created")) || res.ResultStatus.Equals("OK")) { //string json = response.Content; res.JsonResult = response.Content; //res.ResultData = JsonConvert.DeserializeObject<OData>(json); } else if (res.ResultStatus.Equals("Conflict")) { res.ErrorDescription = "Conflict - Check with system administrator"; } else if (res.ResultStatus.ToLower().Equals("forbidden")) { res.ErrorDescription = response.Content;// "Call Network system administrator, ned to reset 'Priority .NET Service'"; } else if (res.ResultStatus.ToLower().Equals("internal server error")) { res.ErrorDescription = "No Data."; } else { doc.LoadXml(response.Content); XmlNodeList parentNode = doc.GetElementsByTagName("InterfaceErrors"); if (null != parentNode) { AppLogger.log.Debug(AppLogger.CreateLogText("CreateResultApi => Response XML", response.Content), null); foreach (XmlNode childrenNode in parentNode) { res.ErrorDescription += childrenNode.InnerText.Replace("'", "''") + "<br/>"; } } } } catch (Exception ex) { AppLogger.log.Debug(AppLogger.CreateLogText("CreateResultApi", ex.Message)); } return(res); }
private DateTime TestDateFormat(string date, string time) { AppLogger.log.Debug(AppLogger.CreateLogText("TestDateFormat => Date Value:", date)); double hh = 0; double mm = 0; if (null == date) { return(DateTime.Now); } DateTime dtRes = new DateTime(); if (string.IsNullOrEmpty(time)) { time = DateTime.Now.ToShortTimeString(); } string[] arrT = time.Split(':'); if (arrT.Length > 0) { hh = Convert.ToDouble(arrT[0]); mm = Convert.ToDouble(arrT[1]); } if (DateTime.TryParse(date, out dtRes)) { dtRes.AddHours(hh); dtRes.AddMinutes(mm); } else { string[] arr = date.Split('-'); if (arr.Length > 0) { dtRes = new DateTime(Convert.ToInt32(arr[2]), Convert.ToInt32(arr[1]), Convert.ToInt32(arr[0]), (int)hh, (int)mm, 0); } else { AppLogger.log.Debug(AppLogger.CreateLogText("TestDateFormat => Date Value:", "Wrong date format")); } } return(dtRes); }