예제 #1
0
        public async Task InstallAsync(IInteractionCallback <InteractionMessage, bool?> interactCallback, Action finalCallback)
        {
            if (Settings.OnlineUpdate == EOnlineUpdate.no)
            {
                return;
            }

            await getSetupRefAsync();

            // do we have a new version?
            bool newVersion = _version > ApplEnv.AssemblyVersion;

            if (!newVersion)
            {
                return;
            }

            // do we have it downloaded already?
            bool exists = await checkDownloadAsync();

            if (!exists)
            {
                return;
            }

            install(interactCallback, R.MsgOnlineUpdateInstallLater);

            finalCallback?.Invoke();
        }
예제 #2
0
        public async Task UpdateAsync(
            IInteractionCallback <InteractionMessage, bool?> interactCallback,
            Action finalCallback,
            Func <bool> busyCallback
            )
        {
            if (!Settings.OnlineUpdate.HasValue)
            {
                return;
            }

            await getSetupRefAsync();

            // do we have a new version?
            bool newVersion = _version > ApplEnv.AssemblyVersion;

            if (!newVersion)
            {
                return;
            }

            // do we have it downloaded already?
            bool exists = await checkDownloadAsync();

            if (!exists)
            {
                if (!Settings.OnlineUpdate.Value)
                {
                    string msg1    = $"{R.MsgOnlineUpdateNewVersion} {_version} {R.MsgOnlineUpdateDownload}";
                    bool?  result1 = interactCallback.Interact(new InteractionMessage {
                        Message = msg1, Type = ECallbackType.question
                    });
                    if (!(result1.Value))
                    {
                        return;
                    }
                }

                // no: download,  verify md5
                await downloadSetupAsync();
            }

            bool isBusy = busyCallback();

            if (isBusy)
            {
                return;
            }

            bool cont = install(interactCallback, R.MsgOnlineUpdateInstallNow);

            if (!cont)
            {
                return;
            }

            finalCallback?.Invoke();
        }
예제 #3
0
        private bool install(IInteractionCallback <InteractionMessage, bool?> interactCallback, string prompt)
        {
            string msg2 =
                $"{R.MsgOnlineUpdateNewVersion} {_version} {R.MsgOnlineUpdateInstall}" +
                $"{Environment.NewLine}{prompt}";
            bool?result2 = interactCallback.Interact(new InteractionMessage {
                Message = msg2, Type = ECallbackType.question
            });

            if (!(result2 ?? true))
            {
                return(false);
            }

            // launch installer
            try {
                Process.Start(_setupFile);
            } catch (Exception) {
            }

            return(true);
        }
 public InMemoryStorageService(IInteractionCallback callback)
 {
     this.callback = callback;
     interactions = new List<Interaction>();
 }
예제 #5
0
 public CallbackWrapper(CancellationToken token, IProgress <ProgressMessage> progress, IInteractionCallback <InteractionMessage, bool?> interaction = null)
 {
     _token       = token;
     _progress    = progress;
     _interaction = interaction;
 }
예제 #6
0
 public void AddInteractionCallback(IMessage message, IInteractionCallback callback)
 => _interactionCallbacks[message.Id] = callback;