Beispiel #1
0
    private void LoadKpiData()
    {
        int kpiId  = Convert.ToInt32(KpiIdHiddenField.Value);
        int userId = UserBLL.GetUserIdByUsername(User.Identity.Name);

        UserIdHiddenField.Value = userId.ToString();

        KPI kpi = KPIBLL.GetKPIById(kpiId);

        KpiNameLiteral.Text = kpi.Name;

        //Inicializo los valores conocidos
        string     lang   = LanguageUtilities.GetLanguageFromContext();
        KPITypeBLL theBll = new KPITypeBLL();
        KPIType    type   = theBll.GetKPITypesByID(kpi.KpiTypeID, lang);

        KpiType.Text = type != null ? type.TypeName : kpi.KpiTypeID;
        //WebServiceId.Text = "<div class='col-md-4 col-sm-4'>Web Service ID:</div><div class='col-md-8 col-sm-8'>SERV-Reliavility</div>";
        ReportingUnit.Text = kpi.ReportingUnitName;
        KpiTarget.Text     = (kpi.TargetPeriod == 0 ? Resources.KpiDetails.NoTargetLabel : kpi.TargetPeriod + " " + kpi.ReportingUnitID);

        //if (caso <= 50)
        //{
        //    StartingDate.Text = "<div class='col-md-4 col-sm-4'>Starting Date:</div><div class='col-md-8 col-sm-8'>01/15/16</div>";
        //    MeanTimeGraphic.Visible = true;
        //    MeanTimeProgress.Visible = true;
        //}
        //else
        //{
        StartingDate.Text = kpi.StartDate != DateTime.MinValue ? kpi.StartDate.ToShortDateString() : "-";
        RevenueCollectionGraphic.Visible = true;
        //RevenueCollectionProgress.Visible = true;
        ChartControl.KpiId               = kpiId;
        ExportControl.KpiId              = kpiId;
        StatsControl.KpiId               = kpiId;
        MeasurementsControl.KpiId        = kpiId;
        MeasurementsControl.Unit         = kpi.UnitID;
        MeasurementsControl.Currency     = kpi.Currency;
        MeasurementsControl.CurrencyUnit = kpi.CurrencyUnitForDisplay;

        UnitIdHiddenField.Value       = kpi.UnitID;
        CurrencyHiddenField.Value     = kpi.Currency;
        CurrencyUnitHiddenField.Value = kpi.CurrencyUnitForDisplay;

        //CurrencyUnitBLL currencyUnitBll = new CurrencyUnitBLL();
        //CurrencyUnit currencyUnit = currencyUnitBll.GetCurrencyUnitsById(lang, ;

        //MeasurementsControl.Currency = kpi.Currency;

        //}

        List <KPICategoyCombination> categories = KPICategoryCombinationBLL.GetCategoryItemsCombinatedByKpiId(kpiId);

        if (categories.Count > 0)
        {
            CategoriesRepeater.DataSource = categories;
            CategoriesRepeater.DataBind();
            CategoriesPanel.Visible = true;
        }
    }
Beispiel #2
0
    protected override void OnPreRender(EventArgs e)
    {
        try
        {
            KPI     objKpi         = KPIBLL.GetKPIById(KpiId);
            decimal currentValue   = 0;
            decimal lowestValue    = 0;
            decimal highestValue   = 0;
            decimal averageValue   = 0;
            decimal progress       = 0;
            decimal trend          = 0;
            bool    isTime         = objKpi.UnitID == "TIME";
            int     firstDayOfWeek = Artexacta.App.Configuration.Configuration.GetFirstDayOfWeek();
            KPIBLL.GetKpiStats(KpiId, CategoryId, CategoryItemId, firstDayOfWeek, ref currentValue, ref lowestValue, ref highestValue, ref averageValue, ref progress, ref trend);

            CurrentValueLiteral.Text = GetValue(currentValue, objKpi.UnitID, objKpi.Currency, objKpi.CurrencyUnitID);
            LowestValueLiteral.Text  = GetValue(lowestValue, objKpi.UnitID, objKpi.Currency, objKpi.CurrencyUnitID);
            HighestValueLiteral.Text = GetValue(highestValue, objKpi.UnitID, objKpi.Currency, objKpi.CurrencyUnitID);
            AverageLiteral.Text      = GetValue(averageValue, objKpi.UnitID, objKpi.Currency, objKpi.CurrencyUnitID);

            ProgressLiteral.Text = progress == decimal.MinValue ? "-" : progress != 0 ? progress.ToString(CultureInfo.InvariantCulture) + "%": "0%";

            if (trend < 0)
            {
                IconLabel.CssClass = "text-danger";
                IconLabel.Text     = "<i class='zmdi zmdi-long-arrow-down zmdi-hc-fw'></i>";
                TrendLiteral.Text  = Resources.Kpi.DownLabel;
            }
            else if (trend > 0)
            {
                IconLabel.CssClass = "text-success";
                IconLabel.Text     = "<i class='zmdi zmdi-long-arrow-up zmdi-hc-fw'></i>";
                TrendLiteral.Text  = Resources.Kpi.UpLabel;
            }
            else
            {
                IconLabel.Text    = "-";
                TrendLiteral.Text = Resources.KpiStats.NoChangesLabel;

                PeriodLiteral.Text = objKpi.ReportingUnitName.ToLower();
                return;
            }

            TrendPercentageLiteral.Text = Math.Abs(trend).ToString() + " %";
            PeriodLiteral.Text          = objKpi.ReportingUnitName.ToLower();
        }
        catch (Exception ex)
        {
            log.Error("Error getting stats for KPI", ex);
        }
    }
Beispiel #3
0
    private void LoadKPI()
    {
        if (KPIId > 0 && DataTypeHiddenField.Value.Equals("KPI"))
        {
            KPI theData = null;
            try
            {
                theData = KPIBLL.GetKPIById(KPIId);
            }
            catch (Exception exc)
            {
                SystemMessages.DisplaySystemErrorMessage(exc.Message);
            }
            if (theData != null)
            {
                if (theData.OrganizationID > 0)
                {
                    pnlKPIEnabled.Style["display"]  = "block";
                    pnlKPIDisabled.Style["display"] = "none";
                }
                else
                {
                    pnlKPIEnabled.Style["display"]  = "none";
                    pnlKPIDisabled.Style["display"] = "block";
                }

                if (theData.AreaID > 0 || theData.ProjectID > 0 || theData.ActivityID > 0 || theData.PersonID > 0)
                {
                    pnlKPIData.Style["display"] = "block";
                }
                else
                {
                    pnlKPIData.Style["display"] = "none";
                }

                OrganizationId = theData.OrganizationID;
                AreaId         = theData.AreaID;
                ProjectId      = theData.ProjectID;
                ActivityId     = theData.ActivityID;
                PersonId       = theData.PersonID;
            }
        }
    }
Beispiel #4
0
    private void LoadData()
    {
        //-- verify is user is OWNER
        PermissionObject theUser = new PermissionObject();

        try
        {
            theUser = PermissionObjectBLL.GetPermissionsByUser(PermissionObject.ObjectType.KPI.ToString(), Convert.ToInt32(KPIIdHiddenField.Value));
        }
        catch (Exception exc)
        {
            SystemMessages.DisplaySystemErrorMessage(exc.Message);
            Response.Redirect("~/Kpi/KpiList.aspx");
        }

        if (theUser == null || !theUser.TheActionList.Exists(i => i.ObjectActionID.Equals("OWN")))
        {
            SystemMessages.DisplaySystemWarningMessage(Resources.ShareData.UserNotOwnKpi);
            Response.Redirect("~/Kpi/KpiList.aspx");
        }

        //-- show Data
        KPI theData = null;

        try
        {
            theData = KPIBLL.GetKPIById(Convert.ToInt32(KPIIdHiddenField.Value));
        }
        catch (Exception exc)
        {
            SystemMessages.DisplaySystemErrorMessage(exc.Message);
            Response.Redirect("~/Kpi/KpiList.aspx");
        }

        if (theData != null)
        {
            KPINameLiteral.Text = theData.Name;
        }
    }
Beispiel #5
0
 private void LoadKPI()
 {
     if (KPIId > 0 && DataTypeHiddenField.Value.Equals("KPI"))
     {
         KPI theData = null;
         try
         {
             theData = KPIBLL.GetKPIById(KPIId);
         }
         catch (Exception exc)
         {
             SystemMessages.DisplaySystemErrorMessage(exc.Message);
         }
         if (theData != null)
         {
             OrganizationId = theData.OrganizationID;
             AreaId         = theData.AreaID;
             ProjectId      = theData.ProjectID;
             ActivityId     = theData.ActivityID;
             PersonId       = theData.PersonID;
         }
     }
 }
Beispiel #6
0
    private void LoadData()
    {
        //-- verify is user has permissions
        PermissionObject theUser = new PermissionObject();

        try
        {
            theUser = PermissionObjectBLL.GetPermissionsByUser(PermissionObject.ObjectType.KPI.ToString(), Convert.ToInt32(KPIIdHiddenField.Value));
        }
        catch (Exception exc)
        {
            SystemMessages.DisplaySystemErrorMessage(exc.Message);
            Response.Redirect("~/Kpi/KpiList.aspx");
        }

        if (theUser == null)
        {
            SystemMessages.DisplaySystemWarningMessage(Resources.ShareData.UserNotOwnKpi);
            Response.Redirect("~/Kpi/KpiList.aspx");
        }

        if (theUser.TheActionList.Exists(i => i.ObjectActionID.Equals("OWN")))
        {
            pnlUploadFile.Visible = true;
            pnlEnterData.Visible  = false;
            KpiMeasurementGridView.Columns[0].Visible = true;
        }
        else if (theUser.TheActionList.Exists(i => i.ObjectActionID.Equals("ENTER_DATA")))
        {
            pnlUploadFile.Visible = true;
            pnlEnterData.Visible  = false;
            KpiMeasurementGridView.Columns[0].Visible = false;
        }
        else if (theUser.TheActionList.Exists(i => i.ObjectActionID.Equals("VIEW_KPI")))
        {
            pnlUploadFile.Visible = false;
            pnlEnterData.Visible  = false;
            KpiMeasurementGridView.Columns[0].Visible = false;
        }
        else
        {
            SystemMessages.DisplaySystemWarningMessage(Resources.ShareData.UserNotOwnKpi);
            Response.Redirect("~/Kpi/KpiList.aspx");
        }

        //-- show Data
        KPI theData = null;

        try
        {
            theData = KPIBLL.GetKPIById(Convert.ToInt32(KPIIdHiddenField.Value));
        }
        catch (Exception exc)
        {
            SystemMessages.DisplaySystemErrorMessage(exc.Message);
            Response.Redirect("~/Kpi/KpiList.aspx");
        }

        if (theData != null)
        {
            SubtitleLabel.Text            = theData.Name;
            KPIType.Text                  = theData.KPITypeName;
            ReportingPeriod.Text          = theData.ReportingUnitName;
            StartingDate.Text             = theData.StartDate == DateTime.MinValue ? " - " : TextUtilities.GetDateTimeToString(theData.StartDate);
            UnitIdHiddenField.Value       = theData.UnitID;
            CurrencyHiddenField.Value     = theData.Currency;
            CurrencyUnitHiddenField.Value = theData.CurrencyUnitForDisplay;

            switch (UnitIdHiddenField.Value)
            {
            case "TIME":
                DataDescriptionLabel.Text = Resources.ImportData.TimeDataDescription;
                break;

            case "INT":
                DataDescriptionLabel.Text = Resources.ImportData.IntegerDataDescription;
                break;

            default:
                DataDescriptionLabel.Text = Resources.ImportData.DecimalDataDescription;
                break;
            }

            BindGridView();
        }
    }
Beispiel #7
0
    public void BuildChart()
    {
        int     kpiId          = KpiId;
        string  strategyId     = "";
        string  startingPeriod = "";
        string  endingPeriod   = "";
        decimal target         = 0;
        int     firstDayOfWeek = Artexacta.App.Configuration.Configuration.GetFirstDayOfWeek();

        List <KpiChartData> measurements = KpiMeasurementBLL.GetKPIMeasurementForChart(kpiId, CategoryId, CategoryItemId, firstDayOfWeek,
                                                                                       ref strategyId, ref target, ref startingPeriod, ref endingPeriod);
        Dictionary <string, object> standardSerie       = new Dictionary <string, object>();
        Dictionary <string, object> targetStandardSerie = new Dictionary <string, object>();

        Dictionary <string, object> sumSerie       = new Dictionary <string, object>();
        Dictionary <string, object> targetSumSerie = new Dictionary <string, object>();

        KPI objKpi = KPIBLL.GetKPIById(kpiId);

        bool hasTarget      = target != -1;
        bool isSum          = strategyId == "SUM";
        bool isTargetUsable = false;
        //bool isSerieUsable = false;

        decimal sumMeasurement = 0;
        decimal sumTarget      = 0;

        foreach (var item in measurements)
        {
            //if (!string.IsNullOrEmpty(startingPeriod) && item.Period == startingPeriod)
            //    isSerieUsable = true;
            //if (isSerieUsable)
            standardSerie.Add(item.Period, item.Measurement);
            //else
            //    standardSerie.Add(item.Period, null);

            if (isSum)
            {
                sumMeasurement = sumMeasurement + item.Measurement;

                //if (isSerieUsable)
                sumSerie.Add(item.Period, sumMeasurement);
                //else
                //    sumSerie.Add(item.Period, null);
                if (hasTarget)
                {
                    if (!string.IsNullOrEmpty(startingPeriod) && item.Period == startingPeriod)
                    {
                        isTargetUsable = true;
                    }

                    if (!string.IsNullOrEmpty(endingPeriod) && item.Period == endingPeriod)
                    {
                        isTargetUsable = false;
                    }

                    if (isTargetUsable)
                    {
                        sumTarget = sumTarget + target;
                        targetSumSerie.Add(item.Period, sumTarget);
                    }
                    else
                    {
                        targetSumSerie.Add(item.Period, null);
                    }
                }
            }
            if (hasTarget)
            {
                if (!string.IsNullOrEmpty(startingPeriod) && item.Period == startingPeriod)
                {
                    isTargetUsable = true;
                }

                if (!string.IsNullOrEmpty(endingPeriod) && item.Period == endingPeriod)
                {
                    isTargetUsable = false;
                }

                if (isTargetUsable)
                {
                    targetStandardSerie.Add(item.Period, target);
                }
                else
                {
                    targetStandardSerie.Add(item.Period, null);
                }
            }
        }
        List <Series> series = new List <Series>();

        series.Add(new Series
        {
            Name = Resources.KpiDetails.ValuesLabel,
            Data = new Data(standardSerie.Values.ToArray <object>())
        });
        if (hasTarget)
        {
            series.Add(new Series
            {
                Name  = Resources.KpiDetails.KpiTargetLabel,
                Color = System.Drawing.Color.Red,
                Data  = new Data(targetStandardSerie.Values.ToArray <object>())
            });
        }

        DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts(ClientID)
                                             .InitChart(new Chart()
        {
            Type = ChartTypes.Line
        })
                                             .SetTitle(new Title()
        {
            Text = ""
        })
                                             .SetXAxis(new XAxis
        {
            Categories = standardSerie.Keys.ToArray <string>()
        })
                                             .SetSeries(series.ToArray())
                                             .SetLegend(new Legend()
        {
            Layout        = Layouts.Horizontal,
            Align         = HorizontalAligns.Center,
            VerticalAlign = VerticalAligns.Bottom,
            BorderWidth   = 0
        });
        if (objKpi.UnitID != "TIME")
        {
            //chart.SetTooltip(new Tooltip()
            //{
            //    ValueSuffix = " " + objKpi.uni.ToLower() + "s"

            //});
        }
        else
        {
            chart.SetTooltip(new Tooltip()
            {
                Formatter = "function (){" +
                            "return decimalToYYMMDDhhmm(this.y).toString('" + Resources.DataTime.YearsValueSingle + "','" + Resources.DataTime.YearsValue + "'," +
                            "'" + Resources.DataTime.MonthsValueSingle + "'," +
                            "'" + Resources.DataTime.MonthsValue + "'," +
                            "'" + Resources.DataTime.DaysValueSingle + "'," +
                            "'" + Resources.DataTime.DaysValue + "'," +
                            "'" + Resources.DataTime.HoursValueSingle + "'," +
                            "'" + Resources.DataTime.HoursValue + "'," +
                            "'" + Resources.DataTime.MinutesValueSingle + "'," +
                            "'" + Resources.DataTime.MinutesValue + "');" +
                            "}"
            });
        }

        ChartLiteral.Text = chart.ToHtmlString();

        if (isSum)
        {
            series = new List <Series>();
            series.Add(new Series
            {
                Name = Resources.KpiDetails.ValuesLabel,
                Data = new Data(sumSerie.Values.ToArray <object>())
            });
            if (hasTarget)
            {
                series.Add(new Series
                {
                    Name  = Resources.KpiDetails.KpiTargetLabel,
                    Color = System.Drawing.Color.Red,
                    Data  = new Data(targetSumSerie.Values.ToArray <object>())
                });
            }
            chart = new DotNet.Highcharts.Highcharts(ClientID + "_sum")
                    .InitChart(new Chart()
            {
                Type = ChartTypes.Line
            })
                    .SetTitle(new Title()
            {
                Text = ""
            })
                    .SetXAxis(new XAxis
            {
                Categories = standardSerie.Keys.ToArray <string>()
            })
                    .SetSeries(series.ToArray())
                    .SetLegend(new Legend()
            {
                Layout        = Layouts.Horizontal,
                Align         = HorizontalAligns.Center,
                VerticalAlign = VerticalAligns.Bottom,
                BorderWidth   = 0
            });
            if (objKpi.UnitID != "TIME")
            {
                //chart.SetTooltip(new Tooltip()
                //{
                //    ValueSuffix = " " + objKpi.uni.ToLower() + "s"

                //});
            }
            else
            {
                chart.SetTooltip(new Tooltip()
                {
                    Formatter = "function (){" +
                                "return decimalToYYMMDDhhmm(this.y).toString('" + Resources.DataTime.YearsValueSingle + "','" + Resources.DataTime.YearsValue + "'," +
                                "'" + Resources.DataTime.MonthsValueSingle + "'," +
                                "'" + Resources.DataTime.MonthsValue + "'," +
                                "'" + Resources.DataTime.DaysValueSingle + "'," +
                                "'" + Resources.DataTime.DaysValue + "'," +
                                "'" + Resources.DataTime.HoursValueSingle + "'," +
                                "'" + Resources.DataTime.HoursValue + "'," +
                                "'" + Resources.DataTime.MinutesValueSingle + "'," +
                                "'" + Resources.DataTime.MinutesValue + "');" +
                                "}"
                });
            }
            SumChartLiteral.Text  = chart.ToHtmlString();
            SumChartPanel.Visible = true;
        }
    }