예제 #1
0
        }         // Get

        public virtual void Set <T>(string key, T value, MP_ServiceLog serviceLog) where T : class
        {
            m_oRetryer.Retry(() => {
                Log.InfoFormat("Setting data to MP_ExperianBankCache for key '{0}', service log id={1}...", key, serviceLog.Id);

                var item = GetAll().FirstOrDefault(i => i.Key == key) ?? new MP_ExperianBankCache();

                item.Key            = key;
                item.LastUpdateDate = DateTime.UtcNow;
                item.Data           = JsonConvert.SerializeObject(value);
                item.LogItem        = serviceLog;

                SaveOrUpdate(item);
            }, "ExperianBankCacheRepository.Set(" + key + ")");
        }         // Set
예제 #2
0
        }         // CacheNotExpired

        private ExperianConsumerData ConsumerDebugResult(string surname, int customerId)
        {
            var    content  = string.Empty;
            string testPart = string.Empty;

            string filename = string.Empty;

            if (surname != null && surname.Contains("_"))
            {
                string[] splitValues = surname.Split('_');

                if (splitValues.Length > 1 && !string.IsNullOrEmpty(splitValues[1]))
                {
                    testPart = splitValues[1];

                    if (!testPart.Contains(":"))
                    {
                        int mpSeviceLogId;
                        int.TryParse(testPart, out mpSeviceLogId);

                        if (mpSeviceLogId > 0)
                        {
                            var log = ObjectFactory.GetInstance <ServiceLogRepository>();
                            TryRead(() => m_oRetryer.Retry(() => content = log.GetById(mpSeviceLogId).ResponseData));
                        }                         // if
                    }
                    else
                    {
                        try
                        {
                            filename = testPart;
                            content  = File.ReadAllText(filename);
                        }
                        catch (Exception e)
                        {
                            Log.ErrorFormat("Can't read experian file:{0}. Exception:{1}", filename, e);
                        } // try
                    }     // if
                }         // if
            }             // if

            if (string.IsNullOrEmpty(content))
            {
                try
                {
                    filename = string.IsNullOrEmpty(testPart) ? @"C:\Temp\Experian.xml" : testPart;
                    content  = File.ReadAllText(filename);
                }
                catch (Exception e)
                {
                    Log.ErrorFormat("Can't read experian file:{0}. Exception:{1}", filename, e);
                }         // try
            }             // if

            if (string.IsNullOrEmpty(content))
            {
                var           sl     = ObjectFactory.GetInstance <ServiceLogRepository>();
                MP_ServiceLog oFirst = m_oRetryer.Retry(() => sl.GetFirst());
                content = oFirst.ResponseData;
            }

            var outputRootSerializer = new XmlSerializer(typeof(OutputRoot));
            var outputRoot           = (OutputRoot)outputRootSerializer.Deserialize(new StringReader(content));

            Log.InfoFormat("Get consumer info for test user: {0}", surname);
            var input = new Input {
                Applicant = new [] { new InputApplicant {
                                         FormattedName = surname, ClientPersonID = customerId.ToString(CultureInfo.InvariantCulture)
                                     } }
            };
            var serviceLog = Utils.WriteLog(input, outputRoot, ExperianServiceType.Consumer, customerId, null, null, surname, null, null);

            SaveDefaultAccountIntoDb(outputRoot, customerId, serviceLog.ServiceLog);
            var builder = new ConsumerExperianModelBuilder();

            return(builder.Build(outputRoot, customerId));
        }         // ConsumerDebugResult
예제 #3
0
        }         // GetConsumerInfo

        private void SaveDefaultAccountIntoDb(OutputRoot output, int customerId, MP_ServiceLog serviceLog)
        {
            var customerRepo = ObjectFactory.GetInstance <CustomerRepository>();

            var customer = customerRepo.Get(customerId);

            OutputFullConsumerDataConsumerDataCAIS[] cais = null;

            TryRead(() => cais = output.Output.FullConsumerData.ConsumerData.CAIS);

            if (cais == null)
            {
                return;
            }

            var dateAdded = DateTime.UtcNow;
            var repo      = ObjectFactory.GetInstance <NHibernateRepositoryBase <ExperianDefaultAccount> >();

            foreach (var caisData in cais)
            {
                if (caisData.CAISDetails == null)
                {
                    continue;
                }
                foreach (var detail in caisData.CAISDetails.Where(detail => detail.AccountStatus == "F"))
                {
                    int relevantYear, relevantMonth, relevantDay;

                    if (detail.SettlementDate != null)
                    {
                        relevantYear  = detail.SettlementDate.CCYY;
                        relevantMonth = detail.SettlementDate.MM;
                        relevantDay   = detail.SettlementDate.DD;
                    }
                    else
                    {
                        relevantYear  = detail.LastUpdatedDate.CCYY;
                        relevantMonth = detail.LastUpdatedDate.MM;
                        relevantDay   = detail.LastUpdatedDate.DD;
                    }                     // if

                    var settlementDate    = new DateTime(relevantYear, relevantMonth, relevantDay);
                    var currentDefBalance = 0;
                    var balance           = 0;
                    var reg        = new Regex("[^0-9,]");
                    var tempDetail = detail;

                    TryRead(() =>
                            int.TryParse(reg.Replace(tempDetail.CurrentDefBalance.Amount, ""), out currentDefBalance)
                            );

                    TryRead(() => int.TryParse(reg.Replace(tempDetail.Balance.Amount, ""), out balance));

                    var eda = new ExperianDefaultAccount {
                        AccountType       = AccountTypeDictionary.GetAccountType(detail.AccountType ?? string.Empty),
                        Date              = settlementDate,
                        DelinquencyType   = "Default",
                        Customer          = customer,
                        DateAdded         = dateAdded,
                        CurrentDefBalance = currentDefBalance,
                        Balance           = balance,
                        ServiceLog        = serviceLog,
                    };

                    m_oRetryer.Retry(() => repo.SaveOrUpdate(eda));
                } // foreach detail in cais datum
            }     // foreach cais datum in cais data
        }         // SaveDefaultAccountIntoDb
예제 #4
0
 public override void Set <T>(string key, T value, MP_ServiceLog serviceLog)
 {
 }