Exemple #1
0
 public static void ShutDown()
 {
     CacheTimer.Stop();
     CacheTimer.Enabled = false;
     CacheTimer.Dispose();
     Globals.WindowChangeEventHandler.Dispose();
     //Globals.workLock.Dispose();
     Globals.FileWatchr.Dispose();
     WindowPolling.SuspendWindowPolling();
     WindowPolling.Timer.Dispose();
 }
Exemple #2
0
        private void Locked()
        {
            var      accessDenied   = false;
            var      _currentApp    = Globals.LastWindowEvent.AppName;
            IDEMatch ideMatchObject = null;
            bool     writeDB        = false;

            _locked = true;

            // turn off polling while locked, so we will not see any window change while locked
            // therefore LastWindowEvent should be the one created below when we detect unlock
            WindowPolling.SuspendWindowPolling();

            // Try to get the project name for the Globals.LastWindowEvent
            var cfp = new Classes.CheckForProjectName();
            Tuple <string, IDEMatch, bool, string> cfpObject = cfp.GetProjectName(Globals.LastWindowEvent.WindowTitle, accessDenied, Globals.LastWindowEvent.AppName, writeDB);
            string devProjectName = cfpObject.Item1;

            writeDB        = cfpObject.Item3;
            ideMatchObject = cfpObject.Item2;

            if (!string.IsNullOrWhiteSpace(Globals.LastWindowEvent.DevProjectName))
            {
                Globals.LastWindowEvent.DevProjectName = devProjectName;
            }

            var hlpr = new DHWindowEvents(AppWrapper.AppWrapper.DevTrkrConnectionString);

            lock (Globals.SyncLockObject)
            {
                // now, make it look like the current window when the lock occurs is being moved away from
                // by writing it to database
#if DEBUG
                Console.WriteLine($"     ** Locked Writing Time: {LockStartTime} AppName: {Globals.LastWindowEvent.AppName} Title: {Globals.LastWindowEvent.WindowTitle} Project: {Globals.LastWindowEvent.DevProjectName}");
#endif
                Globals.LastWindowEvent.EndTime = LockStartTime;
                hlpr.InsertWindowEvent(Globals.LastWindowEvent);

                // next, start a new LastWindowEvent called ComputerLocked
                // and put it in Globals.LastWindowEvent
                string displayName;
                try
                {
                    displayName = UserPrincipal.Current.DisplayName;
                }
                catch (Exception ex)
                {
                    displayName = Environment.UserName;
                }

                var item = new WindowEvent
                {
                    ID              = Guid.NewGuid().ToString(),
                    StartTime       = LockStartTime,
                    WindowTitle     = locked,
                    AppName         = locked,
                    ModuleName      = locked,
                    EndTime         = LockEndTime,
                    DevProjectName  = locked,
                    ITProjectID     = string.Empty,
                    UserName        = Environment.UserName,
                    MachineName     = Environment.MachineName,
                    UserDisplayName = displayName
                };
                Globals.LastWindowEvent = item;
            }
        }