Beispiel #1
0
 public Section CurrentSystemSection(string OysterPassword)
 {
     if(OysterPassword == "6419DC43-84B9-43e2-89FE-BB8C96D5CF6F")
     {
         Functions F = new Functions();
         Section X = F.GetSystemSection();
         return X;
     }
     else
         return null;
 }
Beispiel #2
0
        //        public void ReleaseCameras()
        //        {
        //
        //            if(NeedToRelinqueshControl == true)
        //            {
        //                try
        //                {
        //                    NeedToRelinqueshControl = false;
        //                    UserTimer.Enabled = false;
        //                    //Functions F = new Functions();
        //                    Functions F = new Functions();
        //                    F.ForceEncoderFree(CurrentControlledEncoder);
        ////                    if(SC.State == ConnectionState.Closed)
        ////                    {
        ////                        
        ////                        //SC.Open();
        ////                        
        ////                       // F.ShareOpenConnection(ref SC);
        ////                                  
        ////                    }
        //            
        //
        //                   // string sSQL = "DELETE FROM tblUserStreamingEncoderRel WHERE StreamingEncoderId = " + CurrentControlledEncoder;
        //                    //SqlCommand cm = new SqlCommand(sSQL,SC);
        //                   // int numrecs = cm.ExecuteNonQuery();
        //            
        //                    
        //                    //SC.Close();
        //                }
        //                catch(Exception Err)
        //                {
        //                    string peekerrror = Err.Message;
        //                }
        //            }
        //        }
        //        public void UserTimer_Tick(object sender, ElapsedEventArgs e)
        //        {
        //            if(ControllingCamera == true)
        //            {
        //                if(SC == null)
        //                {
        //                    Functions F = new Functions();
        //                    
        //                    F.ShareOpenConnection(ref SC);
        //
        //                }
        //                string sSQL = "UPDATE tblUserStreamingEncoderRel SET LastUpdatedTime = '" + System.DateTime.Now +
        //                    "' WHERE StreamingEncoderId = " + CurrentControlledEncoder +
        //                    " AND UserId = " + mvarID;
        //                SqlCommand CM = new SqlCommand(sSQL,SC);
        //                try
        //                {
        //                    int numRecs = CM.ExecuteNonQuery();
        //                    if(numRecs == 0)
        //                        throw new ApplicationException("ERROR: Failed to update system with new camera control time for SE.ID:" + CurrentControlledEncoder);
        //                }
        //                catch(Exception Err)
        //                {
        //                    string peekerror = Err.Message;
        //                    throw new ApplicationException("ERROR: Failed to update system with new camera control time for SE.ID:" + CurrentControlledEncoder + " ERROR MESSAGE: " + Err.Message);
        //                }
        //                NeedToRelinqueshControl = true;
        //            }
        //
        //        }
        //        public bool AquireCameraControl(int StreamingEncoderId)
        //        {
        //            Functions F = new Functions();
        //            
        //            NeedToRelinqueshControl = false;
        //            StreamingEncoder S = F.GetStreamingEncoder(StreamingEncoderId);
        //            if(S == null)
        //                return false;
        //            if(S.HasControlableCamera == false)
        //                return false;
        //            
        //            F.ShareOpenConnection(ref SC);
        //
        //
        //            string sSQL = "SELECT * FROM tblUserStreamingEncoderRel WHERE StreamingEncoderId = " + StreamingEncoderId;
        //            SqlDataAdapter da = new SqlDataAdapter(sSQL,SC);
        //            DataTable dt = new DataTable();
        //            da.Fill(dt);
        //            try
        //            {
        //                if(dt.Rows.Count > 0)  //Then another User has control of it already
        //                {
        //                    return false;
        //                }
        //            }
        //            catch(Exception Err)
        //            {
        //                string peekerror = Err.Message;
        //            }
        //    
        //                
        //            //Enforce that this user will only control 1 camera at a time
        //            sSQL = "DELETE FROM tblUserStreamingEncoderRel WHERE UserId = " + mvarID;
        //            SqlCommand CM = new SqlCommand(sSQL,SC);
        //            CM.ExecuteNonQuery();
        //
        //            sSQL = "Insert INTO tblUserStreamingEncoderRel(StreamingEncoderId, UserId, LastUpdatedTime) Values(" +
        //                    StreamingEncoderId + "," + mvarID + ",'" + System.DateTime.Now + "')";
        //            CM = new SqlCommand(sSQL,SC);
        //            int numRecs = CM.ExecuteNonQuery();
        //            if(numRecs == 0)
        //            {
        //                CurrentControlledEncoder = 0;
        //                ControllingCamera = false;
        //                UserTimer.Enabled = false;
        //                return false;
        //            }
        //            else
        //            {
        //                CurrentControlledEncoder = StreamingEncoderId;
        //                UserTimer.Enabled = true;
        //                ControllingCamera = true;
        //                NeedToRelinqueshControl = true;
        //                return true;
        //            
        //            }
        //        }
        public bool Update(string FirstName, string MiddleName, string LastName,
                    string LoginName, string Password, bool CanRecord, string CardNumber)
        {
            Functions F = new Functions();

            FirstName = F.CheckSqlSafeString(FirstName);
            MiddleName = F.CheckSqlSafeString(MiddleName);
            LastName = F.CheckSqlSafeString(LastName);
            LoginName = F.CheckSqlSafeString(LoginName);
            Password = F.CheckSqlSafeString(Password);
            CardNumber = F.CheckSqlSafeString(CardNumber);

            string Description = LastName + ", " + FirstName + " " + MiddleName;
            int SysAdminID = ((Section)F.GetSystemSection()).OwnerID;
            if(mvarID == SysAdminID)
                Description = mvarDescription;

               // string sSQL = "SELECT * FROM tblUser WHERE ID = " + mvarID;

               // SqlDataAdapter DA = new SqlDataAdapter(sSQL,MC);
            string sCommand = "UPDATE tblUSER SET Name = '" + Description +
                            "' , FirstName = '" + FirstName +
                            "' , MiddleName = '" + MiddleName +
                            "' , LastName = '" + LastName +
                            "' , LoginName = '" + LoginName +
                            "' , Password = '******' , CanRecord = "  + Convert.ToInt32(CanRecord) +
                            "  , CardNumber = '" + CardNumber +
                            "' WHERE ID = " + mvarID;
            int orow = F.ExecuteNonQuery(sCommand);
            F.Dispose();
            if(orow == 0)
                return false;
            else
                return true;
        }