Exemplo n.º 1
0
        public static bool IsEqual(this XmlSyntaxException @this, XmlSyntaxException other)
        {
            // XmlSyntaxException is stubbed out in Core therefore we are skipping some equality checks.

            return(@this != null &&
                   other != null &&
                   // On full framework, line number may be method body start
                   // On Net Native we can't reflect on Exceptions and change its StackTrace
                   ((PlatformDetection.IsFullFramework || PlatformDetection.IsNetNative) ? true :
                    (@this.StackTrace == other.StackTrace)) &&
                   @this.Data.CheckSequenceEquals(other.Data) &&
                   @this.Source == other.Source &&
                   @this.HelpLink == other.HelpLink);
        }
Exemplo n.º 2
0
        public void Save()
        {
            Logger.WriteEvent("BookStorage.Saving... (eventual destination: {0})", PathToExistingHtml);

            Dom.UpdateMetaElement("Generator", "Bloom " + ErrorReport.GetVersionForErrorReporting());
            if (null != Assembly.GetEntryAssembly())             // null during unit tests
            {
                var ver = Assembly.GetEntryAssembly().GetName().Version;
                Dom.UpdateMetaElement("BloomFormatVersion", kBloomFormatVersion);
            }
            MetaData.FormatVersion = kBloomFormatVersion;
            string tempPath = SaveHtml(Dom);


            string errors = ValidateBook(tempPath);

            if (!string.IsNullOrEmpty(errors))
            {
                Logger.WriteEvent("Errors saving book {0}: {1}", PathToExistingHtml, errors);
                var badFilePath = PathToExistingHtml + ".bad";
                File.Copy(tempPath, badFilePath, true);
                //hack so we can package this for palaso reporting
                errors += string.Format("{0}{0}{0}Contents:{0}{0}{1}", Environment.NewLine,
                                        File.ReadAllText(badFilePath));
                var ex = new XmlSyntaxException(errors);

                Palaso.Reporting.ErrorReport.NotifyUserOfProblem(ex, "Before saving, Bloom did an integrity check of your book, and found something wrong. This doesn't mean your work is lost, but it does mean that there is a bug in the system or templates somewhere, and the developers need to find and fix the problem (and your book).  Please click the 'Details' button and send this report to the developers.  Bloom has saved the bad version of this book as " + badFilePath + ".  Bloom will now exit, and your book will probably not have this recent damage.  If you are willing, please try to do the same steps again, so that you can report exactly how to make it happen.");
                Process.GetCurrentProcess().Kill();
            }
            else
            {
                Logger.WriteMinorEvent("ReplaceFileWithUserInteractionIfNeeded({0},{1})", tempPath, PathToExistingHtml);
                if (!string.IsNullOrEmpty(tempPath))
                {
                    FileUtils.ReplaceFileWithUserInteractionIfNeeded(tempPath, PathToExistingHtml, null);
                }
            }

            MetaData.Save();
        }