예제 #1
0
        void cleanupTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            List <Lock> timedOutLocks = Locks.GetUnlockList();

            foreach (Lock l in timedOutLocks)
            {
                l.Status = Lock.LOCK_STATUS_UNLOCKED;
                l.Save();
            }
            foreach (Lock l in timedOutLocks)
            {
                try
                {
                    FirewallPolicyManager.Instance.RemoveIpAddressFromBlockList(l.IpAddress);
                    // IntrusionLog.AddEntry(DateTime.Now, Guid.Empty, l.IpAddress, IntrusionLog.STATUS_UNLOCK_REQUESTED, false);
                    OnClientIpAddressUnlocked(l, null);
                    //l.Save();
                }
                catch (Exception ex)
                {
                    // IntrusionLog.AddEntry(DateTime.Now, Guid.Empty, l.IpAddress, IntrusionLog.STATUS_UNLOCK_ERROR, false);
                    WindowsLogManager.Instance.WriteEntry(String.Format("IP address {0} cannot be unlocked. Error details: {1}",
                                                                        l.IpAddress, ex.Message),
                                                          EventLogEntryType.Error, Globals.CYBERARMS_EVENT_ID_INVALID_FUNCTION_CALL, Globals.CYBERARMS_LOG_CATEGORY_RUNTIME);
                    if (FirewallPolicyManager.Instance.IsLocked(l.IpAddress))
                    {
                        l.Status = Lock.LOCK_STATUS_UNLOCK_ERROR;
                    }
                    else
                    {
                        l.Status = Lock.LOCK_STATUS_UNLOCKED;
                    }
                    l.Save();
                    OnClientIpAddressUnlocked(l, ex);
                }
                //if (l.UnlockDate < DateTime.Now.AddDays(-1) || (l.Status == Lock.LOCK_STATUS_LOCK_ERROR || l.Status == Lock.LOCK_STATUS_UNLOCK_ERROR)) {
                //    l.Status = Lock.LOCK_STATUS_HISTORY;
                //}
            }
        }