protected void Application_End(Object sender, EventArgs e) { OpacApplication app = null; try { /* * // 调试用 * OpacApplication.WriteErrorLog("成功进入Application_End", EventLogEntryType.Information); * */ // 错误信息采用两级存放策略。 // 如果LibraryAppliation对象已经存在,则采用其ErrorInfo成员的值; // 否则,采用Application["errorinfo"]值 string strErrorInfo = ""; app = (OpacApplication)Application["app"]; if (app != null) { strErrorInfo = app.GlobalErrorInfo; } else { strErrorInfo = (string)Application["errorinfo"]; } // 系统错误字符串为空时才保存.xml配置文件 if (String.IsNullOrEmpty(strErrorInfo) == true) { /* * // 调试用 * OpacApplication.WriteWindowsLog("进行了 opac.xml 保存", EventLogEntryType.Information); * */ app.Save(null, false); app.Close(); } else { /* * // 调试用 * OpacApplication.WriteWindowsLog("没有进行 opac.xml 保存,因为错误字符串 '" + ErrorInfo + "'", EventLogEntryType.Information); * */ } } catch (Exception ex) { string strErrorText = "Application_End阶段出现异常: " + ExceptionUtil.GetDebugText(ex); OpacApplication.WriteWindowsLog(strErrorText); if (app != null) { app.GlobalErrorInfo = strErrorText; } else { Application["errorinfo"] = strErrorText; } } }