Ejemplo n.º 1
0
        //保存扩展属性
        private void SaveExts(Base_Catalog cat, NameValueCollection form)
        {
            cat.Exts.Clear();
            var ids           = form["ExtId"].Split(',');
            var names         = form["ExtName"].Split(',');
            var defaultValues = form["DefaultValue"].Split(',');
            var dataTypes     = form["DataType"].Split(',');
            var maxLengths    = form["MaxLength"].Split(',');
            //var allownulls = form["AllowNull"].Split(',');
            var states          = form["ExtState"].Split(',');
            var dataSourceTypes = form["DataSourceType"].Split(',');
            var dataSources     = form["DataSource"].Split(',');

            for (int i = 1; i < names.Length; i++)
            {
                if (!string.IsNullOrEmpty(names[i]))
                {
                    Base_CatalogExt ext = new Base_CatalogExt
                    {
                        Id           = CommOp.ToInt(ids[i]),
                        CatalogId    = cat.Id,
                        Name         = names[i],
                        DefaultValue = defaultValues[i],
                        DataType     = CommOp.ToEnum <ExtDataType>(dataTypes[i]),
                        State        = states[i] == "" ? ArticleState.Published : CommOp.ToInt(states[i]),
                        Ord          = i,
                        //AllowNull = CommOp.ToBool(allownulls[i] == "on" ? true : false),
                        MaxLength      = CommOp.ToInt(maxLengths[i]),
                        DataSourceType = CommOp.ToEnum <ExtDataSourceType>(dataSourceTypes[i]),
                        DataSource     = dataSources[i]
                    };
                    cat.Exts.Add(ext);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据指定的类型名称和属性名称获取对应的属性配置项
        /// </summary>
        /// <param name="className">类型名称</param>
        /// <param name="propName">属性名称</param>
        /// <param name="attr">标签属性</param>
        /// <returns>属性配置项</returns>
        public static AdvDataConfigItem GetPropertyConfig(CatalogExtAttribute attr, string className, string propName)
        {
            AdvDataConfigItem foundItem = null;
            var classConfig             = _configCache.FirstOrDefault(cfg => cfg.ClassName.Equals(className));

            if (classConfig == null)
            {
                classConfig = new AdvDataConfig()
                {
                    ClassName = className
                };
                _configCache.Add(classConfig);
                _modified = true;
            }
            foundItem = classConfig.Items.FirstOrDefault(c => c.PropertyName == propName);
            if (foundItem == null)
            {
                foundItem = new AdvDataConfigItem
                {
                    OverWrite    = true,
                    FormOrder    = 1,
                    PropertyName = propName,
                    GridOrder    = 1,

                    AllowNull      = attr.AllowNull,
                    DataSource     = attr.DataSource.ToStr(),
                    DataSourceType = CommOp.ToStr(attr.DataSourceType),
                    DataType       = attr.DataType.ToString(),
                    MaxLength      = attr.MaxLength,
                    MinLength      = attr.MinLength,
                    MaxValue       = CommOp.ToStr(attr.MaxValue),
                    MinValue       = CommOp.ToStr(attr.MinValue),
                    RegExpr        = attr.RegExpr,
                    DefaultValue   = attr.DefaultValue,
                    InputFormat    = attr.InputFormat,
                    DisplayFormat  = attr.DisplayFormat,
                    Browsable      = attr.Browsable,
                };
                classConfig.Items.Add(foundItem);
                _modified = true;
            }
            else if (foundItem.OverWrite)
            {
                attr.DefaultValue   = foundItem.DefaultValue;
                attr.DataType       = CommOp.ToEnum <ExtDataType>(foundItem.DataType);
                attr.AllowNull      = foundItem.AllowNull;
                attr.DataSource     = foundItem.DataSource;
                attr.DataSourceType = CommOp.ToEnum <ExtDataSourceType>(foundItem.DataSourceType);
                attr.MaxLength      = foundItem.MaxLength;
                attr.MinLength      = foundItem.MinLength;
                attr.MaxValue       = foundItem.MaxValue;
                attr.MinValue       = foundItem.MinValue;
                attr.RegExpr        = foundItem.RegExpr;
                attr.InputFormat    = foundItem.InputFormat;
                attr.DisplayFormat  = foundItem.DisplayFormat;
                attr.Browsable      = foundItem.Browsable;
            }

            return(foundItem);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 输出日志到Log4Net
 /// </summary>
 /// <param name="logInfo"></param>
 /// <param name="ex"></param>
 public static void Write(JLogInfo logInfo, Exception ex = null)
 {
     //修改人:卢英杰
     //修改于: 2015.8.26。
     //原因:发现写入日志文件的时候有许多空日志,所以加入一些判断来限制空日志信息的产生。
     //if (log != null)   原方法
     if (log != null && logInfo != null && !string.IsNullOrWhiteSpace(logInfo.ActionName) &&
         !string.IsNullOrWhiteSpace(logInfo.ModuleName))
     {
         log.Write(logInfo, CommOp.ToEnum <JLogType>(logInfo.LogType), ex);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 重写此方法以获取当前的控制器和视图,检查是否有AllowAnonymous特性。
        /// </summary>
        /// <param name="filterContext">筛选器上下文</param>
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerType.FullName;
            string actionName     = filterContext.ActionDescriptor.ActionName;
            var    method         = CommOp.ToEnum <WebMethod>(filterContext.HttpContext.Request.HttpMethod.ToUpper());
            var    macthFunctions = AppManager.Instance.FunctionManager.GetAll()
                                    .Where(f => !f.ActionName.IsEmpty() && !f.ControllerName.IsEmpty() &&
                                           actionName.Equals(f.ActionName, StringComparison.OrdinalIgnoreCase) &&
                                           controllerName.StartsWith(f.ControllerName, StringComparison.OrdinalIgnoreCase) &&
                                           f.Method == method);

            mFunction       = null;
            mIsParamMatched = true;

            foreach (var func in macthFunctions.OrderByDescending(func => func.Parameters.Count))
            {
                bool match = true;
                foreach (var ap in func.Parameters)
                {
                    var pattern = ap.ValuePattern ?? "";

                    var str = filterContext.RequestContext.GetParamsValue(ap.Name);

                    if (!Regex.IsMatch(str, "^" + pattern + "$"))
                    {
                        match = false;
                        break;
                    }
                }
                if (match)
                {
                    mFunction = func;
                    break;
                }
            }

            BaseController controller = filterContext.Controller as BaseController;

            if (controller != null)
            {
                controller.Function = mFunction;
            }

            base.OnAuthorization(filterContext);
        }