Exemplo n.º 1
0
        public async Task <FormsListResponse> GetForms(FormsListRequest model)
        {
            try
            {
                var trans = GetTrans(model.CallerOrgCode, model.UserName, model.OrderId);
                if (trans == null)
                {
                    //TODO: Log Something
                    throw new ADMServerException("Couldn't find Trans");
                }

                var formsList = trans.FormInstances.ToList();
                await Task.Delay(1);

                var retObj = new FormsListResponse()
                {
                    CorrelationGuid = model.CorrelationGuid,
                    FormInstances   = MapFormInstances(formsList, model.IncludePdfString)
                };

                return(retObj);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemplo n.º 2
0
        public async Task <IHttpActionResult> Get([FromUri] FormsListRequest model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                FormsListResponse response = await _service.GetForms(model);

                return(Ok(response));
            }
            catch (Exception e)
            {
                return(InternalServerError(e));
            }
        }
Exemplo n.º 3
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;
            }
        }