Example #1
0
        /// <summary>
        /// 获取记录集
        /// </summary>
        /// <param name="where">WHERE条件</param>
        /// <param name="pageNum">页容量</param>
        /// <param name="page">当前页</param>
        /// <param name="fields">字段集,第一个字段用来排序</param>
        /// <returns>记录集,获取失败则为 null||Count==0</returns>
        public List <Dictionary <string, string> > Get(string where, int pageNum, int page, params string[] fields)
        {
            string field = string.Empty;

            foreach (string f in fields)
            {
                field += f + ",";
            }
            field = field.Remove(field.Length - 1);

            string sql = "SELECT " + field + " FROM " + _table
                         + (where == "" ? "" : " WHERE " + where) + (fields[0] == "*" ? "" : " ORDER BY " + fields[0]);
            CVRJsonParser jp = base.SelectJsonSync(sql, pageNum, page);

            if (jp != null)
            {
                List <Dictionary <string, string> > rss = new List <Dictionary <string, string> >();
                for (int i = 0; i < jp.Count; ++i)
                {
                    if (jp[i] != null)
                    {
                        rss.Add(jp[i]);
                    }
                }
                return(rss);
            }

            return(null);
        }
Example #2
0
        /// <summary>
        /// 获取记录集数量
        /// 针对大数据集采用排序可以提高效率
        /// </summary>
        /// <param name="field">排序字段</param>
        /// <returns>记录集数量,-1则错误</returns>
        public int GetCount(string field = "")
        {
            CVRJsonParser jp = base.SelectJsonSync("SELECT " + (field == "" ? "*" : field) + " FROM "
                                                   + _table + (field == "" ? "" : " ORDER BY " + field));

            return(jp.Count);
        }
Example #3
0
 private void _ic_Notified(CVResult r, object o)
 {
     if (r == CVResult.TableQueryReceived)
     {
         if (o is QueryResultPt)
         {
             QueryResultPt qrp = o as QueryResultPt;
             if (qrp.success == 0)
             {
                 if (qrp.resultFmart == "xml")
                 {
                     _txw = new TableXmlWrapper(qrp);
                     Notified?.Invoke(CVRTableResult.SelectXmlReceived, _txw);
                 }
                 else if (qrp.resultFmart == "json")
                 {
                     _cjp = new CVRJsonParser(qrp.result)
                     {
                         Token = qrp.token,
                         Count = qrp.count
                     };
                     Notified?.Invoke(CVRTableResult.SelectJsonReceived, _cjp);
                 }
             }
             else
             {
                 Notified?.Invoke(CVRTableResult.SelectFailed, qrp.msg);
             }
         }
     }
     else if (r == CVResult.TableUpdateReceived)
     {
         if (o is ExecuteResultPt)
         {
             ExecuteResultPt erp = o as ExecuteResultPt;
             _ui = new UpdateItem
             {
                 Id      = erp.token,
                 Succeed = erp.success == 0,
                 Msg     = erp.msg
             };
             Notified?.Invoke(CVRTableResult.UpdateResultReceived, _ui);
         }
     }
 }