protected void Application_Start(object sender, EventArgs e) { BundleConfig.RegisterBundles(BundleTable.Bundles); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException); AppRuntime.Start(); AppEventLog.Warning("TIMMIS STARTED"); }
public static void LogError(string method, string message, bool sendemail) { try { //EventLog.WriteEntry(eventSource, string.Format("Error in: {0}\r\nMessage:{1}", new object[] { method, message }), EventLogEntryType.Error); AppEventLog appLog = new AppEventLog(); appLog.AppName = "HarperSERVICE"; appLog.DateCreated = DateTime.Now; appLog.Event = "ERROR_LOGGED"; appLog.Message1 = message; appLog.Section = method; using (SupportDataDataContext context = new SupportDataDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString)) { context.AppEventLogs.InsertOnSubmit(appLog); context.SubmitChanges(); } Mailer emailer = new Mailer(); emailer.SendEmail(ConfigurationManager.AppSettings["mailserviceuser"], ConfigurationManager.AppSettings["mailservicepwd"], "SERVICE ERROR LOGGED", ConfigurationManager.AppSettings["erroremailsfrom"], ConfigurationManager.AppSettings["erroremailsto"], string.Empty, string.Empty, message, false, ConfigurationManager.AppSettings["erroremailsmtpserver"]); } catch { } }
protected void Application_End(object sender, EventArgs e) { AppRuntime.Stopping(); string msg = "TIMMIS Stopped"; AppRuntime.Stop(); AppEventLog.Error(msg); }
private void PrepareTaskQueue() { this.m_TaskQueue.Clear(); Type[] baseInAssemblies = this.FindTypesByBaseInAssemblies(this.FindAssembliesByNameKeyInAppDomain("T_"), typeof(TaskBase)); Array tasksInfo = this.GetTasksInfo(); bool flag = tasksInfo == null; if (flag) { AppEventLog.Debug("task info is null"); } else { Type[] array = baseInAssemblies; for (int i = 0; i < array.Length; i++) { Type type = array[i]; foreach (TaskBase taskBase in tasksInfo) { bool flag2 = taskBase == null || taskBase.TaskResult == TaskExecResult.Executed; if (flag2) { AppEventLog.Debug("task executed, pre task queue"); } else { TaskBase task = (TaskBase)Activator.CreateInstance(type); task.Init(); bool flag3 = taskBase.MdId.ToString() == task.MdId.ToString() && taskBase.ComId == task.ComId; if (flag3) { task.JobId = taskBase.JobId; task.JobName = taskBase.JobName; task.MdId = taskBase.MdId; task.MdName = taskBase.MdName; task.ComId = taskBase.ComId; task.ExecUserId = taskBase.ExecUserId; task.FailNoticeUserId = taskBase.FailNoticeUserId; task.RequiredExecuteTime = taskBase.RequiredExecuteTime; task.ExecuteTime = taskBase.ExecuteTime; task.NextExecuteTime = taskBase.NextExecuteTime; task.CycleOption = taskBase.CycleOption; this.AddTask(task); string str = taskBase.MdId.ToString(); string str2 = "|"; string str3 = task.MdId.ToString(); AppEventLog.Debug(str + str2 + str3); AppEventLog.Debug(taskBase.ComId + "|" + task.ComId); AppEventLog.Debug("task mdid or comid compare"); } } } } } }
private void application_BeginRequest(object sender, EventArgs e) { HttpContext context = ((HttpApplication)sender).Context; HttpRequest request = context.Request; string filePath = request.FilePath; string executionFilePath = request.AppRelativeCurrentExecutionFilePath; GlobalCulture.SetContextCulture(); LogicContext current = LogicContext.Current; current.SetDatabase(AppConfig.DefaultDbId); current.Source = filePath; HttpCookie cookie = request.Cookies[CookieMemory.FormsCookieName]; bool flag = cookie != null; if (flag) { CookieMemory cookie2 = new CookieMemory(cookie); LogicSession logicSession = AuthUtils.GetLogicSession(cookie2); bool flag2 = logicSession != null && logicSession.UserId == cookie2.UserId; if (!flag2) { AppEventLog.Debug("无法恢复"); return; } current.CookieUpdateTime = cookie2.UpdateTime; logicSession.LastRequestTime = AppRuntime.ServerDateTime; current.SetLogicSession(logicSession); current.UserAuthCookies = cookie; } bool flag3 = filePath == null; if (!flag3) { string s = StringHelper.RightSubstring(filePath, 5); bool flag4 = (!StringHelper.EqualsIgnoreCase(s, ".aspx") && !StringHelper.EqualsIgnoreCase(s, ".asmx") && !StringHelper.EqualsIgnoreCase(s, ".ashx")) || context.Request.Url.ToString().IndexOf("ActiveModule.aspx") < 0; if (!flag4) { string routeUrl = ModuleUtils.GetRouteUrl(request.QueryString["AMID"].ToString().Trim().ToInt()); current.AmId = request.QueryString["AMID"].ToString().Trim().ToInt(); bool flag5 = routeUrl.IndexOf("?") < 0; if (flag5) { context.Response.Redirect(routeUrl + "?" + context.Request.QueryString, false); } else { context.Response.Redirect(routeUrl + "&" + context.Request.QueryString, false); } } } }
/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { SipStringManager.CreateResourceManager("EnhancedAllowList"); AppEventLog appEventLog = new AppEventLog(Config.ServiceName, "Application"); Config.AppEventLog = appEventLog; #if VSDEBUG // // Registration/Unregistration code for stand alone exe. // Service process reg/unreg will be done at install/uninstall time. // if (args.Length > 0) { string firstArg = args[0].ToLower(); if (firstArg == "/register") { PolicyManager.Register(); } else if (firstArg == "/unregister") { PolicyManager.Unregister(); } else { Console.WriteLine("Unknown argument - {0}", firstArg); } return; } ConsoleApp app = new ConsoleApp(); app.Start(); MessageBox.Show("Hit OK to exit ... ", "EAL Server"); app.Stop(); #else ServiceBase[] ServicesToRun; ServicesToRun = new ServiceBase[] { new ServiceMain() }; ServiceBase.Run(ServicesToRun); #endif }
internal static double GN(int mdId, string param) { double num = 0.0; IDataModule dataModule = null; DataModuleUtils.m_dicMdId_DataModule.TryGetValue(mdId, out dataModule); bool flag = dataModule != null; if (flag) { num = dataModule.GN(param); } else { AppEventLog.Debug(string.Format("不存在[{0}]数据模块", mdId)); } return(num); }
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 void Execute() { DateTime now = DateTime.Now; this.Init(); TaskBase[] taskBaseArray = this.DequeueTasks(DateTime.Now); TaskBase[] array = taskBaseArray; for (int i = 0; i < array.Length; i++) { TaskBase taskBase = array[i]; bool flag = !this.UpdateNextTime(taskBase.JobId, taskBase.ExecuteTime, taskBase.NextExecuteTime); if (flag) { taskBase.TaskResult = TaskExecResult.Executed; } } AppEventLog.Debug("tasks:" + taskBaseArray.Length.ToString()); TaskBase[] array2 = taskBaseArray; for (int j = 0; j < array2.Length; j++) { TaskBase task = array2[j]; try { bool flag2 = task.TaskResult == TaskExecResult.Executed; if (flag2) { AppEventLog.Debug("TaskResult:true."); } bool flag3 = task.TaskResult != TaskExecResult.Executed; if (flag3) { DateTime dateTime = this.AddZQ(now, task.RequiredExecuteTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime); bool flag4 = DateTime.Compare(dateTime, now) < 0; if (flag4) { bool skipExecute = task.SkipExecute; if (skipExecute) { task.TaskResult = TaskExecResult.Skip; List <string> list = task.LogInfoDetail; string format = "{0} C|跳过 {1} 作业计划已过期,跳过该次运行。"; string str = DateTime.Now.ToString(); string str2 = task.RequiredExecuteTime.ToString(); string str3 = string.Format(format, str, str2); list.Add(str3); while (DateTime.Compare(this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime), now) < 0) { task.RequiredExecuteTime = dateTime; dateTime = this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime); task.TaskResult = TaskExecResult.Skip; List <string> list2 = task.LogInfoDetail; string format2 = "{0} C|跳过 {1} 作业计划已过期,跳过该次运行。"; string str4 = DateTime.Now.ToString(); string str5 = task.RequiredExecuteTime.ToString(); string str6 = string.Format(format2, str4, str5); list2.Add(str6); } JobLogUtils.WriteServiceLog(task); } else { task.NextExecuteTime = dateTime; TimerJob timerJob = new TimerJob(); timerJob.TaskModule = task; TimerManager.RunTask(timerJob, task.ExecUserId, AppConfig.DefaultDbId); while (DateTime.Compare(this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime), now) < 0) { task.RequiredExecuteTime = dateTime; dateTime = this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime); task.NextExecuteTime = dateTime; timerJob.TaskModule = task; TimerManager.RunTask(timerJob, task.ExecUserId, AppConfig.DefaultDbId); } bool flag5 = task.TaskResult != TaskExecResult.Failure && task.TaskResult != TaskExecResult.Exception; if (flag5) { task.TaskResult = TaskExecResult.Success; } JobLogUtils.WriteServiceLog(task); } bool flag6 = DateTime.Compare(dateTime, now) < 0; if (flag6) { task.RequiredExecuteTime = dateTime; task.NextExecuteTime = this.AddZQ(now, dateTime, task.CycleOption.CycleUnit, task.CycleOption.CycleValue, task.CycleOption.CycleExecWeek, task.CycleOption.CycleExecMonth, task.CycleOption.CycleExecTime); TimerManager.RunTask(new TimerJob { TaskModule = task }, task.ExecUserId, AppConfig.DefaultDbId); bool flag7 = task.TaskResult != TaskExecResult.Failure && task.TaskResult != TaskExecResult.Exception; if (flag7) { task.TaskResult = TaskExecResult.Success; } JobLogUtils.WriteServiceLog(task); } } else { TimerManager.RunTask(new TimerJob { TaskModule = task }, task.ExecUserId, AppConfig.DefaultDbId); bool flag8 = task.TaskResult != TaskExecResult.Failure && task.TaskResult != TaskExecResult.Exception; if (flag8) { task.TaskResult = TaskExecResult.Success; } JobLogUtils.WriteServiceLog(task); } } } catch (Exception ex_4E3) { task.TaskResult = TaskExecResult.Exception; JobLogUtils.WriteServiceLog(task); } } }
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; } }