Example #1
0
        int ILabelInfo.GetSearchCount(NoPersonKeywordView keywordView)
        {
            Contract.Requires <ArgumentNullException>(keywordView != null, "参数keywordView:不为空!");
            int    result  = 0;
            string message = string.Empty;
            MiicConditionCollections condition      = keywordView.visitor(this);
            MiicCondition            validCondition = new MiicCondition(Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.Valid),
                                                                        ((int)MiicValidTypeSetting.Valid).ToString(),
                                                                        DbType.String,
                                                                        MiicDBOperatorSetting.Equal);

            condition.Add(new MiicConditionLeaf(validCondition));
            try
            {
                result = dbService.GetCount <LabelInfo>(null, condition, out message);
            }
            catch (Exception ex)
            {
                Config.IlogicLogService.Write(new LogicLog()
                {
                    AppName       = Config.AppName,
                    ClassName     = ClassName,
                    NamespaceName = NamespaceName,
                    MethodName    = MethodBase.GetCurrentMethod().Name,
                    Message       = ex.Message,
                    Oper          = Config.Oper
                });
            }
            return(result);
        }
    public string LabelSearch(Miic.Friends.Community.NoPersonKeywordView keywordView, MiicPage page)
    {
        string    result = CommonService.InitialJsonList;
        DataTable dt     = IlabelInfo.Search(keywordView, page);

        if (dt.Rows.Count > 0)
        {
            var temp = from dr in dt.AsEnumerable()
                       group dr by new
            {
                ID          = dr[Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.ID)],
                Name        = dr[Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.LabelName)],
                CommunityID = keywordView.CommunityID,
                CreaterID   = dr[Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.CreaterID)],
                CreaterName = dr[Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.CreaterName)],
                CreateTime  = dr[Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, DateTime?>(o => o.CreateTime)]
            } into g
                select new
            {
                ID           = g.Key.ID,
                Name         = g.Key.Name,
                CommunityID  = g.Key.CommunityID,
                CreaterID    = g.Key.CreaterID,
                CreaterName  = g.Key.CreaterName,
                CreateTime   = g.Key.CreateTime,
                PublishCount = (from item in g.AsEnumerable()
                                where Convert.IsDBNull(item[Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(u => u.PublishID)]) == false
                                select new
                {
                    PublishID = item[Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.PublishID)]
                }).Distinct().Count(),
                UserList = g.Count(o => Convert.IsDBNull(o[Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(u => u.PublishID)]) == false) == 0 ? null : (from item in g.AsEnumerable()
                                                                                                                                                                                  select new
                {
                    UserID = item[Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.UserID)],
                    UserName = item[Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.UserName)],
                    UserType = item[Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.UserType)],
                    UserUrl = CommonService.GetManageFullUrl(item[Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.UserUrl)].ToString())
                }).Distinct().Take(14)
            };
            result = Config.Serializer.Serialize(temp);
        }
        return(result);
    }
Example #3
0
        DataTable ILabelInfo.Search(NoPersonKeywordView keywordView, MiicPage page)
        {
            Contract.Requires <ArgumentNullException>(keywordView != null, "参数keywordView:不为空!");
            DataTable result  = new DataTable();
            string    message = string.Empty;
            MiicConditionCollections condition = keywordView.visitor(this);

            MiicRelation relation = new MiicRelation(Config.Attribute.GetSqlTableNameByClassName <LabelInfo>(),
                                                     Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.ID),
                                                     Config.Attribute.GetSqlTableNameByClassName <LabelSearchInfo>(),
                                                     Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.LabelID),
                                                     MiicDBOperatorSetting.Equal,
                                                     MiicDBRelationSetting.LeftJoin);
            MiicColumnCollections columns       = new MiicColumnCollections();
            MiicColumn            labelIDColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelInfo>(),
                                                                 Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.ID));

            columns.Add(labelIDColumn);
            MiicColumn labelNameColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelInfo>(),
                                                        Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.LabelName));

            columns.Add(labelNameColumn);

            MiicColumn createTimeColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelInfo>(),
                                                         Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, DateTime?>(o => o.CreateTime));

            columns.Add(createTimeColumn);
            MiicColumn createrIDColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelInfo>(),
                                                        Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.CreaterID));

            columns.Add(createrIDColumn);
            MiicColumn createrNameColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelInfo>(),
                                                          Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.CreaterName));

            columns.Add(createrNameColumn);
            MiicColumn sortNoColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelInfo>(),
                                                     Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, int?>(o => o.SortNo));

            columns.Add(sortNoColumn);

            MiicColumn labelSearchPublishIDColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelSearchInfo>(),
                                                                   Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.PublishID));

            columns.Add(labelSearchPublishIDColumn);
            MiicColumn labelSearchUserIDColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelSearchInfo>(),
                                                                Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.UserID));

            columns.Add(labelSearchUserIDColumn);
            MiicColumn labelSearchUserNameColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelSearchInfo>(),
                                                                  Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.UserName));

            columns.Add(labelSearchUserNameColumn);
            MiicColumn labelSearchUserTypeColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelSearchInfo>(),
                                                                  Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.UserType));

            columns.Add(labelSearchUserTypeColumn);
            MiicColumn labelSearchUserUrlColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <LabelSearchInfo>(),
                                                                 Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.UserUrl));

            columns.Add(labelSearchUserUrlColumn);
            try
            {
                if (page != null)
                {
                    List <MiicOrderBy> order = new List <MiicOrderBy>();
                    order.Add(new MiicOrderBy()
                    {
                        Desc         = true,
                        PropertyName = Config.Attribute.GetSqlColumnNameByPropertyNameWithTable <LabelInfo, int?>(o => o.SortNo)
                    });
                    condition.order = order;
                    result          = dbService.GetInformationsPage(columns, relation, condition, page, out message, MiicDBPageRowNumberSetting.DenseRank);
                }
                else
                {
                    result = dbService.GetInformations(columns, relation, condition, out message);
                }
            }
            catch (Exception ex)
            {
                Config.IlogicLogService.Write(new LogicLog()
                {
                    AppName       = Config.AppName,
                    ClassName     = ClassName,
                    NamespaceName = NamespaceName,
                    MethodName    = MethodBase.GetCurrentMethod().Name,
                    Message       = ex.Message,
                    Oper          = Config.Oper
                });
            }
            return(result);
        }
 public int GetLabelSearchCount(Miic.Friends.Community.NoPersonKeywordView keywordView)
 {
     return(IlabelInfo.GetSearchCount(keywordView));
 }