Esempio n. 1
0
        public void Create(object arguments)
        {
            string[] inputs    = (string[])arguments;
            string   username  = inputs[0];
            string   password  = inputs[1];
            string   savePath  = inputs[2];
            int      noteCount = Helper.GetNoteCount(enNotebooks);//max value to loop creating records/note files

            try
            {
                OpfWriter opf = new OpfWriter(tempFolder.FullName);
                if (!tempFolder.Exists)
                {
                    tempFolder.Create();
                }

                UpdateProgress(83, "Creating NCX (1/5)");
                opf.CreateNCX(enNotebooks);
                UpdateProgress(86, "Creating TOC (2/5)");
                opf.CreateTOC(enNotebooks);
                UpdateProgress(89, "Creating Notes (3/5)");
                opf.CreateDataFiles(enNotebooks);
                UpdateProgress(92, "Creating OPF (4/5)");
                opf.CreateOPF(noteCount);
                UpdateProgress(95, "Creating MOBI (5/5)");

                int kindleResult = Helper.LaunchKindleGen(tempFolder);
                if (kindleResult == 2)
                {
                    throw new ApplicationException("KindleGen Exception. Please refer to online documents for troubleshooting.");
                }

                UpdateProgress(99, "Copying MOBI file");
                File.Copy(tempFolder + @"\en2ki.mobi", savePath + @"\en2ki.mobi", true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                EnableControls(true);
                return;
            }
            finally
            {
                tempFolder.Delete(true);
            }

            UpdateProgress(100, "Complete");
            ConfirmClose();
        }
Esempio n. 2
0
File: Form1.cs Progetto: bvp/en2ki
        public void Create(object arguments)
        {
            string[] inputs = (string[])arguments;
            string username = inputs[0];
            string password = inputs[1];
            string savePath = inputs[2];
            int noteCount = Helper.GetNoteCount(enNotebooks);//max value to loop creating records/note files

            try
            {
                OpfWriter opf = new OpfWriter(tempFolder.FullName);
                if (!tempFolder.Exists) tempFolder.Create();

                UpdateProgress(83, "Creating NCX (1/5)");
                opf.CreateNCX(enNotebooks);
                UpdateProgress(86, "Creating TOC (2/5)");
                opf.CreateTOC(enNotebooks);
                UpdateProgress(89, "Creating Notes (3/5)");
                opf.CreateDataFiles(enNotebooks);
                UpdateProgress(92, "Creating OPF (4/5)");
                opf.CreateOPF(noteCount);
                UpdateProgress(95, "Creating MOBI (5/5)");

                int kindleResult = Helper.LaunchKindleGen(tempFolder);
                if (kindleResult == 2)
                {
                    throw new ApplicationException("KindleGen Exception. Please refer to online documents for troubleshooting.");
                }

                UpdateProgress(99, "Copying MOBI file");
                File.Copy(tempFolder + @"\en2ki.mobi", savePath + @"\en2ki.mobi", true);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                EnableControls(true);
                return;
            }
            finally
            {
                tempFolder.Delete(true);
            }

            UpdateProgress(100, "Complete");
            ConfirmClose();
        }