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(); } }
public static void Check(bool condition, String errorText, int lineNumber) { if (!condition) { String detailMessage = String.Empty; StringBuilder strBuilder; GenerateStackTrace(lineNumber, out detailMessage); strBuilder = new StringBuilder(); strBuilder.Append("Assert: ").Append("\r\n").Append(errorText).Append("\r\n").Append(detailMessage); ApplicationLog.WriteWarning(strBuilder.ToString()); System.Diagnostics.Debug.Fail(errorText, detailMessage); } }
private void FailedLogin(string email) { ApplicationLog.WriteWarning("Unexpected User try to sign in Email: " + email); lbMsg.Text = "Invalid Email or Password, please try again."; lbMsg.Visible = true; }
/// <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); }