예제 #1
0
        public string CreateIndex(string indexname, string path)
        {
            string dir = @"C:\Users\meharr\AppData\Local\dtSearch\" + indexname;

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }
            else
            {
                return("index with name " + indexname + " already exist");
            }
            indexjob.FoldersToIndex.Add(path + @"\<+>");
            //foreach(var file in Directory.GetFiles(path))
            //{
            //    indexjob.ToAddFileListName = file;
            //}
            indexjob.IndexPath    = dir;
            indexjob.ActionCreate = true;
            indexjob.ActionAdd    = true;
            bool result = indexjob.Execute();

            if (result == true)
            {
                return("Index Succesfully created");
            }
            else
            {
                return("Something Wrong");
            }
        }
예제 #2
0
        private void RemoveOldIndexItems(LoginUser loginUser, string indexPath, Organization organization, ReferenceType referenceType, string deletedIndexItemsFileName)
        {
            LogVerbose("Removing deleted items:  " + referenceType.ToString());
            if (!Directory.Exists(indexPath))
            {
                Logs.WriteEvent("Path does not exist:  " + indexPath);
                return;
            }
            DeletedIndexItems items = new DeletedIndexItems(loginUser);

            LogVerbose(string.Format("Retrieving deleted items:  RefType: {0}, OrgID: {1}", referenceType.ToString(), organization.OrganizationID.ToString()));
            items.LoadByReferenceType(referenceType, organization.OrganizationID);
            if (items.IsEmpty)
            {
                LogVerbose("No Items to delete");
                return;
            }


            StringBuilder builder = new StringBuilder();

            foreach (DeletedIndexItem item in items)
            {
                builder.AppendLine(item.RefID.ToString());
            }

            string fileName = Path.Combine(indexPath, deletedIndexItemsFileName);

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }
            using (StreamWriter writer = new StreamWriter(fileName))
            {
                LogVerbose("Adding IDs to delete file: " + builder.ToString());
                writer.Write(builder.ToString());
            }


            LogVerbose("Deleting Items");
            using (IndexJob job = new IndexJob())
            {
                job.IndexPath           = indexPath;
                job.ActionCreate        = false;
                job.ActionAdd           = false;
                job.ActionRemoveListed  = true;
                job.ToRemoveListName    = fileName;
                job.CreateRelativePaths = false;
                job.Execute();
            }

            LogVerbose("Items deleted");
            UpdateHealth();
            items.DeleteAll();
            items.Save();
            LogVerbose("Finished Removing Old Indexes - OrgID = " + organization.OrganizationID + " - " + referenceType.ToString());
        }
예제 #3
0
        public void Start()
        {
            Console.WriteLine("FilmIndexHost Starting...");
            var appDataPath = ConfigurationManager.AppSettings["ExportPath"];

            Console.WriteLine($"AppDataPath: {appDataPath}");
            var filmPaths   = new List <string>();
            var searchPaths = ConfigurationManager.GetSection("indexInfo/searchPath") as NameValueCollection;

            for (int i = 0; i < searchPaths.Count; i++)
            {
                filmPaths.Add(searchPaths[i]);
                Console.WriteLine($"SearchPath: {searchPaths[i]}");
            }

            var paths       = new List <string>();
            var samplePaths = ConfigurationManager.GetSection("indexInfo/samplePath") as NameValueCollection;

            for (int i = 0; i < samplePaths.Count; i++)
            {
                paths.Add(samplePaths[i]);
                Console.WriteLine($"SamplePath: {samplePaths[i]}");
            }

            var indexJob = new IndexJob {
                AppDataPath = appDataPath, FilmPaths = filmPaths, SamplePaths = paths
            };

            Console.WriteLine($"Start Indexing...");
            var sw = new Stopwatch();

            sw.Start();
            indexJob.Execute();
            sw.Stop();
            Console.WriteLine($"End Indexing...");
            Console.WriteLine($"elapse time: {sw.ElapsedMilliseconds}");
            Console.ReadKey();
        }