Exemple #1
0
        public async Task <IHttpActionResult> RenderForms([FromBody] RenderFormsVm model)
        {
            try
            {
                if (!ModelState.IsValid || model == null)
                {
                    return(BadRequest(ModelState));
                }

                var response = await _service.RenderForms(model);

                if (response == null)
                {
                    return(BadRequest("No Response from Service Layer"));
                }
                //if (response.Status == ResponseStatus.BadRequest)
                //{
                //    return BadRequest(response.Message);
                //}
                //if (response.Status == ResponseStatus.NotFound)
                //{
                //    return Content(HttpStatusCode.NotFound, response.Message);
                //}
                return(Ok(response));
            }
            catch (FmsAuthenticationException e)
            {
                _logManager.WriteEntry(e, 4036);
                return(Content(HttpStatusCode.Forbidden, e.Message));
            }
            catch (Exception e)
            {
                _logManager.WriteEntry(e, 4036);
                return(InternalServerError(e));
            }
        }
Exemple #2
0
        public async Task <FormsListResponse> RenderForms(RenderFormsVm model)
        {
            try
            {
                var trans = GetTrans(model.CallerOrgCode, model.UserName, model.OrderId);
                if (trans == null)
                {
                    throw new ADMServerException("Couldn't find Trans");
                }

                var transString = trans.GetXml()?.OuterXml;
                //Create request for formservice

                //Make request to formservice

                var formServiceResponse = await RenderFormsWebServiceCall(transString, model);

                //if status code isn't good throw exception

                var formServiceResponseString = await formServiceResponse.Content.ReadAsStringAsync();

                var jObj      = JObject.Parse(formServiceResponseString);
                var admString = jObj["TxPayload"].ToString();

                //TODO: is this Step Necessary?
                var formsMsg = new AdmMessage()
                {
                    Body = admString
                };
                var formsTrans = formsMsg.GetBodyAsDataEntity() as IAdmTrans;

                //loopthrough formInstances of forms trans. Add each Form to trans
                formsTrans?.FormInstances.ToList().ForEach(formInstance =>
                {
                    var fi                                = trans.FormInstances.AddNew("FormInstance_Attachment");
                    fi.FormName                           = formInstance.FormName;
                    fi.ProviderFormNumber                 = formInstance.ProviderFormNumber;
                    fi.FormInstanceTrackingID             = formInstance.FormInstanceTrackingID;
                    fi.DocumentControlNumber              = formInstance.DocumentControlNumber;
                    fi.FormInstanceStatus                 = formInstance.FormInstanceStatus;
                    fi.FormOptional                       = formInstance.FormOptional;
                    fi.UserCode                           = formInstance.UserCode;
                    fi.Sequence                           = formInstance.Sequence;
                    fi.InfoSourceTC                       = formInstance.InfoSourceTC;
                    fi.Attachments[0].AttachmentData.Data =
                        formInstance.Attachments[0].AttachmentData.Data;
                });

                //Update Trans in DB

                //trans.Store.Update(trans);
                //trans.Store.Refresh(trans);
                //Return new Appropriate response Message
                var retObj = new FormsListResponse()
                {
                    CorrelationGuid = model.CorrelationGuid,
                    FormInstances   = MapFormInstances(trans.FormInstances.ToList())
                };
                return(retObj);
            }
            catch (Exception e)
            {
                _logManager.WriteEntry($"{e.Message} | CorrelationGUID: {model.CorrelationGuid}", LogLevel.Error, 4025);

                throw;
            }
        }
Exemple #3
0
        private async Task <HttpResponseMessage> RenderFormsWebServiceCall(string transString, RenderFormsVm model)
        {
            using (var client = new HttpClient())
            {
                JObject request = new JObject {
                    { "CallerOrgCode", model.CallerOrgCode },
                    { "CorrelationGUID", model.CorrelationGuid },
                    { "Stage", "57" },
                    { "TxPayload", transString },
                    { "NgenDataFormat", false }
                };
                JToken data = JToken.FromObject(request);
                var    requestServiceUrl = "https://FormService-rnd-qa.gobluefrog.com"; //_service.GetConfigurationParameter("InternalFormServiceUrl");
                client.BaseAddress = new Uri(requestServiceUrl);
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));

                var requestContent = new StringContent(data.ToString(), Encoding.UTF8, "application/json");
                return(await client.PostAsync("https://FormService-rnd-qa.gobluefrog.com/api/forms/renderform", requestContent));
            }
        }