Beispiel #1
0
        public ActionResult GetInboundXml(int id)
        {
            InboundXmlUpdateModel model = new InboundXmlUpdateModel();
            ErrorLog error = new ErrorLog();

            error.CEA_Xml_id = id;
            using (var client = new HttpClient())
            {
                try
                {
                    var token = Request.Cookies["access_token"].Value;
                    client.BaseAddress = new Uri(ConfigurationManager.AppSettings["ApiUrl"].ToString());
                    client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
                    client.DefaultRequestHeaders.Accept.Add(
                        new MediaTypeWithQualityHeaderValue("application/json"));

                    //HTTP GET
                    var responseTask = client.PostAsJsonAsync <ErrorLog>("GetXmlFromCeaXmlId", error);
                    responseTask.Wait();

                    var result = responseTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        InboundXmlModel inboundModel = new InboundXmlModel();
                        var             readTask     = result.Content.ReadAsAsync <InboundXmlModel>();
                        readTask.Wait();
                        if (readTask.Result.InboundXMLString != null && readTask.Result.InboundXMLString != " ")
                        {
                            inboundModel.InboundXMLString = readTask.Result.InboundXMLString;
                            inboundModel.XmlElements      = XmlClient.GetAllUniqueElements(inboundModel.InboundXMLString);
                            model.ActivityLogPolicyId     = id;
                        }
                        else
                        {
                            ModelState.AddModelError(string.Empty, "Inbound XMl  Not Found");
                        }
                        model.InboundXmlModel = inboundModel;
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                        return(RedirectToAction("ErrorLog"));
                    }
                }
                catch (Exception ex)
                {
                    return(RedirectToAction("_ErrorLog"));
                }

                return(PartialView("_XmlEditorPopup", model));
            }
        }