Example #1
0
        public byte[] GenerateReport(IList <LoanModel> loans, string fullName)
        {
            var worksheet = _workbook.Worksheets[_workbook.Worksheets.ActiveSheetIndex];

            worksheet.Name = "Loans History";
            CreateHead(worksheet, fullName);
            int row = 2;

            CreateXlsHeader(worksheet, row);
            row++;
            var sumLoanAmount = loans.Sum(x => x.LoanAmount);
            var sumRepayments = loans.Sum(x => x.Repayments);
            var sumBalance    = loans.Sum(x => x.Balance);

            foreach (var loan in loans)
            {
                row++;
                worksheet.Cells[row, 0].PutValue(loan.RefNumber);

                worksheet.Cells[row, 1].PutValue(FormattingUtils.NumericFormats(loan.LoanAmount));
                worksheet.Cells[row, 2].PutValue(FormattingUtils.NumericFormats(loan.Repayments));
                worksheet.Cells[row, 3].PutValue(loan.Date.ToString("MMM dd yyyy", CultureInfo.CreateSpecificCulture("en-gb")));
                worksheet.Cells[row, 4].PutValue(FormattingUtils.NumericFormats(loan.Balance));
                worksheet.Cells[row, 5].PutValue(loan.StatusDescription);
                SetCellStyle(worksheet, row, false);
            }
            row++;
            worksheet.Cells[row, 0].PutValue("Total");
            worksheet.Cells[row, 1].PutValue(FormattingUtils.NumericFormats(sumLoanAmount));
            worksheet.Cells[row, 2].PutValue(FormattingUtils.NumericFormats(sumRepayments));
            worksheet.Cells[row, 4].PutValue(FormattingUtils.NumericFormats(sumBalance));
            SetCellStyle(worksheet, row, true);
            return(_workbook.SaveToStream().ToArray());
        }
Example #2
0
        }         // FromDirector

        public static DirectorModel FromExperianDirector(ExperianDirector director, TypeOfBusinessReduced nBusinessType)
        {
            return(new DirectorModel {
                IsExperian = true,
                Id = director.ID,
                Name = director.FirstName,
                Middle = director.MiddleName,
                Surname = director.LastName,
                Position = 0,
                DateOfBirth = FormattingUtils.FormatDateToString(director.BirthDate, "-/-/-"),

                DirectorAddress = new [] {
                    new CustomerAddress {
                        Line1 = director.Line1,
                        Line2 = director.Line2,
                        Line3 = director.Line3,
                        Town = director.Town,
                        County = director.County,
                        Postcode = director.Postcode,
                        AddressType = nBusinessType == TypeOfBusinessReduced.Limited
                                                        ? CustomerAddressType.LimitedDirectorHomeAddress
                                                        : CustomerAddressType.NonLimitedDirectorHomeAddress
                    },
                },

                PrevDirectorAddress = new CustomerAddress[0],
                Gender = director.Gender.HasValue ? director.Gender.Value : ' ',
                Email = director.Email,
                Phone = director.MobilePhone,
                IsDirector = director.IsDirector ? Yes : No,
                IsShareholder = director.IsShareholder ? Yes : No,
            });
        } // FromExperianDirector
Example #3
0
        internal override void OnLoadScript(ExecutionEngine vm, byte[] script)
        {
            var context = vm.CallingContext;

            if (context != null)
            {
                var sb = new StringBuilder();
                for (int i = 0; i < context.EvaluationStack.Count; i++)
                {
                    var item = context.EvaluationStack.Peek(i);
                    if (sb.Length > 0)
                    {
                        sb.Append(",");
                    }
                    ;
                    sb.Append(FormattingUtils.StackItemAsString(item));
                }
                Logger("Inputs: " + sb.ToString());
            }

            base.OnLoadScript(vm, script);

            if (_debugger != null)
            {
                _debugger.SendScript(script);
            }
        }
Example #4
0
        public static bool Log(ExecutionEngine engine)
        {
            var msg = engine.EvaluationStack.Pop();

            DoLog(FormattingUtils.StackItemAsString(msg));
            return(true);
        }
Example #5
0
        public bool Runtime_Log(ExecutionEngine engine)
        {
            var msg = engine.CurrentContext.EvaluationStack.Pop();

            Logger(FormattingUtils.StackItemAsString(msg));
            return(true);
        }
Example #6
0
        }         // Execute

        private void SendMailAndMarkDB(string templateName, SafeReader sr, string spName, string fieldName)
        {
            decimal amountDue = sr["AmountDue"];
            string  firstName = sr["FirstName"];
            //string mail = sr["Email"];
            DateTime sceduledDate   = sr["SceduledDate"];
            string   creditCard     = sr["CreditCardNo"];
            int      customerId     = sr["customerId"];
            int      loanScheduleId = sr["id"];

            var variables = new Dictionary <string, string> {
                { "FirstName", firstName },
                { "AmountDueScalar", amountDue.ToString(CultureInfo.InvariantCulture) },
                { "Date", FormattingUtils.FormatDateToString(sceduledDate) },
                { "DebitCard", creditCard }
            };

            XDaysDueMails xDaysDueMails = new XDaysDueMails(customerId, templateName, variables);

            xDaysDueMails.Execute();

            DB.ExecuteNonQuery(spName,
                               CommandSpecies.StoredProcedure,
                               new QueryParameter("Id", loanScheduleId),
                               new QueryParameter(fieldName, true)
                               );

            //TODO update loan schedule x days due
            Log.Info("update loan schedule x days due for customer {0}", customerId);
        }
Example #7
0
        private ExecutionEngine ExecuteVM(Transaction tx, TriggerType trigger)
        {
            Logger("Executing VM with trigger " + trigger);
            var vm = new ChainVM(this, tx);

            currentTrigger = trigger;
            currentGas     = 0;
            vm.LoadScript(tx.script);

            vm.Execute(x => OnVMStep(x));

            int index = 0;

            var sb = new StringBuilder();

            foreach (StackItem item in vm.EvaluationStack)
            {
                if (index > 0)
                {
                    sb.Append(" / ");
                }

                sb.Append(FormattingUtils.StackItemAsString(item, true));
                index++;
            }
            Logger("Stack: " + sb);

            return(vm);
        }
Example #8
0
        }         // DirectorFirstMiddleLastName

        private void DobLess21()
        {
            if (!this.customer.PersonalInfo.DateOfBirth.HasValue)
            {
                this.fraudDetections.Add(Helper.CreateDetection(
                                             "Customer.DateOfBirth is null",
                                             this.customer,
                                             null,
                                             "",
                                             null,
                                             null
                                             ));

                return;
            }             // if

            if ((DateTime.UtcNow - this.customer.PersonalInfo.DateOfBirth).Value.Days / 365.25 < 21)
            {
                this.fraudDetections.Add(Helper.CreateDetection(
                                             "Customer.DateOfBirth < 21",
                                             this.customer,
                                             null,
                                             "",
                                             null,
                                             FormattingUtils.FormatDateTimeToString(this.customer.PersonalInfo.DateOfBirth)
                                             ));
            }     // if
        }         // DobLess21
Example #9
0
        private static string FormatMethodName(MethodDefinition definition)
        {
            var result = new StringBuilder();
              result.Append(FormattingUtils.GetMethodName(definition));

              // Parameters
              result.Append("(");

              if (definition.HasParameters)
              {
            for (int i = 0; i < definition.Parameters.Count; i++)
            {
              var parameter = definition.Parameters[i];
              result.Append(parameter.ParameterType.ToShortTypeName());
              if (i != definition.Parameters.Count - 1) result.Append(", ");
            }
              }

              result.Append(")");

              // Return type
              result.AppendFormat(" : {0}", definition.ReturnType.ToShortTypeName());

              return result.ToString();
        }
Example #10
0
        public bool Convert(object val, Type targetType, object parameter, CultureInfo culture, out object result)
        {
            result = null;
            if (val == null)
            {
                return(false);
            }

            TimeSpan?timeSpan = null;

            if (val is TimeSpan)
            {
                timeSpan = (TimeSpan)val;
            }
            if (val is double)
            {
                timeSpan = TimeSpan.FromSeconds((Double)val);
            }
            if (val is int)
            {
                timeSpan = TimeSpan.FromMinutes((int)val);
            }

            if (!timeSpan.HasValue)
            {
                return(false);
            }

            string customFormat = (parameter != null ? parameter.ToString() : null);

            result = customFormat != null?timeSpan.Value.ToString(customFormat) : FormattingUtils.FormatMediaDuration(timeSpan.Value);

            return(true);
        }
Example #11
0
        public override string ToString()
        {
            var sb = new StringBuilder();

            //sb.AppendLine(FormattingUtils.OutputLine("Offset", "Opcode", "Comment"));
            foreach (var entry in this.lines)
            {
                string opStr   = entry.name;
                string hintStr = entry.comment;

                if (!string.IsNullOrEmpty(hintStr))
                {
                    if (hintStr.Contains("$$"))
                    {
                        hintStr = hintStr.Replace("$$", FormattingUtils.OutputData(entry.data, true));
                    }

                    if (hintStr.Contains("$XX"))
                    {
                        hintStr = hintStr.Replace("$XX", entry.data.ByteToHex());
                    }

                    hintStr = "// " + hintStr;
                }

                sb.AppendLine(opStr.PadRight(8, ' ') + hintStr);
            }

            return(sb.ToString());
        }
Example #12
0
        public static bool Notify(ExecutionEngine engine)
        {
            //params object[] state
            var something = engine.EvaluationStack.Pop();

            if (something is ICollection)
            {
                var sb = new StringBuilder();

                var items = (ICollection)something;

                int index = 0;

                foreach (StackItem item in items)
                {
                    if (index > 0)
                    {
                        sb.Append(" / ");
                    }

                    sb.Append(FormattingUtils.StackItemAsString(item, true));
                    index++;
                }

                DoLog(sb.ToString());
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #13
0
        public ActionResult Index()
        {
            var customer = _context.Customer;
            var loan     = customer.Loans.Last();

            ViewData["LoanId"]     = loan.Id;
            ViewData["Amount"]     = FormattingUtils.FormatPounds(loan.LoanAmount);
            ViewData["bankNumber"] = customer.BankAccount.AccountNumber;
            ViewData["schedule"]   = loan.Schedule.ToModel();
            ViewData["name"]       = customer.PersonalInfo.FirstName + " " + customer.PersonalInfo.Surname;
            ViewData["email"]      = customer.Name;
            ViewData["loanNo"]     = loan.RefNumber;
            ViewData["SetupFee"]   = loan.SetupFee > 0 ? FormattingUtils.FormatPounds(loan.SetupFee) : "";
            ViewData["Total"]      = FormattingUtils.FormatPounds(loan.Balance + loan.SetupFee);
            ViewData["IsAlibaba"]  = customer.IsAlibaba;

            ViewData["Term"]           = loan.CustomerSelectedTerm;
            ViewData["Gender"]         = customer.PersonalInfo.GenderName;
            ViewData["IndustryType"]   = customer.PersonalInfo.IndustryTypeDescription;
            ViewData["Age"]            = customer.PersonalInfo.Age;
            ViewData["TypeOfBusiness"] = customer.PersonalInfo.TypeOfBusinessDescription;

            var addr = customer.AddressInfo.PersonalAddress.FirstOrDefault();

            ViewData["Postcode"] = addr == null ? null : addr.Postcode;
            ViewData["LeadID"]   = customer.RefNumber;
            ViewData["Status"]   = customer.Status.ToString();
            return(View("Index"));
        }
        public byte[] GenerateReport(LoanOffer loanOffer, bool isExcel, bool isShowDetails, string header)
        {
            var worksheet = _workbook.Worksheets[_workbook.Worksheets.ActiveSheetIndex];

            worksheet.Name = "Loan Offer";

            int row    = 6;
            int column = 1;

            _workbook.ChangePalette(Color.FromArgb(197, 197, 197), 55);
            _workbook.ChangePalette(Color.FromArgb(221, 221, 221), 54);
            _workbook.ChangePalette(Color.FromArgb(123, 178, 36), 53);

            HeaderReportGenerator.CreateHeader(worksheet, header, column - 1, column, 7);

            worksheet.Cells.SetColumnWidth(0, 1);
            worksheet.Cells.SetColumnWidth(1, 16);
            worksheet.Cells.SetColumnWidth(2, 15);

            CreateXlsHeader(worksheet, row, column);
            var i = 0;

            foreach (var item in loanOffer.Schedule)
            {
                row++;
                i++;
                worksheet.Cells[row, column].PutValue(item.Date.ToString("dd/MM/yyyy", CultureInfo.InvariantCulture));
                worksheet.Cells[row, column + 1].PutValue("£" + FormattingUtils.FormatMiddle(item.LoanRepayment));
                worksheet.Cells[row, column + 2].PutValue("£" + FormattingUtils.FormatMiddle(item.Interest));
                worksheet.Cells[row, column + 3].PutValue(FormattingUtils.FormatMiddle(item.InterestRate * 100) + "%");
                var fee = loanOffer.SetupFee > 0 && i == 1 ? loanOffer.SetupFee : 0;
                if (item.Fees > 0)
                {
                    fee += item.Fees;
                }
                var res  = fee != 0 ? "£" + FormattingUtils.FormatMiddle(fee) : "-";
                var res1 = loanOffer.SetupFee > 0 && i == 1 ? "*" : string.Empty;
                worksheet.Cells[row, column + 4].PutValue(res + res1);
                //worksheet.Cells.Merge(row, column + 5, 1, 3);
                worksheet.Cells[row, column + 5].PutValue("£" + FormattingUtils.FormatMiddle(item.AmountDue));
                SetCellStyle(worksheet, row, column, false);
            }

            row = CreateTotalBlock(loanOffer, row, column, worksheet);

            if (loanOffer.Details.IsModified)
            {
                row++;
                worksheet.Cells.Merge(row, column, 1, 7);
                worksheet.Cells[row, column].PutValue("Offer was manually modified");
                worksheet.Cells[row, column].Style.Font.IsBold = true;
            }
            if (isShowDetails)
            {
                CreateDetails(loanOffer.Details, row, column, worksheet);
            }

            return(ConvertFormat(_workbook, isExcel ? FileFormatType.Excel2003 : FileFormatType.Pdf));
        }
Example #15
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value is string)
     {
         return(FormattingUtils.formatReportStartTime((string)value));
     }
     return(value);
 }
        public override void Execute(string[] args, Action <ShellMessageType, string> output)
        {
            DataNode inputs;

            try
            {
                inputs = JSONReader.ReadFromString(args[1]);
            }
            catch
            {
                output(ShellMessageType.Error, "Invalid arguments format. Must be valid JSON.");
                return;
            }

            if (args.Length >= 3)
            {
                bool valid = false;

                if (args[2].ToLower() == "with")
                {
                    if (args.Length >= 5)
                    {
                        var assetAmount = BigInteger.Parse(args[3]);
                        var assetName   = args[4];

                        foreach (var entry in Asset.Entries)
                        {
                            if (entry.name == assetName)
                            {
                                output(ShellMessageType.Default, $"Attaching {assetAmount} {assetName} to transaction");
                                Shell.Debugger.Emulator.SetTransaction(entry.id, assetAmount);
                                break;
                            }
                        }

                        valid = true;
                    }
                }

                if (!valid)
                {
                    output(ShellMessageType.Error, "Invalid sintax.");
                    return;
                }

                output(ShellMessageType.Default, "Executing transaction...");

                Shell.Debugger.Emulator.Reset(inputs, null);
                Shell.Debugger.Emulator.Run();

                var val = Shell.Debugger.Emulator.GetOutput();

                Shell.Debugger.Blockchain.Save();

                output(ShellMessageType.Success, "Result: " + FormattingUtils.StackItemAsString(val));
                output(ShellMessageType.Default, "GAS used: " + Shell.Debugger.Emulator.usedGas);
            }
        }
Example #17
0
        public override void Execute(string[] args)
        {
            var storage = Shell.debugger.currentAddress.storage;

            foreach (var entry in storage.entries)
            {
                Shell.Write(FormattingUtils.OutputData(entry.Key, false) + " => " + FormattingUtils.OutputData(entry.Value, false, true));
            }
        }
Example #18
0
        public static string ReplaceParam(this string tmpl, KeyValuePair <string, object> paramKvp)
        {
            if (FormattingUtils.IsNullKvp(paramKvp))
            {
                throw new ArgumentNullException(nameof(paramKvp));
            }

            return(tmpl.Replace("{" + paramKvp.Key + "}", paramKvp.Value.ToString()));
        }
Example #19
0
        public override void Execute(string[] args, Action <ShellMessageType, string> output)
        {
            var storage = Shell.Debugger.Emulator.currentAccount.storage;

            foreach (var entry in storage.entries)
            {
                output(ShellMessageType.Default, FormattingUtils.OutputData(entry.Key, false) + " => " + FormattingUtils.OutputData(entry.Value, false));
            }
        }
Example #20
0
        public bool Runtime_Notify(ExecutionEngine engine)
        {
            //params object[] state
            var something = engine.EvaluationStack.Pop();

            if (something is ICollection)
            {
                var items = (ICollection)something;

                string eventName = null;
                var    eventArgs = new List <object>();

                int index = 0;

                var sb = new StringBuilder();
                foreach (StackItem item in items)
                {
                    if (index > 0)
                    {
                        sb.Append(" / ");
                        eventArgs.Add(StackItemToObject(item));
                    }
                    else
                    {
                        eventName = item.GetString();
                    }

                    sb.Append(FormattingUtils.StackItemAsString(item, true));
                    index++;
                }

                List <Notification> list;
                var tx = (Transaction)engine.ScriptContainer;

                if (notifications.ContainsKey(tx.Hash))
                {
                    list = notifications[tx.Hash];
                }
                else
                {
                    list = new List <Notification>();
                    notifications[tx.Hash] = list;
                }

                list.Add(new Notification()
                {
                    name = eventName, args = eventArgs.ToArray()
                });

                Logger(sb.ToString());
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #21
0
 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     if (value is string)
     {
         string val = (string)value;
         return(FormattingUtils.removeNewlines(val));
     }
     return("");
 }
Example #22
0
        public override string ToString()
        {
            var s = opcode.ToString();

            if (data != null)
            {
                s = $"{s} => {FormattingUtils.OutputData(data, false)}";
            }
            return(s);
        }
Example #23
0
        public ActionResult Pay(decimal amount, string type, int loanId, int rolloverId)
        {
            try {
                log.Msg("Payment request for customer id {0}, amount {1}", this.context.Customer.Id, amount);

                amount = CalculateRealAmount(type, loanId, amount);
                if (amount < 0)
                {
                    return(View("Error"));
                }

                var oCustomer = this.context.Customer;

                PayPointFacade payPointFacade = new PayPointFacade(
                    oCustomer.MinOpenLoanDate(),
                    oCustomer.CustomerOrigin.Name
                    );

                int      payPointCardExpiryMonths = payPointFacade.PayPointAccount.CardExpiryMonths;
                DateTime cardMinExpiryDate        = DateTime.UtcNow.AddMonths(payPointCardExpiryMonths);

                var callback = Url.Action("Callback", "Paypoint", new {
                    Area = "Customer",
                    loanId,
                    type,
                    username          = (this.context.User != null ? this.context.User.Name : ""),
                    cardMinExpiryDate = FormattingUtils.FormatDateToString(cardMinExpiryDate),
                    hideSteps         = true,
                    payEarly          = true,
                    origin            = oCustomer.CustomerOrigin.Name
                }, "https");

                var url = payPointFacade.GeneratePaymentUrl(oCustomer, amount, callback);

                this.logRepository.Log(
                    this.context.UserId,
                    DateTime.UtcNow,
                    "Paypoint Pay Redirect to " + url,
                    "Successful",
                    ""
                    );

                return(Redirect(url));
            } catch (Exception e) {
                log.Alert(
                    e,
                    "Error while executing Pay(amount = {0}, type = '{1}', loan id = {2}, rollover id = {3}).",
                    amount,
                    type,
                    loanId,
                    rolloverId
                    );
                return(View("Error"));
            }     // try
        }         // Pay
Example #24
0
        private void StorageForm_Load(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();

            var storage = debugger.currentAddress.storage;

            foreach (var entry in storage.entries)
            {
                dataGridView1.Rows.Add(FormattingUtils.OutputData(entry.Key, false), FormattingUtils.OutputData(entry.Value, false, true));
            }
        }
        public void LoadSequenceTest()
        {
            List <object> resultList = debugManager.RunSequence("Method1Method2");

            Assert.AreEqual(2, resultList.Count);
            string name   = FormattingUtils.StackItemAsString((VM.StackItem)resultList[0]);
            string symbol = FormattingUtils.StackItemAsString((VM.StackItem)resultList[1]);

            Assert.AreEqual("BNDES Token", name);
            Assert.AreEqual("BNDT", symbol);
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            int val = 0;

            try
            {
                val = int.Parse(value.ToString());
            }
            catch { }
            return(FormattingUtils.formatReportDuration(val));
        }
Example #27
0
        private void StorageForm_Load(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();

            var storage = _debugger.currentAddress.storage;

            foreach (var entry in storage.entries)
            {
                string hintType = entry.Key.Length == 20 ? "Integer" : "Integer";
                dataGridView1.Rows.Add(FormattingUtils.OutputData(entry.Key, false), FormattingUtils.OutputData(entry.Value, false, hintType));
            }
        }
		} // GetSetupFees

		private IList<FormattedSchedule> CreateSchedule(IEnumerable<LoanScheduleItem> schedule) {
			return schedule.Select((installment, i) => new FormattedSchedule {
				AmountDue = FormattingUtils.NumericFormats(installment.AmountDue),
				Principal = FormattingUtils.NumericFormats(installment.LoanRepayment),
				Interest = FormattingUtils.NumericFormats(installment.Interest),
				Fees = "0",
				Date = FormattingUtils.FormatDateToString(installment.Date),
				StringNumber = FormattingUtils.ConvertingNumberToWords(i + 1),
				InterestRate = string.Format("{0:0.00}", installment.InterestRate * 100),
				Iterration = i + 1,
			}).ToList();
		} // CreateSchedule
Example #29
0
 public static CaisModel FromModel(CaisReportsHistory caisReport)
 {
     return(new CaisModel {
         Id = caisReport.Id,
         CaisUploadStatus = caisReport.UploadStatus.ToString(),
         Date = FormattingUtils.FormatDateTimeToString(caisReport.Date),
         GoodUsers = caisReport.GoodUsers.ToString(),
         FileName = caisReport.FileName,
         Type = caisReport.Type.ToString(),
         OfItems = caisReport.OfItems.ToString(),
         Defaults = caisReport.Defaults.HasValue ? caisReport.Defaults.Value.ToString(CultureInfo.InvariantCulture) : "-"
     });
 }
Example #30
0
        public AudioItem(MediaItem mediaItem) : base(mediaItem)
        {
            MediaItemAspect audioAspect;

            if (mediaItem.Aspects.TryGetValue(AudioAspect.ASPECT_ID, out audioAspect))
            {
                IEnumerable <string> artistsEnumer = audioAspect == null ? null : (IEnumerable <string>)audioAspect[AudioAspect.ATTR_ARTISTS];
                string artists = artistsEnumer == null ? null : StringUtils.Join(", ", artistsEnumer);
                SimpleTitle = Title + (string.IsNullOrEmpty(artists) ? string.Empty : (" (" + artists + ")"));
                double?duration = audioAspect == null ? null : (double?)audioAspect[AudioAspect.ATTR_DURATION];
                Duration = duration.HasValue ? FormattingUtils.FormatMediaDuration(TimeSpan.FromSeconds(duration.Value)) : string.Empty;
            }
        }