Exemple #1
0
        public static DataTable GetTable(string sql)
        {
            DataTable dt = new DataTable();

            try
            {
                using (var conn = GetConnection())
                {
                    conn.Open();

                    var cmd             = GetCmd(conn, sql);
                    MySqlDataAdapter da = new MySqlDataAdapter(cmd);
                    da.Fill(dt);
                }
            }
            catch (Exception e)
            {
                string str = string.Format("sql: {0}", sql);
                CommonLogger.WriteLog(
                    ELogCategory.Fatal,
                    string.Format("DbHelper.GetTable Exception: {0}{1}{2}", e.Message, Environment.NewLine, str),
                    e
                    );
            }

            return(dt);
        }
Exemple #2
0
        protected void Application_Start()
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("myDebugAppender");
            CommonLogger.WriteLog(ELogCategory.Info, "MySqlDemo.Web MvcApplication Startup ...");

            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
        }
Exemple #3
0
        private static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
        {
            CommonLogger.WriteLog(
                ELogCategory.Fatal,
                string.Format("Program.Application_ThreadException Exception: {0}", e.Exception.Message),
                e.Exception
                );

            MessageBox.Show(string.Format("Program.Application_ThreadException Exception: {0}{1}", Environment.NewLine, e.Exception.Message));
        }
Exemple #4
0
        protected void Application_Start()
        {
            log4net.ILog logger = log4net.LogManager.GetLogger("myDebugAppender");
            CommonLogger.WriteLog(ELogCategory.Info, "WebApplication1 MvcApplication Startup ...");

            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            MvcHandler.DisableMvcResponseHeader = false;
        }
Exemple #5
0
        private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
        {
            var exception = e.ExceptionObject as Exception;

            CommonLogger.WriteLog(
                ELogCategory.Fatal,
                string.Format("Program.CurrentDomain_UnhandledException Exception: {0}", exception.Message),
                exception
                );

            MessageBox.Show(string.Format("Program.CurrentDomain_UnhandledException Exception: {0}{1}", Environment.NewLine, exception.Message));
        }
Exemple #6
0
        protected void Application_Error(object sender, EventArgs e)
        {
            HttpApplication http      = sender as HttpApplication;
            Exception       exception = Server.GetLastError();

            Exception[] exceptions = http.Context.AllErrors;
            CommonLogger.WriteLog(
                ELogCategory.Fatal,
                string.Format("MvcApplication.Application_Error Exception: {0}", exception.Message),
                e: exception
                );

            //Server.ClearError();
            //http.Response.StatusCode = 500;
        }
        public override void OnException(ExceptionContext filterContext)
        {
            CommonLogger.WriteLog(
                ELogCategory.Fatal,
                string.Format("MyCustomErrorFilterAttribute.OnException, Msg: {0}", filterContext.Exception.Message),
                filterContext.Exception
                );

            if (!filterContext.ExceptionHandled)
            {
                filterContext.ExceptionHandled = true;
                filterContext.HttpContext.Server.ClearError();
                filterContext.HttpContext.Response.StatusCode = 500;
            }
        }
Exemple #8
0
        static void Main()
        {
            string path = AppDomain.CurrentDomain.BaseDirectory + "log4net.config";

            log4net.Config.XmlConfigurator.Configure(new FileInfo(path));
            CommonLogger.WriteLog(
                ELogCategory.Debug,
                string.Format("Md5PwdTool Startup ...")
                );

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += Application_ThreadException;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }