예제 #1
0
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/"));
            NetUtils.ApplyProxy();

            if (args == null) args = new string[0];
            if (args.Length < 3 || args.Length > 4)
            {
                Msg.Inform(null, string.Format(Resources.WrongNoArguments, ExeName + " SOURCE-PATH NEW-VERSION TARGET-PATH [--rerun|--restart-central]"), MsgSeverity.Error);
                return;
            }
            bool rerun = args.Contains("--rerun");
            bool restartCentral = args.Contains("--restart-central");

            try
            {
                var updateProcess = new UpdateProcess(source: args[0], newVersion: args[1], target: args[2]);
                Application.Run(new MainForm(updateProcess, rerun, restartCentral));
            }
                #region Error handling
            catch (ArgumentException ex)
            {
                Log.Error(ex);
                if (Environment.UserName != "SYSTEM") Msg.Inform(null, ex.Message, MsgSeverity.Error);
            }
            catch (IOException ex)
            {
                Log.Error(ex);
                if (Environment.UserName != "SYSTEM") Msg.Inform(null, ex.Message, MsgSeverity.Error);
            }
            #endregion
        }
예제 #2
0
        private async Task ClientOnReady()
        {
            if (AlreadyInitiated)
            {
                return;
            }

            AlreadyInitiated = true;
            $"Bot started! Press Control + C to exit!".Log();

            while (Garden.TheFriendTree == null)
            {
                Garden.TheFriendTree = _client.GetGuild(719734487415652382);
                await Task.Delay(100).ConfigureAwait(false);
            }

            Executor.Recur(async() =>
            {
                if (await GithubChecker.UpdateAvailable())
                {
                    Console.WriteLine("Updating Gardener...");
                    await UpdateProcess.StartUpdate();
                }
            }, TimeSpan.FromSeconds(10), StopToken);


            await _client.SetStatusAsync(UserStatus.DoNotDisturb).ConfigureAwait(false);

            await _client.SetActivityAsync(new CustomActivity($"commit {await GithubChecker.GetRemoteVersionShort()}",
                                                              ActivityType.Watching, ActivityProperties.None, "")).ConfigureAwait(false);

            _client.MessageUpdated += ClientOnMessageUpdated;

            await Garden.OnStart();
        }
        public void Test_source_and_destination_records_can_only_be_initialized()
        {
            UpdateProcess <Data, Key> updater = new UpdateProcess <Data, Key>();
            IEnumerable <Data>        Empty   = new List <Data>();
            List <Data> OneRecord             = new List <Data>();

            OneRecord.Add(new Data());

            // empty then one record
            updater.SourceRecords = Empty.AsEnumerable();
            updater.SourceRecords = OneRecord.AsEnumerable();
            int SourceRecordCount = updater.SourceRecords.Count();

            Assert.AreEqual(0, SourceRecordCount);

            // one record then empty (opposite order from above)
            updater.DestRecords = OneRecord.AsEnumerable();
            updater.DestRecords = Empty.AsEnumerable();
            int DestRecordCount = updater.DestRecords.Count();

            Assert.AreEqual(1, DestRecordCount);

            // catch issues where source points at private dest instance
            updater.SourceRecords = Empty.AsEnumerable();
            updater.SourceRecords = OneRecord.AsEnumerable();
            int SourceRecordCount_Try2 = updater.SourceRecords.Count();

            Assert.AreEqual(0, SourceRecordCount_Try2);
        }
예제 #4
0
        /// <summary>
        /// Creates a new update GUI.
        /// </summary>
        /// <param name="updateProcess">The update process to execute and track.</param>
        /// <param name="rerun">Indicates whether the updater has alread respawned itself as an administator. This is used to prevent infinite loops.</param>
        /// <param name="restartCentral">Indicates whether the updater shall restart the "0install central" GUI after the update.</param>
        public MainForm(UpdateProcess updateProcess, bool rerun, bool restartCentral)
        {
            _updateProcess  = updateProcess;
            _rerun          = rerun;
            _restartCentral = restartCentral;

            InitializeComponent();
        }
예제 #5
0
        /// <summary>
        /// Creates a new update GUI.
        /// </summary>
        /// <param name="updateProcess">The update process to execute and track.</param>
        /// <param name="rerun">Indicates whether the updater has alread respawned itself as an administator. This is used to prevent infinite loops.</param>
        /// <param name="restartCentral">Indicates whether the updater shall restart the "0install central" GUI after the update.</param>
        public MainForm(UpdateProcess updateProcess, bool rerun, bool restartCentral)
        {
            _updateProcess = updateProcess;
            _rerun = rerun;
            _restartCentral = restartCentral;

            InitializeComponent();
        }
예제 #6
0
        public UpdateService(BackgroundWorker worker, IDictionary <CommandLineParameter, string> parameters)
        {
            if (worker == null)
            {
                throw new ArgumentNullException("worker");
            }

            this.worker        = worker;
            this.updateProcess = new UpdateProcess(parameters);
        }
예제 #7
0
        private void frmUpdateProcess_Load(object sender, System.EventArgs e)
        {
            UpdateProcess update = new UpdateProcess();

            update.OnStart     += new EventHandler(update_OnStart);
            update.OnError     += new EventHandler(update_OnError);
            update.OnExecuting += new EventHandler(update_OnExecuting);
            update.OnFinished  += new EventHandler(update_OnFinished);
            ThreadStart threadStart = new ThreadStart(update.Execute);
            Thread      thread      = new Thread(threadStart);

            thread.Start();
        }
예제 #8
0
        public static async Task OnStart()
        {
            if (File.Exists("data/updateinfo.garden"))
            {
                Console.WriteLine("Running Post-Update Procedure...");
                await UpdateProcess.PostUpdate();
            }

            await Tree.LoadAsync();

            LetterMatchGame = new LetterMatch();
            await LetterMatchGame.LoadData();

            Config.Ready = true;
        }
예제 #9
0
        private void BootstrapAutoUpdate()
        {
            var serviceFactory    = new ServiceFactory();
            var timerService      = serviceFactory.CreateTimerService();
            var httpService       = serviceFactory.CreateHttpService();
            var processService    = serviceFactory.CreateProcessService();
            var conversionService = serviceFactory.CreateConversionService();
            var settingService    = serviceFactory.CreateSettingsService();

            _updateProcess = new UpdateProcess(timerService, httpService, processService, conversionService, settingService);

            var args = CreateUpdateProcessArgs(settingService, conversionService);

            _updateProcess.Start(args);
        }
        public void Test_source_and_destination_records_cant_be_changed_externally_once_initialized()
        {
            UpdateProcess <Data, Key> updater = new UpdateProcess <Data, Key>();
            IEnumerable <Data>        Empty   = new List <Data>();
            List <Data> OneRecord             = new List <Data>();

            OneRecord.Add(new Data()
            {
                Stuff = string.Empty
            });

            updater.SourceRecords = OneRecord.AsEnumerable();
            updater.DestRecords   = OneRecord.AsEnumerable();
            // shouldn't update
            // OneRecord.First().Stuff = "xxx"; // compiler doesn't allow
            Assert.AreEqual(string.Empty, updater.SourceRecords.First().Stuff);
            Assert.AreEqual(string.Empty, updater.DestRecords.First().Stuff);
        }
        public void Test_GetUpdatesByKeys_OneOfTwoRecordsChanges()
        {
            UpdateProcess <Data, Guid> updater = new UpdateProcess <Data, Guid>();

            updater.fGetKey = fGetKey;

            Guid guid1 = Guid.NewGuid();
            Guid guid2 = Guid.NewGuid();

            updater.SourceRecords = GetSourceRecords(guid1, guid2);
            updater.DestRecords   = GetDifferentSourceRecords(guid1, guid2);

            IEnumerable <Data> ChangedRecords = updater.GetUpdatesByKeys();
            Data UpdatedRecord = ChangedRecords.FirstOrDefault();

            Assert.AreEqual(guid2, UpdatedRecord.ID);
            Assert.AreEqual(secondItemStuff, UpdatedRecord.Stuff); // src = original text so remove changes
            Assert.AreEqual(1, ChangedRecords.Count());
        }
        public void Test_GetUpdatesByCommonFields_OneOfTwoRecordsChanges()
        {
            UpdateProcess <Data, Guid> updater = new UpdateProcess <Data, Guid>();

            updater.fGetKey = fGetKey;

            Guid guid1 = Guid.NewGuid();
            Guid guid2 = Guid.NewGuid();

            updater.SourceRecords = GetSourceRecords(guid1, guid2);
            updater.DestRecords   = GetDifferentSourceRecords(guid1, guid2);

            IEnumerable <Tuple <Data, Data> > ChangedRecords = updater.GetUpdatesByCommonFields();
            Tuple <Data, Data> UpdatedRecordPair             = ChangedRecords.FirstOrDefault();

            Assert.AreEqual(guid2, UpdatedRecordPair.Item1.ID);
            Assert.AreEqual(guid2, UpdatedRecordPair.Item2.ID);
            Assert.AreNotEqual(UpdatedRecordPair.Item1.Stuff, UpdatedRecordPair.Item2.Stuff);
            Assert.AreEqual(1, ChangedRecords.Count());
        }
예제 #13
0
        [STAThread] // Required for WinForms
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            ErrorReportForm.SetupMonitoring(new Uri("https://0install.de/error-report/"));
            NetUtils.ApplyProxy();

            if (args == null)
            {
                args = new string[0];
            }
            if (args.Length < 3 || args.Length > 4)
            {
                Msg.Inform(null, string.Format(Resources.WrongNoArguments, "0update-win SOURCE-PATH NEW-VERSION TARGET-PATH [--rerun|--restart-central]"), MsgSeverity.Error);
                return;
            }
            bool rerun          = args.Contains("--rerun");
            bool restartCentral = args.Contains("--restart-central");

            try
            {
                var updateProcess = new UpdateProcess(args[0], args[1], args[2]);
                Application.Run(new MainForm(updateProcess, rerun, restartCentral));
            }
            #region Error handling
            catch (IOException ex)
            {
                Msg.Inform(null, ex.Message, MsgSeverity.Error);
            }
            catch (UnauthorizedAccessException ex)
            {
                Msg.Inform(null, ex.Message, MsgSeverity.Error);
            }
            catch (NotSupportedException ex)
            {
                Msg.Inform(null, ex.Message, MsgSeverity.Error);
            }
            #endregion
        }
        public void Test_fGetKey_Can_Only_Be_Initialized()
        {
            Func <Data, Guid> fGetFakeKey;

            fGetFakeKey = (x) =>
            {
                return(Guid.NewGuid());
            };

            UpdateProcess <Data, Guid> updater = new UpdateProcess <Data, Guid>();

            updater.fGetKey = fGetKey;
            updater.fGetKey = fGetFakeKey; // attempt to override fGetKey with Fake Key

            Guid guid1 = Guid.NewGuid();
            Guid guid2 = Guid.NewGuid();

            updater.SourceRecords = GetSourceRecords(guid1, guid2);

            Guid result = updater.fGetKey(updater.SourceRecords.First());

            Assert.AreEqual(guid1, result);
        }
예제 #15
0
        //! Check for updates, prompting the end-user to download and install if found.
        private void CheckForUpdates()
        {
            UpdateProcess = ApplicationUpdate.CheckForUpdate();
            if (UpdateProcess == null)
            {
                const string msg = "Velvet Pearl Lottery could not check for updates.\n\nThis may be caused by a lack of internet connection or Enjin being down for maintenance. " +
                                   "If the problem persists, contact denDAY at \nwww.enjin.com/profile/493549.";
                WndDialogMessage.Show(this, msg, "Update Check Failed", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }
            else if (!UpdateProcess.UpdateAvailable)
            {
                return;
            }

            var choice = WndDialogMessage.Show(this, "A new update is available.\n\nDownload and install?", "New Update", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (choice != MessageBoxResult.Yes)
            {
                return;
            }

            // Download and register the install function (event handler) and cancel token.
            if (!UpdateProcess.DownloadUpdateAsync(InstallUpdate))
            {
                return;
            }
            var cancelToken = new CancellationTokenSource();

            cancelToken.Token.Register(CancelUpdate);
            UpdateStatusWnd = new WndUpdateStatus(cancelToken)
            {
                StatusText = "Downloading update ...", Owner = this
            };
            UpdateStatusWnd.ShowDialog();
        }
예제 #16
0
 public void SetComponent(UpdateProcess updateProcess)
 {
     this.updateProcess = updateProcess;
 }
예제 #17
0
 public void AddUpdateProcess(UpdateProcess Proc)
 {
     Updating.Add(Proc);
 }
예제 #18
0
 //! Cancel the process downloading the update.
 public void CancelUpdate()
 {
     UpdateWasCancelled = true;
     UpdateProcess.CancelDownload();
     UpdateProcess = null;
 }
예제 #19
0
 protected override void OnClosing(CancelEventArgs e)
 {
     UpdateProcess.sendGiaoXuInfo();
     base.OnClosing(e);
 }
예제 #20
0
 public Task Update()
 {
     return(UpdateProcess.StartUpdate());
 }