/// <summary> /// 根据批次号更新服务码起始时间 /// </summary> /// <param name="user"></param> /// <param name="batchCode"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public static async Task <Tuple <bool, string> > UpdateBeautyServiceCodeTimeByBatchCode(string user, string batchCode, DateTime startTime, DateTime endTime) { var result = false; var msg = string.Empty; try { var writeStr = BeautyServicePackageDal.GetTuhuGrouponWriteConnstr(); using (var dbhelper = new SqlDbHelper(writeStr)) { dbhelper.BeginTransaction(); var updateCodeResult = BeautyServicePackageDal.UpdateBeautyServicePackageDetailCodeTimeByBatchCode(dbhelper, batchCode, startTime, endTime); if (!updateCodeResult) { throw new Exception("根据批次号更新服务码时间失败,方法UpdateBeautyServicePackageDetailCodeTimeByBatchCode"); } var serviceCodes = BeautyServicePackageDal.SelectServiceCodesByBatchCode(batchCode); if (serviceCodes != null && serviceCodes.Any()) { if (serviceCodes.Count() > 10000) { throw new Exception("暂时不支持服务码数量大于10000的修改操作"); } using (var client = new ServiceCodeClient()) { var batchSize = 1000; var index = 0; while (index < serviceCodes.Count()) { var batchCodes = serviceCodes.Skip(index).Take(batchSize).ToList(); var kxChangeCodeTimeModel = new ChangeCodeTimeRequest { ServiceCodes = batchCodes, OverdueTime = endTime }; var kxChangeResult = client.ChangeOverdueTime(kxChangeCodeTimeModel); if (!kxChangeResult.Success) { throw kxChangeResult.Exception; } if (kxChangeResult.Result != null && kxChangeResult.Result.FailServiceCode != null && kxChangeResult.Result.FailServiceCode.Any()) { var serviceCodeFailedLog = new BeautyOprLog { LogType = "ChangeOverdueTimeFailedCodes", IdentityID = $"{batchCode}", OldValue = null, NewValue = JsonConvert.SerializeObject(kxChangeResult.Result.FailServiceCode), Remarks = $"根据批次号修改服务码过期时间失败,批次:{batchCode},OverdueTime应该改为:{endTime}", OperateUser = user, }; LoggerManager.InsertLog("BeautyOprLog", serviceCodeFailedLog); } index += batchSize; } dbhelper.Commit(); result = true; } } } } catch (Exception ex) { msg = ex.Message; Logger.Error(ex.Message, ex); } return(new Tuple <bool, string>(result, msg)); }
/// <summary> /// Returns all the currently defined loggers in the specified domain. /// </summary> /// <param name="domain">the domain to lookup in</param> /// <remarks> /// The root logger is <b>not</b> included in the returned array. /// </remarks> /// <returns>All the defined loggers</returns> public static ILogExtention[] GetCurrentLoggers(string domain) { return(WrapLoggers(LoggerManager.GetCurrentLoggers(domain))); }
/// <summary> /// Returns all the currently defined loggers in the specified assembly's domain. /// </summary> /// <param name="assembly">the assembly to use to lookup the domain</param> /// <remarks> /// The root logger is <b>not</b> included in the returned array. /// </remarks> /// <returns>All the defined loggers</returns> public static IEventIDLog[] GetCurrentLoggers(Assembly assembly) { return(WrapLoggers(LoggerManager.GetCurrentLoggers(assembly))); }
/// <summary> /// Shorthand for <see cref="LogManager.GetLogger(string)"/>. /// </summary> /// <remarks> /// Get the logger for the fully qualified name of the type specified. /// </remarks> /// <param name="domain">the domain to lookup in</param> /// <param name="type">The full name of <paramref name="type"/> will /// be used as the name of the logger to retrieve.</param> /// <returns>the logger with the name specified</returns> public static ILogExtention GetLogger(string domain, Type type) { return(WrapLogger(LoggerManager.GetLogger(domain, type))); }
/// <summary> /// Returns the named logger if it exists /// </summary> /// <remarks> /// <para>If the named logger exists (in the specified domain) then it /// returns a reference to the logger, otherwise it returns /// <c>null</c>.</para> /// </remarks> /// <param name="domain">the domain to lookup in</param> /// <param name="name">The fully qualified logger name to look for</param> /// <returns>The logger found, or null</returns> public static ILogExtention Exists(string domain, string name) { return(WrapLogger(LoggerManager.Exists(domain, name))); }
/// <summary> /// Shuts down the repository specified. /// </summary> /// <remarks> /// <para> /// Calling this method will <b>safely</b> close and remove all /// appenders in all the loggers including root contained in the /// repository. The repository is looked up using /// the <paramref name="repositoryAssembly"/> specified. /// </para> /// <para> /// Some appenders need to be closed before the application exists. /// Otherwise, pending logging events might be lost. /// </para> /// <para> /// The <c>shutdown</c> method is careful to close nested /// appenders before closing regular appenders. This is allows /// configurations where a regular appender is attached to a logger /// and again to a nested appender. /// </para> /// </remarks> /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param> public static void ShutdownRepository(Assembly repositoryAssembly) { LoggerManager.ShutdownRepository(repositoryAssembly); }
/// <summary> /// Returns all the currently defined loggers in the specified assembly's domain. /// </summary> /// <param name="assembly">the assembly to use to lookup the domain</param> /// <remarks> /// The root logger is <b>not</b> included in the returned array. /// </remarks> /// <returns>All the defined loggers</returns> public static ILogExtention[] GetCurrentLoggers(Assembly assembly) { return(WrapLoggers(LoggerManager.GetCurrentLoggers(assembly))); }
/// <summary> /// Shorthand for <see cref="LogManager.GetLogger(string)"/>. /// </summary> /// <remarks> /// Gets the logger for the fully qualified name of the type specified. /// </remarks> /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param> /// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param> /// <returns>The logger with the name specified.</returns> public static ILog GetLogger(Assembly repositoryAssembly, Type type) { return(WrapLogger(LoggerManager.GetLogger(repositoryAssembly, type))); }
/// <summary> /// Creates a repository with the specified name. /// </summary> /// <remarks> /// <para> /// Creates the default type of <see cref="ILoggerRepository"/> which is a /// <see cref="log4net.Repository.Hierarchy.Hierarchy"/> object. /// </para> /// <para> /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined. /// An <see cref="Exception"/> will be thrown if the repository already exists. /// </para> /// </remarks> /// <param name="repository">The name of the repository, this must be unique amongst repositories.</param> /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns> /// <exception cref="LogException">The specified repository already exists.</exception> public static ILoggerRepository CreateRepository(string repository) { return(LoggerManager.CreateRepository(repository)); }
/// <summary> /// Retrieves or creates a named logger. /// </summary> /// <remarks> /// <para> /// Retrieve a logger named as the <paramref name="name"/> /// parameter. If the named logger already exists, then the /// existing instance will be returned. Otherwise, a new instance is /// created. /// </para> /// <para> /// By default, loggers do not have a set level but inherit /// it from the hierarchy. This is one of the central features of /// log4net. /// </para> /// </remarks> /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param> /// <param name="name">The name of the logger to retrieve.</param> /// <returns>The logger with the name specified.</returns> public static ILog GetLogger(Assembly repositoryAssembly, string name) { return(WrapLogger(LoggerManager.GetLogger(repositoryAssembly, name))); }
/// <summary> /// Shorthand for <see cref="LogManager.GetLogger(string)"/>. /// </summary> /// <remarks> /// Gets the logger for the fully qualified name of the type specified. /// </remarks> /// <param name="repository">The repository to lookup in.</param> /// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param> /// <returns>The logger with the name specified.</returns> public static ILog GetLogger(string repository, Type type) { return(WrapLogger(LoggerManager.GetLogger(repository, type))); }
/// <summary> /// Returns all the currently defined loggers in the specified assembly's repository. /// </summary> /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param> /// <remarks> /// The root logger is <b>not</b> included in the returned array. /// </remarks> /// <returns>All the defined loggers.</returns> public static ILog[] GetCurrentLoggers(Assembly repositoryAssembly) { return(WrapLoggers(LoggerManager.GetCurrentLoggers(repositoryAssembly))); }
/// <summary> /// Returns all the currently defined loggers in the specified repository. /// </summary> /// <param name="repository">The repository to lookup in.</param> /// <remarks> /// The root logger is <b>not</b> included in the returned array. /// </remarks> /// <returns>All the defined loggers.</returns> public static ILog[] GetCurrentLoggers(string repository) { return(WrapLoggers(LoggerManager.GetCurrentLoggers(repository))); }
/// <summary> /// Returns the named logger if it exists. /// </summary> /// <remarks> /// <para> /// If the named logger exists (in the repository for the specified assembly) then it /// returns a reference to the logger, otherwise it returns /// <c>null</c>. /// </para> /// </remarks> /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param> /// <param name="name">The fully qualified logger name to look for.</param> /// <returns> /// The logger, or <c>null</c> if the logger doesn't exist in the specified /// assembly's repository. /// </returns> public static ILog Exists(Assembly repositoryAssembly, string name) { return(WrapLogger(LoggerManager.Exists(repositoryAssembly, name))); }
/// <summary> /// Shuts down the log4net system. /// </summary> /// <remarks> /// <para> /// Calling this method will <b>safely</b> close and remove all /// appenders in all the loggers including root contained in all the /// default repositories. /// </para> /// <para> /// Some appenders need to be closed before the application exists. /// Otherwise, pending logging events might be lost. /// </para> /// <para>The <c>shutdown</c> method is careful to close nested /// appenders before closing regular appenders. This is allows /// configurations where a regular appender is attached to a logger /// and again to a nested appender. /// </para> /// </remarks> public static void Shutdown() { LoggerManager.Shutdown(); }
/// <summary> /// Creates a repository with the specified name and repository type. /// </summary> /// <remarks> /// <para> /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined. /// An <see cref="Exception"/> will be thrown if the repository already exists. /// </para> /// </remarks> /// <param name="repository">The name of the repository, this must be unique to the repository.</param> /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/> /// and has a no arg constructor. An instance of this type will be created to act /// as the <see cref="ILoggerRepository"/> for the repository specified.</param> /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns> /// <exception cref="LogException">The specified repository already exists.</exception> public static ILoggerRepository CreateRepository(string repository, Type repositoryType) { return(LoggerManager.CreateRepository(repository, repositoryType)); }
/// <summary> /// Shuts down the repository for the repository specified. /// </summary> /// <remarks> /// <para> /// Calling this method will <b>safely</b> close and remove all /// appenders in all the loggers including root contained in the /// <paramref name="repository"/> specified. /// </para> /// <para> /// Some appenders need to be closed before the application exists. /// Otherwise, pending logging events might be lost. /// </para> /// <para>The <c>shutdown</c> method is careful to close nested /// appenders before closing regular appenders. This is allows /// configurations where a regular appender is attached to a logger /// and again to a nested appender. /// </para> /// </remarks> /// <param name="repository">The repository to shutdown.</param> public static void ShutdownRepository(string repository) { LoggerManager.ShutdownRepository(repository); }
/// <summary> /// Creates a repository for the specified assembly and repository type. /// </summary> /// <remarks> /// <para> /// The <see cref="ILoggerRepository"/> created will be associated with the repository /// specified such that a call to <see cref="GetRepository(Assembly)"/> with the /// same assembly specified will return the same repository instance. /// </para> /// </remarks> /// <param name="repositoryAssembly">The assembly to use to get the name of the repository.</param> /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/> /// and has a no arg constructor. An instance of this type will be created to act /// as the <see cref="ILoggerRepository"/> for the repository specified.</param> /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns> public static ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType) { return(LoggerManager.CreateRepository(repositoryAssembly, repositoryType)); }
public ILoggerAdapter Create(Type targetType) { ILogger logger = LoggerManager.GetLogger(targetType.Assembly, this.loggerName ?? targetType.FullName); return(new Log4NetAdapter(logger)); }
/// <summary> /// Gets the list of currently defined repositories. /// </summary> /// <remarks> /// <para> /// Get an array of all the <see cref="ILoggerRepository"/> objects that have been created. /// </para> /// </remarks> /// <returns>An array of all the known <see cref="ILoggerRepository"/> objects.</returns> public static ILoggerRepository[] GetAllRepositories() { return(LoggerManager.GetAllRepositories()); }
/// <summary> /// Retrieve or create a named logger. /// </summary> /// <remarks> /// <para>Retrieve a logger named as the <paramref name="name"/> /// parameter. If the named logger already exists, then the /// existing instance will be returned. Otherwise, a new instance is /// created.</para> /// /// <para>By default, loggers do not have a set level but inherit /// it from the hierarchy. This is one of the central features of /// log4net.</para> /// </remarks> /// <param name="assembly">the assembly to use to lookup the domain</param> /// <param name="name">The name of the logger to retrieve.</param> /// <returns>the logger with the name specified</returns> public static ILogExtention GetLogger(Assembly assembly, string name) { return(WrapLogger(LoggerManager.GetLogger(assembly, name))); }
/// <summary> /// Returns the default <see cref="ILoggerRepository"/> instance. /// </summary> /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns> /// <remarks> /// <para> /// Gets the <see cref="ILoggerRepository"/> for the repository specified /// by the <paramref name="repository"/> argument. /// </para> /// </remarks> /// <param name="repository">The repository to lookup in.</param> public static ILoggerRepository GetRepository(string repository) { return(LoggerManager.GetRepository(repository)); }
/// <summary> /// Shorthand for <see cref="LogManager.GetLogger(string)"/>. /// </summary> /// <remarks> /// Get the logger for the fully qualified name of the type specified. /// </remarks> /// <param name="assembly">the assembly to use to lookup the domain</param> /// <param name="type">The full name of <paramref name="type"/> will /// be used as the name of the logger to retrieve.</param> /// <returns>the logger with the name specified</returns> public static ILogExtention GetLogger(Assembly assembly, Type type) { return(WrapLogger(LoggerManager.GetLogger(assembly, type))); }
/// <summary> /// Returns the default <see cref="ILoggerRepository"/> instance. /// </summary> /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns> /// <remarks> /// <para> /// Gets the <see cref="ILoggerRepository"/> for the repository specified /// by the <paramref name="repositoryAssembly"/> argument. /// </para> /// </remarks> /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param> public static ILoggerRepository GetRepository(Assembly repositoryAssembly) { return(LoggerManager.GetRepository(repositoryAssembly)); }
/// <summary> /// Returns the named logger if it exists /// </summary> /// <remarks> /// <para>If the named logger exists (in the specified assembly's domain) then it /// returns a reference to the logger, otherwise it returns /// <c>null</c>.</para> /// </remarks> /// <param name="assembly">the assembly to use to lookup the domain</param> /// <param name="name">The fully qualified logger name to look for</param> /// <returns>The logger found, or null</returns> public static ILogExtention Exists(Assembly assembly, string name) { return(WrapLogger(LoggerManager.Exists(assembly, name))); }
/// <summary> /// Resets all values contained in this repository instance to their defaults. /// </summary> /// <remarks> /// <para> /// Reset all values contained in the repository instance to their /// defaults. This removes all appenders from all loggers, sets /// the level of all non-root loggers to <c>null</c>, /// sets their additivity flag to <c>true</c> and sets the level /// of the root logger to <see cref="Level.Debug"/>. Moreover, /// message disabling is set to its default "off" value. /// </para> /// </remarks> /// <param name="repository">The repository to reset.</param> public static void ResetConfiguration(string repository) { LoggerManager.ResetConfiguration(repository); }
public BaseApiController() { logger = new LoggerManager(); }
/// <summary> /// Resets all values contained in this repository instance to their defaults. /// </summary> /// <remarks> /// <para> /// Reset all values contained in the repository instance to their /// defaults. This removes all appenders from all loggers, sets /// the level of all non-root loggers to <c>null</c>, /// sets their additivity flag to <c>true</c> and sets the level /// of the root logger to <see cref="Level.Debug"/>. Moreover, /// message disabling is set to its default "off" value. /// </para> /// </remarks> /// <param name="repositoryAssembly">The assembly to use to lookup the repository to reset.</param> public static void ResetConfiguration(Assembly repositoryAssembly) { LoggerManager.ResetConfiguration(repositoryAssembly); }
/// <summary> /// Retrieve or create a named logger. /// </summary> /// <remarks> /// <para>Retrieve a logger named as the <paramref name="name"/> /// parameter. If the named logger already exists, then the /// existing instance will be returned. Otherwise, a new instance is /// created.</para> /// /// <para>By default, loggers do not have a set level but inherit /// it from the hierarchy. This is one of the central features of /// log4net.</para> /// </remarks> /// <param name="domain">the domain to lookup in</param> /// <param name="name">The name of the logger to retrieve.</param> /// <returns>the logger with the name specified</returns> public static IEventIDLog GetLogger(string domain, string name) { return(WrapLogger(LoggerManager.GetLogger(domain, name))); }
public static Tuple <bool, string> UpdateBeautyServicePackageDetail(BeautyServicePackageDetail packageDetail) { bool result = false; var msg = string.Empty; var writeStr = BeautyServicePackageDal.GetTuhuGrouponWriteConnstr(); using (var dbhelper = new SqlDbHelper(writeStr)) { try { var oldValue = GetBeautyServicePackageDetail(packageDetail.PKID); dbhelper.BeginTransaction(); var updatePackageDetailResult = BeautyServicePackageDal.UpdateBeautyServicePackageDetail(dbhelper, packageDetail); if (!updatePackageDetailResult) { throw new Exception("更新服务码配置失败"); } if (packageDetail.IsServiceCodeGenerated && (oldValue.ServiceCodeStartTime != packageDetail.ServiceCodeStartTime || oldValue.ServiceCodeEndTime != packageDetail.ServiceCodeEndTime)) { if (oldValue.ServiceCodeNum > 10000) { throw new Exception("大于10000暂时不支持修改"); } var updateServiceCodeTimeResult = BeautyServicePackageDal.UpdateServiceCodeTime(dbhelper, packageDetail.PKID, packageDetail.ServiceCodeStartTime, packageDetail.ServiceCodeEndTime); if (!updateServiceCodeTimeResult) { throw new Exception("更新服务码时间失败"); } if (oldValue.ServiceCodeEndTime != packageDetail.ServiceCodeEndTime && packageDetail.ServiceCodeEndTime != null) { var serviceCodes = (GetBeautyServicePackageDetailCodesByPackageDetailId(packageDetail.PKID))?.Select(t => t.ServiceCode)?.ToList(); if (serviceCodes != null && serviceCodes.Any()) { using (var client = new ServiceCodeClient()) { var batchSize = 1000; var index = 0; while (index < serviceCodes.Count) { var batchCodes = serviceCodes.Skip(index).Take(batchSize).ToList(); var kxChangeCodeTimeModel = new ChangeCodeTimeRequest { ServiceCodes = batchCodes, OverdueTime = Convert.ToDateTime(packageDetail.ServiceCodeEndTime) }; var kxChangeResult = client.ChangeOverdueTime(kxChangeCodeTimeModel); if (!kxChangeResult.Success) { throw kxChangeResult.Exception; } if (kxChangeResult.Result != null && kxChangeResult.Result.FailServiceCode != null && kxChangeResult.Result.FailServiceCode.Any()) { var serviceCodeFailedLog = new BeautyOprLog { LogType = "ChangeOverdueTimeFailedCodes", IdentityID = $"{packageDetail.PKID}", OldValue = null, NewValue = JsonConvert.SerializeObject(kxChangeResult.Result.FailServiceCode), Remarks = $"修改服务码过期时间失败", OperateUser = packageDetail.UpdateUser, }; LoggerManager.InsertLog("BeautyOprLog", serviceCodeFailedLog); } index += batchSize; } } } } } dbhelper.Commit(); result = true; var log = new BeautyOprLog { LogType = "UpdateBeautyServicePackageDetail", IdentityID = $"{packageDetail.PKID}", OldValue = JsonConvert.SerializeObject(oldValue), NewValue = JsonConvert.SerializeObject(packageDetail), Remarks = $"修改集团客户礼包详情,详情ID为{packageDetail.PKID}", OperateUser = packageDetail.UpdateUser, }; LoggerManager.InsertLog("BeautyOprLog", log); } catch (Exception ex) { msg = ex.Message; dbhelper.Rollback(); Logger.Error(ex.Message, ex); }; } return(new Tuple <bool, string>(result, msg)); }