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; }
private static string convert_Item2Json( string[] cols_select, Dictionary <int, m_column[]> dic_type_col, decimal[] ar, int id) { try { #region long me_id = (long)ar[3]; if (me_id < 1000000) { return(""); } int d_type = (int)ar[0]; m_column[] a_col = new m_column[] { }; if (dic_type_col.TryGetValue(d_type, out a_col)) { string error_Parse = ""; string[] lii = new string[] { }; #region /// process cols ... d4_tech tech = d4_tech._; if (ar.Length > 9) { tech = (d4_tech)ar[9]; } int len_val = a_col.Length - ar.Length; string col_miss = ""; if (len_val > 0) { for (int x = 0; x < len_val; x++) { m_column cx = a_col[x + ar.Length]; col_miss += @",""" + cx.code + @""":""-"""; } } lii = ar.Zip(a_col, (val, col) => { #region // ... string sii = ""; object rso = ""; if (col.code.Length == 2) { error_Parse = "config data type " + d_type.ToString(); return(@"""_x" + col.code + @""":" + val.ToString()); } else { #region //... try { if (d_type > 999) { switch (col.index) { case 6: rso = @"""" + ((d1_pha)val).ToString() + @""""; break; case 7: rso = @"""" + ((d2_data)val).ToString() + @""""; break; case 8: rso = @"""" + ((d4_tech)val).ToString() + @""""; break; case 9: rso = @"""" + ((d5_nsx)val).ToString() + @""""; break; default: int div10n = col.div10n; if (div10n > 0) { rso = (decimal)val / div10n; } else { rso = (decimal)val; } break; } } else { rso = (decimal)val; } sii = @"""" + col.code + @""":" + rso.ToString(); } catch (Exception ex) { error_Parse = ex.ToString(); return(@"""" + col.code + @"_error"":""" + val.ToString() + "|" + error_Parse + @""""); } #endregion } return(sii); #endregion }).ToArray(); #endregion string s_stt_export = ""; if (error_Parse == "") { s_stt_export = @"""__ok"":true, "; } else { s_stt_export = @"""__ok"":false, ""__msg"":""" + error_Parse + @""", "; } string json = ""; if (lii.Length > 0) { json = "{" + s_stt_export + string.Join(",", lii) + col_miss + "}"; } return(json); } #endregion } catch (Exception ex) { return("{" + @"""msg"":""" + ex.Message.Replace(":", "").Replace("\\", "").Replace(@"""", "") + @""", " + @"""data"":" + JsonConvert.SerializeObject(ar) + "}"); } return(""); }
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)); }