예제 #1
0
        public void RestoreDatabase(string inputPath)
        {
            if (AppSettings.Instance.UseRemoteSearchDatabase)
            {
                throw new InvalidOperationException("Não é possível realizar a restauração a partir da máquina cliente.");
            }

            if (!IOHelper.IsFile(inputPath))
            {
                throw new InvalidOperationException("O caminho selecionado deve apontar para um arquivo válido.");
            }

            // Close database
            (_database as IDisposable).Dispose();

            // Close all indexes
            foreach (var indexName in _indexProvider.List())
            {
                (_indexProvider.GetOrCreate(indexName) as IDisposable).Dispose();
            }

            // Delete all current files
            Directory.Delete(AppSettings.Instance.ApplicationDataDirectoryPath, recursive: true);

            ZipFile.ExtractToDirectory(inputPath, AppSettings.Instance.ApplicationDataDirectoryPath);
        }
예제 #2
0
 private IEnumerable <IIndex> GetIndexes(IEnumerable <string> indexNames)
 {
     if (indexNames.IsNullOrEmpty())
     {
         indexNames = _indexProvider.List();
     }
     foreach (var indexName in indexNames)
     {
         yield return(_indexProvider.GetOrCreate(indexName));
     }
 }
예제 #3
0
        public void Describe(Orchard.Forms.Services.DescribeContext context)
        {
            Func <IShapeFactory, object> form =
                shape =>
            {
                var f = _shapeFactory.Form(
                    Id: "SearchFilterForm",
                    _Index: _shapeFactory.SelectList(
                        Id: "Index", Name: "Index",
                        Title: T("Index"),
                        Description: T("The selected index will be queried."),
                        Size: 5,
                        Multiple: false),
                    _SearchQuery: _shapeFactory.Textbox(
                        Id: "SearchQuery", Name: "SearchQuery",
                        Title: T("Search query"),
                        Description: T("The search query to match against."),
                        Classes: new[] { "tokenized" }),
                    _HitCountLimit: _shapeFactory.Textbox(
                        Id: "HitCountLimit", Name: "HitCountLimit",
                        Title: T("Hit count limit"),
                        Description: T("For performance reasons you can limit the maximal number of search hits used in the query. Having thousands of search hits will result in poor performance and increased load on the database server."))
                    );

                foreach (var index in _indexProvider.List())
                {
                    f._Index.Add(new SelectListItem {
                        Value = index, Text = index
                    });
                }


                return(f);
            };

            context.Form("SearchFilter", form);
        }
예제 #4
0
 private IEnumerable <string> Indexes()
 {
     return(_provider.List());
 }