Beispiel #1
0
        public async Task <bool> IsServiceAvailable()
        {
            bool isAvailable = false;

            try
            {
                await _certifyClient.GetAppVersion();

                isAvailable = true;
            }
            catch (Exception)
            {
                isAvailable = false;
            }
            return(isAvailable);
        }
Beispiel #2
0
        public async Task <bool> IsServiceAvailable()
        {
            var isAvailable = false;

            try
            {
                await _certifyClient.GetAppVersion();

                isAvailable = true;
            }
            catch (Exception exp)
            {
                System.Diagnostics.Debug.WriteLine(exp.ToString());
                isAvailable = false;
            }
            return(isAvailable);
        }
Beispiel #3
0
        /// <summary>
        /// Get the Certify system version string in ActionResult.Message
        /// </summary>
        /// <returns></returns>
        public async Task <ActionResult> GetSystemVersion()
        {
            try
            {
                var result = await _client.GetAppVersion();

                return(new ActionResult(result, true));
            }
            catch (Exception exp)
            {
                return(new ActionResult {
                    IsSuccess = false, Message = "Failed to get system version: " + exp.ToString()
                });
            }
        }
        /// <summary>
        /// Checks the service availability by fetching the version. If the service is available but the version is wrong an exception will be raised.
        /// </summary>
        /// <returns></returns>
        public async Task <bool> CheckServiceAvailable(ICertifyClient client)
        {
            string version = null;

            try
            {
                version = await client.GetAppVersion();

                IsServiceAvailable = true;
            }
            catch (Exception exp)
            {
                System.Diagnostics.Debug.WriteLine(exp);

                //service not available
                IsServiceAvailable = false;
            }

            if (version != null)
            {
                // ensure service is correct version
                var v = Version.Parse(version.Replace("\"", ""));

                var assemblyVersion = typeof(ServiceConfig).Assembly.GetName().Version;

                if (v.Major != assemblyVersion.Major)
                {
                    throw new Exception($"Mismatched service version ({v}). Please ensure the old version of the app has been fully uninstalled, then re-install the latest version.");
                }
                else
                {
                    return(IsServiceAvailable);
                }
            }
            else
            {
                return(IsServiceAvailable);
            }
        }
Beispiel #5
0
        /// <summary>
        /// Checks the service availability by fetching the version. If the service is available but the version is wrong an exception will be raised.
        /// </summary>
        /// <returns></returns>
        public async Task <bool> CheckServiceAvailable()
        {
            string version = null;

            try
            {
                version = await CertifyClient.GetAppVersion();

                IsServiceAvailable = true;
            }
            catch (Exception)
            {
                //service not available
                IsServiceAvailable = false;
            }

            if (version != null)
            {
                // ensure service is correct version
                var v = Version.Parse(version.Replace("\"", ""));

                var assemblyVersion = typeof(AppViewModel).Assembly.GetName().Version;

                if (v.Major != assemblyVersion.Major)
                {
                    throw new Exception($"Invalid service version ({v}). Please ensure the old version of the app has been fully uninstalled, then re-install the latest version.");
                }
                else
                {
                    return(IsServiceAvailable);
                }
            }
            else
            {
                return(IsServiceAvailable);
            }
        }