static void AddPowerToChart(Chart vcChart, TGroupTPResult groupTpResult, IVisualDataRequestObjectsNames getNameInterface, int c, Func <enumPowerFlag, string> getPowerFlagMessage, bool isManySeries, bool isShowMaxPowerLine = false) { if (groupTpResult.PowerHoursList == null || !groupTpResult.PowerHoursList.Any(p => p != null)) { return; //нет нормальных значений, выходим } var titleName = string.Empty; if (groupTpResult.HierarchyObject != null) { titleName = groupTpResult.HierarchyObject.ToString(); } else if (groupTpResult.ID.TypeHierarchy == enumTypeHierarchy.Section) { titleName = getNameInterface.GetSectionName(groupTpResult.ID.ID); } else if (groupTpResult.ID.TypeHierarchy == enumTypeHierarchy.Info_TP) { titleName = getNameInterface.GetTPName(groupTpResult.ID.ID); } Brush colorMax = new SolidColorBrush(Color.FromArgb(0xFF, 0xAE, 0x7F, 0x2B)), colorMaxExcess = new SolidColorBrush(Color.FromRgb(255, 0, 0)), colorMin = new SolidColorBrush(Color.FromRgb(0, 0, 255)); var ser = new DataSeries { Color = GetColorByIndexSeries(c), //Здесь присваиваем цвет LabelEnabled = false, RenderAs = isManySeries ? RenderAs.QuickLine : RenderAs.Line, XValueType = ChartValueTypes.DateTime, Name = titleName, XValueFormatString = "dd.MM.yyyy HH:mm", //MarkerType = MarkerTypes.Circle, MarkerEnabled = false, LineThickness = 1, //Effect = effect, //DataSource = source, }; DataSeries maxPowerSerie = null; if (isShowMaxPowerLine && groupTpResult.PowerMax.HasValue) { maxPowerSerie = new DataSeries { Color = GetColorByIndexSeries(c + 1), //Здесь присваиваем цвет LabelEnabled = false, RenderAs = RenderAs.Line, XValueType = ChartValueTypes.DateTime, Name = @"Pmax - " + titleName, XValueFormatString = "dd.MM.yyyy HH:mm", //MarkerType = MarkerTypes.Circle, MarkerEnabled = false, LineThickness = 1, BorderStyle = BorderStyles.Dotted, //Effect = effect, //DataSource = source, //ToolTip = titleName, }; } ser.BeginInit(); try { foreach (var av in groupTpResult.PowerHoursList) { if (av == null) { return; } //Это новая серия просто заполняем точками var dp = new DataPoint() { XValue = av.EventDateTime, YValue = av.F_VALUE, //AxisXLabel = Mar }; if (getPowerFlagMessage != null) { dp.ToolTipText = titleName + "\n" + av.EventDateTime.ToString("dd.MM.yyyy HH:mm") + " " + av.F_VALUE.ToString("#,##0.######") + "\n" + getPowerFlagMessage(av.PowerFlag); } if (av.PowerFlag.HasFlag(enumPowerFlag.MaxPowerExcess)) { //превышение максимальной мощности dp.MarkerType = MarkerTypes.Triangle; dp.MarkerScale = 2; dp.Color = colorMaxExcess; dp.MarkerEnabled = true; } else if (av.PowerFlag.HasFlag(enumPowerFlag.IsMaxPowerInDay) || av.PowerFlag.HasFlag(enumPowerFlag.IsMaxPowerInDayInSystemOperatorHour)) { dp.MarkerType = MarkerTypes.Circle; dp.MarkerScale = 2; dp.Color = colorMax; dp.MarkerEnabled = true; } else if (av.PowerFlag.HasFlag(enumPowerFlag.IsMinPowerInDay) || av.PowerFlag.HasFlag(enumPowerFlag.IsMinPowerInDayInSystemOperatorHour)) { dp.MarkerType = MarkerTypes.Square; dp.MarkerScale = 2; dp.Color = colorMin; dp.MarkerEnabled = true; } ser.DataPoints.Add(dp); if (isShowMaxPowerLine && groupTpResult.PowerMax.HasValue) { var tt = titleName + "\n" + "P max: " + groupTpResult.PowerMax.Value.ToString("#,##0.######"); if (av.PowerFlag.HasFlag(enumPowerFlag.MaxPowerExcess)) { tt += "\n" + "▲ на : " + (av.F_VALUE - groupTpResult.PowerMax.Value).ToString("#,##0.######"); } maxPowerSerie.DataPoints.Add(new DataPoint { XValue = av.EventDateTime, YValue = groupTpResult.PowerMax.Value, ToolTip = tt, ToolTipText = tt //AxisXLabel = Mar }); } } //foreach } finally { ser.EndInit(); } vcChart.Series.Add(ser); if (isShowMaxPowerLine && groupTpResult.PowerMax.HasValue) { vcChart.Series.Add(maxPowerSerie); } }
public ExtendedXlsFile TestExecuteBalansHierLev0_Valtage_220_330_Full(BalansHierLev0Result HierLev0, TExportExcelAdapterType ExportType, IVisualDataRequestObjectsNames getNameInterface) { Dictionary <ID_TypeHierarchy, string> dictionaryOfNames = HierLev0.DictionaryOfNames; InitData data = new InitData(HierLev0.VoltageClassPoints); InternalData internalData = new InternalData(ExportType); InitBlock initBlock = new InitBlock(data, internalData); Classes.TitleInfo titleData = new Classes.TitleInfo(getNameInterface.GetBalanceNameForHierLev0(HierLev0.BalanceId), HierLev0.DTStart, HierLev0.DTEnd); TitleBlock titleBlock = new TitleBlock(titleData); initBlock.AddBlock(titleBlock); HeaderFooterData headFootData = new HeaderFooterData(HierLev0.VoltageClass, HierLev0.HighLimit); HeaderFooterBlock headerFooter = new HeaderFooterBlock(headFootData, internalData); initBlock.AddBlock(headerFooter); foreach (TIntegral_HierLev0_Values balanceSection in HierLev0.Result_Values) { BalancePartData balData = new BalancePartData(getNameInterface.GetBalanceSectionName(balanceSection.HierLev0Group_Name), HierLev0.BalPartList.Where(x => x.IsUseInGeneralBalance).Select(x => x.Name).Contains(balanceSection.HierLev0Group_Name), HierLev0.BalPartList.Where(x => x.IsRsk).Select(x => x.Name).Contains(balanceSection.HierLev0Group_Name)); BalancePartBlock balPartBlock = new BalancePartBlock(balData, internalData); foreach (KeyValuePair <ID_IsOurSide, TIntegral_PS_ValuesForHierLev0> psBalSect in balanceSection.HierLev0DetailGroupResult) { string psName; TIntegral_PS_ValuesForHierLev0 psBalSectData = psBalSect.Value; ID_IsOurSide side = psBalSect.Key; ID_TypeHierarchy key = new ID_TypeHierarchy(enumTypeHierarchy.Dict_PS, -1); key.TypeHierarchy = side.IsOurSide ? enumTypeHierarchy.Dict_PS : enumTypeHierarchy.Dict_Contr_PS; key.ID = side.ID; if (!dictionaryOfNames.TryGetValue(key, out psName)) { psName = getNameInterface.GetPSName(side.ID, !side.IsOurSide); } PsBlock psBlock = new PsBlock(psName, internalData); foreach (TI_Integral_ValuesForHierLev0 tiPsBalSect in psBalSectData.TI_List) { string tIName = string.Empty; key.TypeHierarchy = tiPsBalSect.TypeHierarchy; key.ID = tiPsBalSect.ID; if (!dictionaryOfNames.TryGetValue(key, out tIName)) { switch (tiPsBalSect.TypeHierarchy) { case enumTypeHierarchy.Dict_PS: tIName = getNameInterface.GetPSName(tiPsBalSect.ID, !side.IsOurSide); break; case enumTypeHierarchy.Info_TI: tIName = getNameInterface.GetTIName(tiPsBalSect.ID, false); break; case enumTypeHierarchy.Info_ContrTI: tIName = getNameInterface.GetTIName(tiPsBalSect.ID, true); break; case enumTypeHierarchy.Info_TP: tIName = getNameInterface.GetTPName(tiPsBalSect.ID); break; } } List <TVALUES_DB> inputValues; List <TVALUES_DB> outputValues; Data.Full.TiData tiData = new Data.Full.TiData(tIName); if (tiPsBalSect.Val_List.TryGetValue(1, out inputValues)) { tiData.InputByVoltages.Add(tiPsBalSect.VoltageClassPoint, inputValues[0]); } if (tiPsBalSect.Val_List.TryGetValue(2, out outputValues)) { tiData.OutputByVoltages.Add(tiPsBalSect.VoltageClassPoint, outputValues[0]); } TiBlock tiBlock = new TiBlock(tiData, internalData); psBlock.AddBlock(tiBlock); } balPartBlock.AddBlock(psBlock); } headerFooter.AddBlock(balPartBlock); } ExtendedXlsFile xls = new ExtendedXlsFile(ExportType); initBlock.Render(xls); return(xls); }
public ExtendedXlsFile TestExecuteBalansHierLev0_Valtage_220_330_Interval(BalansHierLev0Result HierLev0, TExportExcelAdapterType ExportType, IVisualDataRequestObjectsNames getNameInterface) { Dictionary <ID_TypeHierarchy, string> dictionaryOfNames = HierLev0.DictionaryOfNames; InternalData internalData = new InternalData(ExportType, HierLev0.NumbersValues); InitBlock initBlock = new InitBlock(internalData); Classes.TitleInfo titleData = new Classes.TitleInfo(getNameInterface.GetBalanceNameForHierLev0(HierLev0.BalanceId), HierLev0.DTStart, HierLev0.DTEnd); TitleBlock titleBlock = new TitleBlock(titleData); initBlock.AddBlock(titleBlock); List <DateTime> dateTimeListForPeriod = getNameInterface.GetDateTimeListForPeriod(HierLev0.DTStart, HierLev0.DTEnd, HierLev0.DiscreteType, HierLev0.IsSummerOrWinter); List <DateTimePeriod> dateTimePeriods = new List <DateTimePeriod>(); for (int i = 0; i < dateTimeListForPeriod.Count; i += 1) { var dateList = dateTimeListForPeriod.GetRange(i, Math.Min(2, dateTimeListForPeriod.Count - i)); if (dateList.Count > 1) { dateTimePeriods.Add(new DateTimePeriod(dateList[0], dateList[1])); } } dateTimePeriods.Add(new DateTimePeriod(dateTimeListForPeriod.Max(), HierLev0.DTEnd.AddMinutes(30))); HeaderFooterBlock headerFooter = new HeaderFooterBlock(new Data.HeaderFooterData(HierLev0.VoltageClass, dateTimePeriods)); initBlock.AddBlock(headerFooter); foreach (TIntegral_HierLev0_Values balanceSection in HierLev0.Result_Values) { BalansHierLev0.Data.Full.BalancePartData balData = new BalansHierLev0.Data.Full.BalancePartData(getNameInterface.GetBalanceSectionName(balanceSection.HierLev0Group_Name), HierLev0.BalPartList.Where(x => x.IsUseInGeneralBalance).Select(x => x.Name).Contains(balanceSection.HierLev0Group_Name), HierLev0.BalPartList.Where(x => x.IsRsk).Select(x => x.Name).Contains(balanceSection.HierLev0Group_Name)); BalancePartBlock balPartBlock = new BalancePartBlock(balData); foreach (KeyValuePair <ID_IsOurSide, TIntegral_PS_ValuesForHierLev0> psBalSect in balanceSection.HierLev0DetailGroupResult) { string psName; TIntegral_PS_ValuesForHierLev0 psBalSectData = psBalSect.Value; ID_IsOurSide side = psBalSect.Key; ID_TypeHierarchy key = new ID_TypeHierarchy(enumTypeHierarchy.Dict_PS, -1); key.TypeHierarchy = side.IsOurSide ? enumTypeHierarchy.Dict_PS : enumTypeHierarchy.Dict_Contr_PS; key.ID = side.ID; if (!dictionaryOfNames.TryGetValue(key, out psName)) { psName = getNameInterface.GetPSName(side.ID, !side.IsOurSide); } PsBlock psBlock = new PsBlock(psName); foreach (TI_Integral_ValuesForHierLev0 tiPsBalSect in psBalSectData.TI_List) { string tIName = string.Empty; key.TypeHierarchy = tiPsBalSect.TypeHierarchy; key.ID = tiPsBalSect.ID; if (!dictionaryOfNames.TryGetValue(key, out tIName)) { switch (tiPsBalSect.TypeHierarchy) { case enumTypeHierarchy.Dict_PS: tIName = getNameInterface.GetPSName(tiPsBalSect.ID, !side.IsOurSide); break; case enumTypeHierarchy.Info_TI: tIName = getNameInterface.GetTIName(tiPsBalSect.ID, false); break; case enumTypeHierarchy.Info_ContrTI: tIName = getNameInterface.GetTIName(tiPsBalSect.ID, true); break; case enumTypeHierarchy.Info_TP: tIName = getNameInterface.GetTPName(tiPsBalSect.ID); break; } } List <TVALUES_DB> inputValues; List <TVALUES_DB> outputValues; Data.TiData tiData = new Data.TiData(tIName); if (tiPsBalSect.Val_List.TryGetValue(1, out inputValues)) { tiData.InputInterval = inputValues.Select(x => new TVALUES_DB(x.F_FLAG, x.F_VALUE / 1000)).ToList(); } if (tiPsBalSect.Val_List.TryGetValue(2, out outputValues)) { tiData.OutputInterval = outputValues.Select(x => new TVALUES_DB(x.F_FLAG, x.F_VALUE / 1000)).ToList(); } TiBlock tiBlock = new TiBlock(tiData); psBlock.AddBlock(tiBlock); } balPartBlock.AddBlock(psBlock); } headerFooter.AddBlock(balPartBlock); } ExtendedXlsFile xls = new ExtendedXlsFile(ExportType); initBlock.Render(xls); return(xls); }