Beispiel #1
0
    public static bool getReportSettings(ReportCalculations reportCalculations, Projecto p)
    {
        int zero = -1;
        int zeroC = -1;
        String StrEscala = p.getCurrentConfig("SCALE");
        String[] Escalas = StrEscala.Split('«');
        String[] Valores = Escalas[0].Split('|');
        int realScaleSize = Valores.Count();

        String StrEscalaC = p.getCurrentConfig("SCALE_C");
        String[] EscalasC = StrEscalaC.Split('«');
        String[] ValoresC = EscalasC[0].Split('|');
        int realScaleSizeC = ValoresC.Count();

        // o primeiro valor pode ser o NR, ou não
        int.TryParse(Valores[0], out zero);
        Valores[0] = zero.ToString();
        realScaleSize = Valores.Count();

        // o primeiro valor pode ser o NR, ou não
        int.TryParse(ValoresC[0], out zeroC);
        ValoresC[0] = zeroC.ToString();
        realScaleSizeC = ValoresC.Count();

        if (zero == 0)
            realScaleSize--;
        if (zeroC == 0)
            realScaleSizeC--;

        reportCalculations.MAX_ESCALA = realScaleSize;
        reportCalculations.MAX_ESCALA_C = realScaleSizeC;

        switch (realScaleSize)
        {
            case 5:
                reportCalculations.GAP_DELTA_MAX = 0.5;
                reportCalculations.GAP_DELTA_MIN = -0.5;

                reportCalculations.MEDIA_CRITIC_DOWN_CUT = 2F;
                reportCalculations.MEDIA_CRITIC_UP_CUT = 4F;

                reportCalculations.FRACOS_FORTES_BOTTOM = 3.4999F;
                reportCalculations.FRACOS_FORTES_TOP = 4.25F;

                reportCalculations.DIST_BAD = 0.06F;
                reportCalculations.DIST_MED_BOTTOM = 0.3F;
                reportCalculations.DIST_MED_TOP = 0.6F;
                reportCalculations.DIST_GOOD_BOTTOM = 0.7F;

                reportCalculations.VALOR_ESCALA_CUT_BAIXO = 2;
                reportCalculations.VALOR_ESCALA_CUT_ALTO = 4;
                break;
            case 6:
                // ESCALA DE 6
                reportCalculations.GAP_DELTA_MAX = 0.5;
                reportCalculations.GAP_DELTA_MIN = -0.5;

                reportCalculations.MEDIA_CRITIC_DOWN_CUT = 3F;
                reportCalculations.MEDIA_CRITIC_UP_CUT = 5F;

                reportCalculations.FRACOS_FORTES_BOTTOM = 3.0F;
                reportCalculations.FRACOS_FORTES_TOP = 5.0F;

                reportCalculations.DIST_BAD = 0.06F;
                reportCalculations.DIST_MED_BOTTOM = 0.3F;
                reportCalculations.DIST_MED_TOP = 0.6F;
                reportCalculations.DIST_GOOD_BOTTOM = 0.7F;

                reportCalculations.VALOR_ESCALA_CUT_BAIXO = 3;
                reportCalculations.VALOR_ESCALA_CUT_ALTO = 5;
                break;
            case 7:
                reportCalculations.GAP_DELTA_MAX = 0.5;
                reportCalculations.GAP_DELTA_MIN = -0.5;

                reportCalculations.MEDIA_CRITIC_DOWN_CUT = 3.5F;
                reportCalculations.MEDIA_CRITIC_UP_CUT = 5.5F;

                reportCalculations.FRACOS_FORTES_BOTTOM = 3.5F;
                reportCalculations.FRACOS_FORTES_TOP = 5.5F;

                reportCalculations.DIST_BAD = 0.06F;
                reportCalculations.DIST_MED_BOTTOM = 0.3F;
                reportCalculations.DIST_MED_TOP = 0.6F;
                reportCalculations.DIST_GOOD_BOTTOM = 0.7F;

                reportCalculations.VALOR_ESCALA_CUT_BAIXO = 3;
                reportCalculations.VALOR_ESCALA_CUT_ALTO = 6;
                break;
            case 8:
                reportCalculations.GAP_DELTA_MAX = 0.5;
                reportCalculations.GAP_DELTA_MIN = -0.5;

                reportCalculations.MEDIA_CRITIC_DOWN_CUT = 3F;
                reportCalculations.MEDIA_CRITIC_UP_CUT = 6F;

                reportCalculations.FRACOS_FORTES_BOTTOM = 4.0F;
                reportCalculations.FRACOS_FORTES_TOP = 6.0F;

                reportCalculations.DIST_BAD = 0.06F;
                reportCalculations.DIST_MED_BOTTOM = 0.3F;
                reportCalculations.DIST_MED_TOP = 0.6F;
                reportCalculations.DIST_GOOD_BOTTOM = 0.7F;

                reportCalculations.VALOR_ESCALA_CUT_BAIXO = 4;
                reportCalculations.VALOR_ESCALA_CUT_ALTO = 7;
                break;
        }

        switch (realScaleSizeC)
        {
            case 5:
                reportCalculations.CRITIC_DOWN_CUT = 2F;
                reportCalculations.CRITIC_UP_CUT = 4F;
                break;
            case 6:
                // ESCALA DE 6
                reportCalculations.CRITIC_DOWN_CUT = 3F;
                reportCalculations.CRITIC_UP_CUT = 5F;
                break;
            case 7:
                reportCalculations.CRITIC_DOWN_CUT = 3.5F;
                reportCalculations.CRITIC_UP_CUT = 5.5F;
                break;
            case 8:
                reportCalculations.CRITIC_DOWN_CUT = 3F;
                reportCalculations.CRITIC_UP_CUT = 6F;
                break;
        }

        String reportSettings = p.getreportSettings();

        if (reportSettings == null) return true;

        String[] vars = reportSettings.Split(';');
        Dictionary<String, double> valores = new Dictionary<string, double>();
        String[] dim;

        foreach (String var in vars)
        {
            dim = var.Split('=');
            if (dim.Length == 2)
            {
                if (dim[0] != "VALOR_ESCALA_CUT_BAIXO" && dim[0] != "VALOR_ESCALA_CUT_ALTO")
                    valores.Add(dim[0], float.Parse(dim[1]) / 100.0);
                else
                    valores.Add(dim[0], float.Parse(dim[1]));
            }
        }

        if (valores.ContainsKey("MEDIA_CRITIC_DOWN_CUT"))
            reportCalculations.MEDIA_CRITIC_DOWN_CUT = valores["MEDIA_CRITIC_DOWN_CUT"];

        if (valores.ContainsKey("MEDIA_CRITIC_UP_CUT"))
            reportCalculations.MEDIA_CRITIC_UP_CUT = valores["MEDIA_CRITIC_UP_CUT"];

        if (valores.ContainsKey("FRACOS_FORTES_BOTTOM"))
            reportCalculations.FRACOS_FORTES_BOTTOM = valores["FRACOS_FORTES_BOTTOM"];

        if (valores.ContainsKey("FRACOS_FORTES_TOP"))
            reportCalculations.FRACOS_FORTES_TOP = valores["FRACOS_FORTES_TOP"];

        if (valores.ContainsKey("DIST_BAD"))
            reportCalculations.DIST_BAD = valores["DIST_BAD"];

        if (valores.ContainsKey("DIST_MED_BOTTOM"))
            reportCalculations.DIST_MED_BOTTOM = valores["DIST_MED_BOTTOM"];

        if (valores.ContainsKey("DIST_MED_TOP"))
            reportCalculations.DIST_MED_TOP = valores["DIST_MED_TOP"];

        if (valores.ContainsKey("DIST_GOOD_BOTTOM"))
            reportCalculations.DIST_GOOD_BOTTOM = valores["DIST_GOOD_BOTTOM"];

        if (valores.ContainsKey("VALOR_ESCALA_CUT_BAIXO"))
            reportCalculations.VALOR_ESCALA_CUT_BAIXO = (int)valores["VALOR_ESCALA_CUT_BAIXO"];

        if (valores.ContainsKey("VALOR_ESCALA_CUT_ALTO"))
            reportCalculations.VALOR_ESCALA_CUT_ALTO = (int)valores["VALOR_ESCALA_CUT_ALTO"];

        if (valores.ContainsKey("CRITIC_DOWN_CUT"))
            reportCalculations.CRITIC_DOWN_CUT = valores["CRITIC_DOWN_CUT"];

        if (valores.ContainsKey("CRITIC_UP_CUT"))
            reportCalculations.CRITIC_UP_CUT = valores["CRITIC_UP_CUT"];

        if (valores.ContainsKey("GAP_DELTA_MAX"))
            reportCalculations.GAP_DELTA_MAX = valores["GAP_DELTA_MAX"];

        if (valores.ContainsKey("GAP_DELTA_MIN"))
            reportCalculations.GAP_DELTA_MIN = valores["GAP_DELTA_MIN"];

        return true;
    }