Пример #1
0
 public d1234(d1_pha p1_pha, d2_data p2_data, d4_tech p4_tech, d5_nsx p5_nsx)
 {
     v1_pha  = p1_pha;
     v2_data = p2_data;
     v3_tech = p4_tech;
     v4_nsx  = p5_nsx;
 }
        public static string f_yyyyMMdd(d2_data data_type, string s)
        {
            switch (s.Length)
            {
            case 6:
                if (data_type == d2_data.FIX_MONTH)
                {
                    return(s[2].ToString() + s[3].ToString() + "/20" + s[0].ToString() + s[1].ToString());
                }
                else
                {
                    return(s[4].ToString() + s[5].ToString() + "/" + s[2].ToString() + s[3].ToString() + "/20" + s[0].ToString() + s[1].ToString());
                }

            case 8:
                if (data_type == d2_data.FIX_MONTH)
                {
                    return(s[4].ToString() + s[5].ToString() + "/20" + s[2].ToString() + s[3].ToString());
                }
                else
                {
                    return(s[6].ToString() + s[7].ToString() + "/" + s[4].ToString() + s[5].ToString() + "/20" + s[2].ToString() + s[3].ToString());
                }
            }
            return("");
        }
        public static string f_HHmmss(d2_data data_type, string s)
        {
            if (data_type == d2_data.FIX_DAY || data_type == d2_data.FIX_MONTH)
            {
                return("00:00");
            }
            else
            {
                switch (s.Length)
                {
                case 5:
                    return("0" + s[0].ToString() + ":" + s[1].ToString() + s[2].ToString() + ":" + s[3].ToString() + s[4].ToString());

                case 6:
                    return(s[0].ToString() + s[1].ToString() + ":" + s[2].ToString() + s[3].ToString() + ":" + s[4].ToString() + s[5].ToString());
                }
            }

            return("");
        }
        private static string convert_Item2TD(
            string tem_item,
            string tem_item_def,
            string[] cols_select,
            Dictionary <int, m_column[]> dic_type_col,
            decimal[] ar, int id)
        {
            string tr = tem_item_def;

            if (id == 252)
            {
                tr = tem_item_def;
            }

            int d_type = (int)ar[0];

            d2_data data_type = d2_data._;

            switch (d_type.ToString().Length)
            {
            case 6:
                data_type = (d2_data)(d_type.ToString().Substring(0, 1).TryParseToInt() * 100000);
                break;

            case 7:
                data_type = (d2_data)(d_type.ToString().Substring(1, 1).TryParseToInt() * 100000);
                break;
            }

            m_column[] a_col = new m_column[] { };
            if (dic_type_col.TryGetValue(d_type, out a_col))
            {
                tr = tem_item;
                string ss  = "";
                int    len = ar.Length;
                for (int k = 0; k < a_col.Length; k++)
                {
                    try
                    {
                        string val   = "-";
                        int    index = a_col[k].index;
                        if (index < len)
                        {
                            val = ar[k].ToString();
                            int div10n = a_col[k].div10n;
                            if (div10n > 0)
                            {
                                val = ((decimal)ar[k] / div10n).ToString("0,0.00");
                            }
                        }


                        string code = a_col[k].code;
                        switch (code)
                        {
                        case "device_id":
                        case "meter_id":
                            tr = tr.Replace("{{device_id}}", val)
                                 .Replace("{{meter_id}}", val);
                            break;

                        case "yyyyMMdd":
                            tr = tr.Replace("{{yyyyMMdd}}", "&nbsp;" + f_yyyyMMdd(data_type, val));
                            break;

                        case "HHmmss":
                            tr = tr.Replace("{{HHmmss}}", "&nbsp;" + f_HHmmss(data_type, val));
                            break;

                        default:
                            tr = tr.Replace("{{" + a_col[k].code + "}}", val);
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        ss = ex.Message + k.ToString();
                    }
                }

                tr = tr.Replace(col_index_key, (id + 1).ToString());
            }

            return(tr);
        }
Пример #5
0
        public static d1234 f_data_type
            (string s_line_data, string factory_type)
        {
            s_line_data = s_line_data.Split(new String[] { "\t", " " }, StringSplitOptions.None)[0].Trim();

            d1_pha  v1_pha  = 0;
            d2_data v2_data = 0;
            d4_tech v4_tech = 0;
            d5_nsx  v5_nsx  = 0;

            int k = 0;

            switch (s_line_data)
            {
            case "tsvh":     //1pha;
                v1_pha  = d1_pha._1pha;
                v2_data = d2_data.TSVH;
                v4_tech = d4_tech.RF;
                break;

            case "tsvhvalue":     //3pha;
                v1_pha  = d1_pha._3pha;
                v2_data = d2_data.TSVH;
                break;

            case "tstt":     //1pha;
                v1_pha  = d1_pha._1pha;
                v2_data = d2_data.TSTT;
                v4_tech = d4_tech.RF;
                break;

            case "tstt_3pha???":    //3pha;
                v1_pha  = d1_pha._3pha;
                v2_data = d2_data.TSTT;
                break;

            case "loadvalue_???":    //1pha;
                v1_pha  = d1_pha._1pha;
                v2_data = d2_data.LOAD_PROFILE;
                v4_tech = d4_tech.RF;
                break;

            case "loadvalue":     //3pha;
                v1_pha  = d1_pha._3pha;
                v2_data = d2_data.LOAD_PROFILE;
                break;

            case "load1dayvalue???":     //1pha;
                v1_pha  = d1_pha._1pha;
                v2_data = d2_data.LOAD_PROFILE_DAY;
                v4_tech = d4_tech.RF;
                break;

            case "load1dayvalue":     //3pha;
                v1_pha  = d1_pha._3pha;
                v2_data = d2_data.LOAD_PROFILE_DAY;
                break;

            case "even":    //1pha;
                v1_pha  = d1_pha._1pha;
                v2_data = d2_data.EVEN;
                v4_tech = d4_tech.RF;
                break;

            case "eventvalue":    //3pha;
                v1_pha  = d1_pha._3pha;
                v2_data = d2_data.EVEN;
                break;

            case "fday":     //1pha;
                v1_pha  = d1_pha._1pha;
                v2_data = d2_data.FIX_DAY;
                v4_tech = d4_tech.RF;
                break;

            case "cscvalue":     //3pha;
                v1_pha  = d1_pha._3pha;
                v2_data = d2_data.FIX_DAY;
                break;

            case "fmon":     //1pha;
                v1_pha  = d1_pha._1pha;
                v2_data = d2_data.FIX_MONTH;
                v4_tech = d4_tech.RF;
                break;

            case "fmon_3pha???":    //3pha;
                v1_pha  = d1_pha._3pha;
                v2_data = d2_data.FIX_MONTH;
                break;
            }

            if (v2_data == 0 && s_line_data.StartsWith("tsvh"))
            {
                // if PLC is 1 pha - fix day
                v1_pha  = d1_pha._1pha;
                v2_data = d2_data.FIX_DAY;
                v4_tech = d4_tech.PLC;
            }

            if (v1_pha == d1_pha._1pha)
            {
                if (factory_type.Contains("psmart"))
                {
                    v5_nsx = d5_nsx.PSMART;
                }
                else if (factory_type.Contains("vnsino"))
                {
                    v5_nsx = d5_nsx.VNSINO;
                }
                else if (factory_type.Contains("omni"))
                {
                    v5_nsx = d5_nsx.OMNI;
                }
            }


            return(new d1234(v1_pha, v2_data, v4_tech, v5_nsx));
        }