/// <summary>
        /// method to parse line with NameDef
        /// </summary>
        /// <param name="config">config structure</param>
        /// <param name="tableName">name of table</param>
        /// <param name="column">name of column in db</param>
        /// <param name="line">a line in names</param>
        /// <param name="nameLine">a line in names</param>
        /// <param name="names">names which will contains name in all langs</param>
        private static void parseNameDefLine(CIniFile config, string tableName, string column, string line, List <string> nameLine, string[] names)
        {
            int           iterator    = 0;                   //for string[] names intaration
            List <string> units       = new List <string>(); //here add units
            string        lineTmp     = line.Substring(line.IndexOf("=") + 1);
            List <string> nameDefLine = lineTmp.Split(Const.separ_names, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim()).ToList();

            if (nameDefLine.Count <= config.LangEnbList.Count) //magic constant (dbidx + column + space)
            {
                for (int j = 0; j < nameDefLine.Count; j++)
                {
                    names[iterator] = nameDefLine[j];
                    iterator++;
                }
            }
            else
            {
                for (int j = 0; j < nameDefLine.Count; j += 2)
                {
                    names[iterator] = nameDefLine[j];
                    units.Add(nameDefLine[j + 1]);
                    iterator++;
                }
            }
            NameDefinition.Add(config, column, names, units, tableName); //Adds name to names
        }
        /// <summary>
        /// method to parse multitext defined in only one line
        /// </summary>
        /// <param name="config">config structure</param>
        /// <param name="tableName">name of table</param>
        /// <param name="column">name of column in db</param>
        /// <param name="line">a line in names</param>
        /// <param name="names">names which will contains name in all langs</param>
        private static void parseMultitextInLine(CIniFile config, string tableName, string column, string line, string[] names)
        {
            string[] Tmp      = line.Split(Const.separ_equate, StringSplitOptions.RemoveEmptyEntries);
            string   Variable = Tmp[0]; // not used
            string   DefBody  = Tmp[1];

            string[] langs = DefBody.Split(Const.separ_dollar, StringSplitOptions.RemoveEmptyEntries);
            langs = langs.Where(p => p.Length > 2).ToArray();
            int LangCnt = langs.Length;

            string[][] items = new string[LangCnt][];

            for (int j = 0; j < LangCnt; j++)
            {
                string[] Tmp2 = langs[j].Split(Const.separ_names, StringSplitOptions.RemoveEmptyEntries);
                names[j] = Tmp2[0];
                string itemList = Tmp2[1];

                items[j] = itemList.Split(Const.separ_backslashNew, StringSplitOptions.RemoveEmptyEntries);
            }

            // pricny pruchod
            List <string[]> values = new List <string[]>(); //For the ending state of values
            List <int>      Idxs   = new List <int>();      //Initial defintion

            int itemCnt = items[0].Length;                  // bacha, spoleha se, ze jsou vsechna pole stejne dlouha - patri se monzna Minimum delek

            for (int x = 0; x < itemCnt; x++)
            {
                string[] tmpPole = new string[LangCnt];
                for (int L = 0; L < LangCnt; L++)
                {
                    tmpPole[L] = items[L][x];   // transpozice matice
                }
                Idxs.Add(x);
                values.Add(tmpPole);
            }
            for (int i = 0; i < names.Length; i++)
            {
                if (names[i].Contains(@"\"))
                {
                    names[i] = names[i].Replace(@"\", "-");
                }
            }
            TextlistDefinition.Add(config, column, values, Idxs);        //name is not present so add name as tablename
            List <string> units = null;                                  //yes add only null

            NameDefinition.Add(config, column, names, units, tableName); //Adds name to names
        }
Exemple #3
0
        private static void parseMultitextInLine2(CIniFile config, string tableName, string column, string line, string[] names)
        {
            List <string[]> values = new List <string[]>(); //For the ending state of values
            List <int>      Idxs   = new List <int>();      //Initial defintion

            string[]   langs = line.Split(Const.separ_dollar, StringSplitOptions.RemoveEmptyEntries);
            string[][] vals  = vals = new string[langs.Length][];


            for (int j = 0; j < langs.Length; j++)
            {
                int equalPos     = langs[j].LastIndexOf(@"=");
                int semicolonPos = langs[j].IndexOf(@";");
                if (equalPos != -1)
                {
                    names[j] = langs[j].Substring(equalPos + 1, (semicolonPos - equalPos));
                    langs[j] = langs[j].Substring(equalPos + 1);
                }
                else
                {
                    names[j] = langs[j].Substring(0, (semicolonPos));
                    langs[j] = langs[j].Substring(semicolonPos + 1);
                }
                string[] prevals = langs[j].Split(Const.separ_backslashNew, StringSplitOptions.RemoveEmptyEntries);
                int      index   = 0;

                for (int k = 0; k < prevals.Length; k++)
                {
                    //vals[j][index] = new string[];
                    vals[j][index] = prevals[index];
                    index++;
                }
            }
            for (int k = 0; k < vals.Length; k++)
            {
                Idxs.Add(k);
                values.Add(vals[k]);
            }
            TextlistDefinition.Add(config, tableName, values, Idxs);     //name is not present so add name as tablename
            List <string> units = null;                                  //yes add only null

            NameDefinition.Add(config, column, names, units, tableName); //Adds name to names
        }
        /// <summary>
        /// method to parse multitext defined in only one line
        /// </summary>
        /// <param name="config">config structure</param>
        /// <param name="tableName">name of table</param>
        /// <param name="column">name of column in db</param>
        /// <param name="line">a line in names</param>
        /// <param name="nameLine">a line in names</param>
        /// <param name="names">names which will contains name in all langs</param>
        private static string parseMultitextLine(CIniFile config, string tableName, string column, string line, List <string> nameLine, string[] names)
        {
            //Textlist on a tag
            int    multitextIndex = nameLine.FindIndex(s => s.Contains("multitext"));
            string TextListName   = nameLine[multitextIndex + 1].Trim();

            ColumnTextlistDefine.Add(column, TextListName); //To add textlist into helper class
            //Only add rest of tag also into NameDef
            string[] eqeuateSplit = line.Split(Const.separ_equate, StringSplitOptions.RemoveEmptyEntries);
            string[] langs        = eqeuateSplit[1].Split(Const.separ_dollar, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < langs.Length; i++)
            {
                string[] parts = langs[i].Split(Const.separ_semicolon, StringSplitOptions.RemoveEmptyEntries);
                names[i] = parts[0];
            }
            List <string> units = null;                                  //yes add only null

            NameDefinition.Add(config, column, names, units, tableName); //Adds name to names
            return(TextListName);
        }
Exemple #5
0
        private int parseNameDefinition(CIniFile config, string[] separators, string[] lines, int startLineIdx)
        {
            string[]        nameLine        = null, nameLineFirstPart = null, nameLineLangMutate = null;
            string          tableName       = null;
            List <string[]> multitext_lines = new List <string[]>();

            for (int i = startLineIdx; i < lines.Length; i++)
            {
                List <string> units = new List <string>();
                string[]      langs = new string[config.LangEnbList.Count];
                if (!(lines[i].StartsWith("#")) && (lines[i].Length != 0))
                {
                    nameLine           = lines[i].Split(Const.separ_equate, StringSplitOptions.RemoveEmptyEntries);
                    nameLineFirstPart  = nameLine[0].Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    nameLineLangMutate = nameLine[1].Split(Const.separ_names, StringSplitOptions.RemoveEmptyEntries);
                    foreach (CView view in config.ViewList)
                    {
                        foreach (CField field in view.FieldList)
                        {
                            foreach (CSignal signal in field.SigList)
                            {
                                if (signal.column.Contains(nameLineFirstPart[1]))
                                {
                                    tableName = signal.table;
                                }
                            }
                        }
                    }
                    int j = 0;
                    for (int idx = 0; idx < nameLineLangMutate.Length; idx = idx + 2)
                    {
                        if (!(nameLineLangMutate[idx + 1].Contains(@"\")) && !(nameLineLangMutate[idx + 1].Contains("multitext:")))
                        {
                            if (nameLineLangMutate.Length > config.LangEnbList.Count)
                            {
                                langs[j] = nameLineLangMutate[idx];
                                units.Insert(j, nameLineLangMutate[idx + 1]);
                                j++;
                            }
                            else
                            {
                                langs[j] = nameLineLangMutate[idx];
                                j++;
                            }
                        }
                        else
                        {
                            langs[j] = nameLineLangMutate[idx];
                            if (!(nameLineLangMutate[idx + 1].Contains("multitext:")))
                            {
                                multitextInline(config, tableName, nameLine[1]);
                                idx = nameLineLangMutate.Length;
                            }
                            else
                            {
                                int    pos          = nameLineLangMutate[idx + 1].LastIndexOf(":");
                                string TextlistName = nameLineLangMutate[idx + 1].Substring(pos + 1);
                                ColumnTextlistDefine.Add(nameLineFirstPart[1], TextlistName);
                            }
                            j++;
                        }
                    }
                    NameDefinition.Add(config, nameLineFirstPart[1], langs, units, tableName);
                }
                else
                {
                    return(i);
                }
            }
            return(0);
        }