Ejemplo n.º 1
0
        public ActionResult Input(Deferred InputForm, string ButtonType)
        {
            String Scheme = this.Request.RequestContext.RouteData.DataTokens["area"].ToString();
            String CalcType = this.ControllerContext.RouteData.Values["controller"].ToString();

            object Calculation = Calculate(InputForm, Scheme, CalcType, InputForm.CalcReference, false);
            string InputXML = xmlfunction.XMLStringBuilder(InputForm);
            string OutputXML = xmlfunction.XMLStringBuilder(Calculation);

            if (ButtonType == "Download")
            {
                List<OutputList> Output = new List<OutputList>();
                Output = Calculation as List<OutputList>;
                return new DownloadFileActionResult(Output, "Output.xls");
            }
            else if (ButtonType == "Regression")
            {
                CalculationRegressionAdd(InputXML, OutputXML, InputForm.CalcReference, Scheme, CalcType, false);
                return RedirectToAction("Input");
            }
            else
            {
                return PartialView("_Output", Calculation);
            }
        }
        public virtual ActionResult Upload(FormCollection formCollection)
        {
            if (Request != null)

            {
                string OutputString = "";
                StringFunctions StringFunctions = new StringFunctions();

                HttpPostedFileBase file = Request.Files["UploadedFile"];

                if ((file != null) && (file.ContentLength > 0) && !string.IsNullOrEmpty(file.FileName))

                {

                    string fileName = file.FileName;

                    string fileContentType = file.ContentType;

                    byte[] fileBytes = new byte[file.ContentLength];

                    var data = file.InputStream.Read(fileBytes, 0, Convert.ToInt32(file.ContentLength));

                    var usersList = new List<Deferred>();

                    using (var package = new ExcelPackage(file.InputStream))

                    {

                        var currentSheet = package.Workbook.Worksheets;

                        var workSheet = currentSheet.First();

                        var noOfCol = workSheet.Dimension.End.Column;

                        var noOfRow = workSheet.Dimension.End.Row;

                        for (int colIterator = 2; colIterator <= noOfCol; colIterator++)

                        {

                            var model = new Deferred();
                            var properties = new Dictionary<string, object>();
                            var i = 1;

                            foreach (var prop in model.GetType().GetProperties())
                            {

                                var Value = workSheet.Cells[i, colIterator].Value == null ? string.Empty : workSheet.Cells[i, colIterator].Value.ToString();

                                DateTime dateTime;
                                double number;

                                if (DateTime.TryParse(Value, out dateTime))
                                {

                                    prop.SetValue(model, dateTime, null);

                                }
                                else if (Double.TryParse(Value, out number))
                                {
                                    prop.SetValue(model, number, null);
                                }
                                else if (Value == "")
                                {
                                    prop.SetValue(model, null, null);
                                }
                                else
                                {
                                    prop.SetValue(model, Value, null);
                                }

                                i = i + 1;

                            }

                            usersList.Add(model);

                        }

                        var stringBuilder = new StringBuilder();

                        Response.ClearContent();
                        Response.AddHeader("content-disposition", "attachment;filename=Output.csv");

                        Response.ContentType = "text/csv";

                        int HeaderRow = 0;

                        foreach (var Member in usersList)
                        {
                            DeferredFunctions List = new DeferredFunctions();
                            List.Setup(Member);
                            OutputString = StringFunctions.BulkCalc(List.List, HeaderRow, stringBuilder);
                            HeaderRow = 1;
                        }
                        Response.Write(OutputString);
                        Response.End();
                    }
                }
            }

            return View("Index");
        }
Ejemplo n.º 3
0
        public object Setup(object Input)
        {
            InputForm = Input as Deferred;
            getFactors();

            List.Add(new OutputList { ID = "EGC1.0", Field = "Calculation Reference", Value = Convert.ToString(InputForm.CalcReference), Group = "Deferred Calculation"});
            List.Add(new OutputList { ID = "EGC1.1", Field = "Hypothetical Pension", Value = Convert.ToString(getHypotheticalPension()), Group = "Deferred Calculation"});
            List.Add(new OutputList { ID = "EGC1.2", Field = "Base Pension", Value = Convert.ToString(getBasePension()), Group = "Deferred Calculation"});
            List.Add(new OutputList { ID = "EGC1.4", Field = "Total Contributions", Value = Convert.ToString(getTotalCPDPension()), Group = "Deferred Calculation"});
            List.Add(new OutputList { ID = "EGC1.5", Field = "Added Years Pension", Value = Convert.ToString(getAddedYearsPension()), Group = "Deferred Calculation"});
            List.Add(new OutputList { ID = "EGC1.6", Field = "Total Gross Pension", Value = Convert.ToString(getTotalGrossPension()), Group = "Deferred Calculation"});
            List.Add(new OutputList { ID = "EGC1.7", Field = "PI on Pension", Value = Convert.ToString(getPIonPension()), Group = "Deferred Calculation"});
            List.Add(new OutputList { ID = "EGC1.8", Field = "Current Value of Pension Debit", Value = Convert.ToString(InputForm.CVofPensionDebit), Group = "Deferred Calculation"});
            List.Add(new OutputList { ID = "EGC1.9", Field = "Total Gross Pension at Exit", Value = Convert.ToString(getTotalGrossPensionatExit()), Group = "Deferred Calculation"});
            List.Add(new OutputList { ID = "EGC1.10", Field = "Total Pension at Exit", Value = Convert.ToString(getTotalPensionatExit()), Group = "Deferred Calculation" });
            List.Add(new OutputList { ID = "EGI1.1", Field = "Date of Leaving", Value = Convert.ToString(InputForm.DOL.ToShortDateString()), Group = "Deferred Calculation" });
            List.Add(new OutputList { ID = "EGI1.2", Field = "Average Pensionable Pay", Value = Convert.ToString(InputForm.APP), Group = "Deferred Calculation" });
            List.Add(new OutputList { ID = "EGI1.4", Field = "Pension Increase Date Overide", Value = Convert.ToString(InputForm.PIDateOverride.ToShortDateString()), Group = "Deferred Calculation" });
            List.Add(new OutputList { ID = "EGI2.1", Field = "Date of Birth", Value = Convert.ToString(InputForm.DOB.Date), Group = "Member Details" });
            List.Add(new OutputList { ID = "EGI2.2", Field = "Marital Status", Value = Convert.ToString(InputForm.MarStat), Group = "Member Details" });
            List.Add(new OutputList { ID = "EGI2.3", Field = "Date Joined Scheme", Value = Convert.ToString(InputForm.DJS.Date), Group = "Member Details" });
            List.Add(new OutputList { ID = "EGI2.4", Field = "Added Years Service", Value = Convert.ToString(InputForm.AddedYrsService), Group = "Member Details" });
            List.Add(new OutputList { ID = "EGI2.5", Field = "Transferred in Service", Value = Convert.ToString(InputForm.TransInService), Group = "Member Details" });
            List.Add(new OutputList { ID = "EGI2.6", Field = "Part Time Service", Value = Convert.ToString(InputForm.PartTimeService), Group = "Member Details" });
            List.Add(new OutputList { ID = "EGI2.7", Field = "Breaks", Value = Convert.ToString(InputForm.Breaks), Group = "Member Details" });
            List.Add(new OutputList { ID = "EGI2.9", Field = "Hypothetical Pension Date", Value = Convert.ToString(getHypotheticalPensionDate()), Group = "Member Details" });
            List.Add(new OutputList { ID = "EGI3.1", Field = "Age at Date of leaving", Value = Convert.ToString(getAgeatDOL()), Group = "Dates Ages & Factors" });
            List.Add(new OutputList { ID = "EGI3.2", Field = "Calculation Date", Value = Convert.ToString(InputForm.CalcDate.ToShortDateString()), Group = "Dates Ages & Factors" });
            List.Add(new OutputList { ID = "EGI3.3", Field = "Eligible Payment Date", Value = Convert.ToString(getEligiblePaymentDate().ToShortDateString()), Group = "Dates Ages & Factors" });
            List.Add(new OutputList { ID = "EGI3.4", Field = "Pension Increase Factor", Value = Convert.ToString(setPensionIncreaseFactor), Group = "Dates Ages & Factors" });
            List.Add(new OutputList { ID = "EGI4.1", Field = "Total Pension Service", Value = Convert.ToString(getTotalPensionService()), Group = "Service" });
            List.Add(new OutputList { ID = "EGI4.2", Field = "Potential Pensionable Service to HRA", Value = Convert.ToString(getPotentialPensionableServicetoHRA()), Group = "Service" });
            List.Add(new OutputList { ID = "EGI4.3", Field = "Total Entitlement Service", Value = Convert.ToString(getTotalEntitlementService()), Group = "Service" });
            List.Add(new OutputList { ID = "EGI4.4", Field = "Part Time Adjustment", Value = Convert.ToString(getPartTimeAdjustment()), Group = "Service" });
            List.Add(new OutputList { ID = "EGI4.5", Field = "Total Post 88 Pension Service", Value = Convert.ToString(getTotalPost88PensionService()), Group = "Service" });
            List.Add(new OutputList { ID = "EGI4.6", Field = "Total Service for Survivor Requisite Benefit Pension", Value = Convert.ToString(getTotalServiceSurvivorRequisiteBenefitPension()), Group = "Service" });
            List.Add(new OutputList { ID = "EGR1.1", Field = "Date Effective", Value = Convert.ToString(getAADateEffective()), Group = "Annual Allowance" });
            List.Add(new OutputList { ID = "EGR1.2", Field = "AVC Contributions", Value = Convert.ToString(InputForm.SumAVCCont), Group = "Annual Allowance" });
            List.Add(new OutputList { ID = "EGR1.3", Field = "Annual Allowance Pension", Value = Convert.ToString(getAnnualAllowancePension()), Group = "Annual Allowance" });
            List.Add(new OutputList { ID = "EGR2.1", Field = "Survivor Contingent Pension", Value = Convert.ToString(getSurvivorContingentPension()), Group = "Survivor Benefits" });
            List.Add(new OutputList { ID = "EGR2.2", Field = "PI on Contingent Survivor Pension", Value = Convert.ToString(getPIonSurvivorContingentPension()), Group = "Survivor Benefits" });
            List.Add(new OutputList { ID = "EGR2.3", Field = "Survivor LSI Pension", Value = Convert.ToString(getSurvivorLSIPension()), Group = "Survivor Benefits" });
            List.Add(new OutputList { ID = "EGR2.4", Field = "Survivor CPD Pension", Value = Convert.ToString(getSurvivorCPDPension()), Group = "Survivor Benefits" });
            List.Add(new OutputList { ID = "EGR2.5", Field = "Total Contingent Survivor Pension", Value = Convert.ToString(getTotalContingentSurvivorPension()), Group = "Survivor Benefits" });
            List.Add(new OutputList { ID = "EGR2.6", Field = "Survivor's Requisite Benefit Pension", Value = Convert.ToString(getSurvivorRequisiteBenefitPension()), Group = "Survivor Benefits" });

            return List;
        }