Example #1
0
        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();
        }
Example #2
0
        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 { }
        }
        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);
        }
Example #5
0
        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);
        }
        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);
        }