Esempio n. 1
0
        /// <summary>
        /// OnStartup registers all trackers to be available to the user
        /// </summary>
        /// <param name="e"></param>
        protected override void OnStartup(StartupEventArgs e)
        {
            // Create log directory if it doesn't already exist
            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PersonalAnalytics");

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }

            //////////////////////////////////////////////////////
            // Various Initializations
            //////////////////////////////////////////////////////

            // don't automatically shut down
            this.ShutdownMode = ShutdownMode.OnExplicitShutdown;

            // Initialize & Connect the database
            Database.GetInstance().Connect();

            // prepare settings
            TrackerManager.GetInstance().PrepareSettings();

            // register app for PC startup
            RegisterAppForPcStartup();

            // add a firewall exception
            //AddFirewallException(); // disabled because it causes problems if not system admin

            //////////////////////////////////////////////////////
            // initialize task bar icon & context menu
            //////////////////////////////////////////////////////
            TrackerManager.GetInstance().InitializeTaskBarIcon();

            //////////////////////////////////////////////////////
            // Start Tracker Manager (i.e. the monitoring tool)
            //////////////////////////////////////////////////////
            var trackers = TrackerManager.GetInstance().RegisterTrackers();

            TrackerManager.GetInstance().SetAppVersion(GetPublishedAppVersion());
            TrackerManager.GetInstance().Start();

            //////////////////////////////////////////////////////
            // Start the Retrospection
            //////////////////////////////////////////////////////
            if (Retrospection.Settings.IsEnabled)
            {
                Retrospection.Handler.GetInstance().Start(trackers, GetPublishedAppVersion()); // register the same trackers from the monitoring tool for the retrospection
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Singleton
 /// </summary>
 /// <returns></returns>
 public static TrackerManager GetInstance()
 {
     return(_manager ?? (_manager = new TrackerManager()));
 }
Esempio n. 3
0
        /// <summary>
        /// Ads a firewall exception
        /// </summary>
        //private static void AddFirewallException()
        //{
        //    try
        //    {
        //        var type = Type.GetTypeFromCLSID(new Guid("{304CE942-6E39-40D8-943A-B913C40C9CD4}"));
        //        var firewallManager = (INetFwMgr)Activator.CreateInstance(type);
        //        type = Type.GetTypeFromProgID("HNetCfg.FwAuthorizedApplication");
        //        var authapp = (INetFwAuthorizedApplication)Activator.CreateInstance(type);
        //        authapp.Name = "PersonalAnalytics";
        //        authapp.ProcessImageFileName = Assembly.GetExecutingAssembly().Location; // location of application
        //        authapp.Scope = NET_FW_SCOPE_.NET_FW_SCOPE_ALL;
        //        authapp.IpVersion = NET_FW_IP_VERSION_.NET_FW_IP_VERSION_ANY;
        //        authapp.Enabled = true;
        //        firewallManager.LocalPolicy.CurrentProfile.AuthorizedApplications.Add(authapp);
        //    }
        //    catch (Exception e)
        //    {
        //        // Known exception if user doesn't run the application as an admin
        //        Logger.WriteToLogFile(e);
        //    }
        //}

        /// <summary>
        /// Application is closed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void App_SessionEnding(object sender, SessionEndingCancelEventArgs e)
        {
            TrackerManager.GetInstance().Stop();
        }
 /// <summary>
 /// Singleton
 /// </summary>
 /// <returns></returns>
 public static TrackerManager GetInstance()
 {
     return _manager ?? (_manager = new TrackerManager());
 }