public static string toJSON(CIniFile config) { string json = "\"NameDef\": ["; foreach (NameDef NameDef in config.NameDefList) { json += "{"; json += "\"table\":\"" + NameDef.table + "\", \"column\":\"" + NameDef.column + "\","; for (int i = 0; i < NameDef.fullNames.Length; i++) { LangDef LangDef = config.LangEnbList[i]; if (NameDef.fullNames[i] != null) { if (NameDef.fullNames[i].Length != 0) { json += "\"fullName_" + LangDef.LangAbbreviation + "\":\"" + NameDef.fullNames[i] + "\","; } } } if (NameDef.units != null) { for (int i = 0; i < NameDef.units.Count; i++) { LangDef LangDef = config.LangEnbList[i]; json += "\"unit_" + LangDef.LangAbbreviation + "\":\"" + NameDef.units[i] + "\","; } } json = json.Substring(0, json.Length - 1); json += "},"; } json = json.Substring(0, json.Length - 1); json += "]"; return(json); }
public string toJSON(CView view, CIniFile config) { string json = "{"; int pos = 0; foreach (LangDef LangDef in config.LangEnbList) { if (pos < view.Names.Count) { json += "\"name_" + LangDef.LangAbbreviation + "\":\"" + view.Names[pos] + "\", "; } pos++; } json += "\"defLang\": \"" + view.defLang + "\", "; if (FieldList.Count != 0) { json += "\"field\":["; foreach (CField field in FieldList) { string fieldJSON = field.toJSON(field); json += fieldJSON; } json = json.Substring(0, json.Length - 1); json += "]"; } else { json = json.Substring(0, json.Length - 1); } json += "},"; return(json); }
public static string toJSON(CIniFile config) { string json = "\"TextlistDef\": ["; foreach (TextlistDef TextlistDef in config.TextlistDefList) { json += "{\"textlist\": \"" + TextlistDef.textlist + "\","; json += "\"values\": ["; foreach (Values Values in TextlistDef.values) { json += "{\"idx\":" + Values.idx + ","; for (int i = 0; i < Values.langTexts.Length; i++) { LangDef LangDef = config.LangEnbList[i]; json += "\"text_" + LangDef.LangAbbreviation + "\":\"" + Values.langTexts[i] + "\","; } json = json.Substring(0, json.Length - 1); json += "},"; } json = json.Substring(0, json.Length - 1); json += "]},"; } json = json.Substring(0, json.Length - 1); json += "]"; return(json); }
public static void DeleteOtherLangs(CIniFile config, int langCount) { for (int i = langCount; i < config.LangDefList.Count - 1; i++) { config.LangDefList.RemoveAt(i); } }
public static string Add(CIniFile config, string ascolumn, string[] asfullNames, List <string> asunits, string astable = null) { config.NameDefList.Add(new NameDef() { table = astable, column = ascolumn, fullNames = asfullNames, units = asunits }); return(ascolumn); }
/// <summary> /// /// </summary> /// <param name="textlist"></param> /// <returns></returns> public static string Find(CIniFile config, string textlist) { foreach (TextlistDef TextlistDef in config.TextlistDefList) { if (TextlistDef.textlist.Contains(textlist)) { return(TextlistDef.textlist); } } return(null); }
public static TableDef FindTable(CIniFile config, string shortName) { foreach (TableDef TableDef in config.TableDefList) { if (TableDef.tabName.Contains(shortName)) { return(TableDef); } } return(null); }
public static string Find(CIniFile config, string column) { foreach (NameDef NameDef in config.NameDefList) { if (NameDef.column.Contains(column)) { return(NameDef.column); } } return(null); }
// public static List public static string Find(CIniFile config, int ConnNo, string TabName) { foreach (TableDef TableDef in config.TableDefList) { if (TableDef.dbIdx == ConnNo & TableDef.tabName.Contains(TabName)) { return(TableDef.shortName); } } return(null); }
public int Find(CIniFile config, string lang) { foreach (LangDef LangDef in config.LangDefList) { if (LangDef.LangAbbreviation.Contains(lang)) { return(config.LangDefList.IndexOf(LangDef)); } } return(0); }
public static bool UpdateName(CIniFile config, string oldName, string newName) { foreach (TextlistDef TextlistDef in config.TextlistDefList) { if (TextlistDef.textlist.Contains(oldName)) { TextlistDef.textlist = newName; return(true); } } return(false); }
/// <summary> /// /// </summary> /// <param name="lang">lang which you want to add</param> /// <param name="position">Optional parameter</param> public static void Add(CIniFile config, string lang, int position = 0) { if (position == 0) { config.LangEnbList.Add(new LangDef() { LangAbbreviation = lang }); } else { config.LangEnbList.Insert(position, new LangDef() { LangAbbreviation = lang }); } }
public static string toJSON(CIniFile config) { string json = "\"TableDef\": [ "; foreach (TableDef TableDef in config.TableDefList) { json += "{"; json += "\"shortName\":\"" + TableDef.shortName + "\","; json += "\"dbIdx\":" + TableDef.dbIdx + ","; json += "\"tabName\":\"" + TableDef.tabName + "\","; json += "\"period\":" + TableDef.period; json += "},"; } json = json.Substring(0, json.Length - 1); json += "]"; return(json); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="textsArray"></param> /// <param name="Idxs"></param> /// <returns></returns> public static string Add(CIniFile config, string name, List <string[]> textsArray, List <int> Idxs) { List <Values> tempValues = new List <Values>(); for (int i = 0; i < textsArray.Count; i++)//First row is name row - textlist name { tempValues.Add(new Values() { idx = Idxs[i], langTexts = textsArray[i] }); } config.TextlistDefList.Add(new TextlistDef() { textlist = name, values = tempValues }); return(name); }
public static string toJSON(CIniFile config) { string json = "\"LangDef\": ["; foreach (LangDef LangDef in config.LangDefList) { json += "\"" + LangDef.LangAbbreviation + "\","; } json = json.Substring(0, json.Length - 1); json += "],"; json += "\"LangEnb\": ["; foreach (LangDef LangDef in config.LangEnbList) { json += "\"" + LangDef.LangAbbreviation + "\","; } json = json.Substring(0, json.Length - 1); json += "]"; return(json); }
public static string Add(CIniFile config, int ConnNo, string TabName) { int subscoreIdx, iperiod; try { subscoreIdx = TabName.LastIndexOf("_"); } catch (ArgumentNullException e) { throw new Exception(e.Message); } string shortedName = TabName.Substring(subscoreIdx + 1); switch (shortedName) { case "xslow": iperiod = 300; break; case "slow": iperiod = 60; break; case "norm": iperiod = 20; break; case "sec10": iperiod = 10; break; case "sec5": iperiod = 5; break; default: iperiod = 20; break; } config.TableDefList.Add(new TableDef() { shortName = shortedName, dbIdx = ConnNo, tabName = TabName, period = iperiod }); return(shortedName); }
public string toJSON(CIniFile IniFile) { string json = "{"; json += LangDefinition.toJSON(this); json += ","; json += TableDefinition.toJSON(this); json += ","; json += NameDefinition.toJSON(this); json += ","; json += TextlistDefinition.toJSON(this); json += ","; json += "\"View\":["; foreach (CView view in ViewList) { json += view.toJSON(view, IniFile); } json = json.Substring(0, json.Length - 1); json += "]}"; return(json); }
public static CSignal FromIni(CIniFile config, string[] separ_cfg_string) { int ConnectionStringNumber; string SignalName, TableName, TableDefName; int Decimal; Color Color; // priklad: Signal=3:iWMU_Temp arBF_norm 1 255,0,0 // 0 1 2 3 4 5 6 7 ConnectionStringNumber = int.Parse(separ_cfg_string[1]); SignalName = separ_cfg_string[2]; TableName = separ_cfg_string[3]; TableDefName = TableDefinition.Find(config, ConnectionStringNumber, TableName); if (TableDefName == null) { TableDefName = TableDefinition.Add(config, ConnectionStringNumber, TableName); } Decimal = int.Parse(separ_cfg_string[4]); Color = Color.FromArgb(int.Parse(separ_cfg_string[5]), int.Parse(separ_cfg_string[6]), int.Parse(separ_cfg_string[7])); return(new CSignal(SignalName, TableDefName, Decimal, Color)); }
/// <summary> /// /// </summary> /// <param name="separ_names_string">First row of that </param> /// <param name="separ_cfg_string"></param> /// <returns></returns> public static CSigMultitext FromIni(CIniFile config, string[] separ_cfg_string) { string TableDefName, Column, TableName, textlist; int ConnectionStringNumber; Color Color; ConnectionStringNumber = int.Parse(separ_cfg_string[1]); Column = separ_cfg_string[2]; TableName = separ_cfg_string[3]; TableDefName = TableDefinition.Find(config, ConnectionStringNumber, TableName); if (TableDefName == null) { TableDefinition.Add(config, ConnectionStringNumber, TableName); } Color = Color.FromArgb(int.Parse(separ_cfg_string[5]), int.Parse(separ_cfg_string[6]), int.Parse(separ_cfg_string[7])); textlist = ColumnTextlistDefine.FindtextlistName(separ_cfg_string[2]); if (textlist == null) { } return(new CSigMultitext(TableDefName, Column, Color, textlist)); }