예제 #1
0
            private void SavePriority(IndexDefinitionModel indexDefinitionModel)
            {
                if (indexDefinitionModel.PriorityChanged == false)
                {
                    return;
                }

                var priority = Abstractions.Data.IndexingPriority.Normal;

                switch (indexDefinitionModel.IndexingPriority.Value)
                {
                case "Normal":
                    priority = Abstractions.Data.IndexingPriority.Normal;
                    break;

                case "Idle":
                    priority = Abstractions.Data.IndexingPriority.Idle | Abstractions.Data.IndexingPriority.Forced;
                    break;

                case "Disabled":
                    priority = Abstractions.Data.IndexingPriority.Disabled | Abstractions.Data.IndexingPriority.Forced;
                    break;

                case "Abandoned":
                    priority = Abstractions.Data.IndexingPriority.Abandoned | Abstractions.Data.IndexingPriority.Forced;
                    break;
                }
                var priorityString = priority.ToString().Replace(" ", "");

                ApplicationModel.Current.Server.Value.SelectedDatabase.Value
                .AsyncDatabaseCommands
                .CreateRequest(string.Format("/indexes/set-priority/{0}?priority={1}", Uri.EscapeUriString(indexDefinitionModel.Name), priorityString), "POST")
                .ExecuteRequestAsync();
            }
예제 #2
0
        public override void LoadModelParameters(string parameters)
        {
            var urlParser = new UrlParser(parameters);

            if (urlParser.GetQueryParam("mode") == "dynamic")
            {
                IsDynamicQuery = true;
                DatabaseCommands.GetTermsAsync("Raven/DocumentsByEntityName", "Tag", "", 100)
                .ContinueOnSuccess(collections => DynamicOptions.Match(new[] { "AllDocs" }.Concat(collections).ToArray()));
                return;
            }

            IndexName = urlParser.Path.Trim('/');

            DatabaseCommands.GetIndexAsync(IndexName)
            .ContinueOnSuccessInTheUIThread(definition =>
            {
                if (definition == null)
                {
                    IndexDefinitionModel.HandleIndexNotFound(IndexName);
                    return;
                }
                fields.Match(definition.Fields);
                IsSpatialQuerySupported = definition.Map.Contains("SpatialIndex.Generate");
                SetSortByOptions(fields);
                Execute.Execute(string.Empty);
            }).Catch();
        }
예제 #3
0
        public override void LoadModelParameters(string parameters)
        {
            var urlParser = new UrlParser(parameters);

            IndexName = urlParser.Path.Trim('/');

            DatabaseCommands.GetIndexAsync(IndexName)
            .ContinueOnSuccessInTheUIThread(definition =>
            {
                if (definition == null)
                {
                    IndexDefinitionModel.HandleIndexNotFound(IndexName);
                    return;
                }
            }).Catch();
        }
예제 #4
0
        public override void LoadModelParameters(string parameters)
        {
            var urlParser = new UrlParser(parameters);

            IndexName = urlParser.Path.Trim('/');

            DatabaseCommands.GetIndexAsync(IndexName)
            .ContinueOnSuccessInTheUIThread(definition =>
            {
                if (definition == null)
                {
                    IndexDefinitionModel.HandleIndexNotFound(IndexName);
                    return;
                }
                fields.Match(definition.Fields);

                foreach (var field in fields)
                {
                    var localterms = fieldsTermsDictionary[field] = new List <string>();
                    GetTermsForField(field, localterms);
                }
            }).Catch();
        }
예제 #5
0
        public override void LoadModelParameters(string parameters)
        {
            var urlParser = new UrlParser(parameters);

            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;
            IndexName      = urlParser.Path.Trim('/');

            DatabaseCommands.GetIndexAsync(IndexName)
            .ContinueOnUIThread(task =>
            {
                if (task.IsFaulted || task.Result == null)
                {
                    IndexDefinitionModel.HandleIndexNotFound(IndexName);
                    return;
                }
                var fields             = task.Result.Fields;
                QueryIndexAutoComplete = new QueryIndexAutoComplete(fields, IndexName, QueryDocument);

                const string spatialindexGenerateLegacy = "SpatialIndex.Generate";
                const string spatialindexGenerate       = "SpatialGenerate";

                IsSpatialQuerySupported =
                    task.Result.Maps.Any(x => x.Contains(spatialindexGenerate) || x.Contains(spatialindexGenerateLegacy)) ||
                    (task.Result.Reduce != null && (task.Result.Reduce.Contains(spatialindexGenerate) || task.Result.Reduce.Contains(spatialindexGenerateLegacy)));
                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();
        }
예제 #6
0
 public DeleteIndexCommand(IndexDefinitionModel index)
 {
     this.index = index;
 }
예제 #7
0
 public ResetIndexCommand(IndexDefinitionModel index)
 {
     this.index = index;
 }
예제 #8
0
 public RemoveFieldCommand(IndexDefinitionModel index)
 {
     this.index = index;
 }