Exemplo n.º 1
0
        private void CreateNewSystem(SeeCommonDataSet.SysDefsRow defRow, bool sendOpen)
        {
            SqlManagerSystem sqlSys = new SqlManagerSystem();

            sqlSys.SetDb(defRow.DbName, DatabasePath);
            bool dbAvailable = sqlSys.IsDbRegistered();

            if (!dbAvailable)//Create database if necessary
            {
                dbAvailable = CreateSysDatabase(defRow.DbName);
            }
            if (dbAvailable)                                 //Only start monitoring if the database is available
            {
                ManageSystem sys = new ManageSystem(defRow); //Database must be available before creating this object
                SystemsCollection.Add(sys);                  //Add to the collection
                if (sys.IsMonitorOn)
                {
                    ThreadPool.QueueUserWorkItem(new WaitCallback(TurnOnMonitor), sys);
                }
                Thread.Sleep(1000);
                if (sendOpen)
                {
                    SendSysOpenMessage(sys);
                }
            }
        }
Exemplo n.º 2
0
        private void RemoveFromCollection(string name)
        {
            ManageSystem sys = SystemsCollection.GetByName(name);

            if (sys != null)
            {
                RemoveFromCollection(sys);
            }
        }
Exemplo n.º 3
0
        private void SendSysOpenMessage(ManageSystem sys)
        {
            string info = "Off";

            if (sys.IsMonitorOn)
            {
                info = sys.Status.Message;
            }
            SendUdpBroadcast(new UdpMessage(11, DateTime.Now, sys.Name, "Open-" + info));
        }
Exemplo n.º 4
0
        private void ModifySystem(string origName, string currName, bool sendOpen)
        {
            ManageSystem sys = SystemsCollection.GetByName(origName);

            RemoveFromCollection(sys);//remove old system

            SeeCommonDataSet.SysDefsRow defRow = GetSysDefRow(currName);
            if (defRow != null)
            {
                if (origName != currName)
                {
                    RenameDatabase(origName.Replace(' ', '_'), currName.Replace(' ', '_'));
                }
                CreateNewSystem(defRow, sendOpen);
            }                                       //this should start(or stop)polling with new settings
        }
Exemplo n.º 5
0
        private void SendForTrace(string name, string cmdName)
        {
            ManageSystem sys = SystemsCollection.GetByName(name);

            sys.SendForTrace(cmdName);
        }
Exemplo n.º 6
0
        private void SendTcpipCommand(string name, string cmdTxt)
        {
            ManageSystem sys = SystemsCollection.GetByName(name);

            sys.SendTcpipCommand(cmdTxt);
        }
Exemplo n.º 7
0
 private void RemoveFromCollection(ManageSystem sys)
 {
     sys.TurnOffMonitor();
     SystemsCollection.Remove(sys);
     sys.Dispose();
 }
Exemplo n.º 8
0
 private void TurnOnMonitor(ManageSystem sys)
 {
     sys.SendUdpBroadcast += new UdpDelegate(SendUdpBroadcast); //Service1 will dispatch the udp broadcasts
     sys.TurnOnMonitor();                                       //commented out for debugging
 }
Exemplo n.º 9
0
        private void TurnOnMonitor(object state)
        {
            ManageSystem sys = (ManageSystem)state;

            TurnOnMonitor(sys);
        }