Example #1
0
        private void MakeBloomPackInternal(string path, string dir, int dirNameOffset, string dirNamePrefix, bool forReaderTools)
        {
            try
            {
                if (RobustFile.Exists(path))
                {
                    // UI already got permission for this
                    RobustFile.Delete(path);
                }
                using (var pleaseWait = new SimpleMessageDialog("Creating BloomPack...", "Bloom"))
                {
                    try
                    {
                        pleaseWait.Show();
                        pleaseWait.BringToFront();
                        Application.DoEvents();                         // actually show it
                        Cursor.Current = Cursors.WaitCursor;

                        Logger.WriteEvent("BloomPack path will be " + path + ", made from " + dir + " with rootName " + Path.GetFileName(dir));
                        using (var fsOut = RobustFile.Create(path))
                        {
                            using (ZipOutputStream zipStream = new ZipOutputStream(fsOut))
                            {
                                zipStream.SetLevel(9);

                                CompressDirectory(dir, zipStream, dirNameOffset, dirNamePrefix, forReaderTools);

                                zipStream.IsStreamOwner = true;                                 // makes the Close() also close the underlying stream
                                zipStream.Close();
                            }
                        }

                        // show it
                        Logger.WriteEvent("Showing BloomPack on disk");
                        PathUtilities.SelectFileInExplorer(path);
                        Analytics.Track("Create BloomPack");
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                        pleaseWait.Close();
                    }
                }
            }
            catch (Exception e)
            {
                ErrorReport.NotifyUserOfProblem(e, "Could not make the BloomPack at " + path);
            }
        }
Example #2
0
 public void MakeBloomPack(string path)
 {
     try
     {
         if (File.Exists(path))
         {
             //UI already go permission for this
             File.Delete(path);
         }
         Logger.WriteEvent("Making BloomPack");
         using (var pleaseWait = new SimpleMessageDialog("Creating BloomPack..."))
         {
             try
             {
                 pleaseWait.Show();
                 pleaseWait.BringToFront();
                 Application.DoEvents();                        //actually show it
                 Cursor.Current = Cursors.WaitCursor;
                 using (var zip = new ZipFile(Encoding.UTF8))
                 {
                     string dir = TheOneEditableCollection.PathToDirectory;
                     //nb: without this second argument, we don't get the outer directory included, and we need that for the name of the collection
                     zip.AddDirectory(dir, System.IO.Path.GetFileName(dir));
                     zip.Save(path);
                 }
                 //show it
                 Logger.WriteEvent("Showing BloomPack on disk");
                 Process.Start(Path.GetDirectoryName(path));
                 Analytics.Track("Create BloomPack");
             }
             finally
             {
                 Cursor.Current = Cursors.Default;
                 pleaseWait.Close();
             }
         }
     }
     catch (Exception e)
     {
         Palaso.Reporting.ErrorReport.NotifyUserOfProblem(e, "Could not make the BloomPack");
     }
 }
Example #3
0
        private void MakeBloomPackInternal(string path, string dir, string dirNamePrefix, bool forReaderTools)
        {
            try
            {
                if (RobustFile.Exists(path))
                {
                    // UI already got permission for this
                    RobustFile.Delete(path);
                }
                using (var pleaseWait = new SimpleMessageDialog("Creating BloomPack...", "Bloom"))
                {
                    try
                    {
                        pleaseWait.Show();
                        pleaseWait.BringToFront();
                        Application.DoEvents();                         // actually show it
                        Cursor.Current = Cursors.WaitCursor;

                        Logger.WriteEvent("BloomPack path will be " + path + ", made from " + dir + " with rootName " + Path.GetFileName(dir));
                        var excludeAudio = true;                         // don't want audio in bloompack
                        BookCompressor.CompressDirectory(path, dir, dirNamePrefix, forReaderTools, excludeAudio);

                        // show it
                        Logger.WriteEvent("Showing BloomPack on disk");
                        PathUtilities.SelectFileInExplorer(path);
                        Analytics.Track("Create BloomPack");
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                        pleaseWait.Close();
                    }
                }
            }
            catch (Exception e)
            {
                ErrorReport.NotifyUserOfProblem(e, "Could not make the BloomPack at " + path);
            }
        }
        public void MakeBloomPack(string path, bool forReaderTools = false)
        {
            try
            {
                if (File.Exists(path))
                {
                    //UI already got permission for this
                    File.Delete(path);
                }
                Logger.WriteEvent("Making BloomPack");
                using (var pleaseWait = new SimpleMessageDialog("Creating BloomPack..."))
                {
                    try
                    {
                        pleaseWait.Show();
                        pleaseWait.BringToFront();
                        Application.DoEvents();                        //actually show it
                        Cursor.Current = Cursors.WaitCursor;
                        using (var zip = new ZipFile(Encoding.UTF8))
                        {
                            string dir      = TheOneEditableCollection.PathToDirectory;
                            string rootName = Path.GetFileName(dir);
                            foreach (var directory in Directory.GetDirectories(dir))
                            {
                                string repairPath;
                                string repairContent;

                                var dirName = Path.GetFileName(directory);
                                if (dirName.ToLowerInvariant() == "sample texts")
                                {
                                    continue;                                     // Don't want to bundle these up
                                }
                                var zipName = Path.Combine(rootName, dirName);
                                zip.AddDirectory(directory, zipName);
                                if (forReaderTools)
                                {
                                    ReplaceBookWithTemplate(zip, directory, rootName);
                                }
                            }
                            foreach (var file in Directory.GetFiles(dir))
                            {
                                zip.AddFile(file, rootName);
                            }
                            //nb: without this second argument, we don't get the outer directory included, and we need that for the name of the collection
                            //zip.AddDirectory(dir, System.IO.Path.GetFileName(dir));
                            zip.Save(path);
                        }
                        //show it
                        Logger.WriteEvent("Showing BloomPack on disk");
                        PathUtilities.SelectFileInExplorer(path);
                        Analytics.Track("Create BloomPack");
                    }
                    finally
                    {
                        Cursor.Current = Cursors.Default;
                        pleaseWait.Close();
                    }
                }
            }
            catch (Exception e)
            {
                Palaso.Reporting.ErrorReport.NotifyUserOfProblem(e, "Could not make the BloomPack");
            }
        }
Example #5
0
 public void MakeBloomPack(string path)
 {
     try
     {
         if(File.Exists(path))
         {
             //UI already go permission for this
             File.Delete(path);
         }
         Logger.WriteEvent("Making BloomPack");
         using (var pleaseWait = new SimpleMessageDialog("Creating BloomPack..."))
         {
             try
             {
                 pleaseWait.Show();
                 pleaseWait.BringToFront();
                 Application.DoEvents();//actually show it
                 Cursor.Current = Cursors.WaitCursor;
                 using (var zip = new ZipFile(Encoding.UTF8))
                 {
                     string dir = TheOneEditableCollection.PathToDirectory;
                     //nb: without this second argument, we don't get the outer directory included, and we need that for the name of the collection
                     zip.AddDirectory(dir, System.IO.Path.GetFileName(dir));
                     zip.Save(path);
                 }
                 //show it
                 Logger.WriteEvent("Showing BloomPack on disk");
                 Process.Start(Path.GetDirectoryName(path));
                 Analytics.Track("Create BloomPack");
             }
             finally
             {
                 Cursor.Current = Cursors.Default;
                 pleaseWait.Close();
             }
         }
     }
     catch (Exception e)
     {
         Palaso.Reporting.ErrorReport.NotifyUserOfProblem(e, "Could not make the BloomPack");
     }
 }