Beispiel #1
0
        private void InstructionMain()
        {
            int lasRowCount = 0;

            while (true)
            {
                try
                {
                    OledbAdapter o  = new OledbAdapter();
                    var          dt = OledbAdapter.GetInstruction("select * from instructions.dbf");
                    if (dt != null && dt.Rows.Count > lasRowCount)
                    {
                        bool needRefreshAdd    = false;
                        bool needRefreshCancel = false;

                        for (int i = lasRowCount; i < dt.Rows.Count; i++)
                        {
                            RefreshInstructionItem(dt.Rows[i], ref needRefreshAdd, ref needRefreshCancel);
                        }

                        if (_clientID == -1)
                        {
                            int addMax = -1;
                            int canMax = -1;
                            if (AddInstructionDict.Count > 0)
                            {
                                addMax = AddInstructionDict.Values.Max(_ => int.Parse(_.ClientId));
                            }
                            if (CancelInstructionDict.Count > 0)
                            {
                                canMax = CancelInstructionDict.Values.Max(_ => int.Parse(_.ClientId));
                            }
                            _clientID = Math.Max(addMax, canMax) + 1;
                        }
                        if (needRefreshAdd && OnAddInstructionChange != null)
                        {
                            OnAddInstructionChange.Invoke();
                        }
                        //if (needRefreshCancel && OnCancelInstructionChange != null)
                        //{
                        //    OnCancelInstructionChange.Invoke();
                        //}
                        lasRowCount = dt.Rows.Count;
                    }
                    else if (_clientID == -1)
                    {
                        _clientID = 0;
                    }
                }
                catch (Exception ex)
                {
                    Utils.logger.LogInfo("InstructionMain Exception, Message:{0}", ex.Message);
                }

                Thread.Sleep(200);
            }
        }
Beispiel #2
0
        public bool ExistDBFData()
        {
            var insTable = OledbAdapter.GetInstruction("select * from instructions.dbf");

            if (insTable != null && insTable.Rows.Count > 0)
            {
                return(true);
            }
            var ordTable = OledbAdapter.GetDataTable("select * from order_updates.dbf");

            if (ordTable != null && ordTable.Rows.Count > 0)
            {
                return(true);
            }
            return(false);
        }