Пример #1
0
        public static bool PerformProcess()
        {
            if (!Program.properties.AutomaticUpdates)
            {
                return(false);
            }
            ProgramLog.Log("Checking for updates...");

            int build;

            if (!TrySeeIfIsUpToDate(out build))
            {
                ProgramLog.Log("Update found, performing b{0} -> b{1}", Statics.BUILD, build);

                PrintUpdateInfo();

                string myFile = System.AppDomain.CurrentDomain.FriendlyName;

                PerformUpdate(UpdateLink, "Terraria_Server.upd", "Terraria_Server.bak", myFile, 1, MaxUpdates);
                PerformUpdate(UpdateMDBLink, "Terraria_Server.upd.mdb", "Terraria_Server.bak.mdb", myFile + ".mdb", 2, MaxUpdates);

                Platform.PlatformType oldPlatform = Platform.Type; //Preserve old data if command args were used
                Platform.InitPlatform();                           //Reset Data of Platform for determinine exit/enter method.

                if (Platform.Type == Platform.PlatformType.WINDOWS)
                {
                    try
                    {
                        Process.Start(myFile);
                    }
                    catch (Exception e)
                    {
                        Platform.Type = oldPlatform;
                        ProgramLog.Log(e, "Could not boot into the new Update!");
                        return(false);
                    }
                }
                else
                {
                    Platform.Type = oldPlatform;
                    ProgramLog.Log("Exiting, please re-run the program to use your new installation.");
                    throw new UpdateCompleted();
                }

                return(true);
            }
            else
            {
                ProgramLog.Log("TDSM is up to date.");
            }
            return(false);
        }
 public TConsole(string serverLog, Platform.PlatformType platformType)
 {
     streamWriter = new StreamWriter(serverLog);
     this.platformType = platformType;
 }