Exemple #1
0
        /// <summary>
        /// This method is responisble for saving logs into database.
        /// </summary>
        public void Run()
        {
            string Function_Name = "Run";

            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Entered");
            //store current thread instance
            m_thread = Thread.CurrentThread;

            while (true)
            {
                //wait for new item to be added to quene/ termination of thread
                m_addItemSignal.WaitOne();
                if (IsTerminated())
                {
                    break;
                }

                //if there is any item in queue to process
                if (!IsQueneEmpty())
                {
                    //copy to local quene
                    Queue <EtyTrendLog> tempQuene = null;
                    lock (m_ObjectLock)
                    {
                        tempQuene = new Queue <EtyTrendLog>(m_writeQuene.ToArray());
                        m_writeQuene.Clear();
                    }

                    while (tempQuene != null && tempQuene.Count != 0)
                    {
                        if (CheckDatabaseConnection())
                        {
                            EtyTrendLog etyTrendLog = tempQuene.Dequeue();
                            //save into database
                            if (!TrendLogDAO.GetInstance().InsertTrendViewerLog(etyTrendLog))
                            {
                                m_dbDisconnected = true;
                                //check whether insert SQL failed due to database Connection failure
                                if (!CheckDatabaseConnection())
                                {
                                    //insert back to quene
                                    var Items = tempQuene.ToArray();
                                    tempQuene.Clear();
                                    tempQuene.Enqueue(etyTrendLog);
                                    foreach (var item in Items)
                                    {
                                        tempQuene.Enqueue(item);
                                    }
                                }
                                //due to some other error, ignore this item
                            }
                        }
                    }
                }
            }

            // time to end the thread
            Thread.CurrentThread.Abort();
            LogHelper.Trace(CLASS_NAME, Function_Name, "Function_Exited");
        }
Exemple #2
0
        public void InsertTrendViewerLog()
        {
            EtyTrendLog etyTrendLog = new EtyTrendLog();

            etyTrendLog.Data_PT_Host   = TestDBInit.HOST_NAME;
            etyTrendLog.Data_PT_Server = TestDBInit.OPCSERVER_NAME; //"TransActiveDataSource"
            etyTrendLog.Data_PT_Name   = "unitTest_Log1";
            etyTrendLog.Data_PT_Value  = 2;
            etyTrendLog.Data_PT_Time   = DateTime.Now;

            TrendLogDAO.GetInstance().InsertTrendViewerLog(etyTrendLog);
        }
Exemple #3
0
        public void TestGetHistDPLogList()
        {
            EtyHistDataPoint histDP = new EtyHistDataPoint();

            histDP.DPName          = "DT17.COM.CBN.RF2.diiRF-AlarmNormal.Value";
            histDP.DPServer        = TestDBInit.OPCSERVER_NAME; //"TransActiveDataSource"
            histDP.DPHost          = TestDBInit.HOST_NAME;
            histDP.DPStartDateTime = new DateTime(2013, 1, 10);
            histDP.DPEndDateTime   = new DateTime(2013, 1, 12);

            DateTime startTime = new DateTime(2012, 1, 10, 1, 1, 1);
            DateTime endTime   = new DateTime(2012, 1, 12, 23, 59, 59);

            TrendLogDAO.GetInstance().GetHistDPLogList(histDP, startTime, endTime);
        }
Exemple #4
0
 public void TestTrendLogDAOConstructor01()
 {
     TrendLogDAO trendLogDAO = new TrendLogDAO();
 }
Exemple #5
0
 public void TestReleaseInstance01()
 {
     TrendLogDAO.ReleaseInstance();
 }
Exemple #6
0
 public void TestGetInstance01()
 {
     TrendLogDAO trendLogDAO = TrendLogDAO.GetInstance();
 }
Exemple #7
0
        public void TestCreateTrendLogDAO02()
        {
            TrendLogDAO trendLogDAO = CreateTrendLogDAO02();

            Assert.IsNotNull(trendLogDAO);
        }
Exemple #8
0
        public static TrendLogDAO CreateTrendLogDAO02()
        {
            TrendLogDAO trendLogDAO = new TrendLogDAO();

            return(trendLogDAO);
        }
Exemple #9
0
        public static TrendLogDAO CreateTrendLogDAO01()
        {
            TrendLogDAO trendLogDAO = TrendLogDAO.GetInstance();

            return(trendLogDAO);
        }