Пример #1
0
        //查询列表示例
        public static void getlistcondition()
        {
            ConditionFieldModel     condition  = new ConditionFieldModel();
            ConditionFieldItemModel fieldmodel = new ConditionFieldItemModel()
            {
                FieldName = "id", ValueMin = 0, ValueMax = 2012199998
            };

            condition.List.Add(fieldmodel);
            ConditionFieldItemModel fieldmodel2 = new ConditionFieldItemModel()
            {
                FieldName = "num1", ValueMin = 0, ValueMax = 35000
            };

            condition.List.Add(fieldmodel2);
            //ConditionFieldItemModel fieldmodel3 = new ConditionFieldItemModel() { FieldName = "num2", ValueMin = 300, ValueMax = 3500 };
            //condition.List.Add(fieldmodel3);
            long   sqlnum     = 0;
            DBRead serverread = new DBRead();
            //var d1 = serverread.GetCount(condition, ref sqlnum);
            //Console.WriteLine("返回记录总数:" + d1 + ",执行数据库次数:" + sqlnum);
            DataTable ddd2 = serverread.GetList(basemodel, condition, ref sqlnum);

            Console.WriteLine("返回记录数:" + ddd2.Rows.Count + ",执行数据库次数:" + sqlnum);
        }
Пример #2
0
        /// <summary>
        ///查询所有数据示列
        /// </summary>
        public static void getrowallcount()
        {
            long   sqlnum1     = 0;
            DBRead serverread1 = new DBRead();
            var    d1          = serverread1.GetAllCount2(basemodel, ref sqlnum1);

            Console.WriteLine("返回记录总数:" + d1 + ",执行数据库次数:" + sqlnum1);
        }
Пример #3
0
        //---------------db Functions------------

        private void CountLinesInDB()
        {
            SQLiteDataReader DBRead;
            SQLiteCommand    comm = new SQLiteCommand("select count(*) from printView", conn);

            DBRead = comm.ExecuteReader();
            DBRead.Read();
            dblines = DBRead.GetInt32(0);
        }
Пример #4
0
        protected override void OnStop()
        {
            _logger.Log(Category.Info, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ".OnStop()");

            //signal the worker threads to exit
            _syncEvts.GlobalExitEvent.Set();

            if (_DBRead != null)
            {
                _DBRead = null;
            }

            if (_DBWrite != null)
            {
                _DBWrite = null;
            }

            //join all the threads and stop them
            Thread[] thrArr = new Thread[] { DBReadThread, DBWriteThead };
            foreach (Thread t in thrArr)
            {
                if (t != null && t.IsAlive)
                {
                    //gives the threat 5s time to finish otherwise it will be aborted
                    bool b = t.Join(5000);
                    if (!b)
                    {
                        t.Abort();
                    }
                }
            }

            DBReadThread = null;
            DBWriteThead = null;

            //wait additional time to close application
            Thread.Sleep(200);
            //indicate a successful exit
            ExitCode = 0;
        }
Пример #5
0
        protected override void OnStart(string[] args)
        {
            if (!bIsService)
            {
                Console.Title = ConfigurationManager.AppSettings["AppName"];
            }

            _logger.Log(Category.Info, MethodBase.GetCurrentMethod().DeclaringType.Name + ".OnStart");

            Thread.CurrentThread.Name = GetType().Name;

            IntPtr handle = ServiceHandle;

            if (bIsService)
            {
                _svcStatus.currentState = (int)ServiceState.SERVICE_START_PENDING;
                SetServiceStatus(handle, ref _svcStatus);
            }

            ++_syncEvts.ThreadsToRun;
            _DBRead = new DBRead();

            ++_syncEvts.ThreadsToRun;
            _DBWrite = new DBWrite();

            _logger.Log(Category.Info, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": waiting for {0} threads ...", _syncEvts.ThreadsToRun);

            if (_syncEvts.AllThreadsRunning.WaitOne(GlobalParameters._iThreadStartTimeout))
            {
                if (bIsService)
                {
                    _svcStatus.currentState = (int)ServiceState.SERVICE_RUNNING;
                    SetServiceStatus(handle, ref _svcStatus);
                }
            }
            else
            {
                _logger.Log(Category.SysError, MethodBase.GetCurrentMethod().DeclaringType.Name + "_" + MethodBase.GetCurrentMethod().Name + ": waiting for SyncEvts.AllThreadsRunning failed");
            }
        }