private DataTable BuildResourceChartDataTable()
        {
            lock (m_Lock)
            {
                var table = new DataTable();
                IList <ResourceSeriesDto> seriesSet = ResourceSeriesSet.OrderBy(x => x.DisplayOrder).ToList();
                if (seriesSet != null &&
                    seriesSet.Any())
                {
                    table.Columns.Add(new DataColumn(Properties.Resources.Label_TimeAxisTitle));

                    // Create the column titles.
                    for (int seriesIndex = 0; seriesIndex < seriesSet.Count; seriesIndex++)
                    {
                        var column = new DataColumn(seriesSet[seriesIndex].Title, typeof(int));
                        table.Columns.Add(column);
                    }

                    m_DateTimeCalculator.UseBusinessDays(UseBusinessDays);

                    // Pivot the series values.
                    int valueCount = seriesSet.Max(x => x.Values.Count);
                    for (int timeIndex = 0; timeIndex < valueCount; timeIndex++)
                    {
                        var rowData = new List <object>
                        {
                            ChartHelper.FormatScheduleOutput(timeIndex, ShowDates, ProjectStart, m_DateTimeCalculator)
                        };
                        rowData.AddRange(seriesSet.Select(x => x.Values[timeIndex] * (ExportResourceChartAsCosts ? x.UnitCost : 1)).Cast <object>());
                        table.Rows.Add(rowData.ToArray());
                    }
                }
                return(table);
            }
        }
Пример #2
0
        public void CalculateCosts()
        {
            lock (m_Lock)
            {
                IList <IResourceSchedule <int> > resourceSchedules = GraphCompilation?.ResourceSchedules;
                IList <ResourceDto> resources = ResourceSettingsDto.Resources;

                if (resourceSchedules == null || resources == null)
                {
                    return;
                }

                IList <ResourceSeriesDto> resourceSeriesSet = m_ProjectManager.CalculateResourceSeriesSet(resourceSchedules, resources, ResourceSettingsDto.DefaultUnitCost);
                ResourceSeriesSet.Clear();
                foreach (ResourceSeriesDto series in resourceSeriesSet)
                {
                    ResourceSeriesSet.Add(series);
                }

                ClearCosts();
                if (HasCompilationErrors)
                {
                    return;
                }

                CostsDto costs = m_ProjectManager.CalculateProjectCosts(resourceSeriesSet);
                DirectCost   = costs.DirectCost;
                IndirectCost = costs.IndirectCost;
                OtherCost    = costs.OtherCost;
                TotalCost    = costs.TotalCost;
            }
        }
 private bool CanExportResourceChartToCsv()
 {
     lock (m_Lock)
     {
         return(ResourceSeriesSet.Any());
     }
 }
 public void ClearCosts()
 {
     lock (m_Lock)
     {
         ResourceSeriesSet.Clear();
         DirectCost   = null;
         IndirectCost = null;
         OtherCost    = null;
         TotalCost    = null;
     }
 }