Esempio n. 1
0
        public QueryModel()
        {
            ModelUrl = "/query";
            ApplicationModel.Current.Server.Value.RawUrl = null;
            SelectedTransformer = new Observable <string> {
                Value = "None"
            };
            SelectedTransformer.PropertyChanged += (sender, args) => Requery();

            ApplicationModel.DatabaseCommands.GetTransformersAsync(0, 256).ContinueOnSuccessInTheUIThread(transformers =>
            {
                Transformers = new List <string> {
                    "None"
                };
                Transformers.AddRange(transformers.Select(definition => definition.Name));

                OnPropertyChanged(() => Transformers);
            });

            queryDocument = new EditorDocument
            {
                Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("RavenQuery.langdef")
            };

            ExceptionLine   = -1;
            ExceptionColumn = -1;

            CollectionSource = new QueryDocumentsCollectionSource();
            Observable.FromEventPattern <QueryStatisticsUpdatedEventArgs>(h => CollectionSource.QueryStatisticsUpdated += h,
                                                                          h => CollectionSource.QueryStatisticsUpdated -= h)
            .SampleResponsive(TimeSpan.FromSeconds(0.5))
            .TakeUntil(Unloaded)
            .ObserveOnDispatcher()
            .Subscribe(e =>
            {
                QueryTime = e.EventArgs.QueryTime;
                Results   = e.EventArgs.Statistics;
            });
            Observable.FromEventPattern <QueryErrorEventArgs>(h => CollectionSource.QueryError += h,
                                                              h => CollectionSource.QueryError -= h)
            .ObserveOnDispatcher()
            .Subscribe(e => HandleQueryError(e.EventArgs.Exception));

            DocumentsResult = new DocumentsModel(CollectionSource)
            {
                Header = "Results",
                DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index, IndexName, CollectionSource.TemplateQuery),
            };

            QueryErrorMessage = new Observable <string>();
            IsErrorVisible    = new Observable <bool>();

            SortBy = new BindableCollection <StringRef>(x => x.Value);
            SortBy.CollectionChanged += HandleSortByChanged;
            SortByOptions             = new BindableCollection <string>(x => x);
            Suggestions    = new BindableCollection <FieldAndTerm>(x => x.Field);
            DynamicOptions = new BindableCollection <string>(x => x)
            {
                "AllDocs"
            };
            AvailableIndexes = new BindableCollection <string>(x => x);

            SpatialQuery = new SpatialQueryModel {
                IndexName = indexName
            };
        }
Esempio n. 2
0
	    public QueryModel()
		{
			ModelUrl = "/query";
			ApplicationModel.Current.Server.Value.RawUrl = null;
            SelectedTransformer = new Observable<string> { Value = "None" };
            SelectedTransformer.PropertyChanged += (sender, args) => Requery();

		    ApplicationModel.DatabaseCommands.GetTransformersAsync(0, 256).ContinueOnSuccessInTheUIThread(transformers =>
		    {
                Transformers = new List<string>{"None"};
			    Transformers.AddRange(transformers.Select(definition => definition.Name));
			    
			    OnPropertyChanged(() => Transformers);
		    });
            
			queryDocument = new EditorDocument
            {
                Language = SyntaxEditorHelper.LoadLanguageDefinitionFromResourceStream("RavenQuery.langdef")
            };

			ExceptionLine = -1;
			ExceptionColumn = -1;
			
            CollectionSource = new QueryDocumentsCollectionSource();
		    Observable.FromEventPattern<QueryStatisticsUpdatedEventArgs>(h => CollectionSource.QueryStatisticsUpdated += h,
		                                                                 h => CollectionSource.QueryStatisticsUpdated -= h)
		        .SampleResponsive(TimeSpan.FromSeconds(0.5))
                .TakeUntil(Unloaded)
		        .ObserveOnDispatcher()
		        .Subscribe(e =>
		                       {
		                           QueryTime = e.EventArgs.QueryTime;
		                           Results = e.EventArgs.Statistics;
		                       });
		    Observable.FromEventPattern<QueryErrorEventArgs>(h => CollectionSource.QueryError += h,
		                                                     h => CollectionSource.QueryError -= h)
		        .ObserveOnDispatcher()
		        .Subscribe(e => HandleQueryError(e.EventArgs.Exception));

			DocumentsResult = new DocumentsModel(CollectionSource)
								  {
									  Header = "Results",
									  DocumentNavigatorFactory = (id, index) => DocumentNavigator.Create(id, index, IndexName, CollectionSource.TemplateQuery),
								  };

            QueryErrorMessage = new Observable<string>();
            IsErrorVisible = new Observable<bool>();

			SortBy = new BindableCollection<StringRef>(x => x.Value);
			SortBy.CollectionChanged += HandleSortByChanged;
			SortByOptions = new BindableCollection<string>(x => x);
			Suggestions = new BindableCollection<FieldAndTerm>(x => x.Field);
			DynamicOptions = new BindableCollection<string>(x => x) {"AllDocs"};
	        AvailableIndexes = new BindableCollection<string>(x => x);
		    SpatialQuery = new SpatialQueryModel {IndexName = indexName};
		}
		public CalculateGeocodeFromAddressCommand(SpatialQueryModel queryModel)
		{
			this.queryModel = queryModel;
		}