Пример #1
0
        private IProjectionViewModel MappProjectionViewModelModel(
            ConvertCurrencyViewModel projectionsModel)
        {
            OperationLevelProjectionsViewModel model = new OperationLevelProjectionsViewModel()
            {
                Balance       = projectionsModel.Balance,
                Cancellations = projectionsModel.Cancellations,
                CurrentDisbursementExpirationDate =
                    projectionsModel.CurrentDisbursementExpirationDate,
                CurrentProjectionMonth = projectionsModel.CurrentProjectionMonth,
                Disbursement           = default(decimal),
                IsExecution            = projectionsModel.IsExecution,
                IsOperationLevel       = false,
                OldProjection          = projectionsModel.OldProjection,
                OtherFinancingSources  = projectionsModel.OtherFinancingSources,
                PCMailId           = string.Empty,
                ProjectedMonths    = null,
                ProjectedYears     = projectionsModel.ProjectedYears,
                ProjectedYearsList = null,
                Projects           = null,
                RemainingBalance   = projectionsModel.RemainingBalance,
                SumofProjections   = default(decimal),
                Total = projectionsModel.Total,
                TotalProjectionFinancialPlan = default(decimal),
                UndisbursedBalance           = default(decimal)
            };

            return((IProjectionViewModel)model);
        }
Пример #2
0
        public virtual ActionResult GetGraphData(Models.GraphModel graphData)
        {
            var ajaxResult = new Dictionary <string, string>();

            try
            {
                var    result            = new Dictionary <string, List <decimal?[]> >();
                string operationNumber   = graphData.OperationNumber;
                string group             = graphData.Group;
                string pcMail            = IDBContext.Current.UserName;
                var    currentExpiration = graphData.CurrentDisbursementExpirationDate;

                var projectionMatrix = new OperationLevelProjectionsViewModel()
                {
                    ProjectedMonths = graphData.ProjectedMonths != null
                   ? graphData.ProjectedMonths.ConvertToModel()
                   : new List <MW.Domain.Models.Disbursement.ProjectedMonthYearModel>()
                };

                _disbursementService.CalculateGraphPoints(
                    result,
                    projectionMatrix,
                    operationNumber,
                    pcMail,
                    group == DisbursementValues.GROUPED,
                    currentExpiration);

                ajaxResult[DisbursementValues.ACTION] =
                    DisbursementValues.CALL_FUNCTION_PARAMETERED;
                ajaxResult[DisbursementValues.CALL_FUNCTION_FN] =
                    DisbursementValues.DISBURSEMENT_SHOW_GRAPH;
                ajaxResult[DisbursementValues.CALL_FUNCTION_PARAMETERS] =
                    string.Format(
                        DisbursementValues.STRING_FORMAT,
                        new JavaScriptSerializer().Serialize(result));
            }
            catch (Exception e)
            {
                ajaxResult[DisbursementValues.ACTION]     = DisbursementValues.SHOW_ERROR;
                ajaxResult[DisbursementValues.ERROR_TEXT] = e.Message;
                Logger.GetLogger()
                .WriteMessage(
                    DisbursementValues.OPERATION_LEVEL_PROJECTIONS_CONTROLLER,
                    e.Message + e.StackTrace);
            }

            return(Content(new JavaScriptSerializer().Serialize(ajaxResult)));
        }
        public virtual FileResult DownloadReportByLonNumber(
            string operationNumber,
            string loanNumber,
            string fundCode,
            string loanTcdNum,
            string loanProjectNumber,
            string loanCurrencyCode,
            string format = "",
            string group  = DisbursementValues.SELECTED)
        {
            if ((format == DisbursementValues.PDF) || (format == DisbursementValues.EXCEL))
            {
                string pcMail = IDBContext.Current.UserName;

                OperationLevelProjectionsViewModel model;
                var projectionMatrix = _disbursementService.GetProjectionMatrixWithCache(
                    null,
                    operationNumber,
                    pcMail,
                    loanNumber,
                    fundCode,
                    loanTcdNum,
                    loanProjectNumber,
                    loanCurrencyCode);

                var oldProjection = _disbursementService.GetMonthlyProyections(
                    operationNumber,
                    projectionMatrix.CurrentProjectionMonth,
                    false,
                    projectionMatrix.IsExecution,
                    new string[] { loanNumber });

                model =
                    new OperationLevelProjectionsViewModel
                {
                    ProjectedMonths        = projectionMatrix.ProjectedMonths,
                    ProjectedYears         = projectionMatrix.ProjectedYears,
                    OldProjection          = oldProjection,
                    CurrentProjectionMonth = projectionMatrix.CurrentProjectionMonth,
                    Balance = projectionMatrix.Balance
                };

                var exportModel = _disbursementService.FormatOperationLevelModelToExport(model);

                try
                {
                    DownloadDisbursementReportResponse response = _disbursementService
                                                                  .DownloadDisbursementProjectionsReport(exportModel, format);
                    if (!response.IsValid)
                    {
                        throw new Exception(DisbursementValues.MSJ_ERROR_EXPORT
                                            + DisbursementValues.UNDERLINE_STRING + response.ErrorMessage);
                    }

                    string fileName = IDBContext.Current.Operation
                                      + DisbursementValues.UNDERLINE_STRING
                                      + Localization.GetText(DisbursementValues.DISBURSEMENT_PROJECTIONS)
                                      + Localization.GetText(DisbursementValues.LOAN_LEVEL);
                    string application;
                    switch (format)
                    {
                    case DisbursementValues.EXCEL:
                        application = MimeTypeMap.GetMimeType(DisbursementValues.EXCEL);
                        fileName    = fileName + DisbursementValues.DOT_STRING +
                                      DisbursementValues.EXCEL;
                        break;

                    default:
                        application = MimeTypeMap.GetMimeType(DisbursementValues.PDF);
                        fileName    = fileName + DisbursementValues.DOT_STRING +
                                      DisbursementValues.PDF;
                        break;
                    }

                    return(File(response.File, application, fileName));
                }
                catch (Exception)
                {
                    MessageHandler.SetMessage(
                        Localization.GetText(DisbursementValues.WARNING_UNHANDLED_ERROR),
                        DisbursementValues.ERROR);
                }
            }

            return(null);
        }