コード例 #1
0
ファイル: Telemetry.cs プロジェクト: nicklinesla/4.21-arcore
        public TelemetryWriter(string InSqlConnectionString, string InLogFileName)
        {
            Instance = this;

            SqlConnectionString = InSqlConnectionString;

            LogWriter = new BoundedLogWriter(InLogFileName);
            LogWriter.WriteLine("Using connection string: {0}", SqlConnectionString);

            WorkerThread = new Thread(() => WorkerThreadCallback());
            WorkerThread.Start();
        }
コード例 #2
0
        public TelemetryWriter(string InApiUrl, string InLogFileName)
        {
            Instance = this;

            ApiUrl = InApiUrl;

            LogWriter = new BoundedLogWriter(InLogFileName);
            LogWriter.WriteLine("Using connection string: {0}", ApiUrl);

            WorkerThread = new Thread(() => WorkerThreadCallback());
            WorkerThread.Start();
        }
コード例 #3
0
        private static void CurrentDomain_UnhandledException(object Sender, UnhandledExceptionEventArgs Args)
        {
            Exception Ex = Args.ExceptionObject as Exception;

            if (Ex != null)
            {
                StringBuilder ExceptionTrace = new StringBuilder(Ex.ToString());
                for (Exception InnerEx = Ex.InnerException; InnerEx != null; InnerEx = InnerEx.InnerException)
                {
                    ExceptionTrace.Append("\nInner Exception:\n");
                    ExceptionTrace.Append(InnerEx.ToString());
                }
                TelemetryWriter.Enqueue(TelemetryErrorType.Crash, ExceptionTrace.ToString(), null, DateTime.Now);
            }
        }
コード例 #4
0
ファイル: Telemetry.cs プロジェクト: nicklinesla/4.21-arcore
        public static void Enqueue(TelemetryErrorType Type, string Text, string Project, DateTime Timestamp)
        {
            TelemetryWriter Writer = Instance;

            if (Writer != null)
            {
                TelemetryErrorData Error = new TelemetryErrorData();
                Error.Type      = Type;
                Error.Text      = Text;
                Error.UserName  = Environment.UserName;
                Error.Project   = Project;
                Error.Timestamp = Timestamp;

                Writer.QueuedErrorData.Enqueue(Error);
                Writer.RefreshEvent.Set();
            }
        }
コード例 #5
0
ファイル: Telemetry.cs プロジェクト: nicklinesla/4.21-arcore
        public static void Enqueue(string Action, string Result, string Project, DateTime Timestamp, float Duration)
        {
            TelemetryWriter Writer = Instance;

            if (Writer != null)
            {
                TelemetryTimingData Telemetry = new TelemetryTimingData();
                Telemetry.Action    = Action;
                Telemetry.Result    = Result;
                Telemetry.UserName  = Environment.UserName;
                Telemetry.Project   = Project;
                Telemetry.Timestamp = Timestamp;
                Telemetry.Duration  = Duration;

                Writer.QueuedTimingData.Enqueue(Telemetry);
                Writer.RefreshEvent.Set();
            }
        }
コード例 #6
0
ファイル: Telemetry.cs プロジェクト: nicklinesla/4.21-arcore
        public void Dispose()
        {
            bDisposing = true;

            if (WorkerThread != null)
            {
                RefreshEvent.Set();
                if (!WorkerThread.Join(100))
                {
                    WorkerThread.Abort();
                    WorkerThread.Join();
                }
                WorkerThread = null;
            }
            if (LogWriter != null)
            {
                LogWriter.Dispose();
                LogWriter = null;
            }

            Instance = null;
        }
コード例 #7
0
        static void InnerMain(Mutex InstanceMutex, EventWaitHandle ActivateEvent, string[] Args)
        {
            List <string> RemainingArgs = new List <string>(Args);

            string UpdatePath;

            ParseArgument(RemainingArgs, "-updatepath=", out UpdatePath);

            string UpdateSpawn;

            ParseArgument(RemainingArgs, "-updatespawn=", out UpdateSpawn);

            string ServerAndPort;

            ParseArgument(RemainingArgs, "-p4port=", out ServerAndPort);

            string UserName;

            ParseArgument(RemainingArgs, "-p4user="******"-restorestate", out bRestoreState);

            bool bUnstable;

            ParseOption(RemainingArgs, "-unstable", out bUnstable);

            string ProjectFileName;

            ParseArgument(RemainingArgs, "-project=", out ProjectFileName);

            string UpdateConfigFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate.ini");

            MergeUpdateSettings(UpdateConfigFile, ref UpdatePath, ref UpdateSpawn);

            string SyncVersionFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SyncVersion.txt");

            if (File.Exists(SyncVersionFile))
            {
                try
                {
                    SyncVersion = File.ReadAllText(SyncVersionFile).Trim();
                }
                catch (Exception)
                {
                    SyncVersion = null;
                }
            }

            string DataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "UnrealGameSync");

            Directory.CreateDirectory(DataFolder);

            using (TelemetryWriter Telemetry = new TelemetryWriter(DeploymentSettings.ApiUrl, Path.Combine(DataFolder, "Telemetry.log")))
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                using (UpdateMonitor UpdateMonitor = new UpdateMonitor(new PerforceConnection(UserName, null, ServerAndPort), UpdatePath))
                {
                    ProgramApplicationContext Context = new ProgramApplicationContext(UpdateMonitor, DeploymentSettings.ApiUrl, DataFolder, ActivateEvent, bRestoreState, UpdateSpawn, ProjectFileName, bUnstable);
                    Application.Run(Context);

                    if (UpdateMonitor.IsUpdateAvailable && UpdateSpawn != null)
                    {
                        InstanceMutex.Close();
                        bool bLaunchUnstable = UpdateMonitor.RelaunchUnstable ?? bUnstable;
                        Utility.SpawnProcess(UpdateSpawn, "-restorestate" + (bLaunchUnstable? " -unstable" : ""));
                    }
                }
            }
        }
コード例 #8
0
        static void InnerMain(Mutex InstanceMutex, EventWaitHandle ActivateEvent, string[] Args)
        {
            List <string> RemainingArgs = new List <string>(Args);

            string UpdatePath;

            ParseArgument(RemainingArgs, "-updatepath=", out UpdatePath);

            string UpdateSpawn;

            ParseArgument(RemainingArgs, "-updatespawn=", out UpdateSpawn);

            bool bRestoreState;

            ParseOption(RemainingArgs, "-restorestate", out bRestoreState);

            bool bUnstable;

            ParseOption(RemainingArgs, "-unstable", out bUnstable);

            string ProjectFileName;

            ParseArgument(RemainingArgs, "-project=", out ProjectFileName);

            string UpdateConfigFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate.ini");

            MergeUpdateSettings(UpdateConfigFile, ref UpdatePath, ref UpdateSpawn);

            string SyncVersionFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SyncVersion.txt");

            if (File.Exists(SyncVersionFile))
            {
                try
                {
                    SyncVersion = File.ReadAllText(SyncVersionFile).Trim();
                }
                catch (Exception)
                {
                    SyncVersion = null;
                }
            }

            string DataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "UnrealGameSync");

            Directory.CreateDirectory(DataFolder);

            using (TelemetryWriter Telemetry = new TelemetryWriter(SqlConnectionString, Path.Combine(DataFolder, "Telemetry.log")))
            {
                try
                {
                    using (UpdateMonitor UpdateMonitor = new UpdateMonitor(new PerforceConnection(null, null, null), UpdatePath))
                    {
                        MainWindow Window = new MainWindow(UpdateMonitor, SqlConnectionString, DataFolder, ActivateEvent, bRestoreState, UpdateSpawn ?? Assembly.GetExecutingAssembly().Location, ProjectFileName, bUnstable);
                        if (bUnstable)
                        {
                            Window.Text += String.Format(" (UNSTABLE BUILD {0})", Assembly.GetExecutingAssembly().GetName().Version);
                        }
                        Application.Run(Window);

                        if (UpdateMonitor.IsUpdateAvailable && UpdateSpawn != null)
                        {
                            InstanceMutex.Close();
                            Utility.SpawnProcess(UpdateSpawn, "-restorestate" + (bUnstable? " -unstable" : ""));
                        }
                    }
                }
                catch (Exception Ex)
                {
                    TelemetryWriter.Enqueue(TelemetryErrorType.Crash, Ex.ToString(), null, DateTime.Now);
                    MessageBox.Show(String.Format("UnrealGameSync has crashed.\n\n{0}", Ex.ToString()));
                }
            }
        }
コード例 #9
0
        static void InnerMain(Mutex InstanceMutex, EventWaitHandle ActivateEvent, string[] Args)
        {
            string ServerAndPort = null;
            string UserName      = null;
            string UpdatePath    = null;

            Utility.ReadGlobalPerforceSettings(ref ServerAndPort, ref UserName, ref UpdatePath);

            List <string> RemainingArgs = new List <string>(Args);

            string UpdateSpawn;

            ParseArgument(RemainingArgs, "-updatespawn=", out UpdateSpawn);

            bool bRestoreState;

            ParseOption(RemainingArgs, "-restorestate", out bRestoreState);

            bool bUnstable;

            ParseOption(RemainingArgs, "-unstable", out bUnstable);

            string ProjectFileName;

            ParseArgument(RemainingArgs, "-project=", out ProjectFileName);

            string UpdateConfigFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate.ini");

            MergeUpdateSettings(UpdateConfigFile, ref UpdatePath, ref UpdateSpawn);

            string SyncVersionFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SyncVersion.txt");

            if (File.Exists(SyncVersionFile))
            {
                try
                {
                    SyncVersion = File.ReadAllText(SyncVersionFile).Trim();
                }
                catch (Exception)
                {
                    SyncVersion = null;
                }
            }

            string DataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "UnrealGameSync");

            Directory.CreateDirectory(DataFolder);

            using (TelemetryWriter Telemetry = new TelemetryWriter(DeploymentSettings.ApiUrl, Path.Combine(DataFolder, "Telemetry.log")))
            {
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                // Create the log file
                using (TimestampLogWriter Log = new TimestampLogWriter(new BoundedLogWriter(Path.Combine(DataFolder, "UnrealGameSync.log"))))
                {
                    Log.WriteLine("Application version: {0}", Assembly.GetExecutingAssembly().GetName().Version);
                    Log.WriteLine("Started at {0}", DateTime.Now.ToString());

                    if (ServerAndPort == null || UserName == null)
                    {
                        Log.WriteLine("Missing server settings; finding defaults.");
                        GetDefaultServerSettings(ref ServerAndPort, ref UserName, Log);
                        Utility.SaveGlobalPerforceSettings(ServerAndPort, UserName, UpdatePath);
                    }

                    PerforceConnection DefaultConnection = new PerforceConnection(UserName, null, ServerAndPort);
                    using (UpdateMonitor UpdateMonitor = new UpdateMonitor(DefaultConnection, UpdatePath))
                    {
                        ProgramApplicationContext Context = new ProgramApplicationContext(DefaultConnection, UpdateMonitor, DeploymentSettings.ApiUrl, DataFolder, ActivateEvent, bRestoreState, UpdateSpawn, ProjectFileName, bUnstable, Log);
                        Application.Run(Context);

                        if (UpdateMonitor.IsUpdateAvailable && UpdateSpawn != null)
                        {
                            InstanceMutex.Close();
                            bool bLaunchUnstable = UpdateMonitor.RelaunchUnstable ?? bUnstable;
                            Utility.SpawnProcess(UpdateSpawn, "-restorestate" + (bLaunchUnstable? " -unstable" : ""));
                        }
                    }
                }
            }
        }
コード例 #10
0
		public TelemetryWriter(string InSqlConnectionString, string InLogFileName)
		{
			Instance = this;

			SqlConnectionString = InSqlConnectionString;

			LogWriter = new BoundedLogWriter(InLogFileName);
			LogWriter.WriteLine("Using connection string: {0}", SqlConnectionString);

			WorkerThread = new Thread(() => WorkerThreadCallback());
			WorkerThread.Start();
		}
コード例 #11
0
		public void Dispose()
		{
			bDisposing = true;

			if(WorkerThread != null)
			{
				RefreshEvent.Set();
				if(!WorkerThread.Join(100))
				{
					WorkerThread.Abort();
					WorkerThread.Join();
				}
				WorkerThread = null;
			}
			if(LogWriter != null)
			{
				LogWriter.Dispose();
				LogWriter = null;
			}

			Instance = null;
		}
コード例 #12
0
		static void InnerMain(Mutex InstanceMutex, EventWaitHandle ActivateEvent, string[] Args)
		{
			List<string> RemainingArgs = new List<string>(Args);

			string UpdatePath;
			ParseArgument(RemainingArgs, "-updatepath=", out UpdatePath);

			string UpdateSpawn;
			ParseArgument(RemainingArgs, "-updatespawn=", out UpdateSpawn);

			bool bRestoreState;
			ParseOption(RemainingArgs, "-restorestate", out bRestoreState);

			bool bUnstable;
			ParseOption(RemainingArgs, "-unstable", out bUnstable);

            string ProjectFileName;
            ParseArgument(RemainingArgs, "-project=", out ProjectFileName);

			string UpdateConfigFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "AutoUpdate.ini");
			MergeUpdateSettings(UpdateConfigFile, ref UpdatePath, ref UpdateSpawn);

			string SyncVersionFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SyncVersion.txt");
			if(File.Exists(SyncVersionFile))
			{
				try
				{
					SyncVersion = File.ReadAllText(SyncVersionFile).Trim();
				}
				catch(Exception)
				{
					SyncVersion = null;
				}
			}

			string DataFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "UnrealGameSync");
			Directory.CreateDirectory(DataFolder);

			using(TelemetryWriter Telemetry = new TelemetryWriter(SqlConnectionString, Path.Combine(DataFolder, "Telemetry.log")))
			{
				try
				{
					using(UpdateMonitor UpdateMonitor = new UpdateMonitor(new PerforceConnection(null, null, null), UpdatePath))
					{
						MainWindow Window = new MainWindow(UpdateMonitor, SqlConnectionString, DataFolder, ActivateEvent, bRestoreState, UpdateSpawn ?? Assembly.GetExecutingAssembly().Location, ProjectFileName);
						if(bUnstable)
						{
							Window.Text += String.Format(" (UNSTABLE BUILD {0})", Assembly.GetExecutingAssembly().GetName().Version);
						}
						Application.Run(Window);

						if(UpdateMonitor.IsUpdateAvailable && UpdateSpawn != null)
						{
							InstanceMutex.Close();
							Utility.SpawnProcess(UpdateSpawn, "-restorestate" + (bUnstable? " -unstable" : ""));
						}
					}
				}
				catch(Exception Ex)
				{
					TelemetryWriter.Enqueue(TelemetryErrorType.Crash, Ex.ToString(), null, DateTime.Now);
					MessageBox.Show(String.Format("UnrealGameSync has crashed.\n\n{0}", Ex.ToString()));
				}
			}
		}