コード例 #1
0
        private void ProcessUpdateChunk(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Updater.Chunk chunk
                = p as ANWI.Messaging.Updater.Chunk;

            updating = true;
            if (receiver.AddChunk(chunk.data))
            {
                NotifyPropertyChanged("progress");
                MessageRouter.Instance.Send(
                    MessageRouter.Service.Update,
                    new ANWI.Messaging.Request()
                {
                    type = ANWI.Messaging.Request.Type.GetUpdateChunk
                },
                    this);
            }
            else
            {
                NotifyPropertyChanged("progress");

                if (!receiver.Write() ||
                    UpdateDownloaded?.Invoke(receiver.outputPath) == false)
                {
                    updating = false;
                    this.Dispatcher.Invoke(() => {
                        Text_Message.Text = "Patching failed";
                    });
                }
                else
                {
                    updating = false;
                    this.Dispatcher.Invoke(() => {
                        Text_Message.Text = "Patching...";
                    });
                }

                Thread.Sleep(1000);
                this.Dispatcher.Invoke(() => { this.Close(); });
            }
        }
コード例 #2
0
        private void ProcessUpdateStatus(ANWI.Messaging.IMessagePayload p)
        {
            ANWI.Messaging.Updater.CheckResult res
                = p as ANWI.Messaging.Updater.CheckResult;

            if (res.updateNeeded)
            {
                this.Dispatcher.Invoke(() => {
                    Text_Message.Text = "Downloading Update.";
                });

                Thread.Sleep(1000);

                receiver = new UpdateReceiver(res.updateSize);

                MessageRouter.Instance.Send(
                    MessageRouter.Service.Update,
                    new ANWI.Messaging.Request()
                {
                    type = ANWI.Messaging.Request.Type.GetUpdateChunk
                },
                    this);
            }
            else
            {
                this.Dispatcher.Invoke(() => {
                    Text_Message.Text = "Version OK.";
                });

                Thread.Sleep(1000);

                this.Dispatcher.Invoke(() => {
                    this.Close();
                });
            }
        }