private void buildPush(Syntax.SQuery sq, string[] gVal)
 {
     if (gVal.Length == 2)
     {
         //1. table
         //2. Field & value (fd:value);
         var tbName   = gVal[0];
         var tbfields = gVal[1].Replace("[", "").Replace("]", "").Split(',');
         for (int i = 0; i < tbfields.Length; i++)
         {
             var tbfld = split(":", tbfields[i]).ToList();
             if (tbfld.Count == 2)
             {
                 sq.AddTableField(tbName, tbfld[0], tbfld[1]);
             }
             else
             {
                 //throw error
             }
         }
     }
     else
     {
         // throw error;
     }
 }
 private void buildPut(Syntax.SQuery sq, string[] gVal)
 {
     if (gVal.Length >= 2)
     {
         //1. table
         //2. Field & value (fd:value);
         var tbName   = gVal[0];
         var tbfields = gVal[1].Replace("[", "").Replace("]", "").Split(',');
         //var condition = @",(?![^\(\[]*[\]\)])";
         for (int i = 0; i < tbfields.Length; i++)
         {
             var tbfld = tbfields[i].Split(':').Where(s => s != string.Empty).ToList();
             var val   = tbfields[i].Split(':').Where(s => s != string.Empty);
             if (tbfld.Count >= 2)
             {
                 sq.AddTableField(tbName, tbfld[0], tbfld[1]);
             }
             else
             {
                 //throw error
             }
         }
         for (int i = 2; i < gVal.Length; i++)
         {
             if (Scan(QueryDefination.andcondition, gVal[i]))
             {
                 string[] str;
                 str = getValues(QueryDefination.andcondition, gVal[i]);
                 foreach (string s in str)
                 {
                     var tf = getValues(QueryDefination.andorconditionExtract, s);
                     buildAndorCondition(sq, tf, 1);
                 }
             }
             else if (Scan(QueryDefination.orcondition, gVal[i]))
             {
                 string[] str;
                 str = getValues(QueryDefination.orcondition, gVal[i]);
                 foreach (string s in str)
                 {
                     var tf = getValues(QueryDefination.andorconditionExtract, s);
                     buildAndorCondition(sq, tf, 1);
                 }
             }
             //buildAndorCondition()
         }
     }
     else
     {
         // throw error;
     }
 }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sq"></param>
        /// <param name="gVal"></param>
        private void buildSelect(Syntax.SQuery sq, string[] gVal)
        {
            var tb  = "";
            var fld = "";

            string[] tf;
            for (int i = 0; i < gVal.Length; i++)
            {
                tf = gVal[i].Split(':');
                if (tf.Length > 0 && tf.Length == 2)
                {
                    tb  = tf[0];
                    fld = tf[1];
                    sq.AddTableField(tb, fld);
                }
                else
                {
                    //write error here
                }
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sq"></param>
        /// <param name="gVal"></param>
        private void buildSelect(Syntax.SQuery sq, string item)
        {
            var tb = "";

            string[] gVal = getValues(QueryDefination.getTableWithField, item);
            string[] tf;
            for (int i = 0; i < gVal.Length; i++) // only one record will come here
            {
                string tName  = "";
                string tbAlis = "";
                if (Scan(QueryDefination.splitTableName, gVal[i]))   // check table name
                // index 0 tbname index 2 tbalias index 1- table field
                {
                    string[] gv = split(QueryDefination.splitTableName, gVal[i]); // split table name with alias
                    if (gv.Length > 0)
                    {
                        tName = gv[0];
                        if (gv.Length == 3)
                        {
                            tbAlis = gv[2];
                        }
                        string   tbf  = gv[1].Replace("]", "").Replace("[", "");
                        string[] tbfs = tbf.Split(',');
                        foreach (string s in tbfs)
                        {
                            tf = s.Split(':');
                            var fld   = "";
                            var fldas = "";
                            if (tf.Length > 0)
                            {
                                fld = tf[0];
                                if (tf.Length == 2)
                                {
                                    fldas = tf[1];
                                }
                                else
                                {
                                    fldas = fld;
                                }
                                sq.AddTableField(tName, fld, fldas, tbAlis);
                            }
                            else
                            {
                                //write error here
                            }
                        }
                    }
                    else
                    {
                        //add error
                    }
                }
                if (Scan(QueryDefination.getTableRelation, item))
                {
                    string[] gv = getValues(QueryDefination.getTableRelation, item);
                    if (gv.Length > 0)
                    {
                        string relation = gv[0].ToString().Replace("with[", "").Replace("with [", "").Replace("with [ ", "").Replace("]", "");
                        buildRelation(sq, relation.ToString().Split(','), tName);
                    }
                    else
                    {
                        //add error
                    }
                }
            }
        }