Ejemplo n.º 1
0
        /// <summary>
        /// 获得默认的字符串加密、解密对象。在Web.config的AppSetting中通过site.security.encryption.provider指定类的全名。
        /// </summary>
        /// <returns>AbstractStringEncryptor对象实例。可能有异常发生。</returns>
        public static AbstractStringEncryptor GetDefaultEncryptor()
        {
            Conf   conf = Conf.CreateFromWebConfig();
            string type = conf.get("site.security.encryption.provider") as string;

            if (string.IsNullOrEmpty(type))
            {
                type = "Helper.DES";
                // log ...
                AbstractLogger.GetLogger(typeof(AbstractStringEncryptor)).Warn("未配置site.security.encryption.provider,将使用“Helper.DES”类作为字符串加密、解密工具。");
            }
            return(GetEncryptor(type));
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 以DEBUG级别将信息输出到文件日志
 /// </summary>
 /// <param name="strMsg">要输出的信息</param>
 /// <param name="req">当前的请求对象,可以为null</param>
 public static void LogError(string strMsg, HttpContext context)
 {
     try
     {
         // get the default FileLogger instance
         AbstractLogger logger = AbstractLogger.GetLogger(typeof(Function));
         if (logger == null)
         {
             return;
         }
         logger.Error(
             string.Format("[{0}] by [{1}]\r\n{2}\r\n",
                           context == null ? "N/A" : context.Request.RawUrl,
                           context == null ? "N/A" : context.Request.UserHostAddress,
                           strMsg));
     }
     catch (Exception ex)
     {
         System.Diagnostics.Debug.Assert(false, ex.Message);
     }
 }