Пример #1
0
        /// <summary>
        /// 设置指定的查询语句并返回当前语句
        /// </summary>
        /// <param name="command">相关语句</param>
        /// <param name="ids">逗号分隔的实体ID</param>
        /// <param name="cid">竞赛ID</param>
        /// <param name="pid">题目ID</param>
        /// <param name="userName">用户名</param>
        /// <param name="languageType">提交语言</param>
        /// <param name="resultType">提交结果</param>
        /// <param name="startDate">开始时间</param>
        /// <param name="endDate">结束时间</param>
        /// <returns>当前语句</returns>
        internal static T Where <T>(this T command, String ids, Int32 cid, Int32 pid, String userName, LanguageType languageType, ResultType?resultType, DateTime?startDate, DateTime?endDate) where T : AbstractSqlCommandWithWhere
        {
            SqlConditionBuilder  c         = command.ConditionBuilder;
            AbstractSqlCondition condition = command.WhereCondition as AbstractSqlCondition;
            AbstractSqlCondition temp      = null;

            //提交ID
            if (!String.IsNullOrEmpty(ids))
            {
                temp      = c.InInt32(SolutionRepository.SOLUTIONID, ids, ',');
                condition = (condition == null ? temp : condition & temp);
            }

            //竞赛ID
            if (cid >= 0)
            {
                temp      = c.Equal(SolutionRepository.CONTESTID, cid);
                condition = (condition == null ? temp : condition & temp);
            }

            //题目ID
            if (pid >= 0)
            {
                temp      = c.Equal(SolutionRepository.PROBLEMID, pid);
                condition = (condition == null ? temp : condition & temp);
            }

            //用户名
            if (!String.IsNullOrEmpty(userName))
            {
                temp      = c.Equal(SolutionRepository.USERNAME, userName);
                condition = (condition == null ? temp : condition & temp);
            }

            //提交程序语言
            if (!LanguageType.IsNull(languageType))
            {
                temp      = c.Equal(SolutionRepository.LANGUAGE, languageType.ID);
                condition = (condition == null ? temp : condition & temp);
            }

            //提交结果
            if (resultType.HasValue)
            {
                temp      = c.Equal(SolutionRepository.RESULT, (Byte)resultType.Value);
                condition = (condition == null ? temp : condition & temp);
            }

            //开始时间
            if (startDate.HasValue || endDate.HasValue)
            {
                temp      = c.BetweenNullable <DateTime>(SolutionRepository.SUBMITTIME, startDate, endDate);
                condition = (condition == null ? temp : condition & temp);
            }

            command.Where(condition);

            return(command);
        }
Пример #2
0
        /// <summary>
        /// 设置指定的查询语句并返回当前语句
        /// </summary>
        /// <param name="command">选择语句</param>
        /// <param name="fpids">帖子ID列表</param>
        /// <param name="ftids">主题ID列表</param>
        /// <param name="userName">发帖用户名</param>
        /// <param name="title">帖子标题</param>
        /// <param name="content">帖子内容</param>
        /// <param name="isHide">是否隐藏</param>
        /// <param name="startDate">发帖开始时间</param>
        /// <param name="endDate">发帖结束时间</param>
        /// <param name="postip">发帖IP</param>
        /// <returns>当前语句</returns>
        internal static SelectCommand Where(this SelectCommand command, String fpids, String ftids, String userName, String title, String content, Boolean?isHide, DateTime?startDate, DateTime?endDate, String postip)
        {
            SqlConditionBuilder  c         = command.ConditionBuilder;
            AbstractSqlCondition condition = command.WhereCondition as AbstractSqlCondition;
            AbstractSqlCondition temp      = null;

            //帖子ID
            if (!String.IsNullOrEmpty(fpids))
            {
                temp      = c.InInt32(ForumPostRepository.POSTID, fpids, ',');
                condition = (condition == null ? temp : condition & temp);
            }

            //主题ID
            if (!String.IsNullOrEmpty(ftids))
            {
                temp      = c.InInt32(ForumPostRepository.TOPICID, ftids, ',');
                condition = (condition == null ? temp : condition & temp);
            }

            //用户名
            if (!String.IsNullOrEmpty(userName))
            {
                temp      = c.LikeAll(ForumPostRepository.USERNAME, userName);
                condition = (condition == null ? temp : condition & temp);
            }

            //帖子标题
            if (!String.IsNullOrEmpty(title))
            {
                temp      = c.LikeAll(ForumPostRepository.TITLE, title);
                condition = (condition == null ? temp : condition & temp);
            }

            //帖子内容
            if (!String.IsNullOrEmpty(content))
            {
                temp      = c.LikeAll(ForumPostRepository.CONTENT, content);
                condition = (condition == null ? temp : condition & temp);
            }

            //是否隐藏
            if (isHide.HasValue)
            {
                temp      = c.Equal(ForumPostRepository.ISHIDE, isHide.Value);
                condition = (condition == null ? temp : condition & temp);
            }

            //发布日期范围
            if (startDate.HasValue || endDate.HasValue)
            {
                temp      = c.BetweenNullable <DateTime>(ForumPostRepository.POSTDATE, startDate, endDate);
                condition = (condition == null ? temp : condition & temp);
            }

            //发布IP
            if (!String.IsNullOrEmpty(postip))
            {
                temp      = c.LikeAll(ForumPostRepository.POSTIP, postip);
                condition = (condition == null ? temp : condition & temp);
            }

            return(command.Where(condition));
        }
Пример #3
0
        /// <summary>
        /// 设置指定的查询语句并返回当前语句
        /// </summary>
        /// <param name="command">选择语句</param>
        /// <param name="names">用户名包含</param>
        /// <param name="nickname">昵称包含</param>
        /// <param name="email">邮箱包含</param>
        /// <param name="school">学校包含</param>
        /// <param name="lastIP">最后登录IP</param>
        /// <param name="islocked">是否锁定</param>
        /// <param name="regStartDate">注册日期开始</param>
        /// <param name="regEndDate">注册日期结束</param>
        /// <param name="loginStartDate">最后登录日期开始</param>
        /// <param name="loginEndDate">最后登录日期结束</param>
        /// <returns>当前语句</returns>
        internal static SelectCommand Where(this SelectCommand command, String names, String nickname, String email, String school, String lastIP, Boolean?islocked, DateTime?regStartDate, DateTime?regEndDate, DateTime?loginStartDate, DateTime?loginEndDate)
        {
            SqlConditionBuilder  c         = command.ConditionBuilder;
            AbstractSqlCondition condition = command.WhereCondition as AbstractSqlCondition;
            AbstractSqlCondition temp      = null;

            //用户名列表模糊
            if (!String.IsNullOrEmpty(names))
            {
                String[]             arrnames  = names.Split(',');
                AbstractSqlCondition innertemp = null;
                temp = null;

                for (Int32 i = 0; i < arrnames.Length; i++)
                {
                    if (!String.IsNullOrEmpty(arrnames[i]))
                    {
                        innertemp = c.LikeAll(UserRepository.USERNAME, arrnames[i]);
                        temp      = (temp == null ? innertemp : innertemp | temp);
                    }
                }

                condition = (condition == null ? temp : condition & temp);
            }

            //昵称模糊
            if (!String.IsNullOrEmpty(nickname))
            {
                temp      = c.LikeAll(UserRepository.NICKNAME, nickname);
                condition = (condition == null ? temp : condition & temp);
            }

            //邮箱模糊
            if (!String.IsNullOrEmpty(email))
            {
                temp      = c.LikeAll(UserRepository.EMAIL, email);
                condition = (condition == null ? temp : condition & temp);
            }

            //学校模糊
            if (!String.IsNullOrEmpty(school))
            {
                temp      = c.LikeAll(UserRepository.SCHOOL, school);
                condition = (condition == null ? temp : condition & temp);
            }

            //最后登录IP模糊
            if (!String.IsNullOrEmpty(lastIP))
            {
                temp      = c.LikeAll(UserRepository.LASTIP, lastIP);
                condition = (condition == null ? temp : condition & temp);
            }

            //是否锁定
            if (islocked.HasValue)
            {
                temp      = c.Equal(UserRepository.ISLOCKED, islocked.Value);
                condition = (condition == null ? temp : condition & temp);
            }

            //注册日期范围
            if (regStartDate.HasValue || regEndDate.HasValue)
            {
                temp      = c.BetweenNullable <DateTime>(UserRepository.CREATEDATE, regStartDate, regEndDate);
                condition = (condition == null ? temp : condition & temp);
            }

            //登陆日期范围
            if (loginStartDate.HasValue || loginEndDate.HasValue)
            {
                temp      = c.BetweenNullable <DateTime>(UserRepository.LASTDATE, loginStartDate, loginEndDate);
                condition = (condition == null ? temp : condition & temp);
            }

            return(command.Where(condition));
        }
Пример #4
0
        /// <summary>
        /// 设置指定的查询语句并返回当前语句
        /// </summary>
        /// <param name="command">选择语句</param>
        /// <param name="ftids">主题ID列表</param>
        /// <param name="userName">发帖人</param>
        /// <param name="title">主题标题</param>
        /// <param name="type">主题类型</param>
        /// <param name="relativeID">相关ID</param>
        /// <param name="isLocked">是否锁定</param>
        /// <param name="isHide">是否隐藏</param>
        /// <param name="startDate">发帖开始时间</param>
        /// <param name="endDate">发帖结束时间</param>
        /// <returns>当前语句</returns>
        internal static SelectCommand Where(this SelectCommand command, String ftids, String userName, String title, ForumTopicType?type, Int32 relativeID, Boolean?isLocked, Boolean?isHide, DateTime?startDate, DateTime?endDate)
        {
            SqlConditionBuilder  c         = command.ConditionBuilder;
            AbstractSqlCondition condition = command.WhereCondition as AbstractSqlCondition;
            AbstractSqlCondition temp      = null;

            //主题ID
            if (!String.IsNullOrEmpty(ftids))
            {
                temp      = c.InInt32(ForumTopicRepository.TOPICID, ftids, ',');
                condition = (condition == null ? temp : condition & temp);
            }

            //用户名
            if (!String.IsNullOrEmpty(userName))
            {
                temp      = c.LikeAll(ForumTopicRepository.USERNAME, userName);
                condition = (condition == null ? temp : condition & temp);
            }

            //主题标题
            if (!String.IsNullOrEmpty(title))
            {
                temp      = c.LikeAll(ForumTopicRepository.TITLE, title);
                condition = (condition == null ? temp : condition & temp);
            }

            //主题类型
            if (type.HasValue)
            {
                temp      = c.Equal(ForumTopicRepository.TYPE, (Byte)type.Value);
                condition = (condition == null ? temp : condition & temp);
            }

            //相关ID
            if (relativeID >= 0)
            {
                temp      = c.Equal(ForumTopicRepository.RELATIVEID, relativeID);
                condition = (condition == null ? temp : condition & temp);
            }

            //是否锁定
            if (isLocked.HasValue)
            {
                temp      = c.Equal(ForumTopicRepository.ISLOCKED, isLocked.Value);
                condition = (condition == null ? temp : condition & temp);
            }

            //是否隐藏
            if (isHide.HasValue)
            {
                temp      = c.Equal(ForumTopicRepository.ISHIDE, isHide.Value);
                condition = (condition == null ? temp : condition & temp);
            }

            //发布日期范围
            if (startDate.HasValue || endDate.HasValue)
            {
                temp      = c.BetweenNullable <DateTime>(ForumTopicRepository.LASTDATE, startDate, endDate);
                condition = (condition == null ? temp : condition & temp);
            }

            return(command.Where(condition));
        }