Ejemplo n.º 1
0
        // **************************************************************************************************************************
        // ******************************************************     METHODS   *****************************************************
        // **************************************************************************************************************************

        /// <summary> Gets the epm worksheet. </summary>
        /// <returns> </returns>
        public ExcelWorksheet GetEpmWorksheet()
        {
            var funds  = Allocation.GetFunds();
            var awards = Allocation.GetAwards();

            if (funds.Any(p => p.GetCode().GetValue().StartsWith($"{FundCode.B}")))
            {
                try
                {
                    var grid = new Grid(Worksheet, (10, 2));
                    var hdr  = grid.From.Row - 1;
                    var fund = new Fund($"{FundCode.B}");
                    Budget?.SetWorksheetProperties(grid.GetWorksheet());
                    Budget?.SetBudgetHeaderFormat(grid, fund, Allocation.GetBudgetFiscalYear());

                    var prcdata = Allocation.GetData() != null
                        ? Allocation.GetData().Where(f => f.Field <string>($"{Field.FundCode}").StartsWith($"{FundCode.B}")) != null
                            ? Allocation.GetData().Where(f => f.Field <string>($"{Field.FundCode}").StartsWith($"{FundCode.B}")).Where(f => f.Field <string>($"{Field.BocCode}") != $"{BOC.FTE}") != null
                                ? Allocation.GetData().Where(f => f.Field <string>($"{Field.FundCode}").StartsWith($"{FundCode.B}")).Where(f => f.Field <string>($"{Field.BocCode}") != $"{BOC.FTE}").ToLookup(f => f.Field <string>($"{Field.AccountCode}"), f => f)
                                : null
                            : null
                        : null;

                    var start = grid.From.Row;

                    if (prcdata != null)
                    {
                        foreach (var kvp in prcdata)
                        {
                            Budget?.SetAllocationTableFormat(grid, fund);
                            Budget?.PopulateAccountRows(grid, prcdata, kvp);
                            start++;
                        }
                    }

                    var endrow = start;

                    var query = awards?.Where(a => a.GetFundCode().Equals($"{FundCode.B}"))
                                .Select(a => a);

                    if (query?.Any() ?? false)
                    {
                        Budget?.SetAwardsHeaderFormat(grid);
                        Budget?.SetAwardRowsFormat(grid, fund);
                    }

                    return(Worksheet);
                }
                catch (Exception ex)
                {
                    Fail(ex);
                    return(default);
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref = "ExcelBudget"/> class.
 /// </summary>
 /// <param name = "authority" >
 /// The authority.
 /// </param>
 public ExcelBudget(IAuthority authority)
 {
     Excel      = new ExcelPackage(new FileInfo(FilePath));
     Workbook   = Excel.Workbook;
     SheetCount = Workbook.Worksheets.Count;
     Authority  = authority;
     Allocation = Authority.GetAllocation();
     Data       = Allocation.GetData();
     BFY        = Authority.GetBudgetFiscalYear();
     RPIO       = Authority.GetResourcePlanningOffice();
     Fund       = Authority.GetFund();
     AH         = Authority.GetAllowanceHolder();
     ORG        = Authority.GetOrganization();
     RC         = Authority.GetResponsibilityCenter();
     Division   = new Division(RC);
 }