void RetrieveSummary() { using (var session = server.OpenSession()) { ExecuteCollectionQueryWithRetry(session, 5); WorkStarted("fetching recent documents"); session.Advanced.AsyncDatabaseCommands .GetDocumentsAsync(0, 12) .ContinueWith( x => { WorkCompleted("fetching recent documents"); RecentDocuments = new BindableCollection <DocumentViewModel>(x.Result.Select(jdoc => new DocumentViewModel(jdoc))); NotifyOfPropertyChange(() => RecentDocuments); ShowCreateSampleData = !RecentDocuments.Any(); RecentDocumentsStatus = RecentDocuments.Any() ? string.Empty : "The database contains no documents."; }, faulted => { WorkCompleted("fetching recent documents"); NotifyError("Unable to retrieve recent documents from server."); }); } }
public void GetAllProperties(BindableCollection <ClassificationSearchResultContractV2> selectedClasses, string languageCode = null) { List <NodeItem> newNodes = new List <NodeItem>(); foreach (var item in selectedClasses) { if (!_classes.Any(o => o.Name == item.Name)) { newNodes.Add(GetPropertiesInClassification(item.NamespaceUri, languageCode)); } } foreach (var item in newNodes) { if (!_classes.Any(o => o.Name == item.Name)) { _classes.Add(item); } } List <NodeItem> removeList = new List <NodeItem>(); foreach (var item in _classes) { if (!selectedClasses.Any(o => o.Name == item.Name)) { removeList.Add(item); } } foreach (var item in removeList) { _classes.Remove(item); } }
public BindableCollection <SACH> GetBookList(Expression <Func <SACH, bool> > currentEntityFilter) { BindableCollection <SACH> BookList = new BindableCollection <SACH>(); using (QLTVEntities db = new QLTVEntities()) { BookList = new BindableCollection <SACH>(db.SACH.Include(x => x.TACGIA).Include(x => x.THELOAI).Include(x => x.NHAXUATBAN).Include(x => x.CTSACH).Where(currentEntityFilter)); if (BookList.Any()) { foreach (SACH s in BookList) { int c = 0; if (s.CTSACH is null) { continue; } foreach (CTSACH cts in s.CTSACH) { CTSACH t = db.CTSACH.Include(x => x.PHIEUMUONSACH).FirstOrDefault(p => p.MACTS == cts.MACTS); if (t is null) { continue; } c += t.PHIEUMUONSACH.Count(); } s.LUOTMUON = c; } } } return(BookList); }
public void CreateWebSiteWithAdmin(string valueName, string valueRootFolder, string port) { BindableCollection <string> resultadoListaSites = GetWebIisWebSites(); if (resultadoListaSites.Any(v => v == valueName)) { EventAggregationProvider.Aggregator.Publish(new EventoBackend(EventoTipo.Erro, "O site: " + valueName + " ja existe")); } string porta = "*:" + port + ":"; string sitepath = valueRootFolder + valueName; if (!Directory.Exists(sitepath)) { Directory.CreateDirectory(sitepath); } using (var server = new ServerManager()) { var sitetoAdd = server.Sites.Add(valueName, "http", porta, sitepath); sitetoAdd.TraceFailedRequestsLogging.Enabled = true; sitetoAdd.TraceFailedRequestsLogging.Directory = "C:\\inetpub\\Log" + valueName + "\\" + valueName; var resultado = server.ApplicationPools.Any(t => t.Name == "IFEBAPool"); if (resultado == false) { var pool = server.ApplicationPools.Add("IFEBAPool"); pool.ManagedRuntimeVersion = "v4.0"; pool.ManagedPipelineMode = ManagedPipelineMode.Integrated; } server.Sites[valueName].Applications[0].ApplicationPoolName = "IFEBAPool"; sitetoAdd.ServerAutoStart = true; server.CommitChanges(); } }
public void SelectFirstCompanyViewModel() { if (m_CompanyViewModels.Any()) { SelectedCompanyViewModel = m_CompanyViewModels.First(); } }
public BindableCollection <PHIEUNHAPSACH> GetImportBillList(Expression <Func <PHIEUNHAPSACH, bool> > currentEntityFilter) { BindableCollection <PHIEUNHAPSACH> temp; using (QLTVEntities db = new QLTVEntities()) { temp = new BindableCollection <PHIEUNHAPSACH>(db.PHIEUNHAPSACH.Include(x => x.CTSACH).Include(x => x.TAIKHOAN).Where(currentEntityFilter)); if (temp.Any()) { foreach (PHIEUNHAPSACH item in temp) { if (item.CTSACH != null) { item.SOLUONG = item.CTSACH.Count; decimal c = 0; foreach (CTSACH cs in item.CTSACH) { c += cs.GIANHAP ?? 0; } item.TONGTIEN = c; } } } } return(temp); }
public void UpdateTimeline() { timeLine.Clear(); foreach (var show in shows) { var latestSeason = show.Seasons[show.Seasons.Count - 1]; var futureEpisodes = latestSeason.Episodes.Where(w => w.AirDate != null && w.AirDate >= DateTime.Today) .OrderBy(w => w.AirDate) .ToList(); foreach (var episode in futureEpisodes) { if (timeLine.Any(w => w.Episode == episode)) { continue; } timeLine.Add(new TimeLineItem { Show = show, Episode = episode }); } } }
public bool CheckAnswers() { BindableCollection <AnswerModel> selectedAnswers = new BindableCollection <AnswerModel>(); BindableCollection <AnswerModel> correctAnswers = this.CorrectAnswers(); foreach (AnswerModel answer in this.Answers) { if (answer.IsSelected) { selectedAnswers.Add(answer); } } foreach (AnswerModel answer in selectedAnswers) { if (correctAnswers.Contains(answer)) { correctAnswers.Remove(answer); } else { return(false); } } if (correctAnswers.Any()) { return(false); } else { return(true); } }
private FleetState CheckFleetState() { if (Ships.AsList().Count == 0) { return(FleetState.Empty); } if (Expedition != null) { return(FleetState.Expedition); } if (ships.Any(s => s.IsRepairing)) { return(FleetState.Repairing); } if (Ships.Any(s => s.HP.DamageState >= ShipDamageState.HeavilyDamaged)) { return(FleetState.Damaged); } if (Ships.Any(s => !s.Fuel.IsMaximum || !s.Bullet.IsMaximum)) { return(FleetState.Insufficient); } if (Ships.Any(s => s.Morale < 40)) { return(FleetState.Fatigued); } if (owner.CombinedFleet > 0 && (Id == 1 || Id == 2)) { return(FleetState.Combined); } return(FleetState.Ready); }
void ExecuteCollectionQueryWithRetry(IAsyncDocumentSession session, int retry) { WorkStarted("fetching collections"); session.Advanced.AsyncDatabaseCommands .GetTermsCount("Raven/DocumentsByEntityName", "Tag", "", 128) .ContinueWith(task => { if (task.Exception != null && retry > 0) { WorkCompleted("fetching collections"); TaskEx.Delay(50) .ContinueWith(_ => ExecuteCollectionQueryWithRetry(session, retry - 1)); return; } task.ContinueWith( x => { WorkCompleted("fetching collections"); Collections = new BindableCollection <NameAndCount>(x.Result); NotifyOfPropertyChange(() => LargestCollectionCount); NotifyOfPropertyChange(() => Collections); CollectionsStatus = Collections.Any() ? string.Empty : "The database contains no collections."; }, faulted => { WorkCompleted("fetching collections"); const string error = "Unable to retrieve collections from server."; NotifyError(error); CollectionsStatus = error; NotifyOfPropertyChange(() => LargestCollectionCount); NotifyOfPropertyChange(() => Collections); }); }); }
private void SelectFirstInvestmentPlan() { if (m_InvestmentPlanViewModels.Any()) { SelectedInvestmentPlanViewModel = m_InvestmentPlanViewModels.First(); } }
public BindableCollection <SACH> GetNewBookList() { BindableCollection <SACH> BookList; BindableCollection <CTSACH> ctsList; using (QLTVEntities db = new QLTVEntities()) { BookList = new BindableCollection <SACH>(db.SACH.Include(x => x.CTSACH).Where(y => true)); ctsList = new BindableCollection <CTSACH>(db.CTSACH.Include(x => x.SACH.TACGIA).Include(x => x.SACH.THELOAI).Include(x => x.SACH.NHAXUATBAN).Include(x => x.PHIEUNHAPSACH).OrderByDescending(x => x.MACTS)); BookList = new BindableCollection <SACH>(ctsList.GroupBy(x => x.SACH).Select(p => p.Key)); if (BookList.Any()) { foreach (SACH s in BookList) { int c = 0; if (s.CTSACH is null) { continue; } foreach (CTSACH cts in s.CTSACH) { CTSACH t = db.CTSACH.Include(x => x.PHIEUMUONSACH).FirstOrDefault(p => p.MACTS == cts.MACTS); if (t is null) { continue; } c += t.PHIEUMUONSACH.Count(); } s.LUOTMUON = c; } } } return(BookList); }
public SelectTagsViewModel(ITagManager tagManager, IRecordingManager recordingManager) { _recordingManager = recordingManager; _tagManager = tagManager; Tags = new BindableCollection<Tag>(); SelectedTags = new BindableCollection<Tag>(); Tags.CollectionChanged += (sender, args) => HasTags = Tags.Any(); }
/// <summary> /// Gets a value indicating if this instance has a controller /// in the specified <paramref name="questionedMode"/> as a child or model. /// </summary> /// <param name="questionedMode">The questioned mode.</param> /// <returns>true if this instance has a controller in the desired mode, false if not.</returns> public virtual bool HasControllerInMode(Controller.Mode questionedMode) { if (_controller.ControllerMode == questionedMode) { return(true); } return(_childs.Any(childViewModel => childViewModel.HasControllerInMode(questionedMode))); }
public override void LoadModelParameters(string parameters) { var urlParser = new UrlParser(parameters); ExecutionElapsedTime.Value = TimeSpan.Zero; GroupByField.Value = ""; ValueCalculations.Clear(); UpdateAvailableIndexes(); var newIndexName = urlParser.Path.Trim('/'); if (string.IsNullOrEmpty(newIndexName)) { if (AvailableIndexes.Any()) { NavigateToIndexReport(AvailableIndexes.FirstOrDefault()); return; } } IndexName = newIndexName; DatabaseCommands.GetIndexAsync(IndexName) .ContinueOnUIThread(task => { if (task.IsFaulted || task.Result == null) { if (AvailableIndexes.Any()) { NavigateToIndexReport(AvailableIndexes.FirstOrDefault()); } else { NavigateToIndexesList(); } return; } var fields = task.Result.Fields; IndexFields.Match(fields); QueryIndexAutoComplete = new QueryIndexAutoComplete(fields, IndexName, FilterDoc); }).Catch(); }
private bool CityExists(String _cityName) { if (_cityWeathers.Any(w => w.CityName == _cityName)) { return(true); } return(false); }
private void BuildTrackerConnectionProgressChanged(object sender, BuildTrackerConnectionProgressEventArgs e) { if (ShouldExitHandler(e)) { return; } foreach (var project in e.Projects) { var projectToUpdate = _projects.SingleOrDefault(p => p.Id == project.Id); if (projectToUpdate != null) { projectToUpdate.TryUpdate(project.Name); } else { _application.Dispatcher.Invoke(() => { var projectToAdd = _projectFactory.Create(SettingsId, project.Id, project.Name); var names = _projects.Select(p => p.Name).Concat(new[] { projectToAdd.Name }).OrderBy(name => name).ToArray(); var index = Array.IndexOf(names, projectToAdd.Name); _projects.Insert(index, projectToAdd); }); } } var projectsToKeep = e.Projects.Select(project => project.Id).ToArray(); var projectsToRemove = _projects.Where(project => !projectsToKeep.Contains(project.Id)).ToArray(); if (_projects.Any()) { _application.Dispatcher.Invoke(() => { _projects.RemoveRange(projectsToRemove); }); } _trie = new SuffixTrie <IProjectViewModel>(3); foreach (var project in _projects) { _trie.Add(project.Name.ToLowerInvariant(), project); } IsErrored = false; IsBusy = false; NotifyOfPropertyChange(() => HasProjects); NotifyOfPropertyChange(() => HasNoProjects); NotifyOfPropertyChange(() => IsViewable); }
void CheckAnyInstalls(object s, NotifyCollectionChangedEventArgs e) { NotifyOfPropertyChange(() => CanContinue); if (Installs == null || !Installs.Any()) { MinecraftExists = false; MinecraftUnknown = true; return; } MinecraftExists = true; MinecraftUnknown = false; }
protected override void OnActivate() { WorkStarted("fetching collections"); using (var session = Server.OpenSession()) { session.Advanced.AsyncDatabaseCommands .GetTermsCount("Raven/DocumentsByEntityName", "Tag", "", 128) .ContinueWith( x => { WorkCompleted("fetching collections"); Collections = new BindableCollection <CollectionViewModel>( x.Result.Select(item => new CollectionViewModel { Name = item.Name, Count = item.Count })); NotifyOfPropertyChange(() => LargestCollectionCount); NotifyOfPropertyChange(() => Collections); NotifyOfPropertyChange(() => HasCollections); if (ActiveCollection != null) { activeCollection = Collections .Where(collection => collection.Name == ActiveCollection.Name) .FirstOrDefault(); NotifyOfPropertyChange(() => ActiveCollection); TrackCurrentCollection(); } else // select the first one if we weren't asked for one { ActiveCollection = Collections.FirstOrDefault(); } if (executeAfterCollectionsFetched != null) { executeAfterCollectionsFetched(); executeAfterCollectionsFetched = null; } Status = Collections.Any() ? string.Empty : "The database contains no collections."; }, faulted => { WorkCompleted("fetching collections"); const string error = "Unable to retrieve collections from server.";; Status = error; NotifyError(error); }); } }
public EvaluationManagementViewModel([Import] IDiscardRepository contextRepository) { m_Repository = contextRepository; m_Repository.ContextChanged += (s, e) => Application.Current.Dispatcher.Invoke(Reload); Reload(); if (m_ProductionItemViewModels.Any()) { m_SelectedProductionItemViewModel = m_ProductionItemViewModels.First(); } if (m_SelectedInspectionViewModel != null) { m_SelectedInspectionViewModel = InspectionsFromSelectedProductionItems.First(); NotifyOfPropertyChange(() => InspectionName); } }
public ImportManagementViewModel([Import] ISettingsProvider settingsProvider, [Import] IDangerRepository contextRepository, [Import] ISurveyTypeViewModelFactory surveytypeViewModelFactory) { m_SurveyTypeViewModelFactory = surveytypeViewModelFactory; m_Repository = contextRepository; m_Repository.ContextChanged += (s, e) => Application.Current.Dispatcher.Invoke(LoadSurveyTypes); m_SettingsProvider = settingsProvider; m_SurveyTypeList = new BindableCollection <SurveyTypeViewModel>(); Initialize(); if (m_SurveyTypeList != null && m_SurveyTypeList.Any()) { SelectedSurvey = m_SurveyTypeViewModelFactory.CreateSurveyTypeViewModelFromExisting(m_SurveyTypeList.First() .Model); } }
private void GetVideoDevice() { _videoDevices = new BindableCollection <FilterInfo>(); var devices = new FilterInfoCollection(FilterCategory.VideoInputDevice); foreach (FilterInfo device in devices) { _videoDevices.Add(device); } if (_videoDevices.Any()) { _currentDevice = _videoDevices[0]; } else { this.eventAggregator.PublishOnCurrentThread(new Models.Message("Lỗi", "No webcam found")); } }
public async Task UpdateTownList() { var list = new List <WeatherBase>(); IEnumerable <string> towns; try { if (IsInited) { towns = townsList; } else { towns = _townsRepository.LoadTownsList(); } IsBusy = true; list = await _dataAccess.GetWeatherList(towns); IsBusy = false; } catch (Exception ex) { MessageBox.Show(SettingsRes.text_ErrorWhileRetrievingData); _logger.Error(ex.ToString()); } WeatherList = new BindableCollection <WeatherBase>(list); if (WeatherList.Any()) { if (!IsInited) { SelectedTown = WeatherList.FirstOrDefault(); } UpdateWeather(SelectedTown); } else { MessageBox.Show(SettingsRes.text_ErrorWhileRetrievingData); } }
public void AddNewConsumer() { if (!m_Distributors.Any() || !m_ConsumerGroups.Any()) { Dialogs.ShowMessageBox("Bitte legen Sie zunächst Verteiler und Verbrauchergruppen an.", "Unvollständige Auswahl"); } else { m_Repository.Consumers.Add(ModelFactory.CreateConsumer(NewConsumerName, m_Distributors.First() .Model, m_ConsumerGroups.First() .Model)); m_Repository.Save(); NewConsumerName = String.Empty; NotifyOfPropertyChange(() => Consumers); NotifyOfPropertyChange(() => ConsumerGroups); NotifyOfPropertyChange(() => Distributors); NotifyOfPropertyChange(() => NewConsumerName); } }
public void ItemDropLv(DragEventArgs dragArgs) { if (!dragArgs.Data.GetDataPresent(typeof(List <MissionModel>))) { return; } var droppedItems = dragArgs.Data.GetData(typeof(List <MissionModel>)) as List <MissionModel>; foreach (var droppedItem in droppedItems) { if (IgnoredItems.Any(item => item.FileId == droppedItem.FileId)) { continue; } IgnoredItems.Add(new IgnoredModel() { Item = droppedItem.Mission, FileId = droppedItem.FileId }); MissionItems.Remove(droppedItem); if (IsDeleteIgnoredMfChecked) { try { File.Delete(Properties.GetArma3MissionFolderPath + droppedItem.Mission); } catch (IOException e) { MessageBox.Show(e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } } } }
private bool CheckDayForMissingProjectIDs(BindableCollection <TimesheetEntryViewModel> dayEntries) { return(dayEntries.Any(tsvm => String.IsNullOrWhiteSpace(tsvm.TimesheetEntry.ProjectID))); }
public async Task <BindableCollection <Season> > GetDownloadsModel(bool updateDiskSpace = false) { BindableCollection <Season> seasons = new BindableCollection <Season>(); StorageFolder userFolder; try { userFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync(AppDataAccessor.GetUsername()); } catch (FileNotFoundException e) { diskSpaceFromDownloads = new DiskSpaceResponse { totalBytes = 0, formattedSize = "0 MB" }; return(seasons); } if (userFolder != null) { try { StorageFile model = await userFolder.GetFileAsync("CompleteModel"); string text = await Windows.Storage.FileIO.ReadTextAsync(model); seasons = JsonConvert.DeserializeObject <BindableCollection <Season> >(text); } catch (Exception) { } } //BindableCollection<Playlist> playlists = new BindableCollection<Playlist>(); long totalSize = 0; if (seasons.Any()) { foreach (Season s in seasons) { foreach (Game g in s.games) { foreach (Category c in g.categories) { foreach (Playlist p in c.playlists) { //playlists.Add(p); Playlist plFound = downloadedPlaylists.Where(u => u.playlistId == p.playlistId).FirstOrDefault(); if (plFound == null) { downloadedPlaylists.Add(p); } if (p.totalFilesSize != null) { totalSize += p.totalFilesSize; } } } } } } if (updateDiskSpace) { diskSpaceFromDownloads = new DiskSpaceResponse { totalBytes = totalSize, formattedSize = FormatBytes(totalSize) }; } return(seasons); }
private IEnumerable <GroupViewModel> SearchInGroupList() { if (string.IsNullOrEmpty(EmployeeGroupSearchText)) { return(m_Groups); } var searchText = EmployeeGroupSearchText.ToLower(); var searchResult = m_Groups.Where(g => (((g.Name != null) && (g.Name.ToLower() .Contains(searchText))) || (m_Employees.Any(e => (((e.FirstName != null) && (e.FirstName.ToLower() .Contains(searchText)) || ((e.LastName != null) && (e.LastName.ToLower() .Contains(searchText))) || ((e.Number != null) && (e.Number.ToLower() .Contains(searchText)))) && e.Model.Groups.Contains(g.Model)))))); return(searchResult); }
public bool CanDescreen() { return(Pages.Any(p => p.IsSelected)); }
public CarManager() { try { Cars = new BindableCollection <Car>(); List <string> lines = File.ReadAllLines(path).ToList(); foreach (string line in lines) { /* * int startIndex = 0; * int lastIndex = line.IndexOf(','); * List<string> words = new List<string>(); * while (lastIndex < line.Length && lastIndex != -1) * { * words.Add(line.Substring(startIndex, lastIndex - startIndex)); * startIndex = lastIndex + 1; * lastIndex = line.IndexOf(',', startIndex); * } * words.Add(line.Substring(startIndex, line.Length - startIndex)); */ List <string> words = new List <string>(line.Split(';')); Cars.Add(new Car(words[0], words[1], words[2], words[3], words[4], words[5], words[6], words[7], words[8], words[9], words[10], words[11], words[12], words[13], words[14], words[15], words[16])); } if (Cars.Any()) { SelectedCar = Cars.Last(); } MessageBox.Show("Data seccessfully loaded.", "Loaded", MessageBoxButton.OK, MessageBoxImage.Information); } catch (ArgumentException argEx) { MessageBox.Show(argEx.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch (PathTooLongException pathLongEx) { MessageBox.Show(pathLongEx.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch (DirectoryNotFoundException dirNotFound) { MessageBox.Show(dirNotFound.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch (IOException IOEx) { MessageBox.Show(IOEx.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch (UnauthorizedAccessException unAuthorisedEx) { MessageBox.Show(unAuthorisedEx.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch (NotSupportedException notSuporptedEx) { MessageBox.Show(notSuporptedEx.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } catch (SecurityException securityEx) { MessageBox.Show(securityEx.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
public override void LoadModelParameters(string parameters) { var urlParser = new UrlParser(parameters); UpdateAvailableIndexes(); ClearCurrentQuery(); if (urlParser.GetQueryParam("mode") == "dynamic") { var collection = urlParser.GetQueryParam("collection"); IsDynamicQuery = true; DatabaseCommands.GetTermsAsync("Raven/DocumentsByEntityName", "Tag", "", 100) .ContinueOnSuccessInTheUIThread(collections => { DynamicOptions.Match(new[] { "AllDocs" }.Concat(collections).ToArray()); string selectedOption = null; if (!string.IsNullOrEmpty(collection)) { selectedOption = DynamicOptions.FirstOrDefault(s => s.Equals(collection)); } if (selectedOption == null) { selectedOption = DynamicOptions[0]; } DynamicSelectedOption = selectedOption; DocumentsResult.SetChangesObservable(null); }); return; } IsDynamicQuery = false; var newIndexName = urlParser.Path.Trim('/'); if (string.IsNullOrEmpty(newIndexName)) { if (AvailableIndexes.Any()) { NavigateToIndexQuery(AvailableIndexes.FirstOrDefault()); return; } } IndexName = newIndexName; DatabaseCommands.GetIndexAsync(IndexName) .ContinueOnUIThread(task => { if (task.IsFaulted || task.Result == null) { if (AvailableIndexes.Any()) { NavigateToIndexQuery(AvailableIndexes.FirstOrDefault()); } else { NavigateToIndexesList(); } return; } var fields = task.Result.Fields; QueryIndexAutoComplete = new QueryIndexAutoComplete(fields, IndexName, QueryDocument); var regex1 = new Regex(@"(?:SpatialIndex\.Generate|SpatialGenerate)"); var regex2 = new Regex(@"(?:SpatialIndex\.Generate|SpatialGenerate)\(@?\""([^\""]+)\"""); var strs = task.Result.Maps.ToList(); if (task.Result.Reduce != null) { strs.Add(task.Result.Reduce); } var legacyFields = new HashSet <string>(); foreach (var map in task.Result.Maps) { var count = regex1.Matches(map).Count; var matches = regex2.Matches(map).Cast <Match>().Select(x => x.Groups[1].Value).ToList(); if (matches.Count < count) { legacyFields.Add(Constants.DefaultSpatialFieldName); } matches.ForEach(x => legacyFields.Add(x)); } var spatialFields = task.Result.SpatialIndexes .Select(x => new SpatialQueryField { Name = x.Key, IsGeographical = x.Value.Type == SpatialFieldType.Geography, Units = x.Value.Units }) .ToList(); legacyFields.ForEach(x => spatialFields.Add(new SpatialQueryField { Name = x, IsGeographical = true, Units = SpatialUnits.Kilometers })); UpdateSpatialFields(spatialFields); HasTransform = !string.IsNullOrEmpty(task.Result.TransformResults); DocumentsResult.SetChangesObservable( d => d.IndexChanges .Where(n => n.Name.Equals(indexName, StringComparison.InvariantCulture)) .Select(m => Unit.Default)); SetSortByOptions(fields); RestoreHistory(); }).Catch(); }
public async Task<BindableCollection<Season>> GetDownloadsModel(bool updateDiskSpace = false) { BindableCollection<Season> seasons = new BindableCollection<Season>(); StorageFolder userFolder; try { userFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync(AppDataAccessor.GetUsername()); } catch (FileNotFoundException e) { diskSpaceFromDownloads = new DiskSpaceResponse { totalBytes = 0, formattedSize = "0 MB" }; return seasons; } if (userFolder != null) { try { StorageFile model = await userFolder.GetFileAsync("CompleteModel"); string text = await Windows.Storage.FileIO.ReadTextAsync(model); seasons = JsonConvert.DeserializeObject<BindableCollection<Season>>(text); } catch (Exception) { } } //BindableCollection<Playlist> playlists = new BindableCollection<Playlist>(); long totalSize = 0; if (seasons.Any()) { foreach (Season s in seasons) { foreach (Game g in s.games) { foreach (Category c in g.categories) { foreach (Playlist p in c.playlists) { //playlists.Add(p); Playlist plFound = downloadedPlaylists.Where(u => u.playlistId == p.playlistId).FirstOrDefault(); if (plFound == null) { downloadedPlaylists.Add(p); } if (p.totalFilesSize != null) { totalSize += p.totalFilesSize; } } } } } } if (updateDiskSpace) { diskSpaceFromDownloads = new DiskSpaceResponse{totalBytes= totalSize, formattedSize = FormatBytes(totalSize)}; } return seasons; }