Example #1
0
 public bool CompleteTask(RetrieveMerchantInformation model, Int64 tasktypeid, Int64 merchantId, Int64 contractId, int iscompleted, int workflowid, string rawdata, string requestxml)
 {
     return new DataAccess.DataAccess().ExecuteNonQuery("avz_cc_spSaveEvaluationTask", new
     {
         tasktypeid = tasktypeid,
         merchantId = merchantId,
         contractId = contractId,
         score = Convert.ToDouble(model.score),
         roundedscore = Convert.ToDouble(model.roundedscore),
         finalletter = model.finalletter,
         iscompleted = iscompleted,
         workflowid = workflowid,
         rawdata = string.IsNullOrEmpty(rawdata) ? "" : rawdata,
         requestxml = requestxml
     });
 }
Example #2
0
 public bool CompleteTask(RetrieveMerchantInformation model, Int64 tasktypeid, Int64 merchantId, Int64 contractId, int iscompleted, int workflowid, string rawdata, string requestxml)
 {
     return _creditRepository.CompleteTask(model, tasktypeid, merchantId, contractId, iscompleted, workflowid, rawdata, requestxml);
 }
Example #3
0
        public bool PullReportbyId(int reporttypeId, Int64 merchantId, Int64 contractId, string isCompleted, int reportAvailable)
        {
            string strgetjson = "";
            string UserName = ConfigurationManager.AppSettings["UserName"];
            string PassWord = ConfigurationManager.AppSettings["PassWord"];
            string xmlParameters = string.Empty;
            string TipoId = string.Empty;
            string Id = string.Empty;
            if (reportAvailable == 0)
            {
                CreditReportModel analysisModel = new CreditReportModel();
                analysisModel.isavailable = 0;
                analysisModel.image = Encoding.ASCII.GetBytes("");
                // string dateString = DateTime.Now.ToString("yyyy-MM-dd");
                DateTime dt = DateTime.Now;
                //string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00");
                IFormatProvider culture2 = new System.Globalization.CultureInfo("es-DO", true);
                analysisModel.timeofreport = dt;
                analysisModel.monthEvaualted = dt;

                if (reporttypeId == 1)
                {
                    analysisModel.type = "O";
                }
                //Company Report
                else if (reporttypeId == 2)
                {

                    analysisModel.type = "C";
                }
                return InsertCreditreport(analysisModel, merchantId, contractId, isCompleted);
            }
            else
            {
                //Get the values on the basis of the parameters
                CreditReportModel analysisModel = new CreditReportModel();
                if (ConfigurationManager.AppSettings["Testing"] == "0")
                {
                    RetrieveMerchantInformation modelReport = new RetrieveMerchantInformation();
                    using (CreditReportTier mt = new CreditReportTier())
                    {
                        modelReport = mt.RetrieveMerchantInformation(merchantId, contractId);
                    }
                    // Owner Report
                    if (reporttypeId == 1)
                    {
                        TipoId = "C";
                        analysisModel.type = "O";
                        Id = modelReport.ownerId;
                    }
                    //Company Report
                    else if (reporttypeId == 2)
                    {

                        TipoId = "R";
                        analysisModel.type = "C";
                        Id = modelReport.rnc;
                        //  Id = "101088575";
                    }
                    AcmeRuby.clsCaltecServiceSoapClient objServiceReference_AcmeRuby = new AcmeRuby.clsCaltecServiceSoapClient();
                    strgetjson = objServiceReference_AcmeRuby.GetXmlJsonStr(UserName, PassWord, TipoId, Id, xmlParameters);
                    //strgetjson = compJson;
                }
                else
                {
                    //Owner Report
                    if (reporttypeId == 1)
                    {
                        TipoId = "C";
                        Id = "22400033001";
                        //Id = "00113569248";
                        analysisModel.type = "O";

                    }
                    //Company Report
                    else if (reporttypeId == 2)
                    {
                        //Id = "103157531";
                        Id = "101874139";
                        TipoId = "R";
                        analysisModel.type = "C";

                    }
                    AcmeRuby.clsCaltecServiceSoapClient objServiceReference_AcmeRuby = new AcmeRuby.clsCaltecServiceSoapClient();
                    strgetjson = objServiceReference_AcmeRuby.GetXmlJsonStr(UserName, PassWord, TipoId, Id, xmlParameters);
                    // strgetjson = compJson;
                }
                var sr = Newtonsoft.Json.JsonConvert.DeserializeObject(strgetjson);
                JObject obj = (JObject)sr;
                var baseToken = obj.SelectToken("c").SelectToken("DCR");
                var errorToken = baseToken.SelectToken("ErrorHandling");
                if (errorToken.SelectToken("Id").ToString() == "0")
                {

                    var individualToken = baseToken.SelectToken("Individuo");
                    analysisModel.isavailable = 1;
                    var securityToken = baseToken.SelectToken("Seguridad");
                    var creditAnalysisToken = baseToken.SelectToken("AnalisisCrediticio");
                    var breakDownCreditsToken = baseToken.SelectToken("DesgloseCreditos");
                    var productToken = breakDownCreditsToken.SelectToken("Producto");

                    //var accountToken = productToken.SelectToken("Cuenta");
                    var companyToken = baseToken.SelectToken("Empresa");
                    #region Company Information
                    if (companyToken != null)
                    {
                        analysisModel.commercialname = companyToken.SelectToken("NombreComercial").ToString();
                        analysisModel.name = companyToken.SelectToken("Nombre").ToString();
                        analysisModel.rnc = companyToken.SelectToken("RNC").ToString();

                        analysisModel.commercialactivity = companyToken.SelectToken("ActividadComercial").ToString();
                    }
                    else
                    {
                        analysisModel.commercialname = string.Empty;
                        analysisModel.name = string.Empty;
                        analysisModel.rnc = string.Empty;
                        analysisModel.commercialactivity = string.Empty;
                    }
                    #endregion
                    #region Owner Information
                    if (individualToken != null)
                    {
                        analysisModel.firstName = individualToken.SelectToken("Nombres").ToString();
                        analysisModel.lastName = individualToken.SelectToken("Apellidos").ToString();
                        analysisModel.name = string.Concat(analysisModel.firstName, analysisModel.lastName);
                        analysisModel.nationality = individualToken.SelectToken("Nacionalidad").ToString();
                        analysisModel.occupation = individualToken.SelectToken("Ocupacion").ToString();
                        analysisModel.passport = individualToken.SelectToken("Pasaporte").ToString();
                        analysisModel.image = Encoding.ASCII.GetBytes(baseToken.SelectToken("Foto").ToString());
                        if (individualToken.SelectToken("Categoria") != null)
                        {
                            analysisModel.riskCategory = individualToken.SelectToken("Categoria").ToString();
                        }
                    }
                    else
                    {

                        analysisModel.nationality = string.Empty;
                        analysisModel.occupation = string.Empty;
                        analysisModel.passport = string.Empty;
                        analysisModel.image = Encoding.ASCII.GetBytes(baseToken.SelectToken("Foto").ToString());
                    }
                    #endregion
                    #region Genral Information
                    if (securityToken.SelectToken("FechaHora") != null)
                    {
                        string dateString = securityToken.SelectToken("FechaHora").ToString();
                        // DateTime dateTime = new DateTime(Convert.ToInt32(dateString.Split('-')[2].Substring(0, 4)), Convert.ToInt32(dateString.Split('-')[1]), Convert.ToInt32(dateString.Split('-')[0]));
                        dateString = string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00");
                        IFormatProvider culture2 = new System.Globalization.CultureInfo("es-DO", true);
                        analysisModel.timeofreport = Convert.ToDateTime(dateString);
                        analysisModel.monthEvaualted = Convert.ToDateTime(dateString);
                    }

                    //  analysisModel.rawData = Encoding.ASCII.GetBytes(strgetjson);
                    analysisModel.rawData = strgetjson;
                    analysisModel.probabilityOfDefault = 0d;
                    if (errorToken != null)
                    {
                        analysisModel.errors = errorToken.SelectToken("Description").ToString();
                    }

                    #endregion

                    #region Credit Analysis
                    string code = string.Empty;
                    JToken accounts = string.Empty;

                    if (productToken != null)
                    {
                        List<JToken> productList;
                        List<CreditAnalysis> crreport = new List<CreditAnalysis>();
                        if (productToken.Type == JTokenType.Array)
                        {
                            productList = productToken.ToList();
                        }
                        else
                        {
                            productList = new List<JToken>() { productToken };
                        }

                        int iotherAccount = 0;

                        foreach (var item in productList)
                        {
                            if (productToken.Type == JTokenType.Array)
                            {

                                code = item.SelectToken("@Id").ToString();
                                accounts = item.SelectToken("Cuenta");
                            }
                            else
                            {
                                code = productToken.SelectToken("@Id").ToString();
                                accounts = productToken.SelectToken("Cuenta");
                            }
                            var accountsList = accounts;

                            if (accountsList.Type == JTokenType.Array)
                            {

                                foreach (var ceunta in accountsList)
                                {
                                    CreditAnalysis analysis = new CreditAnalysis();

                                    //If loan then
                                    if (code.Equals("Préstamo"))
                                    {
                                        analysis.typeofActivity = "1";
                                        analysisModel.numberofLoans = accountsList.Count();
                                    }
                                    else if (code.Equals("Tarjeta de Crédito"))
                                    {
                                        //Credit Card
                                        analysis.typeofActivity = "2";
                                        analysisModel.numberofCreditCards = accountsList.Count();

                                    }
                                    else
                                    {
                                        iotherAccount += 1;
                                        //Others
                                        analysis.typeofActivity = "3";
                                        analysisModel.numberofOthers = iotherAccount;

                                    }

                                    string status = ceunta.SelectToken("Estatus").SelectToken("#text").ToString();
                                    //  if (status == "1")
                                    {
                                        string affliate = ceunta.SelectToken("Afiliado").ToString();
                                        analysis.currency = ceunta.SelectToken("Moneda").SelectToken("@Des_Moneda").ToString();
                                        string dateString = string.Empty;
                                        if (ceunta.SelectToken("FechaApertura") != null)
                                        {
                                            dateString = string.Concat("01-", ceunta.SelectToken("FechaApertura").ToString());
                                            dateString = string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00");
                                            analysis.firstcreditdate = dateString;
                                        }
                                        analysis.consolidateMonth = string.Concat("01-", (ceunta.SelectToken("MesConsolidado").ToString()));
                                        if (ceunta.SelectToken("TotalAdeudado") != null)
                                        {
                                            if (!String.IsNullOrEmpty(ceunta.SelectToken("TotalAdeudado").ToString())
                                                //  && ceunta.SelectToken("TotalAdeudado").ToString() != "(1)"
                                            )
                                            {
                                                double value;
                                                double.TryParse(ceunta.SelectToken("TotalAdeudado").ToString(), out value);
                                                analysis.loanowedamount = value;
                                                //    analysis.loanowedamount =  Double.Parse((ceunta.SelectToken("TotalAdeudado").ToString()));
                                            }
                                        }
                                        if (ceunta.SelectToken("CreditoAprobado") != null)
                                        {
                                            if (!String.IsNullOrEmpty(ceunta.SelectToken("CreditoAprobado").ToString()))
                                            {
                                                analysis.approvedcredit = Double.Parse(((ceunta.SelectToken("CreditoAprobado").ToString())));
                                            }
                                        }
                                        if (ceunta.SelectToken("Cuota") != null)
                                        {
                                            if (!String.IsNullOrEmpty(ceunta.SelectToken("Cuota").ToString()))
                                            {
                                                analysis.loanmonthlypayment = Double.Parse(((ceunta.SelectToken("Cuota").ToString())));
                                            }
                                        }
                                        if (ceunta.SelectToken("TotalAtraso") != null)
                                        {
                                            if (!String.IsNullOrEmpty(ceunta.SelectToken("TotalAtraso").ToString()))
                                            {
                                                analysis.loanlateamount = (((ceunta.SelectToken("TotalAtraso").ToString())));
                                            }
                                        }

                                    }
                                    crreport.Add(analysis);
                                }
                            }
                            else
                            {
                                string dateString = string.Empty;

                                CreditAnalysis analysis = new CreditAnalysis();
                                if (code.Equals("Préstamo"))
                                {
                                    analysis.typeofActivity = "1";
                                    analysisModel.numberofLoans = accountsList.Count();
                                }
                                else if (code.Equals("Tarjeta de Crédito"))
                                {
                                    //Credit Card
                                    analysis.typeofActivity = "2";
                                    analysisModel.numberofCreditCards = accountsList.Count();

                                }
                                else
                                {
                                    //Others
                                    iotherAccount += 1;
                                    analysis.typeofActivity = "3";
                                    analysisModel.numberofOthers = iotherAccount;

                                }
                                if (productToken.Type == JTokenType.Array)
                                    analysis.currency = item.SelectToken("Cuenta").SelectToken("Moneda").SelectToken("@Des_Moneda").ToString();
                                else
                                    analysis.currency = productToken.SelectToken("Cuenta").SelectToken("Moneda").SelectToken("@Des_Moneda").ToString();
                                string status = accountsList.SelectToken("Estatus").SelectToken("#text").ToString();
                                //  if (status == "1")
                                {
                                    string affliate = accountsList.SelectToken("Afiliado").ToString();
                                    analysis.currency = accountsList.SelectToken("Moneda").SelectToken("@Des_Moneda").ToString();

                                    if (accountsList.SelectToken("FechaApertura") != null)
                                    {
                                        dateString = string.Concat("01-", accountsList.SelectToken("FechaApertura").ToString());
                                        dateString = string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00");

                                        IFormatProvider culture2 = new System.Globalization.CultureInfo("es-DO", true);
                                        analysis.firstcreditdate = dateString;
                                    }
                                    analysis.consolidateMonth = (accountsList.SelectToken("MesConsolidado").ToString());
                                    if (accountsList.SelectToken("TotalAdeudado") != null)
                                    {
                                        if (!String.IsNullOrEmpty(accountsList.SelectToken("TotalAdeudado").ToString()))
                                        {
                                            // analysis.loanowedamount +=Double.Parse((ceunta.SelectToken("TotalAdeudado").ToString()));
                                            analysis.loanowedamount = Double.Parse((accountsList.SelectToken("TotalAdeudado").ToString()));
                                        }
                                    }
                                    if (accountsList.SelectToken("CreditoAprobado") != null)
                                    {
                                        if (!String.IsNullOrEmpty(accountsList.SelectToken("CreditoAprobado").ToString()))
                                        {
                                            //analysis.approvedcredit += Double.Parse(((ceunta.SelectToken("CreditoAprobado").ToString())));
                                            analysis.approvedcredit = Double.Parse(((accountsList.SelectToken("CreditoAprobado").ToString())));
                                        }
                                    }
                                    if (accountsList.SelectToken("Cuota") != null)
                                    {
                                        if (!String.IsNullOrEmpty(accountsList.SelectToken("Cuota").ToString()))
                                        {
                                            analysis.loanmonthlypayment = Double.Parse(((accountsList.SelectToken("Cuota").ToString())));
                                        }
                                    }
                                    if (accountsList.SelectToken("TotalAtraso") != null)
                                    {
                                        if (!String.IsNullOrEmpty(accountsList.SelectToken("TotalAtraso").ToString()))
                                        {
                                            analysis.loanlateamount = (((accountsList.SelectToken("TotalAtraso").ToString())));
                                        }
                                    }
                                    crreport.Add(analysis);
                                }

                            }

                        }

                        analysisModel.creditAnalysis = crreport;

                    }
                    #endregion

                    return InsertCreditreport(analysisModel, merchantId, contractId, isCompleted);
                }
                else
                {
                    analysisModel.errors = errorToken.SelectToken("Description").ToString();
                    analysisModel.rawData = strgetjson;
                    analysisModel.isavailable = 0;
                    analysisModel.image = Encoding.ASCII.GetBytes("");
                    var securityToken = baseToken.SelectToken("Seguridad");
                    if (securityToken.SelectToken("FechaHora") != null)
                    {
                        string dateString = securityToken.SelectToken("FechaHora").ToString();
                        // DateTime dateTime = new DateTime(Convert.ToInt32(dateString.Split('-')[2].Substring(0, 4)), Convert.ToInt32(dateString.Split('-')[1]), Convert.ToInt32(dateString.Split('-')[0]));
                        dateString = string.Concat(dateString.Split('-')[2].Substring(0, 4), "-", dateString.Split('-')[1], "-", dateString.Split('-')[0], " 00:00:00");
                        IFormatProvider culture2 = new System.Globalization.CultureInfo("es-DO", true);
                        analysisModel.timeofreport = Convert.ToDateTime(dateString);
                        analysisModel.monthEvaualted = Convert.ToDateTime(dateString);
                    }
                    return InsertCreditreport(analysisModel, merchantId, contractId, isCompleted);
                }
            }
        }