Ejemplo n.º 1
0
 private async void setViewModel()
 {
     // We use just one Setting (Get and Update this Setting)
     await settingService.GetSettingByIdAsync(1).ContinueWith(async setting =>
     {
         settingViewModel = SettingMap.MapToSettingViewModel(await setting);
         this.DataContext = settingViewModel;
     });
 }
Ejemplo n.º 2
0
        private async void setViewModel()
        {
            // We use just one Setting (Get and Update this Setting)
            var setting = await settingService.GetSettingByIdAsync(1);

            settingViewModel = SettingMap.MapToSettingViewModel(setting);
            // Set IP automatically
            settingViewModel.ServerIP = getMyIP();
            this.DataContext          = settingViewModel;
        }
Ejemplo n.º 3
0
 public async void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     // Save Setting when navigating from page
     try
     {
         await settingService.UpdateSettingAsync(SettingMap.MapSettingViewModelToSetting(settingViewModel));
     }
     catch (Exception ex)
     {
         ModernDialog.ShowMessage(ex.Message, "Hiba mentés közben", MessageBoxButton.OK);
         e.Cancel = true;
     }
 }
Ejemplo n.º 4
0
        public async void OnNavigatingFrom(NavigatingCancelEventArgs e)
        {
            try
            {
                if (String.IsNullOrEmpty(textBoxUserName.Text) || String.IsNullOrWhiteSpace(textBoxUserName.Text))
                {
                    textBoxUserName.Text      = "-";
                    settingViewModel.UserName = "******";
                }

                await settingService.UpdateSettingAsync(SettingMap.MapSettingViewModelToSetting(settingViewModel));
            }
            catch (Exception ex)
            {
                ModernDialog.ShowMessage(ex.Message, "Hiba mentés közben", MessageBoxButton.OK);
                e.Cancel = true;
            }
        }
        /// <inheritdoc />
        public bool Remove(T setting)
        {
            ThrowIfReadOnly();
            if (!NameMap.TryGetValue(setting.MainName, out var guid))
            {
                return(false);
            }

            if (setting.IsHelp)
            {
                HasHelpCommand = false;
            }

            foreach (var name in setting.Names)
            {
                NameMap.Remove(name);
            }
            return(SettingMap.Remove(guid));
        }
Ejemplo n.º 6
0
 public async void OnNavigatingFrom(NavigatingCancelEventArgs e)
 {
     try
     {
         if (!String.IsNullOrEmpty(textBoxServerIP.Text) && textBoxServerIP.Text.Contains("192.168.1.") && !String.IsNullOrEmpty(textBoxPort.Text) && Convert.ToInt32(textBoxPort.Text) > 1000 && Convert.ToInt32(textBoxPort.Text) < 10000 && !String.IsNullOrEmpty(textBoxMoviesPath.Text))
         {
             await settingService.UpdateSettingAsync(SettingMap.MapSettingViewModelToSetting(settingViewModel));
         }
         else
         {
             ModernDialog.ShowMessage("Javítsd a kötelező mezőket", "Hiba mentés közben", MessageBoxButton.OK);
             e.Cancel = true;
         }
     }
     catch (Exception ex)
     {
         ModernDialog.ShowMessage(ex.Message, "Hiba mentés közben", MessageBoxButton.OK);
         e.Cancel = true;
     }
 }
Ejemplo n.º 7
0
        private async void setViewModel()
        {
            // Upload SQLite database through FTP
            await FTPServer.UploadDB();

            // We use just one Setting (Get and Update this Setting)
            settingViewModel = SettingMap.MapToSettingViewModel(await settingService.GetSettingByIdAsync(1));

            // Get movies and Start Socket Server if movies count more than 0 and not null
            await movieService.GetMoviesAsync().ContinueWith(async moviesResult =>
            {
                movies = await moviesResult;

                if (movies != null && movies.Count > 0)
                {
                    SocketServerService socketServer = new SocketServerService();
                    // Start Socket Server listen
                    socketServer.StartServer(settingViewModel);
                }
            });
        }
        /// <inheritdoc />
        public void Add(T setting)
        {
            ThrowIfReadOnly();

            if (setting.IsHelp)
            {
                if (HasHelpCommand)
                {
                    throw new InvalidOperationException("Do not add more than one help command into a setting parser.");
                }
                HasHelpCommand = true;
            }

            var guid = Guid.NewGuid();

            foreach (var name in setting.Names)
            {
                NameMap.Add(name, guid);
            }
            SettingMap.Add(guid, setting);
            setting.AssociateParser(this);
        }
 /// <inheritdoc />
 public void Clear()
 {
     ThrowIfReadOnly();
     NameMap.Clear();
     SettingMap.Clear();
 }
Ejemplo n.º 10
0
 protected static void SetSetting([NotNull] string cronJobName, CronJobSetting?setting)
 {
     SettingMap.AddOrUpdate(cronJobName, setting);
 }
Ejemplo n.º 11
0
 protected static CronJobSetting?GetSetting([NotNull] string cronJobName)
 {
     SettingMap.TryGetValue(cronJobName, out CronJobSetting? setting);
     return(setting);
 }
Ejemplo n.º 12
0
        private async Task <ObservableCollection <MovieViewModel> > setViewModel()
        {
            // We just update Setting and Filter models, no delete - no insert
            var setting = await settingService.GetSettingByIdAsync(1);

            var filter = await filterService.GetFilterByIdAsync(1);

            // FileSizes - FileTypes
            var fileSizes = await fileSizeService.GetFileSizesAsync();

            var fileTypes = await fileTypeService.GetFileTypesAsync();

            // Get viewmodels
            this.Dispatcher.Invoke(() =>
            {
                settingViewModel = SettingMap.MapToSettingViewModel(setting);
                filterViewModel  = FilterMap.MapToFilterViewModel(filter);
                filterViewModel.FileTypeViewModels = FileTypeMap.MapToFileTypeViewModelList(fileTypes);
                filterViewModel.FileSizeViewModels = FileSizeMap.MapToFileSizeViewModelList(fileSizes);

                dockPanelFilter.DataContext = filterViewModel;
            }
                                   );

            // Show message if MoviesPath is not set
            if (!Directory.Exists(settingViewModel.MoviesPath))
            {
                this.Dispatcher.Invoke(() =>
                {
                    MessageBoxResult result = ModernDialog.ShowMessage("A(z) '" + settingViewModel.MoviesPath + "' mappa nem létezik, így nem lehet filmeket keresni! Szeretnéd megváltoztatni most?", "'Filmek' mappa nem létezik", MessageBoxButton.YesNo);
                    if (result == MessageBoxResult.Yes)
                    {
                        IInputElement target = NavigationHelper.FindFrame("_top", this);
                        NavigationCommands.GoToPage.Execute("/Views/Content/SettingServer.xaml", target);
                    }
                    else
                    {
                        IInputElement target = NavigationHelper.FindFrame("_top", this);
                        LinkCommands.NavigateLink.Execute("/Views/Pages/Introduction.xaml", target);
                    }
                });
            }
            // Get movies and set viewmodel
            else
            {
                // Get movies from database
                moviesFromDb = await movieService.GetMoviesAsync();

                movieViewModels = MovieMap.MapToMovieViewModelList(moviesFromDb);

                await Task.Factory.StartNew(async() =>
                {
                    moviesFromFileServer = await MovieServer.GetMovieTitles(settingViewModel.MoviesPath, FileTypeMap.MapToFileTypeList(settingViewModel.FileTypeViewModels));
                });

                // We have no movies in database
                if (movieViewModels.Count <= 0)
                {
                    await movieService.InsertAllMovieAsync(moviesFromFileServer).ContinueWith(async moviesResult =>
                    {
                        movieViewModels = MovieMap.MapToMovieViewModelList(await moviesResult);
                        // Start Socket Server after new movies
                        socketServer.StartServer(settingViewModel);
                    }
                                                                                              );

                    //movieViewModels = MovieMap.MapToMovieViewModelList(insertedMovies);
                }
                else
                {
                    // Delete and insert changes
                    var deleted  = moviesFromDb.Where(m => !moviesFromFileServer.Select(c => c.Title).Contains(m.Title)).ToList();
                    var inserted = moviesFromFileServer.Where(c => !moviesFromDb.Select(m2 => m2.Title).Contains(c.Title)).ToList();

                    if (deleted != null && deleted.Count > 0)
                    {
                        // Delete my movies
                        await movieService.DeleteMoviesByListIdAsync(deleted.Select(d => d.Id).ToList());
                    }
                    if (inserted != null && inserted.Count > 0)
                    {
                        // Insert my movies
                        await movieService.InsertAllMovieAsync(inserted).ContinueWith(moviesResult =>
                                                                                      // Start Socket Server after new movies
                                                                                      socketServer.StartServer(settingViewModel)
                                                                                      );
                    }

                    // Correct current movies what can search with TMDB
                    moviesFromDb = await movieService.GetMoviesAsync();

                    movieViewModels = MovieMap.MapToMovieViewModelList(moviesFromDb);
                }
            };


            return(await Task.FromResult(movieViewModels));
        }
Ejemplo n.º 13
0
        private async void setViewModel()
        {
            // We use just one Setting (Get and Update this Setting)
            await settingService.GetSettingByIdAsync(1).ContinueWith(async settingResult =>
                                                                     settingViewModel = SettingMap.MapToSettingViewModel(await settingResult)
                                                                     );

            // Set MovieViewModels
            await movieService.GetMoviesAsync().ContinueWith(async moviesResult =>
                                                             movieViewModels = MovieMap.MapToMovieViewModelList(await moviesResult)
                                                             );

            BindingContext = settingViewModel;
        }