protected void Application_End(object sender, EventArgs e) { AppRuntime.Stopping(); string msg = "TIMMIS Stopped"; AppRuntime.Stop(); AppEventLog.Error(msg); }
internal static void Start() { AppRuntime.AppType = ((Environment.CurrentDirectory == AppDomain.CurrentDomain.BaseDirectory) ? "WIN" : "WEB"); AppRuntime.AppSiteName = HostingEnvironment.SiteName; AppRuntime.AppRootPath = HostingEnvironment.ApplicationPhysicalPath; string applicationVirtualPath = HostingEnvironment.ApplicationVirtualPath; AppRuntime.AppVirtualPath = ((applicationVirtualPath != "/") ? (applicationVirtualPath + "/") : applicationVirtualPath); AppRuntime.AppBit = ((IntPtr.Size != 4) ? ((IntPtr.Size != 8) ? AppBitType.None : AppBitType.Bit64) : AppBitType.Bit32); AppRuntime.MachineName = Environment.MachineName; Environment.SetEnvironmentVariable("NLS_LANG", "SIMPLIFIED CHINESE_CHINA.ZHS16GBK"); Environment.SetEnvironmentVariable("NLS_DATE_FORMAT", "YYYY-MM-DD HH24:MI:SS"); Environment.SetEnvironmentVariable("NLS_TIMESTAMP_FORMAT", "YYYY-MM-DD HH24:MI:SS"); string str = AppConfig.TNS_ADMIN; bool flag = !string.IsNullOrEmpty(str); if (flag) { Environment.SetEnvironmentVariable("TNS_ADMIN", str); } AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AppRuntime.CurrentDomain_AssemblyResolve); AppRuntime._DbQueryDateTime = AppUtils.GetDbServerDateTime(); AppRuntime.ServerDateTime = AppRuntime._DbQueryDateTime; try { ComponentInit.Init(); UsersInit.Init(); TIM.T_KERNEL.SystemInit.SystemInit.Init(); PermissionOpInit.Init(); CacheEvent.UpdateUCache(); } catch (Exception ex) { AppEventLog.Error("AppRuntime 异常" + ex.Message); } TimerManager.Initialize(); TimerManager.Instance.AddTask(TimerCategory.SessionTask, "AUTHSESSION", typeof(AuthSessionUpdateTask), string.Empty, string.Empty); TimerManager.Instance.AddTask(TimerCategory.SessionTask, "MEMORYSESSION", typeof(UCacheUpdateTask), string.Empty, string.Empty); TimerManager.Instance.AddTask(TimerCategory.TableCacheTask, "TABLECACHE", typeof(UCacheUpdateTask), string.Empty, string.Empty); TimerManager.Instance.AddTask(TimerCategory.TimeModuleTask, "TIMEMODULE", typeof(JobScheduleTask), AppConfig.DefaultDbId, "ADMIN"); }
protected void Application_Error(object sender, EventArgs e) { HttpContext context = ((HttpApplication)sender).Context; bool flag = context == null; if (!flag) { Exception exception = context.Server.GetLastError(); bool flag2 = exception == null; if (!flag2) { base.Server.Transfer("~/T_INDEX/ErrorHandler.aspx"); bool flag3 = exception.InnerException != null; if (flag3) { exception = exception.InnerException; } AppEventLog.Error(exception.Message + exception.StackTrace); context.ClearError(); } } }
public static void WriteServiceLog(TaskBase task) { Database database = LogicContext.GetDatabase(); try { database.BeginTrans(); HSQL sql = new HSQL(database); sql.Add("insert into JOBLOG(JOBLOG_JOBID, JOBLOG_LOGNO, JOBLOG_LOGTIME, JOBLOG_OPERTYPE, JOBLOG_EXECRESULT, JOBLOG_DESC, JOBLOG_DETAIL)"); sql.Add("values(:JOBLOG_JOBID, :JOBLOG_LOGNO, :JOBLOG_LOGTIME, :JOBLOG_OPERTYPE, :JOBLOG_EXECRESULT, :JOBLOG_DESC, :JOBLOG_DETAIL)"); sql.ParamByName("JOBLOG_JOBID").Value = task.JobId; sql.ParamByName("JOBLOG_LOGNO").Value = TimIdUtils.GenUtoId("JOBLOGNO"); sql.ParamByName("JOBLOG_LOGTIME").Value = AppRuntime.ServerDateTime; sql.ParamByName("JOBLOG_OPERTYPE").Value = "E"; sql.ParamByName("JOBLOG_DETAIL").Value = string.Empty; StringBuilder stringBuilder = new StringBuilder(); foreach (string str in task.LogInfoDetail) { stringBuilder.AppendLine(str); } string str2 = stringBuilder.ToString(); string str3 = string.Empty; bool flag = task.TaskResult == TaskExecResult.Success; if (flag) { str3 = string.Format("{0} 作业计划执行成功。", task.RequiredExecuteTime.ToString()); bool flag2 = string.IsNullOrEmpty(str2); if (flag2) { str2 = str3; } sql.ParamByName("JOBLOG_EXECRESULT").Value = "A"; sql.ParamByName("JOBLOG_DESC").Value = str3; sql.AddParam("JOBLOG_DETAIL", TimDbType.Blob, 0, str2); } else { bool flag3 = task.TaskResult == TaskExecResult.Failure; if (flag3) { str3 = string.Format("{0} 作业计划执行失败。", task.RequiredExecuteTime.ToString()); bool flag4 = string.IsNullOrEmpty(str2); if (flag4) { str2 = str3; } sql.ParamByName("JOBLOG_EXECRESULT").Value = "B"; sql.ParamByName("JOBLOG_DESC").Value = str3; sql.AddParam("JOBLOG_DETAIL", TimDbType.Blob, 0, str2); JobLogUtils.SendErrorMsgToMail(task); } else { bool flag5 = task.TaskResult == TaskExecResult.Skip; if (flag5) { str3 = "部分作业计划已过期,跳过运行。"; bool flag6 = string.IsNullOrEmpty(str2); if (flag6) { str2 = str3; } sql.ParamByName("JOBLOG_EXECRESULT").Value = "C"; sql.ParamByName("JOBLOG_DESC").Value = str3; sql.AddParam("JOBLOG_DETAIL", TimDbType.Blob, 0, str2); } else { bool flag7 = task.TaskResult == TaskExecResult.Exception; if (flag7) { str3 = string.Format("{0} 作业计划执行错误。", task.RequiredExecuteTime.ToString()); bool flag8 = string.IsNullOrEmpty(str2); if (flag8) { str2 = str3; } sql.ParamByName("JOBLOG_EXECRESULT").Value = "D"; sql.ParamByName("JOBLOG_DESC").Value = str3; sql.AddParam("JOBLOG_DETAIL", TimDbType.Blob, 0, str2); JobLogUtils.SendErrorMsgToMail(task); } else { bool flag9 = task.TaskResult == TaskExecResult.StartExecute; if (flag9) { str3 = string.Format("{0} 作业计划开始执行。", task.RequiredExecuteTime.ToString()); bool flag10 = string.IsNullOrEmpty(str2); if (flag10) { str2 = str3; } sql.ParamByName("JOBLOG_EXECRESULT").Value = "A"; sql.ParamByName("JOBLOG_DESC").Value = str3; sql.AddParam("JOBLOG_DETAIL", TimDbType.Blob, 0, str2); } } } } } database.ExecSQL(sql); task.LogInfoDetail.Clear(); sql.Clear(); sql.Add("update JOB set JOB_PREEXECTIME = :JOB_PREEXECTIME,JOB_PREEXECSTATUS = :JOB_PREEXECSTATUS,JOB_PREEXECDESC = :JOB_PREEXECDESC "); sql.Add(" where JOB_JOBID = :JOB_JOBID"); sql.ParamByName("JOB_PREEXECSTATUS").Value = ((task.TaskResult != TaskExecResult.Success) ? ((task.TaskResult != TaskExecResult.Failure) ? ((task.TaskResult != TaskExecResult.Exception) ? "C" : "D") : "B") : "A"); sql.ParamByName("JOB_PREEXECTIME").Value = task.ExecuteTime; sql.ParamByName("JOB_PREEXECDESC").Value = str3; sql.ParamByName("JOB_JOBID").Value = task.JobId; database.ExecSQL(sql); database.CommitTrans(); } catch (Exception ex) { database.RollbackTrans(); AppEventLog.Error("记录作业计划日志失败,原因:" + ex.Message); } }
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { AppEventLog.Error("CurrentDomain UnhandledException: " + e.ExceptionObject.ToString()); }
public static void Init() { FileInfo[] files = new DirectoryInfo(AppRuntime.AppRootPath + "\\bin").GetFiles("T_*.dll"); int i = 0; while (i < files.Length) { FileInfo fileInfo = files[i]; TIM.T_KERNEL.DbTableCache.DllComponent dllComponent = null; try { dllComponent = new TIM.T_KERNEL.DbTableCache.DllComponent(fileInfo.FullName).Instance; bool flag = dllComponent != null && !string.IsNullOrWhiteSpace(dllComponent.ComId) && !string.IsNullOrWhiteSpace(dllComponent.ComName); if (!flag) { goto IL_289; } Database database = LogicContext.GetDatabase(); HSQL hsql = new HSQL(database); hsql.Add("SELECT COMPONENT_COMID FROM COMPONENT WHERE COMPONENT_COMID = :COMPONENT_COMID"); hsql.ParamByName("COMPONENT_COMID").Value = dllComponent.ComId; bool flag2 = DbHelper.ExistingRecord(hsql); if (flag2) { hsql.Clear(); hsql.Add("UPDATE COMPONENT SET"); hsql.Add(" COMPONENT_COMNAME = :COMPONENT_COMNAME,"); hsql.Add(" COMPONENT_MDIDSTART = :COMPONENT_MDIDSTART,"); hsql.Add(" COMPONENT_MDIDEND = :COMPONENT_MDIDEND,"); hsql.Add(" COMPONENT_DISABLED = :COMPONENT_DISABLED"); hsql.Add("WHERE COMPONENT_COMID = :COMPONENT_COMID"); hsql.ParamByName("COMPONENT_COMID").Value = dllComponent.ComId; hsql.ParamByName("COMPONENT_COMNAME").Value = dllComponent.ComName; hsql.ParamByName("COMPONENT_MDIDSTART").Value = dllComponent.MdIdStart; hsql.ParamByName("COMPONENT_MDIDEND").Value = dllComponent.MdIdEnd; hsql.ParamByName("COMPONENT_DISABLED").Value = "N"; database.ExecSQL(hsql); } else { hsql.Clear(); hsql.Add("INSERT INTO COMPONENT(COMPONENT_COMID,COMPONENT_COMNAME,COMPONENT_MDIDSTART,COMPONENT_MDIDEND,COMPONENT_DISABLED)"); hsql.Add("VALUES"); hsql.Add("(:COMPONENT_COMID,:COMPONENT_COMNAME,:COMPONENT_MDIDSTART,:COMPONENT_MDIDEND,:COMPONENT_DISABLED)"); hsql.ParamByName("COMPONENT_COMID").Value = dllComponent.ComId; hsql.ParamByName("COMPONENT_COMNAME").Value = dllComponent.ComName; hsql.ParamByName("COMPONENT_MDIDSTART").Value = dllComponent.MdIdStart; hsql.ParamByName("COMPONENT_MDIDEND").Value = dllComponent.MdIdEnd; hsql.ParamByName("COMPONENT_DISABLED").Value = "N"; database.ExecSQL(hsql); } } catch (Exception ex) { AppEventLog.Error("ComponentInit 异常" + ex.Message); } goto IL_27A; IL_289: i++; continue; IL_27A: ModuleInit.Init(dllComponent); DataModuleUtils.Init(dllComponent); goto IL_289; } }