public void SaveIndex() { _ftService.SaveIndex(); }
private void Index() { totalTime.Start(); readBytes = 0; indexedTime = new Stopwatch(); //string[] folders = { @"d:\Part0", @"d:\Part1", @"d:\Part2", @"d:\Part3", @"d:\Part4", @"d:\Part5", @"d:\Part6", @"d:\Part7", @"d:\Part8" }; //string[] folders = { @"J:\Librusec\_Lib.rus.ec - Официальная\lib.rus.ec\" }; //string[] folders = {@"C:\FTS\FVMas_Pages"}; //string archive = @"C:\FTS\b2blogs\temp.7z"; //string unarchive = @"C:\FTS\b2blogs\temp"; //var files = Directory.GetFiles(@"N:\Production-Logs\"); //foreach(var file in files) //{ // File.Copy(file, archive); // string zPath = @"C:\Program Files\7-Zip\7zG.exe";// change the path and give yours // try // { // ProcessStartInfo pro = new ProcessStartInfo(); // pro.WindowStyle = ProcessWindowStyle.Hidden; // pro.FileName = zPath; // pro.Arguments = "x \"" + archive + "\" -o" + unarchive; // Process x = Process.Start(pro); // x.WaitForExit(); // this.IndexFiles(fts, unarchive); // File.Delete(archive); // Directory.Delete(unarchive); // } // catch (System.Exception Ex) // { // //DO logic here // } //} //return; string srcPath = @"\\srv3\fs\Production-Logs\"; string destPath = @"C:\FTS\Logs\"; string logPath = @"C:\FTS\archives.txt"; string logText = string.Empty; if (File.Exists(logPath)) { logText = File.ReadAllText(logPath); } var archives = Directory.GetFiles(srcPath, "*WS*.7z", SearchOption.AllDirectories).Concat( Directory.GetFiles(srcPath, "*BS*.7z", SearchOption.AllDirectories)).ToList(); //N:\Production-Logs foreach (string archive in archives) { try { if (logText.Contains(archive)) { continue; } lbArchive.Text = "Archive " + (archives.IndexOf(archive) + 1).ToString() + " of " + archives.Count.ToString(); string path = archive.Replace(srcPath, destPath); string dirName = Path.GetDirectoryName(path); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } if (!File.Exists(path)) { File.Copy(archive, path, true); } string rootPath = destPath + @"Unpacked\"; string unpackPath = rootPath + Path.GetFileName(archive).Replace(".7z", ""); if (!Directory.Exists(unpackPath)) { Unpack(path, unpackPath); } indexedArchives += archive + "\r\n"; if (this.IndexFiles(fts, rootPath, unpackPath)) //need save on disc { fts.SaveIndex(); File.AppendAllText(logPath, indexedArchives + "\r\n"); indexedArchives = string.Empty; } Directory.Delete(unpackPath, true); File.Delete(path); //File.AppendAllText(logPath, archive + "\r\n"); } catch (Exception ex) { if (MessageBox.Show(ex.Message + " Continue ?", "file", MessageBoxButtons.OKCancel) != DialogResult.OK) { break; } } //break; } fts.SaveIndex(); File.AppendAllText(logPath, indexedArchives + "\r\n"); ////StringBuilder name = new StringBuilder("doc1"); ////StringBuilder str = new StringBuilder("киевский политихнический институт"); ////FTServer.indexText(name, str, str.Length); //fts.SaveIndex(); //fts.StopInstance(); //FTServer.startInstance(); //FTServer.RelevantResult rr = FTServer.searchPhrase("капитан ушел обедать"); //FTServer.saveIndex(); //this.UpdateInstanceInfo(); totalTime.Stop(); }
private void IndexPrevMonth() { //index previous periods DateTime baseDate = new DateTime(2016, 11, 1); //DateTime.Now.AddMonths(-1); //baseDate.AddMonths(16); DateTime startDate = new DateTime(baseDate.Year, baseDate.Month, 1); DateTime endDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); //startDate.AddMonths(1); ThreadPool.QueueUserWorkItem(x => { while (true) { string zipPath; for (int archiveIndex = 1; ; archiveIndex++) { if (archiveIndex == 1) { zipPath = Site.FTRobot_PATH + startDate.Year.ToString("0000") + startDate.Month.ToString("00") + ".zip"; } else { zipPath = Site.FTRobot_PATH + startDate.Year.ToString("0000") + startDate.Month.ToString("00") + "_" + archiveIndex.ToString() + ".zip"; } if (File.Exists(zipPath)) { using (FileStream zipToOpen = new FileStream(zipPath, FileMode.Open)) { using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Read)) { foreach (var ent in archive.Entries) { IndexEntry(ent, 0); DBHelpers.SavePage("", ent.FullName); } //DBHelpers.GetPages(IndexFile, archive, startDate, startDate.AddMonths(1)); } } break; } else { break; } } startDate = startDate.AddMonths(1); if (startDate >= endDate) { break; } } }); Thread.Sleep(100); IndexEqueue(); ////index current period //startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); //DBHelpers.GetPages(IndexFile, null, startDate, startDate.AddMonths(1)); //save index _service.SaveIndex(); }