public void SetText(string text)
        {
            Job1 = EDataType.Text;
            TempText = text;

            string ext = ".log";
            if (Directory.Exists(text) && WorkflowConfig.DestConfig.TextUploaders.Contains(TextDestination.FileUploader))
            {
                ext = ".html";
            }
            string fptxt = FileSystem.GetUniqueFilePath(Engine.ConfigWorkflow, Engine.TextDir,
                                                        new NameParser().Convert("%y.%mo.%d-%h.%mi.%s") + ext);
            UpdateLocalFilePath(fptxt);

            if (Directory.Exists(text))
            {
                var settings = new IndexerAdapter();
                settings.LoadConfig(Engine.ConfigOptions.IndexerConfig);
                Engine.ConfigOptions.IndexerConfig.FolderList.Clear();

                settings.GetConfig().SetSingleIndexPath(Path.Combine(Engine.TextDir, Info.FileName));
                settings.GetConfig().FolderList.Add(TempText);

                Indexer indexer = null;
                switch (settings.GetConfig().IndexingEngineType)
                {
                    case IndexingEngine.TreeLib:
                        indexer = new TreeWalkIndexer(settings);
                        break;
                    case IndexingEngine.TreeNetLib:
                        indexer = new TreeNetIndexer(settings);
                        break;
                }

                if (indexer != null)
                {
                    Job3 = JobLevel3.IndexFolder;
                    TempText = indexer.IndexNow(IndexingMode.IN_ONE_FOLDER_MERGED, false);
                    UpdateLocalFilePath(settings.GetConfig().GetIndexFilePath());
                }
            }
            else if (FileSystem.IsValidLink(text))
            {
                Job3 = JobLevel3.ShortenURL;
            }
            else
            {
                Job3 = JobLevel3.UploadText;
            }
        }
        public override string IndexNow(IndexingMode mIndexMode, bool bWriteToFile = true)
        {
            TreeWalkIndexer tree = new TreeWalkIndexer(mSettings);
            bool isMergeFile = mSettings.GetConfig().MergeFiles;
            bool isRemoveBranches = mSettings.GetConfig().RemoveTreeBranches;

            for (int i = 0; i <= mSettings.GetConfig().FolderList.Count - 1; i++)
            {
                string batFilePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\temp" + i.ToString() + ".bat";
                string CURRENT_DIR = mSettings.GetConfig().FolderList[i];
                string TREE_COMMAND = "%windir%\\system32\\tree.com " + tree.getSourceSwitch(CURRENT_DIR) + tree.getAsciiSwitch() + tree.getAddFilesSwitch() + tree.getOutputSwitch(CURRENT_DIR, mIndexMode);

                using (StreamWriter sw = new StreamWriter(batFilePath))
                {
                    sw.WriteLine(TREE_COMMAND);
                    //1.5.3.4 Didn't tag index files created in the same folder witout appending
                    if (mIndexMode == IndexingMode.IN_EACH_DIRECTORY | i == mSettings.GetConfig().FolderList.Count - 1 | (isMergeFile == false & mIndexMode == IndexingMode.IN_ONE_FOLDER_MERGED))
                    {
                        sw.WriteLine(mSettings.getBlankLine(tree.getCurrentIndexFilePath()));
                        sw.WriteLine(mSettings.GetFooterText(tree.getCurrentIndexFilePath(), IndexingEngine.TreeLib, false));
                    }
                    sw.WriteLine("DEL " + (char)34 + batFilePath + (char)34);
                }

                Process proc = new Process();
                proc = mSettings.StartHiddenProcess(batFilePath, true);

                if (isRemoveBranches)
                {
                    tree.removeTreeBranches(tree.getCurrentIndexFilePath());
                }

                if (mIndexMode == IndexingMode.IN_EACH_DIRECTORY | i == mSettings.GetConfig().FolderList.Count - 1 | (isMergeFile == false & mIndexMode == IndexingMode.IN_ONE_FOLDER_MERGED))
                {
                    if (mSettings.GetConfig().ZipFilesInEachDir)
                    {
                        mSettings.ZipAdminFile(tree.getCurrentIndexFilePath(), null);
                    }
                    if (mSettings.GetConfig().ZipMergedFile)
                    {
                        mSettings.ZipAdminFile(tree.getCurrentIndexFilePath(), null);
                    }
                }

                if (mIndexMode == IndexingMode.IN_ONE_FOLDER_SEPERATE)
                {
                    if (mSettings.GetConfig().ZipFilesInOutputDir)
                    {
                        //MsgBox(tree.getCurrentIndexFilePath())
                        mSettings.ZipAdminFile(tree.getCurrentIndexFilePath(), null);
                    }
                }

                if (proc.HasExited)
                {
                    this.Progress += 1;
                    this.CurrentDirMessage = "Indexed " + mSettings.GetConfig().FolderList[i];
                }
            }

            return File.ReadAllText(tree.getCurrentIndexFilePath());
        }
Example #3
0
        public override string IndexNow(IndexingMode mIndexMode, bool bWriteToFile = true)
        {
            TreeWalkIndexer tree             = new TreeWalkIndexer(mSettings);
            bool            isMergeFile      = mSettings.GetConfig().MergeFiles;
            bool            isRemoveBranches = mSettings.GetConfig().RemoveTreeBranches;

            for (int i = 0; i <= mSettings.GetConfig().FolderList.Count - 1; i++)
            {
                string batFilePath  = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\temp" + i.ToString() + ".bat";
                string CURRENT_DIR  = mSettings.GetConfig().FolderList[i];
                string TREE_COMMAND = "%windir%\\system32\\tree.com " + tree.getSourceSwitch(CURRENT_DIR) + tree.getAsciiSwitch() + tree.getAddFilesSwitch() + tree.getOutputSwitch(CURRENT_DIR, mIndexMode);

                using (StreamWriter sw = new StreamWriter(batFilePath))
                {
                    sw.WriteLine(TREE_COMMAND);
                    //1.5.3.4 Didn't tag index files created in the same folder witout appending
                    if (mIndexMode == IndexingMode.IN_EACH_DIRECTORY | i == mSettings.GetConfig().FolderList.Count - 1 | (isMergeFile == false & mIndexMode == IndexingMode.IN_ONE_FOLDER_MERGED))
                    {
                        sw.WriteLine(mSettings.getBlankLine(tree.getCurrentIndexFilePath()));
                        sw.WriteLine(mSettings.GetFooterText(tree.getCurrentIndexFilePath(), IndexingEngine.TreeLib, false));
                    }
                    sw.WriteLine("DEL " + (char)34 + batFilePath + (char)34);
                }

                Process proc = new Process();
                proc = mSettings.StartHiddenProcess(batFilePath, true);

                if (isRemoveBranches)
                {
                    tree.removeTreeBranches(tree.getCurrentIndexFilePath());
                }

                if (mIndexMode == IndexingMode.IN_EACH_DIRECTORY | i == mSettings.GetConfig().FolderList.Count - 1 | (isMergeFile == false & mIndexMode == IndexingMode.IN_ONE_FOLDER_MERGED))
                {
                    if (mSettings.GetConfig().ZipFilesInEachDir)
                    {
                        mSettings.ZipAdminFile(tree.getCurrentIndexFilePath(), null);
                    }
                    if (mSettings.GetConfig().ZipMergedFile)
                    {
                        mSettings.ZipAdminFile(tree.getCurrentIndexFilePath(), null);
                    }
                }

                if (mIndexMode == IndexingMode.IN_ONE_FOLDER_SEPERATE)
                {
                    if (mSettings.GetConfig().ZipFilesInOutputDir)
                    {
                        //MsgBox(tree.getCurrentIndexFilePath())
                        mSettings.ZipAdminFile(tree.getCurrentIndexFilePath(), null);
                    }
                }

                if (proc.HasExited)
                {
                    this.Progress         += 1;
                    this.CurrentDirMessage = "Indexed " + mSettings.GetConfig().FolderList[i];
                }
            }

            return(File.ReadAllText(tree.getCurrentIndexFilePath()));
        }