示例#1
0
        //Own methods
        private void BookingLog(string ErrorType, string Message)
        {
            //First we write to the normal windows application log
            writeToLog("Computer: " + System.Environment.MachineName + " " + ErrorType, Message);

            //Then try to sende error message til a gmail account
            sendToGmail("Computer: " + System.Environment.MachineName + " " + ErrorType + " " + Message);

            //And last we try to write to the SQL log tabel if possible
            try
            {
                DataClasses1DataContext db = new DataClasses1DataContext();

                Thread.Sleep(100);

                Random _rn = new Random(DateTime.Today.Millisecond);

                SystemEventLog _log = new SystemEventLog();

                _log.bookingLogID = _rn.Next().ToString();
                _log.bookingLogErrorType = "Computer: " + System.Environment.MachineName + " " + ErrorType;
                _log.bookingLogMessage = Message;
                _log.bookingLogDateTime = DateTime.Now;

                db.SystemEventLogs.InsertOnSubmit(_log);

                db.SubmitChanges();
            }
            catch (Exception E)
            {
            }
        }
示例#2
0
        private void stillActiveBookings()
        {
            try
            {
                DataClasses1DataContext db = new DataClasses1DataContext();
                bool stillActiveBookings;

                var query =
                    from b in db.Bookings

                     where b.bookingState == "ACTIVE"
                     where b.bookingResourceID == System.Environment.MachineName

                    select b;

                stillActiveBookings = false;

                foreach (var row in query)
                {
                    stillActiveBookings = true;
                    changeAccountPassword(returnUserNameFromPCName(), row.bookingPassword);
                }

                if (!stillActiveBookings)
                {
                    changeAccountPassword(returnUserNameFromPCName(), @"Albib#123!");
                }

            }
            catch (Exception E)
            {
                BookingLog("EXCEPTION", ":stillActiveBookings:" + E.Message);
            }
        }
示例#3
0
        private void selectExpiredBookings()
        {
            try
            {
                DataClasses1DataContext db = new DataClasses1DataContext();

                var query =
                    from b in db.Bookings

                     where b.bookingState == "ACTIVE"
                     where DateTime.Now.AddSeconds(200) > b.bookingEnd
                     where b.bookingResourceID == System.Environment.MachineName

                    select b;

                foreach (var row in query)
                {
                    row.bookingState = "DONE";
                    row.bookingHash = createMD5FromBookingInformation(row.bookingUserID, BookingSystem_theService.Properties.Settings.Default.HASHKey);
                    row.bookingPassword = "";
                    row.bookingUserID = "";

                    db.SubmitChanges();
                }
            }
            catch (Exception E)
            {
                BookingLog("EXCEPTION", ":selectExpiredBookings:" + E.Message);
            }
        }
示例#4
0
        private void selectNewBookings()
        {
            try
            {
                DataClasses1DataContext db = new DataClasses1DataContext();

                var query =
                    from b in db.Bookings

                     where b.bookingState == "PENDING"
                     where DateTime.Now > b.bookingStart
                     where b.bookingResourceID == System.Environment.MachineName

                    select b;

                foreach (var row in query)
                {
                    row.bookingState = "ACTIVE";

                    changeAccountPassword(returnUserNameFromPCName(), row.bookingPassword);

                    db.SubmitChanges();
                }

            }
            catch (Exception E)
            {
                BookingLog("EXCEPTION", ":selectNewBookings:" + E.Message);
            }
        }
示例#5
0
        private void EndAfter15Min()
        {
            try
            {
                PrincipalContext pc = new PrincipalContext(ContextType.Machine);
                UserPrincipal PCUser_localcontext = UserPrincipal.FindByIdentity(pc, returnUserNameFromPCName());

                DataClasses1DataContext db = new DataClasses1DataContext();

                var query = from x in db.Bookings

                            where x.bookingState == "ACTIVE"
                            where x.bookingResourceID == System.Environment.MachineName
                            where x.bookingStart.AddMinutes(15) < DateTime.Now
                            where PCUser_localcontext.LastLogon < x.bookingStart

                            select x;

                foreach (var t in query)
                {
                    t.bookingMisc = "Never logged on";
                    t.bookingUserID = "";
                    t.bookingPassword = "";
                    t.bookingState = "DONE";
                    t.bookingEnd = DateTime.Now;
                    db.SubmitChanges();
                    changeAccountPassword(returnUserNameFromPCName(), "147896325");
                }
            }
            catch (Exception E )
            {
                BookingLog("EXCEPTION", E.Message);
            }
        }