private bool ShouldContinueLocationSelection(ITheme appliedTheme)
        {
            var errorWindowControl = new LocationErrorViewModel(appliedTheme);
            var errorWindow        = new LocationError(errorWindowControl);

            errorWindow.ShowDialog();

            if (errorWindowControl.ExitMode)
            {
                Application.Current.Shutdown();
                return(false);
            }

            return(true);
        }
Esempio n. 2
0
        internal static Exception ThrowLocationException(int errCode)
        {
            Log.Error(Globals.LogTag, "Throw Location Exception : " + errCode);
            LocationError error = (LocationError)errCode;

            switch (error)
            {
            case LocationError.OutOfMemory:
                return(new InvalidOperationException("Out of memory"));

            case LocationError.InvalidParameter:
                return(new ArgumentException("Invalid Parameter passed"));

            case LocationError.AcessibilityNotallowed:
                return(new UnauthorizedAccessException("Accesibility not allowed"));

            case LocationError.NotSupported:
                return(new NotSupportedException("Not supported"));

            case LocationError.IncorrectMethod:
                return(new InvalidOperationException("Incorrect method used"));

            case LocationError.NetworkFailed:
                return(new InvalidOperationException("Network failed"));

            case LocationError.ServiceNotAvailable:
                return(new InvalidOperationException("Service not available"));

            case LocationError.SettingOff:
                return(new InvalidOperationException("Current locationtype setting is off"));

            case LocationError.SecuirtyRestricted:
                return(new InvalidOperationException("Security Restricted"));

            default:
                return(new InvalidOperationException("Unknown Error"));
            }
        }
Esempio n. 3
0
        public async Task <IActionResult> getAllStates()
        {
            LocationError e      = new LocationError();
            List <State>  states = new List <State>();

            Redis  redis = new Redis(settings, cache);
            string key   = "all_states";

            CancellationTokenSource cts;

            cts = new CancellationTokenSource();
            cts.CancelAfter(settings.Value.redisCancellationToken);

            // validate request
            if (!ModelState.IsValid)
            {
                var modelErrors = new List <LocationError>();
                var eD          = new List <string>();
                foreach (var modelState in ModelState.Values)
                {
                    foreach (var modelError in modelState.Errors)
                    {
                        eD.Add(modelError.ErrorMessage);
                    }
                }
                e.error        = ((int)HttpStatusCode.BadRequest).ToString();
                e.errorDetails = eD;

                return(BadRequest(e));
            }

            try
            {
                //states = await redis.getstates(key, cts.Token);

                if (states != null && states.Count > 0)
                {
                    return(CreatedAtAction("getAllStates", states));
                }
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }

            try
            {
                states = await locateSqlRepo.GetAllStates();
            }
            catch (Exception ex)
            {
                Console.Write(ex.ToString());
            }

            //Write to Redis
            try
            {
                //if (states != null && states.Count > 0)
                //await redis.setstates(key, states, cts.Token);
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
            }
            return(CreatedAtAction("getAllStates", states));
        }
Esempio n. 4
0
        /// <summary>
        /// Tries to get an error for the given original location index.
        /// </summary>
        public static bool TryGetError <T>(this IWeightMatrixAlgorithm <T> algorithm, int locationIdx, out LocationError locationError,
                                           out RouterPointError routerPointError)
        {
            locationError    = null;
            routerPointError = null;
            if (algorithm.MassResolver.Errors.TryGetValue(locationIdx, out locationError))
            {
                return(true);
            }
            var resolvedIndex = algorithm.MassResolver.ResolvedIndexOf(locationIdx);

            if (algorithm.Errors.TryGetValue(resolvedIndex, out routerPointError))
            {
                return(true);
            }
            return(false);
        }