Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
 public bool?Interact(InteractionMessage msg)
 {
     return(_interaction?.Interact(msg));
 }