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 { } }
private void GenerateDataExport() { uclProgress.BindProgressDisplay(100, "Exporting..."); 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)); if (divInputs.Visible) { uclProgress.UpdateDisplay(2, 50, "Exporting..."); uclExport.ExportProfileInputsExcel(entities, PlantIDS[0].ToString(), fromDate, toDate); } else { uclProgress.UpdateDisplay(2, 50, "Exporting..."); if (LocalDataset() is SQMMetricMgr) { uclExport.GenerateExportHistoryExcel(entities, ((SQMMetricMgr)LocalDataset()).ehsCtl.MetricHst, false); } else { SQMMetricMgr metricMgr = new SQMMetricMgr().CreateNew(SessionManager.PrimaryCompany(), "E", fromDate, toDate, 0, PlantIDS); metricMgr.Load(DateIntervalType.month, DateSpanOption.SelectRange); } } uclProgress.ProgressComplete(); }
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 LoadIncidentExportInput() { string searchcriteria = ""; string plantList = ""; DateTime dtFrom = DateTime.Today; DateTime dtTo = DateTime.Today; uclProgress.BindProgressDisplay(100, "Exporting: "); uclProgress.UpdateDisplay(1, 10, "Exporting..."); try { dtFrom = new DateTime(radExportDateSelect1.SelectedDate.Value.Year, radExportDateSelect1.SelectedDate.Value.Month, 1); } catch { dtFrom = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1); } try { dtTo = new DateTime(radExportDateSelect2.SelectedDate.Value.Year, radExportDateSelect2.SelectedDate.Value.Month, 1).AddMonths(1).AddDays(-1); } catch { dtTo = new DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(1).AddDays(-1); } List <decimal> plantIDS = SQMBasePage.GetComboBoxCheckedItems(ddlExportPlantSelect).Select(i => Convert.ToDecimal(i.Value)).ToList(); List <decimal> typeList = ddlExportIncidentType.Items.Where(i => i.Checked == true).Select(i => Convert.ToDecimal(i.Value)).ToList(); HSCalcs = new SQMMetricMgr().CreateNew(SessionManager.PrimaryCompany(), "0", dtFrom, dtTo, new decimal[0]); HSCalcs.ehsCtl = new EHSCalcsCtl().CreateNew(1, DateSpanOption.SelectRange); HSCalcs.ehsCtl.SelectIncidentList(plantIDS, typeList, dtFrom, dtTo, ddlExportStatusSelect.SelectedValue, false); GenerateIncidentExportExcel(HSCalcs.ehsCtl.IncidentHst); uclProgress.ProgressComplete(); }
private int DisplayResults(string cmdID) { int status = 0; SQMMetricMgr metricMgr = null; try { if (!string.IsNullOrEmpty(cmdID)) { EHS_PROFILE_MEASURE metric = EHSModel.LookupEHSProfileMeasure(new PSsqmEntities(), Convert.ToDecimal(cmdID)); decimal calcScopeID = EHSModel.ConvertPRODMeasure(metric.EHS_MEASURE, metric.PRMR_ID); decimal plantID = Convert.ToDecimal(hfInputsListPlantID.Value); DateTime periodDate = Convert.ToDateTime(hfInputsListPeriodDate.Value); divInputsListReviewArea.Visible = true; divInputsListReviewArea.ViewStateMode = System.Web.UI.ViewStateMode.Disabled; if (metricMgr == null) { metricMgr = new SQMMetricMgr().CreateNew(SessionManager.PrimaryCompany(), "I", periodDate.AddMonths(-12), periodDate, new decimal[1] { plantID }); metricMgr.Load(DateIntervalType.month, DateSpanOption.SelectRange); } GaugeDefinition ggCfg = new GaugeDefinition().Initialize(); ggCfg.Title = metric.EHS_MEASURE.MEASURE_NAME.Trim() + " - Input History"; ggCfg.Height = 250; ggCfg.Width = 650; ggCfg.NewRow = true; ggCfg.DisplayLabel = true; ggCfg.DisplayLegend = false; ggCfg.LabelV = "Quantity"; status = uclGauge.CreateControl(SQMChartType.MultiLine, ggCfg, metricMgr.CalcsMethods(new decimal[1] { plantID }, "I", calcScopeID.ToString(), "sum", 32, (int)EHSCalcsCtl.SeriesOrder.PeriodMeasure), divInputsListReviewArea); if (string.IsNullOrEmpty(metric.EHS_MEASURE.PLANT_ACCT_FIELD) && metric.EHS_MEASURE.MEASURE_CATEGORY != "FACT") { ggCfg.Height = 165; ggCfg.Width = 650; ggCfg.Title = ""; ggCfg.DisplayLabel = false; ggCfg.LabelV = "Cost"; status = uclGauge.CreateControl(SQMChartType.MultiLine, ggCfg, metricMgr.CalcsMethods(new decimal[1] { plantID }, "I", calcScopeID.ToString(), "cost", 32, (int)EHSCalcsCtl.SeriesOrder.PeriodMeasure), divInputsListReviewArea); } } } catch { ; } return(status); }
public static LoginStatus InitializeUser(string SSOID, string pwd, bool activeOnly, bool calcStatOfTheDay) { LoginStatus sessionStatus = LoginStatus.Success; SessionManager.UserContext = new UserContext().Initialize(SSOID, pwd, true); if (SessionManager.UserContext.LoginStatus == LoginStatus.Success) { try { if (calcStatOfTheDay) { // only option is currently # days since lost time case SQMMetricMgr stsmgr = new SQMMetricMgr().CreateNew(SessionManager.PrimaryCompany(), "0", DateTime.UtcNow, DateTime.UtcNow, new decimal[1] { SessionManager.UserContext.HRLocation.Plant.PLANT_ID }); stsmgr.ehsCtl = new EHSCalcsCtl().CreateNew(1, DateSpanOption.SelectRange, "0"); stsmgr.ehsCtl.ElapsedTimeSeries(new decimal[1] { SessionManager.UserContext.HRLocation.Plant.PLANT_ID }, new decimal[1] { 8 }, new decimal[1] { 63 }, "YES", true); if (stsmgr.ehsCtl.Results.ValidResult) { SessionManager.StatOfTheDay = new AttributeValue().CreateNew("", stsmgr.ehsCtl.Results.metricSeries[0].ItemList[0].YValue ?? 0); } } else { SessionManager.StatOfTheDay = null; } } catch (Exception ex) { SessionManager.StatOfTheDay = null; //SQMLogger.LogException(ex); } } else { ; } return(SessionManager.UserContext.LoginStatus); }
protected int GeneratePerspectiveView(decimal viewID) { int status = 0; //hfViewOption.Value = viewID.ToString(); divView.ViewStateMode = System.Web.UI.ViewStateMode.Disabled; divView.Controls.Clear(); PERSPECTIVE_VIEW view = LocalViewList.Where(v => v.VIEW_ID == viewID).FirstOrDefault(); if (view == null) { lblReportTitle.CssClass = "promptAlert"; lblReportTitle.Text = hfViewOpenErr.Value; return(-1); } lblReportTitle.CssClass = "labelTitle"; lblReportTitle.Text = PlantSelect + " - " + view.VIEW_DESC; 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, ViewModel.AddFromYear(view), PlantIDS); metricMgr.Load(DateIntervalType.month, DateSpanOption.SelectRange); foreach (PERSPECTIVE_VIEW_ITEM vi in view.PERSPECTIVE_VIEW_ITEM.OrderBy(i => i.ITEM_SEQ).ToList()) { if (vi.STATUS != "I") { GaugeDefinition cfg = new GaugeDefinition().Initialize().ConfigureControl(vi, null, "", false, !string.IsNullOrEmpty(hfwidth.Value) ? Convert.ToInt32(hfwidth.Value) - 62 : 0, 0); uclView.CreateControl((SQMChartType)cfg.ControlType, cfg, metricMgr.CalcsMethods(PlantIDS, vi.CALCS_METHOD, vi.CALCS_SCOPE, vi.CALCS_STAT, vi.CONTROL_TYPE, (int)vi.SERIES_ORDER, vi.FILTER, vi.OPTIONS), divView); } } SetLocalDataset(metricMgr); divView.Visible = true; return(status); }
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); }
SQMMetricMgr SetHSCalcs(SQMMetricMgr hscalcs) { SessionManager.CurrentObject = hscalcs; return(HSCalcs()); }
private int DisplayResults(string cmdID) { int status = 0; SQMMetricMgr metricMgr = null; foreach (RepeaterItem item in rptProfilePeriod.Items) { try { LinkButton lnk = (LinkButton)item.FindControl("lnkMetricCD"); CheckBox cb = (CheckBox)item.FindControl("cbMetricSelect"); if (cb.Checked) // || cmdID == "0") { EHS_PROFILE_MEASURE metric = LocalProfile().GetMeasure(Convert.ToDecimal(lnk.CommandArgument)); decimal calcScopeID = EHSModel.ConvertPRODMeasure(metric.EHS_MEASURE, metric.PRMR_ID); System.Web.UI.HtmlControls.HtmlGenericControl reviewArea = (System.Web.UI.HtmlControls.HtmlGenericControl)item.FindControl("divReviewArea"); LinkButton lnkClose = (LinkButton)item.FindControl("lnkReviewAreaClose"); lnkClose.Visible = reviewArea.Visible = true; lnk.Visible = false; reviewArea.ViewStateMode = System.Web.UI.ViewStateMode.Disabled; if (metricMgr == null) { metricMgr = new SQMMetricMgr().CreateNew(SessionManager.PrimaryCompany(), "I", LocalProfile().InputPeriod.PeriodDate.AddMonths(-12), LocalProfile().InputPeriod.PeriodDate, new decimal[1] { LocalProfile().Profile.PLANT_ID }); metricMgr.Load(DateIntervalType.month, DateSpanOption.SelectRange); } GaugeDefinition ggCfg = new GaugeDefinition().Initialize(); ggCfg.Title = metric.EHS_MEASURE.MEASURE_NAME.Trim() + " - Input History"; ggCfg.Height = 250; ggCfg.Width = 700; ggCfg.NewRow = true; ggCfg.DisplayLabel = true; ggCfg.DisplayLegend = false; ggCfg.LabelV = "Quantity"; status = uclGauge.CreateControl(SQMChartType.MultiLine, ggCfg, metricMgr.CalcsMethods(new decimal[1] { LocalProfile().Profile.PLANT_ID }, "I", calcScopeID.ToString(), "sum", 32, (int)EHSCalcsCtl.SeriesOrder.PeriodMeasure), reviewArea); if (string.IsNullOrEmpty(metric.EHS_MEASURE.PLANT_ACCT_FIELD) && metric.EHS_MEASURE.MEASURE_CATEGORY != "FACT") { ggCfg.Height = 180; ggCfg.Width = 700; ggCfg.Title = ""; ggCfg.DisplayLabel = false; ggCfg.LabelV = "Cost"; status = uclGauge.CreateControl(SQMChartType.MultiLine, ggCfg, metricMgr.CalcsMethods(new decimal[1] { LocalProfile().Profile.PLANT_ID }, "I", calcScopeID.ToString(), "cost", 32, (int)EHSCalcsCtl.SeriesOrder.PeriodMeasure), reviewArea); } } } catch { ; } } BindSharedCalendars(); return(status); }
protected void Page_Load(object sender, EventArgs e) { SETTINGS sets = null; if (IsPostBack) { // Save the current view port width (used for responsive design later) var vpWidth = viewPortWidth.Value; if (!string.IsNullOrEmpty(vpWidth)) { Session["vpWidth"] = vpWidth; } else { Session["vpWidth"] = "1000"; } } else { // if (LoginAttempts == 0) // SessionManager.Clear(); try { string info = System.Configuration.ConfigurationManager.AppSettings["MainInfo"]; if (!string.IsNullOrEmpty(info)) { lblMainInfo.Text = info; lblMainInfo.Visible = true; } System.Web.HttpBrowserCapabilities browser = Request.Browser; // url format login.aspx/?t=ltc:60&p=EHS // execOverride == override query params to force ticker and image posting System.Collections.Specialized.NameValueCollection qry = new System.Collections.Specialized.NameValueCollection(); string execOverride = System.Configuration.ConfigurationManager.AppSettings["LoginOverride"]; if (execOverride != null && execOverride == "QAI") { qry.Add("t", "ltc"); qry.Add("p", "EHS,QS"); } else { sets = SQMSettings.GetSetting("ENV", "LOGINIMAGE"); // force login splash page display if (sets != null && sets.VALUE.ToUpper() == "Y") { qry.Add("p", "EHS,QS"); } sets = SQMSettings.GetSetting("ENV", "LOGINSTAT"); if (sets != null && sets.VALUE.ToUpper() == "LTC") { qry.Add("t", "ltc"); } } sets = SQMSettings.GetSetting("ENV", "LOGINMESSAGE"); if (sets != null && !string.IsNullOrEmpty(sets.VALUE)) { lblLoginMessage.Text = sets.VALUE; divLoginMessage.Visible = true; } if (Request.QueryString.Count > 0) { qry = Request.QueryString; } if (qry.Get("t") != null) { string[] args = qry.Get("t").ToString().Split(':'); COMPANY company = new COMPANY(); decimal[] plantIDS = SQMModelMgr.SelectPlantList(entities, 1, 0).Where(l => l.LOCATION_TYPE == "P").OrderBy(l => l.PLANT_NAME).Select(l => l.PLANT_ID).ToArray(); SQMMetricMgr stsmgr = new SQMMetricMgr().CreateNew(company, "0", DateTime.Now, DateTime.Now, plantIDS); stsmgr.ehsCtl = new EHSCalcsCtl().CreateNew(1, DateSpanOption.SelectRange); stsmgr.ehsCtl.ElapsedTimeSeries(plantIDS, new decimal[1] { 8 }, new decimal[1] { 63 }, "YES", true); GaugeDefinition tikCfg = new GaugeDefinition().Initialize(); tikCfg.Width = 0; tikCfg.Unit = args.Length > 1 ? Convert.ToInt32(args[1]) : 80; tikCfg.Position = "none"; tikCfg.NewRow = false; pnlPosting.Visible = true; divTicker.Visible = true; uclGauge.CreateTicker(tikCfg, stsmgr.ehsCtl.Results.metricSeries, divTicker); } if (qry.Get("p") != null) { string[] args = qry.Get("p").ToString().Split(','); if (args.Contains("EHS")) { pnlPosting.Visible = true; imgPostingEHS.Style.Add("MARGIN-TOP", "8px"); imgPostingEHS.Src = SQM.Website.Classes.SQMDocumentMgr.GetImageSourceString(SQM.Website.Classes.SQMDocumentMgr.FindCurrentDocument("SYS", 31)); } if (args.Contains("QS")) { pnlPosting.Visible = true; imgPostingQS.Style.Add("MARGIN-TOP", "8px"); imgPostingQS.Src = SQM.Website.Classes.SQMDocumentMgr.GetImageSourceString(SQM.Website.Classes.SQMDocumentMgr.FindCurrentDocument("SYS", 32)); } } string externalLinks = System.Configuration.ConfigurationManager.AppSettings["ExternalLinks"]; if (!string.IsNullOrEmpty(externalLinks)) { string[] linkArray = externalLinks.Split(','); foreach (string link in linkArray) { divLinks.Controls.Add(new LiteralControl(" ")); HyperLink hlk = new HyperLink(); hlk.NavigateUrl = hlk.Text = link; hlk.Target = "_blank"; hlk.CssClass = "linkUnderline"; divLinks.Controls.Add(hlk); } divLinks.Visible = true; } } catch { divAnnouncements.Visible = false; } if (Request.QueryString["rdp"] != null) { ViewState["RedirectPath"] = Request.QueryString["rdp"]; } } }