示例#1
0
文件: Pusher.cs 项目: ryujibilly/LGD
 /// <summary>
 /// 获取即将推送的数据
 /// </summary>
 public void getData(SQLiteDBHelper helper, List <String> selecttablist, String instru, String beginDate, String beginTime, String endDate, String endTime)
 {
     try
     {
         foreach (String tabname in selecttablist)
         {
             PushingDataTabQueue.Enqueue(helper.getPushingData(instru, tabname, beginDate, beginTime, endDate, endTime));
         }
     }
     catch (System.Exception ex)
     {
         Debug.WriteLine(ex.Message + "\r\t==========" + "pusher.getDataSQLiteDBHelper helper,List<String> selecttablist,String instru,String beginDate,String beginTime,String endDate,String endTime)");
     }
 }
示例#2
0
文件: Pusher.cs 项目: ryujibilly/LGD
        /// <summary>
        /// 静态推送数据进入队列
        /// </summary>
        /// <param name="helper">SQLitehelper</param>
        /// <param name="selecttablist">推送的表名列</param>
        /// <param name="instru">仪器</param>
        /// <param name="_fps">单词推送表数量</param>
        /// <returns>是否推送完毕</returns>
        public void getData(SQLiteDBHelper helper, List <String> selecttablist, String instru, int _fps)
        {
            IsSynPush = false;
            try
            {
                //锁定入队操作,加互斥锁
                //MTX = new Mutex(true, "ReaddingDB",out canReadDB);

                foreach (String tabname in selecttablist)
                {
                    int       rowidstart = 0;
                    int       rowidend   = 0;
                    DataTable dt         = new DataTable();
                    //起始rowid
                    int _startindex = LastSentRowIDDic[tabname];
                    //截至rowid
                    int _endindex = LastInsertRowIDDic[tabname];
                    //入队条件
                    while (_startindex >= 0 && _endindex >= 0 && _startindex + _fps <= _endindex)
                    {
                        lock (sqliteLockObj)
                        {
                            dt = helper.getPushingData(instru, tabname, _startindex, _fps, out rowidstart, out rowidend).Copy();
                        }
                        _startindex += _fps;
                        //if (PushingDataTabQueue.Count >= 100)
                        //    PushingQueueFull = true;
                        //else
                        PushingDataTabQueue.Enqueue(dt);
                        IsSynPush = true;
                        if (_endindex - _startindex < _fps)
                        {
                            SynchroData(helper, selectedTabList, Instname);
                            break;
                        }
                    }
                }
                //完成入队操作,释放互斥锁
                //MTX.ReleaseMutex();
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine(ex.Message + "\r\t==========" + "pusher.getData(SQLiteDBHelper helper, List<String> selecttablist, String instru,int _fps)");
            }
        }
示例#3
0
文件: Pusher.cs 项目: ryujibilly/LGD
 /// <summary>
 /// 将实时数据放入待推送队列中
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="selecttablist"></param>
 /// <param name="instru"></param>
 public void SynchroData(SQLiteDBHelper helper, List <String> selecttablist, String instru)
 {
     try
     {
         ////锁定入队操作,加互斥锁
         //MTX = new Mutex(true, "ReaddingDB", out canReadDB);
         int rowid = 0;
         foreach (String tabname in selecttablist)
         {
             DataTable dt = new DataTable();
             //起始rowid
             int _startindex = LastSentRowIDDic[tabname];
             //截至rowid
             int _endindex = LastInsertRowIDDic[tabname];
             if (_endindex > _startindex)
             {
                 lock (sqliteLockObj)
                 {
                     dt = helper.getPushingData(instru, tabname, LastSentRowIDDic[tabname], out rowid);
                 }
             }
             if (rowid > 0)
             {
                 LastInsertRowIDDic[tabname] = rowid;
                 if (dt.Rows.Count > 0)
                 {
                     //if (PushingDataTabQueue.Count >= 100)
                     //    PushingQueueFull = true;
                     //else
                     PushingDataTabQueue.Enqueue(dt);
                 }
                 //完成入队后  startindex赋值为最新rowid
                 LastSentRowIDDic[tabname] = rowid;
             }
         }
         IsSynPush = false;
         ////完成入队操作,释放互斥锁
         //MTX.ReleaseMutex();
     }
     catch (System.Exception ex)
     {
         Debug.WriteLine(ex.Message + "\r\t==========" + "pusher.getDataSQLiteDBHelper helper,List<String> selecttablist,String instru,String beginDate,String beginTime,String endDate,String endTime)");
     }
 }
示例#4
0
文件: Pusher.cs 项目: ryujibilly/LGD
        /// <summary>
        /// 获取即将推送的数据
        /// </summary>
        /// <returns>缓存是否读取完</returns>
        public bool getData(SQLiteDBHelper helper, List <String> selecttablist, String instru, int _fps)
        {
            bool isOver = false;

            try
            {
                foreach (String tabname in selecttablist)
                {
                    int       rowidstart  = 0;
                    int       rowidend    = 0;
                    DataTable dt          = new DataTable();
                    int       _startindex = getLastIndex(tabname, IndexTable);
                    if (_startindex >= 0)
                    {
                        dt = helper.getPushingData(instru, tabname, _startindex, _fps, out rowidstart, out rowidend).Copy();
                        String strDate = dt.Rows[dt.Rows.Count - 1].ItemArray[5].ToString();
                        String strTime = dt.Rows[dt.Rows.Count - 1].ItemArray[6].ToString();
                        PushingDataTabQueue.Enqueue(dt);
                        DataRow dr = IndexTable.NewRow();
                        dr[0] = tabname;
                        dr[1] = strDate;
                        dr[2] = strTime;
                        //起始rowid
                        dr[3] = rowidstart;
                        //截至rowid
                        dr[4] = rowidend;
                        IndexTable.Rows.Add(dr);
                    }
                    if ((rowidend - rowidstart + 1) < _fps)
                    {
                        isOver = true;
                        continue;
                    }
                }
                return(isOver);
            }
            catch (System.Exception ex)
            {
                Debug.WriteLine(ex.Message + "\r\t==========" + "pusher.getData(SQLiteDBHelper helper, List<String> selecttablist, String instru,int _fps)");
                return(false);
            }
        }
示例#5
0
文件: Pusher.cs 项目: ryujibilly/LGD
 /// <summary>
 /// 获取即将推送的数据(指定时间)
 /// </summary>
 public void getData(SQLiteDBHelper helper, List <String> selecttablist, String instru, String beginDate, String beginTime, String endDate, String endTime)
 {
     try
     {
         lock (sqliteLockObj)
         {
             foreach (String tabname in selecttablist)
             {
                 DataTable dt = new DataTable();
                 dt = helper.getPushingData(instru, tabname, beginDate, beginTime, endDate, endTime);
                 //if (PushingDataTabQueue.Count >= 100)
                 //    PushingQueueFull = true;
                 //else
                 PushingDataTabQueue.Enqueue(dt);
             }
         }
     }
     catch (System.Exception ex)
     {
         Debug.WriteLine(ex.Message + "\r\t==========" + "pusher.getDataSQLiteDBHelper helper,List<String> selecttablist,String instru,String beginDate,String beginTime,String endDate,String endTime)");
     }
 }