public MainViewModel()
        {
            try
            {
                productCommands = new ProductCommands(_connectionString);
                Products.AddRange(productCommands.GetList());

                ProdCategoryCommands prodCategoryCommands = new ProdCategoryCommands(_connectionString);
                ProdCategories.AddRange(prodCategoryCommands.GetList());

                LocationCommands locationCommands = new LocationCommands(_connectionString);
                Locations.AddRange(locationCommands.GetList());

                LocCategoryCommands locCategoryCommands = new LocCategoryCommands(_connectionString);
                LocationCategories.AddRange(locCategoryCommands.GetList());

                UnitCommands unitCommands = new UnitCommands(_connectionString);
                Units.AddRange(unitCommands.GetList());

                UpdateAppStatus($"Database tables fetched.", Brushes.DarkGreen);
            }
            catch (Exception ex) { UpdateAppStatus($"Error on retrieving tables from SQL database:\n{ex.Message}", Brushes.Red); }

            GenerateTableProductsToDisplay();
            InitializeAllPropertyFields();
            Scheduler();
        }
예제 #2
0
 public MatchContext AddUstIfSuccess(Ust ust)
 {
     if (Success && !IgnoreLocations && ust.TextSpans != null)
     {
         Locations.AddRange(ust.TextSpans);
     }
     return(this);
 }
예제 #3
0
 public MatchContext AddUstIfSuccess(Ust ust)
 {
     if (Success && !IgnoreLocations && !ust.TextSpan.IsZero)
     {
         Locations.AddRange(ust.GetRealTextSpans());
     }
     return(this);
 }
예제 #4
0
 public MatchContext AddMatches(IEnumerable <TextSpan> textSpans)
 {
     Success = true;
     if (!IgnoreLocations)
     {
         Locations.AddRange(textSpans.Where(textSpan => !textSpan.IsZero));
     }
     return(this);
 }
예제 #5
0
 public MatchContext AddMatch(Ust ust)
 {
     Success = true;
     if (!IgnoreLocations && ust != null && ust.TextSpans != null)
     {
         Locations.AddRange(ust.TextSpans);
     }
     return(this);
 }
예제 #6
0
 public MatchContext AddMatch(Ust ust)
 {
     Success = true;
     if (!IgnoreLocations && !ust.TextSpan.IsZero)
     {
         Locations.AddRange(ust.GetRealTextSpans());
     }
     return(this);
 }
예제 #7
0
        /// <summary>
        /// Initializes a new instance with the specified parameters.
        /// </summary>
        /// <param name="name">The directive name within the GraphQL schema.</param>
        /// <param name="locations">A list of locations where the directive can be applied.</param>
        public DirectiveGraphType(string name, IEnumerable <DirectiveLocation> locations)
        {
            Name = name;
            Locations.AddRange(locations);

            if (Locations.Count == 0)
            {
                throw new ArgumentException("Directive must have locations", nameof(locations));
            }
        }
예제 #8
0
        public async Task InitializeContainerAsync()
        {
            await Database.EnsureCreatedAsync();

            Locations.AddRange(GenerateLocations());
            PortDetails.AddRange(GeneratePorts());
            var changed = await SaveChangesAsync();

            Console.WriteLine($"created {changed} records");
        }
예제 #9
0
 private async void AddLocation()
 {
     MainVM.Loading = true;
     if (AddingLocationName != "" && !double.IsNaN(FavAddressSearch.SelectedAddress?.Lat ?? double.NaN))
     {
         if (Editing == null)
         {
             if (await Client.AddAddress(FavAddressSearch.SelectedAddress, AddingLocationName))
             {
                 Locations.Add(new UserLocation(AddingLocationName, FavAddressSearch.SelectedAddress));
                 AddingLocationName = "";
                 FavAddressSearch.SelectedAddress     = null;
                 FavAddressSearch.SelectedAddressText = "";
                 FavAddressSearch.Addresses.Clear();
             }
         }
         else
         {
             if (Editing.Address == FavAddressSearch.SelectedAddress && Editing.Name == AddingLocationName)
             {
                 Editing            = null;
                 AddingLocationName = "";
                 FavAddressSearch.SelectedAddress     = null;
                 FavAddressSearch.SelectedAddressText = "";
                 FavAddressSearch.Addresses.Clear();
             }
             else
             {
                 if (await Client.EditAddress(Editing.Name, AddingLocationName, FavAddressSearch.SelectedAddress))
                 {
                     Editing            = null;
                     AddingLocationName = "";
                     FavAddressSearch.SelectedAddress     = null;
                     FavAddressSearch.SelectedAddressText = "";
                     FavAddressSearch.Addresses.Clear();
                     await Task.Run(async() =>
                     {
                         return(await Client.GetMyAddresses());
                     }).ContinueWith(task =>
                     {
                         Locations.Clear();
                         Locations.AddRange(task.Result);
                         MainVM.Loading = false;
                     }, TaskScheduler.FromCurrentSynchronizationContext());
                 }
             }
         }
     }
     else
     {
         Editing = null;
         FavAddressSearch.Addresses.Clear();
     }
     MainVM.Loading = false;
 }
예제 #10
0
        public async Task RefreshSetup()
        {
            var info = await MakeGetRequest <Location[]>(string.Format(Controller.RootUrl + "/WebAPI/emea/api/v1/location/installationInfo?userId={0}&includeTemperatureControlSystems=True", AccountInfo.UserId));

            foreach (var loc in info)
            {
                loc.Controller = this;
            }
            Locations.Clear();
            Locations.AddRange(info);
            await UpdateStatus();
        }
예제 #11
0
        /// <summary>
        /// Load anything we need here.
        /// </summary>
        public void Load()
        {
            // TODO: Load anything you need!

            // listen to inputs
            Backend.Window.MouseMove += Window_MouseMove;
            Backend.Window.KeyPress  += Window_KeyPress;

            //GenerateMountain();

            Locations.AddRange(CaveGenerator.GenerateCave());
        }
예제 #12
0
        /// <summary>
        /// Initializes a new instance with the specified parameters.
        /// </summary>
        /// <param name="name">The directive name within the GraphQL schema.</param>
        /// <param name="locations">A list of locations where the directive can be applied.</param>
        public Directive(string name, params DirectiveLocation[] locations)
        {
            if (locations == null)
            {
                throw new ArgumentNullException(nameof(locations));
            }
            if (locations.Length == 0)
            {
                throw new ArgumentException("Directive must have locations", nameof(locations));
            }

            Name = name;
            Locations.AddRange(locations);
        }
        public override Task OnLoadedAsync()
        {
            UpdateCanSubmit();

            return(SafeExecuteAsync(async() =>
            {
                var locations = await _locationService.GetAllLocationsAsync();
                Locations.Clear();
                Locations.AddRange(locations);

                if (_originalStation.Location != null)
                {
                    RailwayStationModel.Location = Locations.FirstOrDefault(model => model.Id == _originalStation.Location.Id);
                }
            }));
        }
예제 #14
0
        async Task ExeucteLoadLocationsCommand(bool force)
        {
            if (IsBusy)
            {
                return;
            }

            bool didLoadLocations = false;

            try
            {
                IsBusy = true;

                var items = await StoreManager.LunchStore.GetItemsAsync(force);

                Locations.Clear();
                Locations.AddRange(items);

                OnPropertyChanged(nameof(Locations));

                didLoadLocations = true;
            }
            catch (Exception ex)
            {
                Logger.Report(ex, "Method", "ExecuteLoadEventsAsync");
                MessagingService.Current.SendMessage(MessageKeys.Error, ex);
            }
            finally
            {
                IsBusy = false;
            }

            if (!didLoadLocations)
            {
                NoLocationsFound        = true;
                NoLocationsFoundMessage = "No Lunch Locations Available";
            }
        }
예제 #15
0
 private void LoadData()
 {
     Task.Run(async() =>
     {
         System.Windows.Application.Current.Dispatcher.Invoke(() => MainVM.Loading = true);
         return(await Client.GetMyAddresses());
     }).ContinueWith(task =>
     {
         Locations.Clear();
         Locations.AddRange(task.Result);
         if (Locations.Count > 0)
         {
             FavMap.Center = MapVM.GetLocation(Locations.First().Address);
         }
         else
         {
             FavMap.Center    = new Location(52.0, 19.0);
             FavMap.ZoomLevel = 5;
         }
         OnPropertyChanged(nameof(Locations));
         MainVM.Loading = false;
     }, TaskScheduler.FromCurrentSynchronizationContext());
 }
예제 #16
0
        private async void RefreshInternal()
        {
            if (DataRequestInprogress)
            {
                return;
            }

            try
            {
                DataRequestInprogress = true;

                var VpnLocations = await _LocationService.GetLocations();

                ButtonText = VpnLocations.ButtonText;

                var locations = VpnLocations.Locations.SelectMany(
                    x => x.Servers,
                    (y, z) => {
                    var pinger = _IExecutePingFactory.Create();

                    var location = new LocationModel(pinger)
                    {
                        Name      = y.Name,
                        Icon      = Base64ImageToImage.ToBitmapImage(y.Icon.Value),
                        SortOrder = y.SortOrder,
                        Server    = z
                    };

                    location.LocationPingChanged += Location_LocationPingChanged;

                    return(location);
                }
                    ).ToList();

                Locations.Clear();
                Locations.AddRange(locations);

                await Task.Delay(DefaultLocationServiceintervalTimeSpan);
            }
            catch (UnauthorizedAccessException)
            {
                RaiseApiErrorInteractionRequest(
                    new Notification()
                {
                    Title   = API_ERROR_TITLE,
                    Content = API_ERROR_403
                }
                    );
            }
            catch (TimeoutException)
            {
                RaiseApiErrorInteractionRequest(
                    new Notification()
                {
                    Title   = API_ERROR_TITLE,
                    Content = API_ERROR_TIME_OUT
                }
                    );
            }
            catch (UnknownApiException)
            {
                RaiseApiErrorInteractionRequest(
                    new Notification()
                {
                    Title   = API_ERROR_TITLE,
                    Content = API_ERROR_UNKNOWN
                }
                    );
            }
            catch (Exception e)
            {
                //- swallowing for now
                //- Probably need to log
                //- out of scope for now
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
            finally
            {
                DataRequestInprogress = false;
            }
        }