Esempio n. 1
0
 //        /// <summary>
 //        /// Returns a SystemStructures object that can access to all system objects
 //        /// </summary>
 //        public SystemStructures SYSTEMSTRUCTURE
 //        {
 //            get
 //            {
 //                SystemStructures SS = new SystemStructures();
 //                if((HighestSectionType.PreviousSectionTypeID == -99)&&(SystemAdminAlreadyLoggedIn == false))
 //                    SS.IsEnabled = true;
 //                else
 //                    SS.IsEnabled = false;
 //                return SS;
 //            }
 //        }
 internal void AcquireSystemLock()
 {
     string sSQL = "UPDATE tblSystem SET SysAdminConnected = 1, SysAdminConnectionTime = '" + DateTime.Now +
         "' , SysAdminLastUpdateTime = '" + DateTime.Now + "'";
     if((SC == null)||(SC.State == ConnectionState.Closed))
     {
         Functions F = new Functions();
         //F.ShareOpenConnection(ref SC);
         string ConnS = F.GetConnectionString();
         SC = new SqlConnection(ConnS);
         F.Dispose();
         SC.Open();
     }
     SqlCommand cm = new SqlCommand(sSQL,SC);
     cm.ExecuteNonQuery();
 }
Esempio n. 2
0
        private void OysterTimer_Tick(object source,System.Timers.ElapsedEventArgs e)
        {
            try
            {
                string sSQL = "UPDATE tblSystem SET SysAdminLastUpdateTime = '" + System.DateTime.Now + "'";
                if((SC == null)||(SC.State == ConnectionState.Closed))
                {

                    Functions F = new Functions();
                    //F.ShareOpenConnection(ref SC);
                    string ConnS = F.GetConnectionString();
                    SC = new SqlConnection(ConnS);
                    F.Dispose();
                    SC.Open();
                }
                SqlCommand cm = new SqlCommand(sSQL,SC);
                int numrecs = cm.ExecuteNonQuery();
                if(numrecs == 0)
                    throw new ApplicationException("Error writing update to System variable!");
            }
            catch(Exception Err)
            {
                throw new ApplicationException(Err.Message);
            }
        }
Esempio n. 3
0
        public void ReleaseResources()
        {
            try
            {
                if(OysterTimer.Enabled == true)
                {
                    OysterTimer.Enabled = false;

                    string sSQL = "UPDATE tblSystem SET SysAdminConnected = 0, SysAdminLastUpdateTime = '" + DateTime.Now + "'";
                    //if((SC == null)||(SC.State == ConnectionState.Closed))
                    //{
                    Functions F = new Functions();
                    //F.ShareOpenConnection(ref SC);
                    string ConnS = F.GetConnectionString();
                    SC = new SqlConnection(ConnS);
                    F.Dispose();
                    SC.Open();
                    //}
                    SqlCommand cm = new SqlCommand(sSQL,SC);
                    cm.ExecuteNonQuery();
                    SC.Dispose();
                }
            }
            catch(Exception Err)
            {
                throw new ApplicationException(Err.Message);
            }
        }