private static int insertRatedCostItem(this IXLWorksheet worksheet, RatedCostSummaryItem item, int row) { IXLRow itemRow = worksheet.Row(row); itemRow.Cell("A").Value = item.RatedCost.Name; itemRow.Cell("B").insertDouble(item.Length); itemRow.Cell("C").Value = item.RatedCost.Type; itemRow.Cell("D").insertDollarDouble(item.RatedCost.Cost); itemRow.Cell("E").insertDollarDouble(item.TotalCost); itemRow.Cell("F").insertDouble(item.RatedCost.Labor); itemRow.Cell("G").insertDouble(item.TotalLabor); row++; return(row); }
protected CostBatch removeRatedCost(ICost cost, double length) { if (length > 0) { bool containsItem = ratedCostDictionary.ContainsKey(cost.Guid); if (containsItem) { RatedCostSummaryItem item = ratedCostDictionary[cost.Guid]; CostBatch delta = item.RemoveLength(length); if (cost.Type == CostType.TEC) { RatedTECCostTotal += delta.GetCost(CostType.TEC); RatedTECLaborTotal += delta.GetLabor(CostType.TEC); } else if (cost.Type == CostType.Electrical) { RatedElecCostTotal += delta.GetCost(CostType.Electrical); RatedElecLaborTotal += delta.GetLabor(CostType.Electrical); } if (item.Length <= 0) { ratedCostDictionary.Remove(cost.Guid); if (cost.Type == CostType.TEC) { _ratedTECItems.Remove(item); } else if (cost.Type == CostType.Electrical) { _ratedElecItems.Remove(item); } } return(delta); } else { logger.Error("Rated cost not found. Cannot remove rated cost length. Cost: {0}", cost.Name); return(new CostBatch()); } } else { return(new CostBatch()); } }
private static List <RatedCostSummaryItem> consolidateRatedCostInConnections(IEnumerable <IControllerConnection> connections) { Dictionary <ICost, RatedCostSummaryItem> dictionary = new Dictionary <ICost, RatedCostSummaryItem>(); List <RatedCostSummaryItem> items = new List <RatedCostSummaryItem>(); List <Tuple <ICost, double> > costs = new List <Tuple <ICost, double> >(); foreach (IControllerConnection connection in connections) { foreach (TECElectricalMaterial mat in connection.Protocol.ConnectionTypes) { foreach (ICost rated in mat.RatedCosts) { costs.Add(new Tuple <ICost, double>(rated, connection.Length)); } } if (connection.ConduitType != null) { foreach (ICost rated in connection.ConduitType.RatedCosts) { costs.Add(new Tuple <ICost, double>(rated, connection.ConduitLength)); } } } foreach (Tuple <ICost, double> cost in costs) { if (dictionary.ContainsKey(cost.Item1)) { dictionary[cost.Item1].AddLength(cost.Item2); } else { RatedCostSummaryItem item = new RatedCostSummaryItem(cost.Item1, cost.Item2); dictionary.Add(cost.Item1, item); items.Add(item); } } return(items); }
protected CostBatch addRatedCost(ICost cost, double length) { bool containsItem = ratedCostDictionary.ContainsKey(cost.Guid); if (containsItem) { RatedCostSummaryItem item = ratedCostDictionary[cost.Guid]; CostBatch delta = item.AddLength(length); if (cost.Type == CostType.TEC) { RatedTECCostTotal += delta.GetCost(CostType.TEC); RatedTECLaborTotal += delta.GetLabor(CostType.TEC); } else if (cost.Type == CostType.Electrical) { RatedElecCostTotal += delta.GetCost(CostType.Electrical); RatedElecLaborTotal += delta.GetLabor(CostType.Electrical); } return(delta); } else { RatedCostSummaryItem item = new RatedCostSummaryItem(cost, length); ratedCostDictionary.Add(cost.Guid, item); if (cost.Type == CostType.TEC) { _ratedTECItems.Add(item); RatedTECCostTotal += item.TotalCost; RatedTECLaborTotal += item.TotalLabor; } else if (cost.Type == CostType.Electrical) { _ratedElecItems.Add(item); RatedElecCostTotal += item.TotalCost; RatedElecLaborTotal += item.TotalLabor; } return(new CostBatch(item.TotalCost, item.TotalLabor, cost.Type)); } }