Exemple #1
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);
        }
    }