Ejemplo n.º 1
0
        public Model.AjaxResult Like(HttpContext context, Model.AjaxResult ajax)
        {
            int channel_id = ConvertTool.ToInt(DTRequest.GetString("channel_id"), 0);

            if (channel_id <= 0)
            {
                return(ErrorAjaxResult(ajax, @"频道错误"));
            }

            int article_id = ConvertTool.ToInt(DTRequest.GetString("article_id"), 0);

            if (article_id <= 0)
            {
                return(ErrorAjaxResult(ajax, @"文章错误"));
            }

            BLL.article bllarticle = new BLL.article();
            string      fieldname  = ReflexHelp.Name(() => new Model.article().like_count);
            bool        issu       = bllarticle.UpdateField(channel_id, article_id, string.Format("{0} = {0} + 1", fieldname));

            if (!issu)
            {
                return(ErrorAjaxResult(ajax, @"点赞失败!"));
            }

            ajax.Status = Model.AjaxResult.StatusValue.Success;
            ajax.Msg    = @"点赞成功!";
            return(ajax);
        }
Ejemplo n.º 2
0
 public CaseModel Func_Name()
 {
     return(new CaseModel()
     {
         NameSign = @"获取模型单个属性名称",
         ExeEvent = () => {
             TestModel model = new TestModel();
             string jx_name = ReflexHelp.Name(() => model.Remark);
             return @"Remark" == jx_name;
         },
     });
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 获取信息列表
        /// </summary>
        public ColumnInfo[] GetList()
        {
            Dictionary <string, ColumnInfo> dic = this.GetDictionary <ColumnInfo>(info => {
                info.Attribute = ReflexHelp.AttributeFindOnly <ColumnAttribute>(info.Property);
                return(CheckData.IsObjectNull(info.Attribute) ? null : info);
            });
            List <ColumnInfo> list = new List <ColumnInfo>(dic.Values);

            if (IsNeedSort())
            {
                list.Sort(SortMethod);
            }
            return(list.ToArray());
        }
Ejemplo n.º 4
0
        public CaseModel Func_AttributeFindOnly_Inherit()
        {
            return(new CaseModel()
            {
                NameSign = @"继承查找",
                ExeEvent = () => {
                    Func <TestModel, bool, bool, bool> method = (model, isFindInherit, isNull) => {
                        // isFindInherit = true; // 查找继承链
                        Type type = model.GetType();
                        EntityTableAttribute et_attr = ReflexHelp.AttributeFindOnly <EntityTableAttribute>(type, isFindInherit);
                        // isNull = true; // 是否允许为空
                        if (CheckData.IsObjectNull(et_attr) != isNull)
                        {
                            Console.WriteLine("Type: {0} isFindInherit: {1} 不符合 isNull: {2}", type.Name, isFindInherit, isNull);
                            return false;
                        }
                        return true;
                    };

                    if (!method(new TestModel(), true, false))
                    {
                        return false;
                    }
                    if (!method(new TestModel(), false, false))
                    {
                        return false;
                    }
                    if (!method(new A(), true, false))
                    {
                        return false;
                    }
                    if (!method(new A(), false, true))
                    {
                        return false;
                    }
                    if (!method(new B(), true, false))
                    {
                        return false;
                    }
                    if (!method(new B(), false, true))
                    {
                        return false;
                    }
                    return true;
                },
            });
        }
Ejemplo n.º 5
0
        public CaseModel Func_AttributeFindOnly()
        {
            return(new CaseModel()
            {
                NameSign = @"查找元数据某一种特性",
                ExeEvent = () => {
                    Type type = typeof(TestModel);
                    Func <string, bool, bool, bool> method = (name, isNull_explain, isNull_column) => {
                        PropertyInfo pi_id = type.GetProperty(name);
                        ExplainAttribute explain = ReflexHelp.AttributeFindOnly <ExplainAttribute>(pi_id);
                        if (CheckData.IsObjectNull(explain) != isNull_explain)
                        {
                            Console.WriteLine("name: {0} isNull_explain: {1} 错误", name, isNull_explain);
                            return false;
                        }
                        ColumnAttribute column = ReflexHelp.AttributeFindOnly <ColumnAttribute>(pi_id);
                        if (CheckData.IsObjectNull(column) != isNull_column)
                        {
                            Console.WriteLine("name: {0} isNull_column: {1} 错误", name, isNull_column);
                            return false;
                        }
                        return true;
                    };
                    if (!method("id", false, false))
                    {
                        return false;
                    }
                    if (!method("Money", true, false))
                    {
                        return false;
                    }
                    if (!method("Name", false, true))
                    {
                        return false;
                    }
                    if (!method("Remark", true, true))
                    {
                        return false;
                    }
                    return true;
                },

                SonCases = new CaseModel[] {
                    Func_AttributeFindOnly_Inherit(),
                },
            });
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取结果
        /// </summary>
        /// <typeparam name="I">指定结果类型解析</typeparam>
        /// <param name="AnalyticalItem">对于结果类型进行额外处理</param>
        /// <returns>键值对结果</returns>
        public Dictionary <string, I> GetDictionary <I>(Func <I, I> AnalyticalItem) where I : ShineUponInfo, new()
        {
            if (CheckData.IsObjectNull(this.NeedParserType))
            {
                return(new Dictionary <string, I>());
            }
            ShineUponModelAttribute model_attr = ReflexHelp.AttributeFindOnly <ShineUponModelAttribute>(this.NeedParserType, true);

            if (CheckData.IsObjectNull(model_attr))
            {
                return(new Dictionary <string, I>());
            }
            if (CheckData.IsObjectNull(AnalyticalItem))
            {
                AnalyticalItem = i => i;
            }

            Dictionary <string, I> dic = new Dictionary <string, I>();

            PropertyInfo[] protertys = this.NeedParserType.GetProperties();
            foreach (PropertyInfo property in protertys)
            {
                ShineUponPropertyAttribute spma = ReflexHelp.AttributeFindOnly <ShineUponPropertyAttribute>(property, true);
                if (CheckData.IsObjectNull(spma) || !spma.IsShineUpon)
                {
                    continue;
                }
                ExplainAttribute attr_explain = ExplainAttribute.Extract(property);
                I info = ReflexHelp.CreateNewObject <I>();
                info.Name     = property.Name;
                info.Property = property;
                info.Explain  = attr_explain;

                // 钩子: 子类处理解析内容
                info = AnalyticalItem(info);
                if (CheckData.IsObjectNull(info))
                {
                    continue;
                }
                dic.Add(info.Name, info);
            }
            return(dic);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 数据行 转为 单个映射模型
        /// </summary>
        /// <param name="row">数据行</param>
        /// <returns>单个映射模型</returns>
        public M DataRowToModel(DataRow row)
        {
            if (CheckData.IsSizeEmpty(row))
            {
                return(null);
            }
            M model = ReflexHelp.CreateNewObject <M>();

            ColumnInfo[] columninfos = this.Parser.GetList();
            foreach (ColumnInfo item in columninfos)
            {
                if (CheckData.IsObjectNull(item))
                {
                    continue;
                }
                object value = row[item.Property.Name];
                this.Parser.SetValue_Object(item, model, value);
            }
            return(model);
        }
Ejemplo n.º 8
0
        public CaseModel Func_CloneModelData()
        {
            return(new CaseModel()
            {
                NameSign = @"深度克隆模型数据",
                ExeEvent = () => {
                    TestModel one = new TestModel()
                    {
                        id = 3453,
                        Money = 2328.324f,
                        Name = "UJEIJi",
                        Remark = "来滴覅网"
                    };

                    // 执行克隆
                    TestModel two = ReflexHelp.CloneProperties(one);

                    // 检查与原来是否一样
                    if (!two.id.Equals(one.id))
                    {
                        Console.WriteLine("与原来: id 不一样");
                        return false;
                    }
                    if (!two.Money.Equals(one.Money))
                    {
                        Console.WriteLine("与原来: Money 不一样");
                        return false;
                    }
                    if (!two.Name.Equals(one.Name))
                    {
                        Console.WriteLine("与原来: Name 不一样");
                        return false;
                    }
                    if (!two.Remark.Equals(one.Remark))
                    {
                        Console.WriteLine("与原来: Remark 不一样");
                        return false;
                    }

                    // 重新赋值
                    two.id = 6355555;
                    two.Money = 992929.00033f;
                    two.Name = "wefwefwef";
                    two.Remark = "咯微风";

                    // 再次检查与原来是否一样
                    if (two.id.Equals(one.id))
                    {
                        Console.WriteLine("重新赋值: id 一样");
                        return false;
                    }
                    if (two.Money.Equals(one.Money))
                    {
                        Console.WriteLine("重新赋值: Money 一样");
                        return false;
                    }
                    if (two.Name.Equals(one.Name))
                    {
                        Console.WriteLine("重新赋值: Name 一样");
                        return false;
                    }
                    if (two.Remark.Equals(one.Remark))
                    {
                        Console.WriteLine("重新赋值: Remark 一样");
                        return false;
                    }

                    // 都不一样, 证明成功
                    return true;
                },
            });
        }
Ejemplo n.º 9
0
 public MSSQLServer_StringID()
     : base()
 {
     this.ColName_SID = ReflexHelp.Name(() => this.DefaultModel.SID);
 }
Ejemplo n.º 10
0
 public MSSQLServer_IntID()
     : base()
 {
     this.ColName_IID = ReflexHelp.Name(() => this.DefaultModel.IID);
 }