Пример #1
0
        public static void ConvertFile(GatherFileInformation filehandler)
        {
            switch (filehandler.FileInExtension.ToLower())
            {
            case ".htm":
            case ".html":
                if (FileConvert.MobiIt(filehandler.FileInName))
                {
                    GlobalTools.MoveFile(filehandler.FileInLocation + "\\" + filehandler.FileInNameNoExtension + ".mobi", filehandler.FileOutLocation + "\\" + filehandler.FileInNameNoExtension + ".mobi");
                }
                //mobiApp.applicationArgString = filehandler.FileInEscaped;
                //ExecuteExternalProcessor mobiProcessor = new ExecuteExternalProcessor(mobiApp);
                break;

            case ".mobi":
                string newTitle = Interaction.InputBox("Enter a New Title for This Book", "MetaData Manipulation", filehandler.FileInName, 100, 100);
                mobi2mobiApp.applicationArgString = @"--title " + "\"" + newTitle + "\" " + filehandler.FileInEscaped + @" --outfile " + filehandler.FileInEscaped;
                ExecuteExternalProcessor mobi2mobiProcessor = new ExecuteExternalProcessor(mobi2mobiApp);
                break;

            case ".pdb":
                pdbApp.applicationArgString = filehandler.FileInEscaped + " \"" + tempFolder + filehandler.FileInName + ".html\" \"1\"";
                //MessageBox.Show(pdbApp.applicationArgString);
                ExecuteExternalProcessor pdbProcessor = new ExecuteExternalProcessor(pdbApp);
                if (FileConvert.MobiIt(tempFolder + filehandler.FileInName + ".html"))
                {
                    GlobalTools.MoveFile(filehandler.FileInLocation + "\\" + filehandler.FileInName + ".mobi", filehandler.FileOutLocation + "\\" + filehandler.FileInName + ".mobi");
                }
                break;

            case ".lit":
                string outPath = filehandler.TempLocation + filehandler.FileInNameNoExtension.Replace("'", "");
                if (!Directory.Exists(outPath))
                {
                    Directory.CreateDirectory(outPath);
                }
                clitApp.applicationArgString = "\"" + filehandler.FileInFullPath + "\" \"" + outPath + "\"";
                ExecuteExternalProcessor litProcessor = new ExecuteExternalProcessor(clitApp);
                if (GlobalTools.FileExist(outPath + "\\" + filehandler.FileInNameNoExtension + ".opf"))
                {
                    if (FileConvert.MobiIt(outPath + "\\" + filehandler.FileInNameNoExtension + ".opf"))
                    {
                        GlobalTools.MoveFile(outPath + "\\" + filehandler.FileInNameNoExtension + ".mobi", filehandler.FileOutLocation + "\\" + filehandler.FileInNameNoExtension + ".mobi");
                    }
                }
                else
                {
                    MessageBox.Show(litProcessor.GetapplicationErrorOutput(), "Lit Convert Failed");
                }
                break;

            case ".chm":
                if (filehandler.FileInEscaped == "1")
                {
                    chmApp.applicationArgString = filehandler.FileInEscaped + " \"" + tempFolder + "\"";
                    ExecuteExternalProcessor chmProcessor = new ExecuteExternalProcessor(chmApp);
                }
                break;

            case ".pdf":
                pdfApp.applicationArgString = filehandler.FileInEscaped + " \"" + filehandler.TempLocation + "\\" + filehandler.FileInNameNoExtension + "\"";
                ExecuteExternalProcessor pdfProcessor = new ExecuteExternalProcessor(pdfApp);
                if (FileConvert.MobiIt(tempFolder + "\\" + filehandler.FileInNameNoExtension + "s.html"))
                {
                    GlobalTools.MoveFile(tempFolder + "\\" + filehandler.FileInNameNoExtension + "s.mobi", filehandler.FileOutLocation + "\\" + filehandler.FileInNameNoExtension + ".mobi");
                }
                break;

            default:
                MessageBox.Show("File type not supported", "Not Supported");
                break;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            GlobalTools.CheckPathInRegRestart("thing");
            GatherFileInformation filehandler  = new GatherFileInformation();
            ProcessInformation    mobi2mobiApp = new ProcessInformation();
            ProcessInformation    clitApp      = new ProcessInformation();
            ProcessInformation    pdbApp       = new ProcessInformation();
            ProcessInformation    chmApp       = new ProcessInformation();
            ProcessInformation    pdfApp       = new ProcessInformation();
            string workingDir = GlobalTools.GetexeLocation();
            string tempFolder = workingDir + @"Temp\";

            mobi2mobiApp.applicationString = @"app\mobi2mobi.exe";
            mobi2mobiApp.applicationString = null;
            clitApp.applicationString      = @"app\c**t.exe";
            clitApp.applicationSwitch      = @"-d";
            pdbApp.applicationString       = @"app\abcpalm.exe";
            pdbApp.applicationSwitch       = null;
            chmApp.applicationString       = @"app\chmdecoder.exe";
            chmApp.applicationSwitch       = @"-menu";
            pdfApp.applicationString       = @"app\pdftohtml.exe";
            pdfApp.applicationSwitch       = @"-noframes -c";
            fileLocation fileLocs;

            if (args.Length == 0)
            {
                filehandler.ExecuteFileOpen();
                filehandler.ExecuteFolderSelect();
                fileLocs = filehandler.files;
                if (fileLocs.fileExt.ToLower() == "htm")
                {
                    fileLocs.fileTemp = fileLocs.fileExt;
                    fileLocs.fileExt  = "html";
                }

                switch (fileLocs.fileExt.ToLower())
                {
                case "html":
                    if (fileLocs.fileTemp == "htm")
                    {
                        fileLocs.fileExt = fileLocs.fileTemp;
                    }
                    if (FileConvert.MobiIt(fileLocs.fileIn))
                    {
                        GlobalTools.MoveFile(fileLocs.fileLocationDir + "\\" + fileLocs.fileName + ".mobi", fileLocs.fileOut + "\\" + fileLocs.fileName + ".mobi");
                    }
                    //mobiApp.applicationArgString = fileLocs.fileIn_Escape;
                    //ExecuteExternalProcessor mobiProcessor = new ExecuteExternalProcessor(mobiApp);
                    break;

                case "mobi":
                    string newTitle = Interaction.InputBox("Enter a New Title for This Book", "MetaData Manipulation", fileLocs.fileName, 100, 100);
                    mobi2mobiApp.applicationArgString = @"--title " + "\"" + newTitle + "\" " + fileLocs.fileIn_Escape + @" --outfile " + fileLocs.fileIn_Escape;
                    ExecuteExternalProcessor mobi2mobiProcessor = new ExecuteExternalProcessor(mobi2mobiApp);
                    break;

                case "pdb":
                    pdbApp.applicationArgString = fileLocs.fileIn_Escape + " \"" + tempFolder + fileLocs.fileName + ".html\" \"1\"";
                    //MessageBox.Show(pdbApp.applicationArgString);
                    ExecuteExternalProcessor pdbProcessor = new ExecuteExternalProcessor(pdbApp);
                    if (FileConvert.MobiIt(tempFolder + fileLocs.fileName + ".html"))
                    {
                        GlobalTools.MoveFile(fileLocs.fileLocationDir + "\\" + fileLocs.fileName + ".mobi", fileLocs.fileOut + "\\" + fileLocs.fileName + ".mobi");
                    }
                    break;

                case "lit":
                    clitApp.applicationArgString = fileLocs.fileIn_Escape + " \"" + tempFolder + "\"";
                    ExecuteExternalProcessor litProcessor = new ExecuteExternalProcessor(clitApp);
                    if (GlobalTools.FileExist(tempFolder + fileLocs.fileName + ".html"))
                    {
                        if (FileConvert.MobiIt(tempFolder + fileLocs.fileName + ".html"))
                        {
                            GlobalTools.MoveFile(fileLocs.fileLocationDir + "\\" + fileLocs.fileName + ".mobi", fileLocs.fileOut + "\\" + fileLocs.fileName + ".mobi");
                        }
                    }
                    else
                    {
                        MessageBox.Show(litProcessor.GetapplicationErrorOutput(), "Lit Convert Failed");
                    }
                    break;

                case "chm":
                    if (fileLocs.fileIn_Escape == "1")
                    {
                        chmApp.applicationArgString = fileLocs.fileIn_Escape + " \"" + tempFolder + "\"";
                        ExecuteExternalProcessor chmProcessor = new ExecuteExternalProcessor(chmApp);
                    }
                    break;

                case "pdf":
                    pdfApp.applicationArgString = fileLocs.fileIn_Escape + " \"";
                    ExecuteExternalProcessor pdfProcessor = new ExecuteExternalProcessor(pdfApp);
                    if (FileConvert.MobiIt(tempFolder + fileLocs.fileName + "s.html"))
                    {
                        GlobalTools.MoveFile(tempFolder + fileLocs.fileName + "s.mobi", fileLocs.fileOut + "\\" + fileLocs.fileName + ".mobi");
                    }
                    break;

                default:
                    MessageBox.Show("File type not supported", "Not Supported");
                    break;
                }
            }
            else
            {
                ArgumentHandler arguments = new ArgumentHandler(args);
                fileLocs = arguments.files;
                if (fileLocs.fileOut == null)
                {
                    fileLocs.fileOut = filehandler.ExecuteFolderSelect();
                }
            }
        }