示例#1
0
        private APIReturnValue ProcessAdhocClaim(DataRow ClRow, string CustomFields)
        {
            APIReturnValue    retVal   = new APIReturnValue();
            int               VendorId = Convert.ToInt32(ClRow["venId"]);
            string            strResp  = string.Empty;
            AdhocClaimRequest objClaim = Util.CreateObjectFromRow <AdhocClaimRequest>(ClRow);

            objClaim.projectId   = ProjectId.ToString();
            objClaim.appVendorId = Preprocessor.vendorMasterInfoList[VendorId].appVendorId;
            objClaim.vendorId    = VendorId.ToString();
            if (!string.IsNullOrEmpty(ClRow["ProblemTypeValue"].ToString()))
            {
                ProblemTypeId objPT = new ProblemTypeId();
                objPT.value            = ClRow["ProblemTypeValue"].ToString();
                objPT.id               = Preprocessor.claimFieldLookupValues["problemTypeId"][ClRow["ProblemTypeValue"].ToString().ToLower()];
                objClaim.problemTypeId = objPT;
            }
            if (!string.IsNullOrEmpty(ClRow["RootCauseValue"].ToString()))
            {
                RootCauseId objRC = new RootCauseId();
                objRC.value          = ClRow["RootCauseValue"].ToString();
                objRC.id             = Preprocessor.claimFieldLookupValues["rootCauseId"][ClRow["RootCauseValue"].ToString().ToLower()];
                objClaim.rootCauseId = objRC;
            }
            objClaim.vendorName   = Preprocessor.vendorMasterInfoList[VendorId].vendorName;
            objClaim.vendorNumber = Preprocessor.vendorMasterInfoList[VendorId].vendorNumber;
            dynamic expando = Util.ConvertToExpando(objClaim);

            if (!string.IsNullOrEmpty(CustomFields))
            {
                List <String> lst = CustomFields.Split(",").ToList();
                Dictionary <string, object> tempProps = new Dictionary <string, object>();
                foreach (string str in lst)
                {
                    if (ClRow.Table.Columns.Contains(str) && ClRow[str] != null)
                    {
                        tempProps.Add(str, ClRow[str]);
                    }
                }
                Util.AddProperties(expando, tempProps);
            }
            string strPL = JsonConvert.SerializeObject(expando);
            HttpResponseMessage respMsg = Util.ClaimsAPIURL.AppendPathSegment("claims").WithOAuthBearerToken(Util.bearerToken)
                                          .WithHeader("Content-Type", "application/json").PostStringAsync(strPL).Result;

            strResp           = respMsg.Content.ReadAsStringAsync().Result;
            retVal.StatusDesc = strResp;
            if (respMsg.IsSuccessStatusCode)
            {
                retVal.Status = StatusCode.PartiallyComplete;
                IDictionary <string, object> objResp = JsonConvert.DeserializeObject <ExpandoObject>(strResp);
                retVal.PanopticId = objResp["id"].ToString();
                try
                {
                    ChangeClaimStatus(Convert.ToInt64(retVal.PanopticId), ClRow["StageValue"].ToString(), ClRow["StatusValue"].ToString());
                    retVal.Status = StatusCode.Complete;
                }
                catch (AggregateException ae)
                {
                    ae.Handle(e =>
                    {
                        if (e is FlurlHttpException)
                        {
                            string es         = ((FlurlHttpException)e).GetResponseStringAsync().Result;
                            retVal.StatusDesc = es;
                            Logger.log.Error(e, $"Error Occurred while Post Creation Adhoc Claim Processing for PanopticId: {retVal.PanopticId}. Record Id: {ClRow["RecordId"]}, Response: {es}");
                        }
                        else
                        {
                            Logger.log.Error(e, $"Error Occurred while Post Creation Adhoc Claim Processing for PanopticId: {retVal.PanopticId}. Record Id: {ClRow["RecordId"]}");
                            retVal.StatusDesc = e.Message;
                        }
                        return(true); //continue execution... set to false to break.
                    });
                }
                catch (Exception e)
                {
                    retVal.StatusDesc = e.Message;
                    Logger.log.Error(e, $"Error Occurred while Post Creation Adhoc Claim Processing for PanopticId: {retVal.PanopticId}. Record Id: {ClRow["RecordId"]}");
                }
            }
            else
            {
                retVal.Status = StatusCode.Error;
            }
            return(retVal);
        }
示例#2
0
        private APIReturnValue ProcessCreditClaim(DataRow ClRow, string CustomFields)
        {
            APIReturnValue     retVal   = new APIReturnValue();
            int                VendorId = Convert.ToInt32(ClRow["venId"]);
            string             strResp  = string.Empty;
            CreditClaimRequest objClaim = Util.CreateObjectFromRow <CreditClaimRequest>(ClRow);
            ClaimInput         objInp   = Util.CreateObjectFromRow <ClaimInput>(ClRow);

            objClaim.claimInput             = objInp;
            objClaim.projectId              = ProjectId;
            objClaim.claimInput.appVendorId = Preprocessor.vendorMasterInfoList[VendorId].appVendorId;
            objClaim.uniqueIds              = ClRow["CreditIds"].ToString().Split(',').Select(c => Convert.ToInt32(c)).ToList();
            if (!string.IsNullOrEmpty(ClRow["ProblemTypeValue"].ToString()))
            {
                ProblemTypeId objPT = new ProblemTypeId();
                objPT.value = ClRow["ProblemTypeValue"].ToString();
                objPT.id    = Preprocessor.claimFieldLookupValues["problemTypeId"][ClRow["ProblemTypeValue"].ToString().ToLower()];
                objClaim.claimInput.problemTypeId = objPT;
            }
            if (!string.IsNullOrEmpty(ClRow["RootCauseValue"].ToString()))
            {
                RootCauseId objRC = new RootCauseId();
                objRC.value = ClRow["RootCauseValue"].ToString();
                objRC.id    = Preprocessor.claimFieldLookupValues["rootCauseId"][ClRow["RootCauseValue"].ToString().ToLower()];
                objClaim.claimInput.rootCauseId = objRC;
            }
            objClaim.claimInput.vendorName   = Preprocessor.vendorMasterInfoList[VendorId].vendorName;
            objClaim.claimInput.vendorNumber = Preprocessor.vendorMasterInfoList[VendorId].vendorNumber;
            objClaim.claimInput.claimDate    = DateTime.Parse(ClRow["ClaimDate"].ToString()).ToUniversalTime().ToString("o");
            dynamic claimExpando = Util.ConvertToExpando(objClaim);

            if (!string.IsNullOrEmpty(CustomFields))
            {
                dynamic       expando = Util.ConvertToExpando(objClaim.claimInput);
                List <String> lst     = CustomFields.Split(",").ToList();
                Dictionary <string, object> tempProps = new Dictionary <string, object>();
                foreach (string str in lst)
                {
                    if (ClRow.Table.Columns.Contains(str) && ClRow[str] != null)
                    {
                        tempProps.Add(str, ClRow[str]);
                    }
                }
                Util.AddProperties(expando, tempProps);
                Util.AddProperty(claimExpando, "claimInput", expando);
            }
            string strPL = JsonConvert.SerializeObject(claimExpando);
            HttpResponseMessage respMsg = Util.AuditAPIURL.AppendPathSegment("claim/create").WithOAuthBearerToken(Util.bearerToken)
                                          .WithHeader("Content-Type", "application/json").WithHeader("Accept", "application/json")
                                          .PostStringAsync(strPL).Result;

            strResp           = respMsg.Content.ReadAsStringAsync().Result;
            retVal.StatusDesc = strResp;
            if (respMsg.IsSuccessStatusCode)
            {
                try
                {
                    retVal.Status = StatusCode.PartiallyComplete;
                    long tempId = GetCreditClaimId(objClaim.uniqueIds.FirstOrDefault());
                    if (tempId != 0)
                    {
                        retVal.PanopticId = tempId.ToString();
                        ChangeClaimStatus((long)tempId, ClRow["StageValue"].ToString(), ClRow["StatusValue"].ToString());
                        retVal.Status = StatusCode.Complete;
                    }
                    else
                    {
                        retVal.StatusDesc = $"Credit Claim Created but Further Processing Failed for Vendor Id: {VendorId}.  Claim Id: {ClRow["RecordId"].ToString()}";
                    }
                }
                catch (AggregateException ae)
                {
                    ae.Handle(e =>
                    {
                        if (e is FlurlHttpException)
                        {
                            string es         = ((FlurlHttpException)e).GetResponseStringAsync().Result;
                            retVal.StatusDesc = es;
                            Logger.log.Error(e, $"Error Occurred while Post Creation Credit Claim Processing for PanopticId: {retVal.PanopticId}. Record Id: {ClRow["RecordId"]}, Response: {es}");
                        }
                        else
                        {
                            Logger.log.Error(e, $"Error Occurred while Post Creation Credit Claim Processing for PanopticId: {retVal.PanopticId}. Record Id: {ClRow["RecordId"]}");
                            retVal.StatusDesc = e.Message;
                        }
                        return(true); //continue execution... set to false to break.
                    });
                }
                catch (Exception e)
                {
                    retVal.StatusDesc = e.Message;
                    Logger.log.Error(e, $"Error Occurred while Post Creation Credit Claim Processing for PanopticId: {retVal.PanopticId}. Record Id: {ClRow["RecordId"]}");
                }
            }
            else
            {
                retVal.Status = StatusCode.Error;
            }
            return(retVal);
        }