protected int GenerateEmissionsReport() { int status = 0; try { DateTime fromDate = (DateTime)radDateFrom.SelectedDate; fromDate = new DateTime(fromDate.Year, fromDate.Month, 1); DateTime toDate = (DateTime)radDateTo.SelectedDate; toDate = new DateTime(toDate.Year, toDate.Month, DateTime.DaysInMonth(toDate.Year, toDate.Month)); SQMMetricMgr metricMgr = new SQMMetricMgr().CreateNew(SessionManager.PrimaryCompany(), "E", fromDate, toDate, PlantIDS); //metricMgr.Load(DateIntervalType.month, DateSpanOption.SelectRange); //CalcsResult rslt = metricMgr.CalcsMethods(PlantIDS, "E", "ghg|co2,ch4,n2o", "gwp100|sum", 22, (int)EHSCalcsCtl.SeriesOrder.YearMeasurePlant); metricMgr.Load(DateIntervalType.span, DateSpanOption.SelectRange); CalcsResult rslt = metricMgr.CalcsMethods(PlantIDS, "E", "ghg|co2,ch4,n2o", "gwp100|sum", 22, (int)EHSCalcsCtl.SeriesOrder.MeasurePlant, "", ""); EHSModel.GHGResultList ghgTable = (EHSModel.GHGResultList)rslt.ResultObj; uclGHG.BindGHGReport(ghgTable); divGHG.Visible = true; SetLocalDataset(metricMgr); } catch { status = -1; } return(status); }
public void GenerateEmissionsReport() { string plantList = ""; foreach (RadComboBoxItem item in SQMBasePage.GetComboBoxCheckedItems(ddlExportPlantSelect)) { if (radExportDateSelect1.SelectedDate != null) { if (plantList.Length > 0) { plantList += ", "; } plantList += item.Value; } } try { decimal[] plantArray = Array.ConvertAll(plantList.Split(','), new Converter <string, decimal>(decimal.Parse)); SQMMetricMgr metricMgr = new SQMMetricMgr().CreateNew(SessionManager.PrimaryCompany(), "E", radExportDateSelect1.SelectedDate.Value, radExportDateSelect2.SelectedDate.Value, plantArray); metricMgr.Load(DateIntervalType.month, DateSpanOption.SelectRange); CalcsResult rslt = metricMgr.CalcsMethods(plantArray, "E", "ghg|co2,ch4,n2o", "gwp100|sum", 22, (int)EHSCalcsCtl.SeriesOrder.YearMeasurePlant); EHSModel.GHGResultList ghgTable = (EHSModel.GHGResultList)rslt.ResultObj; uclGHGReport.BindGHGReport(ghgTable); } catch { } }
public CalcsResult DaysElapsedLTC(COMPANY company, decimal[] plantArray) { CalcsResult results = new CalcsResult().Initialize(); SQMMetricMgr metricMgr = new SQMMetricMgr().CreateNew(company, "HS", DateTime.Now, DateTime.Now, plantArray).Load(DateIntervalType.fuzzy, DateSpanOption.SelectRange); metricMgr.CalcsMethods(plantArray, "HS", "63", SStat.deltaDy.ToString(), 5, 1); results = metricMgr.ehsCtl.Results; if (!results.ValidResult) { PLANT plant = SQMModelMgr.LookupPlant(plantArray[0]); if (plant != null && plant.PLANT_START_DT.HasValue) { results.Result = (decimal)Math.Truncate(DateTime.Now.Subtract((DateTime)plant.PLANT_START_DT).TotalDays); results.ValidResult = true; } } return(results); }
protected void Page_Load(object sender, EventArgs e) { this.divTitle.InnerText = this.Title; this.rgReport.DataSource = this.Data; this.rgReport.DataBind(); EHS.EHS_PerformanceReport.gaugeDef.Height = 500; EHS.EHS_PerformanceReport.gaugeDef.Title = "TOTAL RECORDABLE INCIDENT RATE"; EHS.EHS_PerformanceReport.gaugeDef.Target = new PERSPECTIVE_TARGET() { TARGET_VALUE = this.IncidentRateTarget, DESCR_SHORT = "Target" }; var series = new List <GaugeSeries>() { this.IncidentRateSeries, this.IncidentRateTrendSeries }; WebSiteCommon.SetScale(EHS.EHS_PerformanceReport.gaugeDef, series); this.uclChart.CreateMultiLineChart(EHS.EHS_PerformanceReport.gaugeDef, series, this.divTRIR); var calcsResult = new CalcsResult().Initialize(); EHS.EHS_PerformanceReport.gaugeDef.Title = "FREQUENCY RATE"; EHS.EHS_PerformanceReport.gaugeDef.Target = null; WebSiteCommon.SetScale(EHS.EHS_PerformanceReport.gaugeDef, this.FrequencyRateSeries); calcsResult.metricSeries = this.FrequencyRateSeries; this.uclChart.CreateControl(SQMChartType.ColumnChartGrouped, EHS.EHS_PerformanceReport.gaugeDef, calcsResult, this.divFrequencyRate); EHS.EHS_PerformanceReport.gaugeDef.Title = "SEVERITY RATE"; WebSiteCommon.SetScale(EHS.EHS_PerformanceReport.gaugeDef, this.SeverityRateSeries); calcsResult.metricSeries = this.SeverityRateSeries; this.uclChart.CreateControl(SQMChartType.ColumnChartGrouped, EHS.EHS_PerformanceReport.gaugeDef, calcsResult, this.divSeverityRate); if (this.Data[12].Incidents == 0 && this.Data[12].FirstAid == 0) { this.divPie1.Visible = this.divPie2.Visible = this.divPie3.Visible = false; } else { this.divPie1.Visible = this.divPie2.Visible = this.divPie3.Visible = true; this.pieRecordableType.Values = this.OrdinalTypeSeries; this.pieRecordableBodyPart.Values = this.OrdinalBodyPartSeries; this.pieRecordableRootCause.Values = this.OrdinalRootCauseSeries; this.pieRecordableTenure.Values = this.OrdinalTenureSeries; this.pieRecordableDaysToClose.Values = this.OrdinalDaysToCloseSeries; } EHS.EHS_PerformanceReport.smallGaugeDef.Title = "Current Indicators - JSAs & Combined Audits"; EHS.EHS_PerformanceReport.smallGaugeDef.Target = new PERSPECTIVE_TARGET() { TARGET_VALUE = this.JSAsTarget, DESCR_SHORT = "Target" }; series = new List <GaugeSeries>() { this.JSAsSeries, this.JSAsTrendSeries }; WebSiteCommon.SetScale(EHS.EHS_PerformanceReport.smallGaugeDef, series); this.uclChart.CreateMultiLineChart(EHS.EHS_PerformanceReport.smallGaugeDef, series, this.divJSAsAndAudits_Metrics); EHS.EHS_PerformanceReport.smallGaugeDef.Title = "Safety Training Hours"; EHS.EHS_PerformanceReport.smallGaugeDef.Target = null; series = new List <GaugeSeries>() { this.SafetyTrainingHoursSeries, this.SafetyTrainingHoursTrendSeries }; WebSiteCommon.SetScale(EHS.EHS_PerformanceReport.smallGaugeDef, series); this.uclChart.CreateMultiLineChart(EHS.EHS_PerformanceReport.smallGaugeDef, series, this.divSafetyTrainingHours_Metrics); }
public CalcsResult CalcsMethods(decimal[] plantArray, string itemCalcsMethod, string calcsScope, string calcsStat, int controlType, int seriesOrder) { if (controlType == 1 || string.IsNullOrEmpty(calcsScope)) { return(new CalcsResult().Initialize()); } CalcsResult rslt = null; string calcsMethod = itemCalcsMethod; if (this.perspective == "HS") // determine which data set for EH metrics (incidents or plant-accounting) { string[] ids = calcsScope.Split(','); int id = 0; if (int.TryParse(ids[0], out id) == true && id < 1000000) { calcsMethod = "IN"; // incident topic id's } } if (controlType == 5 || controlType == 10 || controlType == 20 || controlType == 60) { calcsMethod += "STAT"; } else { calcsMethod += "SERIES"; } DateTime fromDate = this.FromDate; switch (calcsMethod) { case "ESTAT": // environment stats case "HSSTAT": // HS stats this.ehsCtl.SetCalcParams(itemCalcsMethod, calcsScope, calcsStat, seriesOrder).EHMetric(this.ehsCtl.GetPlantsByScope(plantArray), this.ehsCtl.GetMetricsByScope(), fromDate, this.ToDate); rslt = this.ehsCtl.Results; break; case "ESERIES": // environment series case "HSSERIES": // HS series this.ehsCtl.SetCalcParams(itemCalcsMethod, calcsScope, calcsStat, seriesOrder).MetricSeries((EHSCalcsCtl.SeriesOrder)seriesOrder, fromDate, this.ToDate, this.ehsCtl.GetPlantsByScope(plantArray), this.ehsCtl.GetMetricsByScope(), 0m); rslt = this.ehsCtl.Results; break; case "ISERIES": case "IRSERIES": this.ehsCtl.SetCalcParams(itemCalcsMethod, calcsScope, calcsStat, seriesOrder).InputsSeries((EHSCalcsCtl.SeriesOrder)seriesOrder, plantArray, this.ehsCtl.GetMetricsByScope(), fromDate, this.ToDate); rslt = this.ehsCtl.Results; break; case "INSTAT": // incident stats this.ehsCtl.SetCalcParams(itemCalcsMethod, calcsScope, calcsStat, seriesOrder).IncidentStat(plantArray, this.ehsCtl.GetIncidentTopics(), fromDate, this.ToDate); rslt = this.ehsCtl.Results; break; case "INSERIES": // incident series this.ehsCtl.SetCalcParams(itemCalcsMethod, calcsScope, calcsStat, seriesOrder).IncidentSeries((EHSCalcsCtl.SeriesOrder)seriesOrder, plantArray, fromDate, this.ToDate, this.ehsCtl.GetIncidentTopics()); rslt = this.ehsCtl.Results; break; case "QSSTAT": this.qsCtl.SetCalcParams(itemCalcsMethod, calcsScope, calcsStat, seriesOrder).QSMetric(plantArray, new decimal[] { }, fromDate, this.ToDate); rslt = this.qsCtl.Results; break; case "QSSERIES": this.qsCtl.SetCalcParams(itemCalcsMethod, calcsScope, calcsStat, seriesOrder).MetricSeries(fromDate, this.ToDate, plantArray); rslt = this.qsCtl.Results; break; default: break; } return(rslt); }
protected void ddlChartTypeChange(object sender, EventArgs e) { divChart.ViewStateMode = System.Web.UI.ViewStateMode.Disabled; //if (ddlChartType.SelectedValue == "" || HSCalcs().ehsCtl.IncidentHst == null || HSCalcs().ehsCtl.IncidentHst.Count == 0) if (ddlChartType.SelectedValue == "") { pnlChartSection.Style.Add("display", "none"); lnkChartClose.Visible = lnkPrint.Visible = false; } else { //PERSPECTIVE_VIEW view = null; //divSummaryCharts.Controls.Clear(); //view = ViewModel.LookupView(entities, "HSIR", "HSIR", 0); //if (view != null) //{ // PERSPECTIVE_VIEW_ITEM vi = view.PERSPECTIVE_VIEW_ITEM.Where(i => i.ITEM_SEQ.ToString() == ddlChartType.SelectedValue).FirstOrDefault(); // if (vi != null) // { // GaugeDefinition ggCfg = new GaugeDefinition().Initialize().ConfigureControl(vi, null, "", false, !string.IsNullOrEmpty(hfwidth.Value) ? Convert.ToInt32(hfwidth.Value) - 62 : 0, 0); // ggCfg.Position = null; // HSCalcs().ehsCtl.SetCalcParams(vi.CALCS_METHOD, vi.CALCS_SCOPE, vi.CALCS_STAT, (int)vi.SERIES_ORDER).IncidentSeries((EHSCalcsCtl.SeriesOrder)vi.SERIES_ORDER, SQMBasePage.GetComboBoxCheckedItems(ddlPlantSelect).Select(i => Convert.ToDecimal(i.Value)).ToArray(), new DateTime(1900, 1, 1), SessionManager.UserContext.LocalTime.AddYears(100), HSCalcs().ehsCtl.GetIncidentTopics()); // uclChart.CreateControl((SQMChartType)vi.CONTROL_TYPE, ggCfg, HSCalcs().ehsCtl.Results, divSummaryCharts); // pnlChartSection.Style.Add("display", "inline"); // lnkChartClose.Visible = lnkPrint.Visible = true; // // return; // } //} divChart.Controls.Clear(); switch (ddlChartType.SelectedValue) { case "charts": decimal protection = 0; decimal protectionTotal = 0; decimal surveillance = 0; decimal surveillanceTotal = 0; decimal manualresponse = 0; decimal manualresponseTotal = 0; decimal humanelement = 0; decimal humanelementTotal = 0; decimal hazards = 0; decimal hazardsTotal = 0; decimal maintenence = 0; decimal maintenenceTotal = 0; int iTopic = 0; decimal answerValue; // get the current year results foreach (EHSAuditData audit in HSCalcs().ehsCtl.AuditHst) { foreach (AUDIT_ANSWER answer in audit.Audit.AUDIT_ANSWER) { try { answerValue = Convert.ToInt16(answer.ANSWER_VALUE); } catch { answerValue = 0; } EHSAuditQuestion question = EHSAuditMgr.SelectAuditQuestion(audit.Audit.AUDIT_ID, answer.AUDIT_QUESTION_ID); iTopic = Convert.ToInt16(question.TopicId); switch (iTopic) { case 3: protection += answerValue; protectionTotal += 3; break; case 4: surveillance += answerValue; surveillanceTotal += 3; break; case 5: manualresponse += answerValue; manualresponseTotal += 3; break; case 6: humanelement += answerValue; humanelementTotal += 3; break; case 7: hazards += answerValue; hazardsTotal += 3; break; case 8: maintenence += answerValue; maintenenceTotal += 3; break; } } } List <GaugeSeries> gaugeSeries = new List <GaugeSeries>(); GaugeSeries g = new GaugeSeries(); g.Name = "Percentage"; if (protectionTotal > 0) { answerValue = Math.Round((protection / protectionTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Protection")); if (surveillanceTotal > 0) { answerValue = Math.Round((surveillance / surveillanceTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Surveillance")); if (manualresponseTotal > 0) { answerValue = Math.Round((manualresponse / manualresponseTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Manual Response")); if (humanelementTotal > 0) { answerValue = Math.Round((humanelement / humanelementTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Human Element")); if (hazardsTotal > 0) { answerValue = Math.Round((hazards / hazardsTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Hazards")); if (maintenenceTotal > 0) { answerValue = Math.Round((maintenence / maintenenceTotal), 3) * 100; } else { answerValue = 0; } g.ItemList.Add(new GaugeSeriesItem(0, 0, 0, answerValue, "Maintenence")); gaugeSeries.Add(g); GaugeDefinition gauge = new GaugeDefinition(); gauge.ColorPallete = "chartSeriesColor"; //gauge.ContainerHeight = 550; //gauge.ContainerWidth = 550; gauge.ControlType = 70; gauge.DisplayLabel = true; gauge.DisplayLegend = true; gauge.DisplayTitle = true; gauge.DisplayTooltip = true; gauge.Grouping = 0; gauge.Height = 550; gauge.Width = 650; gauge.ItemVisual = "CENTER"; gauge.MinorTics = false; gauge.Multiplier = 0; gauge.ScaleMax = 100; gauge.ScaleMin = 0; gauge.Title = "Audit Summary"; gauge.DisplayTitle = false; CalcsResult rslt = new CalcsResult(); rslt.metricSeries = gaugeSeries; rslt.Status = 0; rslt.ValidResult = true; uclChart.CreateControl(SQMChartType.SpiderChart, gauge, rslt, divChart); pnlChartSection.Style.Add("display", "inline"); lnkChartClose.Visible = lnkPrint.Visible = true; divChart.Visible = true; divDataResults.Visible = false; break; case "report": lnkChartClose.Visible = lnkPrint.Visible = true; divChart.Visible = false; divDataResults.Visible = true; break; } } }