Exemple #1
0
        private static void UpdateTopicByType(int topicSysNo, int userSysNo, AppEnum.TopicUpdateType type, string topicSysNos)
        {
            string sqlStr;

            if (topicSysNos == string.Empty)
            {
                sqlStr = SQL_UPDATE_TOPIC_BYTYPE.Replace("@SysNo", "SysNo=" + topicSysNo);
            }
            else
            {
                sqlStr = SQL_UPDATE_TOPIC_BYTYPE.Replace("@SysNo", "SysNo in (" + topicSysNos + ")");
            }


            int value;

            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@LastEditUserSysNo", SqlDbType.Int),
                new SqlParameter("@Value", SqlDbType.Int)
            };

            switch (type)
            {
            case AppEnum.TopicUpdateType.AbandonTopic:
                sqlStr = sqlStr.Replace("@Key", "Status");
                value  = (int)AppEnum.TopicStatus.Abandon;
                break;

            case AppEnum.TopicUpdateType.CancelAbandonTopic:
                sqlStr = sqlStr.Replace("@Key", "Status");
                if (TopicReplyDac.HasSysReply(topicSysNo))
                {
                    value = (int)AppEnum.TopicStatus.Replyed;    // 2;
                }
                else
                {
                    value = (int)AppEnum.TopicStatus.confirmed;    //1;
                }
                break;

            case AppEnum.TopicUpdateType.TopicCancelDigset:
                sqlStr = sqlStr.Replace("@Key", "IsDigest");
                value  = 0;
                break;

            case AppEnum.TopicUpdateType.TopicSetDigset:
                sqlStr = sqlStr.Replace("@Key", "IsDigest");
                value  = 1;
                break;

            case AppEnum.TopicUpdateType.TopicCancelTop:
                sqlStr = sqlStr.Replace("@Key", "IsTop");
                value  = 0;
                break;

            case AppEnum.TopicUpdateType.TopicSetTop:
                sqlStr = sqlStr.Replace("@Key", "IsTop");
                value  = 1;
                break;

            case AppEnum.TopicUpdateType.ConfirmTopic:
                sqlStr = sqlStr.Replace("@Key", "Status");
                if (TopicReplyDac.HasSysReply(topicSysNo))
                {
                    value = (int)AppEnum.TopicStatus.Replyed;    // 2;
                }
                else
                {
                    value = (int)AppEnum.TopicStatus.confirmed;    //1;
                }
                break;

            case AppEnum.TopicUpdateType.UnConfirmTopic:
                sqlStr = sqlStr.Replace("@Key", "Status");
                value  = (int)AppEnum.TopicStatus.unconfirmed;;
                break;

            default:
                throw new ArgumentException("Topic Update Type is invalid.");
            }

            parms[0].Value = userSysNo;
            parms[1].Value = value;

            SqlCommand cmd = new SqlCommand(sqlStr);

            cmd.Parameters.AddRange(parms);
            cmd.CommandTimeout = 180;
            SqlHelper.ExecuteNonQuery(cmd);

            if (topicSysNos == string.Empty)
            {
                UpdateProductRemarkCountAndScoreByTopicSysNo(topicSysNo);
            }
            else
            {
                foreach (string s in topicSysNos.Split(new char[] { ',' }))
                {
                    UpdateProductRemarkCountAndScoreByTopicSysNo(int.Parse(s.Trim()));
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// 根据商品ID返回所有评论
        /// </summary>
        /// <param name="productId"></param>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalCount"></param>
        /// <param name="type"> "Top3","All","Digest","Discuss","Exp"</param>
        /// <returns></returns>
        public static List <TopicInfo> GetAllTopicByProductId(int productId, int pageSize, int pageIndex, out int totalCount, string type)
        {
            SqlParameter[] parms = new SqlParameter[]
            {
                new SqlParameter("@ReferenceSysNo", SqlDbType.Int),
                new SqlParameter("@ReferenceType", SqlDbType.Int),
                new SqlParameter("@Status", SqlDbType.Int)
            };
            parms[0].Value = productId;
            parms[1].Value = (int)AppEnum.TopicReferenceType.Product;
            parms[2].Value = (int)AppEnum.TopicStatus.Abandon;

            string sqlStr = SQL_GET_TOPIC_BY_PRODUCTID;

            if (type == "Top3")
            {
                sqlStr = SQL_GET_TOPIC_BY_PRODUCTID.Replace("@select", "SELECT TOP 3");
                sqlStr = sqlStr.Replace("@Value", "1=1");
            }
            else
            {
                sqlStr = sqlStr.Replace("@select", "SELECT");
            }

            if (type == "All")
            {
                sqlStr = sqlStr.Replace("@Value", "1=1");
            }
            if (type == "Digest")
            {
                sqlStr = sqlStr.Replace("@Value", "Topic_Master.IsDigest = 1");
            }
            if (type == "Discuss")
            {
                sqlStr = sqlStr.Replace("@Value", "Topic_Master.TopicType = " + (int)AppEnum.TopicType.Discuss);
            }
            if (type == "Exp")
            {
                sqlStr = sqlStr.Replace("@Value", "Topic_Master.TopicType = " + (int)AppEnum.TopicType.Experience);
            }

            DataTable dt = SqlHelper.ExecuteDataSet(sqlStr, parms).Tables[0];

            if (dt == null || dt.Rows.Count == 0)
            {
                totalCount = 0;
                return(null);
            }

            totalCount = dt.Rows.Count;

            List <TopicInfo> list = new List <TopicInfo>();
            string           ids  = string.Empty;

            if (pageSize > 0)
            {
                // 需要分页的
                int from = pageSize * pageIndex;
                int to   = (totalCount >= (pageSize * pageIndex + pageSize)) ? (pageSize * pageIndex + pageSize) : totalCount;
                for (int i = from; i < to; i++)
                {
                    DataRow row = dt.Rows[i];
                    ids += (ids.Length == 0 ? "" : ",") + row["SysNo"].ToString();
                    list.Add(Map(row));
                }
            }
            else
            {
                foreach (DataRow row in dt.Rows)
                {
                    ids += (ids.Length == 0 ? "" : ",") + row["SysNo"].ToString();
                    list.Add(Map(row));
                }
            }

            // 添加 TopicReply 信息
            List <TopicReplyInfo> replyList = new List <TopicReplyInfo>();

            replyList = TopicReplyDac.GetTopicReplyByTopicIdList(ids);


            //添加TopicImage信息
            List <TopicImageInfo> imageList = new List <TopicImageInfo>();

            imageList = TopicImageDac.GetTopicImageByTopicIdList(ids);
            //添加Imagedac时补充读取Image信息
            FormatTopicInfoList(list, replyList, imageList);

            return(list);
        }