/// <summary> /// log4Net记录信息 /// </summary> /// <param name="messageContainer"></param> /// <param name="messageType"></param> public static void Log4NetWith(this MessageContainer messageContainer, MessageType messageType) { var log = new DefaultLoggerFactory().GetLogger(messageContainer.Name); var messageText = string.Join(Environment.NewLine, messageContainer.Messages.Select(message => string.Format("{0}-{1}-{2}-{3}", message.InsertTime, message.MessageContainerName, message.MessageType, message.MessageContent))); switch (messageType) { case MessageType.Debug: log.DebugFormat(messageText); break; case MessageType.Info: log.InfoFormat(messageText); break; case MessageType.Warn: log.WarnFormat(messageText); break; case MessageType.Error: log.ErrorFormat(messageText); break; case MessageType.Fatal: log.FatalFormat(messageText); break; } }
public JobEntrance() { ISchedulerFactory sf = new StdSchedulerFactory(); _scheduler = sf.GetScheduler(); var loggerFactory = new DefaultLoggerFactory(); _logger = loggerFactory.GetLogger(); }
private static Guid? GetUintId() { var hostName = HttpContext.Current.Request.Url.Host.ToLower(); var log = new DefaultLoggerFactory().GetLogger(); log.DebugFormat("访问的host:{0}", hostName); if (System.Configuration.ConfigurationManager.AppSettings.AllKeys.Contains(hostName)) { log.DebugFormat("对应的id:{0}", System.Configuration.ConfigurationManager.AppSettings[hostName]); return Guid.Parse(System.Configuration.ConfigurationManager.AppSettings[hostName]); } return default(Guid?); }
protected void Application_Error(Object sender, EventArgs e) { var error = Server.GetLastError(); if (error == null) return; var errorMessage = new StringBuilder(); errorMessage.AppendLine(Request.Url.ToString()); errorMessage.AppendLine(error.TargetSite.ToString()); errorMessage.AppendLine(error.Message); errorMessage.AppendLine(error.ToString()); errorMessage.AppendLine(error.StackTrace); var loggerFactory = new DefaultLoggerFactory(); loggerFactory.GetLogger().InfoFormat(errorMessage.ToString()); var url = UrlHelper .GenerateUrl("Default", "Message", "Home", null, RouteTable.Routes, HttpContext.Current.Request.RequestContext, false); if (!string.Equals(Request.Url.AbsolutePath, url, StringComparison.CurrentCultureIgnoreCase)) HttpContext.Current.Response.Redirect(url + "?Message=" + error.Message, true); }
/// <summary> /// log4Net记录信息 /// </summary> /// <param name="messageContainer"></param> public static void Log4Net(this MessageContainer messageContainer) { var log = new DefaultLoggerFactory().GetLogger(messageContainer.Name); var debugs = messageContainer.Messages.Where(o => o.MessageType == MessageType.Debug); var infos = messageContainer.Messages.Where(o => o.MessageType == MessageType.Info); var warns = messageContainer.Messages.Where(o => o.MessageType == MessageType.Warn); var errors = messageContainer.Messages.Where(o => o.MessageType == MessageType.Error); var fatals = messageContainer.Messages.Where(o => o.MessageType == MessageType.Fatal); if (debugs.Any()) { log.DebugFormat(string.Join(Environment.NewLine, debugs.Select(message => string.Format("{0}-{1}-{2}-{3}", message.InsertTime, message.MessageContainerName, message.MessageType, message.MessageContent)))); } if (infos.Any()) { log.DebugFormat(string.Join(Environment.NewLine, infos.Select(message => string.Format("{0}-{1}-{2}-{3}", message.InsertTime, message.MessageContainerName, message.MessageType, message.MessageContent)))); } if (warns.Any()) { log.DebugFormat(string.Join(Environment.NewLine, warns.Select(message => string.Format("{0}-{1}-{2}-{3}", message.InsertTime, message.MessageContainerName, message.MessageType, message.MessageContent)))); } if (errors.Any()) { log.DebugFormat(string.Join(Environment.NewLine, errors.Select(message => string.Format("{0}-{1}-{2}-{3}", message.InsertTime, message.MessageContainerName, message.MessageType, message.MessageContent)))); } if (fatals.Any()) { log.DebugFormat(string.Join(Environment.NewLine, fatals.Select(message => string.Format("{0}-{1}-{2}-{3}", message.InsertTime, message.MessageContainerName, message.MessageType, message.MessageContent)))); } }
public FetchProposalFromMessageJob() { var loggerFactory = new DefaultLoggerFactory(); _logger = loggerFactory.GetLogger(); _proposalService = new ProposalService(); }
static void Main(string[] args) { var file = System.Configuration.ConfigurationManager.AppSettings["path"].ToString(); var logger = new DefaultLoggerFactory().GetLogger("XXXFixed"); Workbook workbook = new Workbook(file); var worksheet = workbook.Worksheets[0]; var cells = worksheet.Cells; var dtImport = cells.ExportDataTableAsString(0, 0, cells.MaxDataRow + 1, cells.MaxDataColumn + 1, true); var rowsOfInsert = new List<int>(); var rowsOfError = new List<int>(); //遍历数据集合 if (dtImport.Rows.Count > 0) { #region 新增语句 var sql = @"INSERT INTO [BerthRecord] ([Id] ,[No] ,[BerthId] ,[PlateNumber] ,[TimeOfBerthIn] ,[TimeOfBerthOut] ,[TotalFee] ,[TollCollectorIdOfBerthIn] ,[TollCollectorIdOfBerthOut] ,[BerthInRecordType] ,[BerthOutRecordType] ,[PaymentType] ,[BerthInDeviceSN] ,[BerthInDeviceNo] ,[BerthOutDeviceSN] ,[BerthOutDeviceNo] ,[CreateTime] ,[LastModifyDateTime] ,[Extension] ,[RecordStatus]) VALUES (@Id ,@No ,@BerthId ,@PlateNumber ,@TimeOfBerthIn ,@TimeOfBerthOut ,@TotalFee ,@TollCollectorIdOfBerthIn ,@TollCollectorIdOfBerthOut ,@BerthInRecordType ,@BerthOutRecordType ,@PaymentType ,@BerthInDeviceSN ,@BerthInDeviceNo ,@BerthOutDeviceSN ,@BerthOutDeviceNo ,@CreateTime ,@LastModifyDateTime ,@Extension ,@RecordStatus)"; #endregion #region 更新语句 var sqlOfUpdate = @"UPDATE [BerthRecord] SET [PlateNumber] = @PlateNumber ,[TimeOfBerthIn] = @TimeOfBerthIn ,[TimeOfBerthOut] = @TimeOfBerthOut ,[TotalFee] = @TotalFee ,[TollCollectorIdOfBerthIn] = @TollCollectorIdOfBerthIn ,[TollCollectorIdOfBerthOut] = @TollCollectorIdOfBerthOut ,[TotalTimeSpan] = @TotalTimeSpan ,[BerthInRecordType] = @BerthInRecordType ,[BerthOutRecordType] = @BerthOutRecordType ,[PaymentType] = @PaymentType ,[BerthInDeviceSN] = @BerthInDeviceSN ,[BerthInDeviceNo] = @BerthInDeviceNo ,[BerthOutDeviceSN] = @BerthOutDeviceSN ,[BerthOutDeviceNo] = @BerthOutDeviceNo ,[CreateTime] = @CreateTime ,[LastModifyDateTime] = @LastModifyDateTime ,[RecordStatus] = @RecordStatus ,[Extension] = @Extension WHERE [Id]=@Id"; #endregion var mainSqlConnection = GetNewConnection(); var rowNum = 2; var updateRows = 0; var insertRows = 0; var errorRows = 0; foreach (DataRow dr in dtImport.Rows) { var timeOfBerthIn = string.Empty; var timeOfBerthOut = string.Empty; var status = string.Empty; SqlDataReader sqlDataReader = null; SqlConnection connOfInsert = null; SqlConnection connOfUpdate = null; try { #region 参数校验及赋值 if (dr["流水号"] == null) { throw new ArgumentException(string.Format("第【{0}】行流水号为null", rowNum)); } var recordNo = dr["流水号"].ToString().Trim(); if (dr["操作员"] == null) { throw new ArgumentException(string.Format("第【{0}】行操作员为null", rowNum)); } var collectorNo = dr["操作员"].ToString().Trim(); if (dr["泊位号"] == null) { throw new ArgumentException(string.Format("第【{0}】行泊位号为null", rowNum)); continue; } var berthNo = dr["泊位号"].ToString().Trim(); if (dr["车牌"] == null) { throw new ArgumentException(string.Format("第【{0}】行车牌为null", rowNum)); } var plateNumber = dr["车牌"].ToString().Trim(); if (dr["进入时间"] == null && dr["离开时间"] == null) { throw new ArgumentException(string.Format("第【{0}】行进入时间和离开时间均为null", rowNum)); } if (dr["进入时间"] != null) { timeOfBerthIn = dr["进入时间"].ToString().Trim(); } if (dr["离开时间"] != null) { timeOfBerthOut = dr["离开时间"].ToString().Trim(); } if (dr["应收金额"] == null && dr["离开时间"] != null) { throw new ArgumentException(string.Format("第【{0}】行离开时间不为空应收金额为null", rowNum)); } var money = dr["应收金额"].ToString().Trim(); if (dr["设备唯一码"] == null) { throw new ArgumentException(string.Format("第【{0}】行设备唯一码为null", rowNum)); } var deviceSn = dr["设备唯一码"].ToString().Trim(); if (dr["上传标志"] != null) { status = dr["上传标志"].ToString().Trim(); } #endregion #region 判断记录是否存在 var selectCountSql = string .Format("Select count(*) from BerthRecord br Join Berth b on b.Id=br.BerthId WHERE br.No='{0}' and (b.No='{1}' or b.No='{1}[已删除]') and (br.BerthInDeviceSN='{2}' or br.BerthOutDeviceSN='{2}') and br.RecordStatus=0", recordNo, berthNo, deviceSn); SqlCommand sqlCommandCount = new SqlCommand(selectCountSql, mainSqlConnection); logger.InfoFormat("第{0}行为查询是否存在Sql语句:{1}", rowNum, selectCountSql); var countObject = sqlCommandCount.ExecuteScalar(); var count = int.Parse(countObject.ToString()); sqlCommandCount.Dispose(); #endregion if (count == 0) { #region 新增记录 connOfInsert = GetNewConnection(); var insertCommand = new SqlCommand(sql, connOfInsert); insertCommand.Parameters.Add(CreateSqlParameter("Extension", "新增")); insertCommand.Parameters.Add(CreateSqlParameter("Id", Guid.NewGuid())); #region berthId var connOfBerthId = GetNewConnection(); SqlCommand sqlCommandOfBerthId = new SqlCommand(string .Format("Select Id from Berth where No='{0}'", berthNo), connOfBerthId); object berthId = sqlCommandOfBerthId.ExecuteScalar(); sqlCommandOfBerthId.Dispose(); connOfBerthId.Close(); if (berthId == null) { throw new ArgumentException(string.Format("服务中不存在泊位号{0}!", berthNo)); } insertCommand.Parameters.Add(CreateSqlParameter("BerthId", berthId)); #endregion insertCommand.Parameters.Add(CreateSqlParameter("PlateNumber", plateNumber)); Func<object> timeOfBerthInFunc = () => { if (string.IsNullOrEmpty(timeOfBerthIn)) { return DBNull.Value; } return DateTime.Parse(timeOfBerthIn); }; insertCommand.Parameters.Add(CreateSqlParameter("TimeOfBerthIn", timeOfBerthInFunc())); Func<object> timeOfBerthOutFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return DateTime.Parse(timeOfBerthOut); }; insertCommand.Parameters.Add(CreateSqlParameter("TimeOfBerthOut", timeOfBerthOutFunc())); Func<object> moneyFunc = () => { if (string.IsNullOrEmpty(money)) { return 0; } return decimal.Parse(money); }; insertCommand.Parameters.Add(CreateSqlParameter("TotalFee", moneyFunc())); #region 泊入泊出收费员 var connOfCollection = GetNewConnection(); SqlCommand sqlCommandOfCollection = new SqlCommand(string .Format("Select Id from TollCollector where No='{0}'", collectorNo), connOfCollection); object collectorId = sqlCommandOfCollection.ExecuteScalar(); sqlCommandOfCollection.Dispose(); connOfCollection.Close(); if (collectorId == null) { throw new ArgumentNullException(string.Format("找不到对应的收费员{0}", collectorNo)); } var collectorIdGuid = Guid.Parse(collectorId.ToString()); Func<object> tollCollectorIdOfBerthInFunc = () => { if (string.IsNullOrEmpty(timeOfBerthIn)) { return DBNull.Value; } return collectorIdGuid; }; insertCommand.Parameters.Add(CreateSqlParameter("TollCollectorIdOfBerthIn", tollCollectorIdOfBerthInFunc())); Func<object> tollCollectorIdOfBerthOutFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return collectorIdGuid; }; insertCommand.Parameters.Add(CreateSqlParameter("TollCollectorIdOfBerthOut", tollCollectorIdOfBerthOutFunc())); #endregion Func<object> berthInRecordTypeFunc = () => { if (string.IsNullOrEmpty(timeOfBerthIn)) { return DBNull.Value; } return CovnertBerthInType(status); }; insertCommand.Parameters.Add(CreateSqlParameter("BerthInRecordType", berthInRecordTypeFunc())); Func<object> berthOutRecordTypeFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return CovnertBerthInType(status); }; insertCommand.Parameters.Add(CreateSqlParameter("BerthOutRecordType", berthOutRecordTypeFunc())); #region 收款类型 Func<object> paymentTypeFun = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } if (CovnertBerthOutType(status) == 2) { return DBNull.Value; } return 0; }; insertCommand.Parameters.Add(CreateSqlParameter("PaymentType", paymentTypeFun())); #endregion Func<object> berthInDeviceSNFunc = () => { if (string.IsNullOrEmpty(timeOfBerthIn)) { return DBNull.Value; } return deviceSn; }; insertCommand.Parameters.Add(CreateSqlParameter("BerthInDeviceSN", berthInDeviceSNFunc())); Func<object> berthOutDeviceSNFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return deviceSn; }; insertCommand.Parameters.Add(CreateSqlParameter("BerthOutDeviceSN", berthOutDeviceSNFunc())); #region 操作机器号 var connectOfDevice = GetNewConnection(); SqlCommand sqlCommandOfDevice = new SqlCommand(string.Format("Select No from Device where SN='{0}'", deviceSn), connectOfDevice); object deviceNoObject = sqlCommandOfDevice.ExecuteScalar(); sqlCommandOfDevice.Dispose(); connectOfDevice.Close(); if (deviceNoObject == null) { throw new ArgumentException(string.Format("唯一码对应的设备未找到{0}", deviceSn)); } Func<object> berthInDeviceNoFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return deviceNoObject; }; insertCommand.Parameters.Add(CreateSqlParameter("BerthInDeviceNo", berthInDeviceNoFunc())); Func<object> berthOutDeviceNoFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return deviceNoObject; }; insertCommand.Parameters.Add(CreateSqlParameter("BerthOutDeviceNo", berthOutDeviceNoFunc())); #endregion var timeOfCreate = string.IsNullOrEmpty(timeOfBerthOut) ? DateTime.Parse(timeOfBerthIn) : DateTime.Parse(timeOfBerthOut); insertCommand.Parameters.Add(CreateSqlParameter("CreateTime", timeOfCreate)); insertCommand.Parameters.Add(CreateSqlParameter("LastModifyDateTime", DateTime.Now)); insertCommand.Parameters.Add(CreateSqlParameter("No", recordNo)); insertCommand.Parameters.Add(CreateSqlParameter("RecordStatus", 0)); insertCommand.ExecuteNonQuery(); #endregion connOfInsert.Close(); insertRows++; rowsOfInsert.Add(rowNum); logger.InfoFormat("第{0}行为遗漏新增,总新增{1}", rowNum, insertRows); } else if (count == 1) { #region 读出已存在的记录 SqlCommand recordsqlCommand = new SqlCommand(string .Format("Select * from BerthRecord br Join Berth b on b.Id=br.BerthId WHERE br.No='{0}' and (b.No='{1}' or b.No='{1}[已删除]') and (br.BerthInDeviceSN='{2}' or br.BerthOutDeviceSN='{2}' ) and br.RecordStatus=0", recordNo, berthNo, deviceSn), mainSqlConnection); sqlDataReader = recordsqlCommand.ExecuteReader(); #endregion #region 更新记录 sqlDataReader.Read(); #region 记录老数据 string oldData = string.Empty; for (var i = 0; i < sqlDataReader.FieldCount; i++) { oldData += "@【" + sqlDataReader.GetName(i) + "=" + sqlDataReader.GetValue(i) + "】"; } #endregion connOfUpdate = GetNewConnection(); var updateCommand = new SqlCommand(sqlOfUpdate, connOfUpdate); updateCommand.Parameters.Add(CreateSqlParameter("Extension", oldData)); updateCommand.Parameters.Add(CreateSqlParameter("PlateNumber", plateNumber)); Func<object> timeOfBerthInFunc = () => { if (string.IsNullOrEmpty(timeOfBerthIn)) { return DBNull.Value; } return DateTime.Parse(timeOfBerthIn); }; updateCommand.Parameters.Add(CreateSqlParameter("TimeOfBerthIn", timeOfBerthInFunc())); Func<object> timeOfBerthOutFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return DateTime.Parse(timeOfBerthOut); }; updateCommand.Parameters.Add(CreateSqlParameter("TimeOfBerthOut", timeOfBerthOutFunc())); Func<object> moneyFunc = () => { if (string.IsNullOrEmpty(money)) { return 0; } return decimal.Parse(money); }; updateCommand.Parameters.Add(CreateSqlParameter("TotalFee", moneyFunc())); #region 收费员 var connOfCollection = GetNewConnection(); SqlCommand sqlCommandOfCollection = new SqlCommand(string .Format("Select Id from TollCollector where No='{0}'", collectorNo), connOfCollection); object collectorId = sqlCommandOfCollection.ExecuteScalar(); sqlCommandOfCollection.Dispose(); connOfCollection.Close(); if (collectorId == null) { throw new ArgumentNullException(string.Format("找不到对应的收费员{0}", collectorNo)); } var collectorIdGuid = Guid.Parse(collectorId.ToString()); Func<object> tollCollectorIdOfBerthInFunc = () => { if (string.IsNullOrEmpty(timeOfBerthIn)) { return DBNull.Value; } return collectorIdGuid; }; updateCommand.Parameters.Add(CreateSqlParameter("TollCollectorIdOfBerthIn", tollCollectorIdOfBerthInFunc())); Func<object> tollCollectorIdOfBerthOutFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return collectorIdGuid; }; updateCommand.Parameters.Add(CreateSqlParameter("TollCollectorIdOfBerthOut", tollCollectorIdOfBerthOutFunc())); #endregion updateCommand.Parameters.Add(CreateSqlParameter("TotalTimeSpan", DBNull.Value)); Func<object> berthInRecordTypeFunc = () => { if (sqlDataReader["BerthInRecordType"] != null && sqlDataReader["BerthInRecordType"] != DBNull.Value) { return int.Parse(sqlDataReader["BerthInRecordType"].ToString()); } if (string.IsNullOrEmpty(timeOfBerthIn)) { return DBNull.Value; } return CovnertBerthInType(status); }; updateCommand.Parameters.Add(CreateSqlParameter("BerthInRecordType", berthInRecordTypeFunc())); Func<object> berthOutRecordTypeFunc = () => { if (sqlDataReader["BerthOutRecordType"] != null && sqlDataReader["BerthOutRecordType"] != DBNull.Value) { return int.Parse(sqlDataReader["BerthOutRecordType"].ToString()); } if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return CovnertBerthInType(status); }; updateCommand.Parameters.Add(CreateSqlParameter("BerthOutRecordType", berthOutRecordTypeFunc())); #region 收费类型 Func<object> paymentTypeFun = () => { if ((sqlDataReader["BerthOutRecordType"] != null && sqlDataReader["BerthOutRecordType"] != DBNull.Value && sqlDataReader["BerthOutRecordType"].ToString() == "2")) { return DBNull.Value; } if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } if (sqlDataReader["PaymentType"] != null && sqlDataReader["PaymentType"] != DBNull.Value) { return int.Parse(sqlDataReader["PaymentType"].ToString()); } return 0; }; updateCommand.Parameters.Add(CreateSqlParameter("PaymentType", paymentTypeFun())); #endregion Func<object> berthInDeviceSNFunc = () => { if (string.IsNullOrEmpty(timeOfBerthIn)) { return DBNull.Value; } return deviceSn; }; updateCommand.Parameters.Add(CreateSqlParameter("BerthInDeviceSN", berthInDeviceSNFunc())); Func<object> berthOutDeviceSNFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return deviceSn; }; updateCommand.Parameters.Add(CreateSqlParameter("BerthOutDeviceSN", berthOutDeviceSNFunc())); #region 设备号 var connectOfDevice = GetNewConnection(); SqlCommand sqlCommandOfDevice = new SqlCommand(string.Format("Select No from Device where SN='{0}'", deviceSn), connectOfDevice); object deviceNoObject = sqlCommandOfDevice.ExecuteScalar(); sqlCommandOfDevice.Dispose(); connectOfDevice.Close(); if (deviceNoObject == null) { throw new ArgumentException(string.Format("唯一码对应的设备未找到{0}", deviceSn)); } Func<object> berthInDeviceNoFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return deviceNoObject; }; updateCommand.Parameters.Add(CreateSqlParameter("BerthInDeviceNo", berthInDeviceNoFunc())); Func<object> berthOutDeviceNoFunc = () => { if (string.IsNullOrEmpty(timeOfBerthOut)) { return DBNull.Value; } return deviceNoObject; }; updateCommand.Parameters.Add(CreateSqlParameter("BerthOutDeviceNo", berthOutDeviceNoFunc())); #endregion var timeOfCreate = string.IsNullOrEmpty(timeOfBerthOut) ? DateTime.Parse(timeOfBerthIn) : DateTime.Parse(timeOfBerthOut); updateCommand.Parameters.Add(CreateSqlParameter("CreateTime", timeOfCreate)); updateCommand.Parameters.Add(CreateSqlParameter("LastModifyDateTime", DateTime.Now)); updateCommand.Parameters.Add(CreateSqlParameter("RecordStatus", 0)); updateCommand.Parameters.Add(CreateSqlParameter("Id", sqlDataReader["Id"])); updateCommand.ExecuteNonQuery(); #endregion connOfUpdate.Close(); updateRows++; logger.InfoFormat("第{0}行记录被更新,总更新{1}", rowNum, updateRows); } else { throw new ArgumentException(string.Format(" No='{0}' and berthNo='{1}'的条件存在{2}条记录,放弃更新", recordNo, berthNo, count)); } } catch (Exception selectEx) { rowsOfError.Add(rowNum); errorRows++; logger.ErrorFormat("第【{0}】行处理时异常:{1}", rowNum, selectEx); } finally { if (sqlDataReader != null) sqlDataReader.Close(); if (connOfInsert != null) connOfInsert.Close(); if (connOfUpdate != null) connOfUpdate.Close(); } rowNum++; } mainSqlConnection.Close(); logger.InfoFormat("总行数{2},总共执行{3}行,总共更新{0},新增{1},出错:{4}", updateRows, insertRows, dtImport.Rows.Count, rowNum - 2, errorRows); logger.Info("新增行号为:" + string.Join(",", rowsOfInsert)); logger.Info("出错行号为:" + string.Join(",", rowsOfError)); logger.Info("文件:" + file + "同步完成"); Console.ReadLine(); } }
protected void Application_EndRequest(object sender, EventArgs e) { var sessionItem = HttpContext.Current.Items[WebSessionManager.NhibernateSessionKey]; var session = sessionItem as ISession; if (session != null) { session.Close(); var log = new DefaultLoggerFactory().GetLogger(); log.InfoFormat("Session已关闭!"); } }
protected void Application_Start() { var log = new DefaultLoggerFactory().GetLogger(); log.InfoFormat("日志已启动!"); AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); }
public DealFlowNodeFlowToJob() { var loggerFactory = new DefaultLoggerFactory(); _logger = loggerFactory.GetLogger(); _flowEngineService = new FlowEngineServiceInEngine(); }
public FlowEngineService() { var loggerFactory = new DefaultLoggerFactory(); _logger = loggerFactory.GetLogger(); _jobEntrance = new JobEntrance(); }
public FlowNodeInstanceJob() { var loggerFactory = new DefaultLoggerFactory(); _logger = loggerFactory.GetLogger(); _flowEngineService = new FlowEngineServiceInEngine(); }
public JobService() { var loggerFactory = new DefaultLoggerFactory(); _logger = loggerFactory.GetLogger(this.GetType().ToString()); _jobSchedule = new JobSchedule(); }