コード例 #1
0
 protected void Dispose(bool Diposing)
 {
     if (!IsDisposed)
     {
         if (Diposing)
         {
             //Clean Up managed resources
             WriteLogCardReader("<-------------System offline------------->");
             if (mCardReader != null)
             {
                 foreach (cCardReader c in this.mCardReader)
                 {
                     if (c != null)
                     {
                         c.Dispose();
                         Thread.Sleep(100);
                     }
                 }
             }
             mCardReader = null;
             if (mPort != null)
             {
                 mPort.Dispose();
             }
             mPort = null;
             mLog  = null;
         }
         //Clean up unmanaged resources
     }
     IsDisposed = true;
 }
コード例 #2
0
        public void InitialProcess(Int32 pCompID)
        {
            //Addlistbox(fMercury.OraDb.ConnectStatus().ToString());
            //PPort = new cPorts(fMercury);
            //PPort.InitialPort(pCompID);
            //PPort.StartThread();
            Thread.Sleep(500);
            string strSQL = "select t.* from tas.VIEW_CR_BAY t" +
                            " where t.comp_id=" + pCompID;
            DataSet   ds = new DataSet();
            DataTable dt;
            string    vMsg = "";

            try
            {
                if (mFMercury.mOraDb.OpenDyns(strSQL, "TableName", ref ds))
                {
                    dt           = ds.Tables["TableName"];
                    mLogFileName = "CRBay" + dt.Rows[0]["bay_no"].ToString();
                    WriteLogCardReader("<-------------System online------------->");
                    mCardReader = new cCardReader[dt.Rows.Count];

                    for (int i = 0; i < mCardReader.Length; i++)
                    {
                        vMsg = "Create " + dt.Rows[i]["card_reader_name"];

                        mCardReader[i] = new cCardReader(this.mFMercury, this);

                        mCardReader[i].mCR_NewValue.IsEnable  = Convert.ToBoolean(dt.Rows[i]["is_enabled"]);
                        mCardReader[i].mCR_NewValue.IsLock    = Convert.ToBoolean(dt.Rows[i]["is_locked"]);
                        mCardReader[i].mCR_NewValue.IsProcess = Convert.ToBoolean(dt.Rows[i]["is_process"]);
                        mCardReader[i].mCR_NewValue.ID        = dt.Rows[0]["card_reader_id"].ToString();
                        vMsg = vMsg + (mCardReader[i].mCR_NewValue.IsEnable ? "" : "[Card Reader disable!!!]").ToString();
                        WriteLogCardReader(vMsg);
                        if (mCardReader[i].mCR_NewValue.IsEnable)
                        {
                            mCardReader[i].InitialCardReader(dt.Rows[i]["card_reader_id"].ToString());
                        }
                        //Thread.Sleep(500);
                        //PCardReader[i].StartThread();
                    }
                }
                WriteLogCardReader("Database connect = " + mFMercury.mOraDb.ConnectStatus().ToString() + "[" +
                                   mFMercury.mOraDb.GetConnectDBName() + "]");
                mPort = new cPorts(mFMercury, this);
                mPort.DataReceived += OnReceive;
                mPort.InitialPort(pCompID);
                mPort.StartThread();
                Thread.Sleep(1000);
                for (int i = 0; i < mCardReader.Length; i++)
                {
                    if (mCardReader[i].mCR_NewValue.IsEnable)
                    {
                        Thread.Sleep(50);
                        mCardReader[i].StartThread(ref mPort);
                    }
                }
            }
            catch (Exception exp)
            {
                WriteLogCardReader(exp.ToString());
            }
            ds = null;
            dt = null;
        }