Exemplo n.º 1
0
        // **************** 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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        public string Call_Get(string query)
        {
            ResultAPI ra = Do_Call_Get(query);

            return(ra.JsonResult);
        }