/// <summary> /// Handles errors that may be encountered when displaying this page. /// <param name="e">An EventArgs that contains the event data.</param> /// </summary> protected override void OnError(EventArgs e) { ApplicationLog.WriteError(ApplicationLog.FormatException(Server.GetLastError(), UNHANDLED_EXCEPTION)); Session["error"] = Server.GetLastError().Message; ErrorPage = fPopup ? "PopupError.aspx" : "Error.aspx"; base.OnError(e); }
public static void Update(DataTable dataTable) { SqlConnection cnx = dbhelper.Connection.GetConnection();; cnx.Open(); SqlTransaction trx = cnx.BeginTransaction(IsolationLevel.Serializable); try { Update((EmpresasDataset.EmpresasDataTable)dataTable, trx); trx.Commit(); } catch (SqlException ex) { ApplicationLog.WriteWarning(ApplicationLog.FormatException(ex, "")); } catch (Exception ex) { trx.Rollback(); ApplicationLog.WriteWarning(ApplicationLog.FormatException(ex, "")); } finally { cnx.Close(); } }
/// <summary> /// Function called when a user session object is nuked from the cache. /// Logs off the user. /// </summary> /// <param name="key"></param> /// <param name="val"></param> /// <param name="reason"></param> private static void UserSessionExpiryCallback(string key, object val, CacheItemRemovedReason reason) { try { ZfLib.UserSession zfUserSession = (ZfLib.UserSession)val; // we cannot user "FromName" because this function doesn't run as the Zetafax user, // and therefore may not have permission to access the user's files to read information // such as the user's from name string strUser = zfUserSession.UserInDir; int nEnd = strUser.LastIndexOf('\\', strUser.LastIndexOf('\\') - 1); int nStart = 1 + strUser.LastIndexOf('\\', nEnd - 1); strUser = strUser.Substring(nStart, nEnd - nStart); ApplicationLog.WriteTrace("Cache remove: " + strUser.ToLower()); zfUserSession.Logoff(); } catch (Exception ex) { // this error usually occurs if NT authentication is used to protect the Zetafax // directories and the ASPNET process doesn't have authority to release the LOK file. ApplicationLog.WriteTrace(ApplicationLog.FormatException(ex, "Failed to log off user session")); } }
/// <summary> /// Configures ASP.NET so that the page is returned in the correct language. /// <remarks> /// The algorithm for finding the correct language is as follows: /// - use forcelang override if specified (english on fail) /// - for each request language try language and lang-neutral language /// stop when you find the first one which loads. /// </remarks> /// </summary> public static ResourceManager ConfigureResources(HttpRequest req) { ResourceManager rmLocal = new ResourceManager("Zetafax.strings", typeof(PageBase).Assembly); if (ZetafaxConfiguration.ForceLangString != String.Empty) { try { // User override of languange CultureInfo cc = CultureInfo.CreateSpecificCulture(ZetafaxConfiguration.ForceLangString); CultureInfo cuic = new CultureInfo(ZetafaxConfiguration.ForceLangString); Thread.CurrentThread.CurrentCulture = cc; Thread.CurrentThread.CurrentUICulture = cuic; } catch (Exception ex) { // Somebody probably asked for a language we don't support. // Log it and continue. ApplicationLog.WriteWarning(ApplicationLog.FormatException(ex, "Error forcing CultureInfo")); } } else { CultureInfo cc = CultureInfo.CurrentCulture; CultureInfo cuic = CultureInfo.CurrentUICulture; CultureInfo cen = new CultureInfo("en"); // Set the culture and UI culture to the browser's accept language string[] arrLanguages = req.UserLanguages; // If the browser doesn't specify locale (like outlook) if (null == arrLanguages || 0 == arrLanguages.Length) { // Use default language if specified if (ZetafaxConfiguration.DefaultLangString != String.Empty) { arrLanguages = new string[] { ZetafaxConfiguration.DefaultLangString }; } else { // No defualt - use english arrLanguages = new string[] { "en" }; } } foreach (string strReqLang in arrLanguages) { // truncate at ";" int iSemi = strReqLang.IndexOf(';'); string strLang; if (iSemi > 0) { strLang = strReqLang.Substring(0, iSemi); } else { strLang = strReqLang; } try { CultureInfo ccLocal = CultureInfo.CreateSpecificCulture(strLang); if (ccLocal.Equals(cen)) { // english culture: break break; } ResourceSet rs = rmLocal.GetResourceSet(ccLocal, true, false); if (rs == null && !ccLocal.IsNeutralCulture) { if (ccLocal.Parent.Equals(cen)) { // english culture: break break; } rs = rmLocal.GetResourceSet(ccLocal.Parent, true, false); } if (rs != null) { cc = ccLocal; cuic = new CultureInfo(strLang); break; } } catch (Exception ex) { // Somebody probably asked for a language we don't support. // Log it and continue. ApplicationLog.WriteInfo(ApplicationLog.FormatException(ex, "Error setting CultureInfo")); } } Thread.CurrentThread.CurrentCulture = cc; Thread.CurrentThread.CurrentUICulture = cuic; } return(rmLocal); }