Exemplo n.º 1
0
        /// <summary>
        /// 获得企业留言列表
        /// </summary>
        /// <param name="orgID">企业ID</param>
        /// <param name="page">分页</param>
        /// <returns>留言列表信息</returns>
        public DataTable GetOrgCommentInfos(string orgID, MiicPage page)
        {
            Contract.Requires <ArgumentNullException>(!string.IsNullOrEmpty(orgID), "参数orgID:不能为空");
            DataTable result  = new DataTable();
            string    message = string.Empty;
            MiicRelationCollections relation     = new MiicRelationCollections(Config.Attribute.GetSqlTableNameByClassName <OrgCommentInfo>());
            MiicFriendRelation      fromRelation = new MiicFriendRelation(Config.Attribute.GetSqlColumnNameByPropertyName <OrgCommentInfo, string>(o => o.FromCommenterID),
                                                                          new MiicTableName()
            {
                TableAliasName = "FROM_USER",
                TableName      = Config.Attribute.GetSqlTableNameByClassName <MiicSocialUserInfo>()
            },
                                                                          Config.Attribute.GetSqlColumnNameByPropertyName <MiicSocialUserInfo, string>(o => o.ID),
                                                                          MiicDBOperatorSetting.Equal,
                                                                          MiicDBRelationSetting.LeftJoin);

            relation.Add(fromRelation);
            MiicFriendRelation toRelation = new MiicFriendRelation(Config.Attribute.GetSqlColumnNameByPropertyName <OrgCommentInfo, string>(o => o.ToCommenterID),
                                                                   new MiicTableName()
            {
                TableAliasName = "TO_USER",
                TableName      = Config.Attribute.GetSqlTableNameByClassName <MiicSocialUserInfo>()
            },
                                                                   Config.Attribute.GetSqlColumnNameByPropertyName <MiicSocialUserInfo, string>(o => o.ID),
                                                                   MiicDBOperatorSetting.Equal,
                                                                   MiicDBRelationSetting.LeftJoin);

            relation.Add(toRelation);
            MiicCondition orgIDCondition = new MiicCondition(Config.Attribute.GetSqlColumnNameByPropertyName <OrgCommentInfo, string>(o => o.OrgID),
                                                             orgID,
                                                             DbType.String,
                                                             MiicDBOperatorSetting.Equal);
            MiicConditionCollections conditions = new MiicConditionCollections();

            conditions.Add(new MiicConditionLeaf(MiicDBLogicSetting.No, orgIDCondition));
            List <MiicOrderBy> order     = new List <MiicOrderBy>();
            MiicOrderBy        timeOrder = new MiicOrderBy()
            {
                Desc         = true,
                PropertyName = Config.Attribute.GetSqlColumnNameByPropertyName <OrgCommentInfo, DateTime?>(o => o.CommentTime)
            };

            order.Add(timeOrder);
            conditions.order = order;
            MiicColumn            allColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <OrgCommentInfo>());
            MiicColumnCollections column    = new MiicColumnCollections();

            column.Add(allColumn);
            MiicColumn fromUserUrlColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <MiicSocialUserInfo>(),
                                                          "FROM_USER",
                                                          Config.Attribute.GetSqlColumnNameByPropertyName <MiicSocialUserInfo, string>(o => o.MicroUserUrl),
                                                          "FROM_USER_URL");

            column.Add(fromUserUrlColumn);
            MiicColumn fromUserTypeColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <MiicSocialUserInfo>(),
                                                           "FROM_USER",
                                                           Config.Attribute.GetSqlColumnNameByPropertyName <MiicSocialUserInfo, string>(o => o.UserType),
                                                           "FROM_USER_TYPE");

            column.Add(fromUserTypeColumn);
            MiicColumn toUserUrlColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <MiicSocialUserInfo>(),
                                                        "TO_USER",
                                                        Config.Attribute.GetSqlColumnNameByPropertyName <MiicSocialUserInfo, string>(o => o.MicroUserUrl),
                                                        "TO_USER_URL");

            column.Add(toUserUrlColumn);
            MiicColumn toUserTypeColumn = new MiicColumn(Config.Attribute.GetSqlTableNameByClassName <MiicSocialUserInfo>(),
                                                         "TO_USER",
                                                         Config.Attribute.GetSqlColumnNameByPropertyName <MiicSocialUserInfo, string>(o => o.UserType),
                                                         "TO_USER_TYPE");

            column.Add(toUserTypeColumn);
            try
            {
                if (page == null)
                {
                    result = dbService.GetInformations(column, relation, conditions, out message);
                }
                else
                {
                    result = dbService.GetInformationsPage(column, relation, conditions, page, 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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据标签ID获取指定标签集合
        /// </summary>
        /// <param name="labelIDs">标签ID数组</param>
        /// <returns>标签集合</returns>
        DataTable ILabelInfo.GetLabelListWithIDs(List <string> labelIDs)
        {
            Contract.Requires <ArgumentNullException>(labelIDs != null, "参数labelIDs:不为空!");
            Contract.Requires <ArgumentOutOfRangeException>(labelIDs.Count != 0, "参数labelIDs:不为空!");
            DataTable result  = new DataTable();
            string    message = string.Empty;
            MiicConditionCollections condition      = new MiicConditionCollections(MiicDBLogicSetting.No);
            MiicCondition            validCondition = new MiicCondition(Config.Attribute.GetSqlColumnNameByPropertyNameWithTable <LabelInfo, string>(o => o.Valid),
                                                                        ((int)MiicValidTypeSetting.Valid).ToString(),
                                                                        DbType.String,
                                                                        MiicDBOperatorSetting.Equal);

            condition.Add(new MiicConditionLeaf(MiicDBLogicSetting.No, validCondition));

            MiicConditionCollections idsCondition = new MiicConditionCollections();

            for (int i = 0, lableCount = labelIDs.Count; i < lableCount; i++)
            {
                if (i == 0)
                {
                    idsCondition.Add(new MiicConditionLeaf(MiicDBLogicSetting.No, new MiicCondition(Config.Attribute.GetSqlColumnNameByPropertyNameWithTable <LabelInfo, string>(o => o.ID),
                                                                                                    labelIDs[i],
                                                                                                    DbType.String,
                                                                                                    MiicDBOperatorSetting.Equal)));
                }
                else
                {
                    idsCondition.Add(new MiicConditionLeaf(MiicDBLogicSetting.Or, new MiicCondition(Config.Attribute.GetSqlColumnNameByPropertyNameWithTable <LabelInfo, string>(o => o.ID),
                                                                                                    labelIDs[i],
                                                                                                    DbType.String,
                                                                                                    MiicDBOperatorSetting.Equal)));
                }
            }
            condition.Add(idsCondition);
            List <MiicOrderBy> order = new List <MiicOrderBy>();

            order.Add(new MiicOrderBy()
            {
                Desc         = true,
                PropertyName = Config.Attribute.GetSqlColumnNameByPropertyNameWithTable <LabelInfo, int?>(o => o.SortNo)
            });
            condition.order = order;

            MiicRelationCollections realtions          = new MiicRelationCollections(Config.Attribute.GetSqlTableNameByClassName <LabelInfo>());
            MiicFriendRelation      searchInfoRelation = new MiicFriendRelation(Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.ID),
                                                                                Config.Attribute.GetSqlTableNameByClassName <LabelSearchInfo>(),
                                                                                Config.Attribute.GetSqlColumnNameByPropertyName <LabelSearchInfo, string>(o => o.LabelID),
                                                                                MiicDBOperatorSetting.Equal,
                                                                                MiicDBRelationSetting.LeftJoin);

            realtions.Add(searchInfoRelation);
            MiicFriendRelation userInfoRelation = new MiicFriendRelation(Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.CreaterID),
                                                                         Config.Attribute.GetSqlTableNameByClassName <Miic.Friends.User.SimpleUserView>(),
                                                                         Config.Attribute.GetSqlColumnNameByPropertyName <Miic.Friends.User.SimpleUserView, string>(o => o.UserID),
                                                                         MiicDBOperatorSetting.Equal,
                                                                         MiicDBRelationSetting.LeftJoin);

            realtions.Add(userInfoRelation);


            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 <Miic.Friends.User.SimpleUserView>(),
                                                          "",
                                                          Config.Attribute.GetSqlColumnNameByPropertyName <Miic.Friends.User.SimpleUserView, string>(o => o.UserName)
                                                          , Config.Attribute.GetSqlColumnNameByPropertyName <LabelInfo, string>(o => o.CreaterName));

            columns.Add(createrNameColumn);

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

            columns.Add(labelSearchCommunityIDColumn);
            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
            {
                result = dbService.GetInformations(columns, realtions, 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);
        }