Пример #1
0
 /// <summary>
 /// Adds the contents of another <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> to the end of the collection.
 /// </summary>
 /// <param name="value">A <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> containing the Components to add to the collection. </param>
 public void AddRange(ShowtopicPageAttachmentInfoCollection value)
 {
     for (int i = 0; (i < value.Count); i = (i + 1))
     {
         this.Add((ShowtopicPageAttachmentInfo)value.List[i]);
     }
 }
		/// <summary>
		/// Adds the contents of another <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> to the end of the collection.
		/// </summary>
		/// <param name="value">A <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> containing the Components to add to the collection. </param>
		public void AddRange(ShowtopicPageAttachmentInfoCollection value) 
		{
			for (int i = 0;	(i < value.Count); i = (i +	1))	
			{
				this.Add((ShowtopicPageAttachmentInfo)value.List[i]);
			}
		}
		/// <summary>
		/// Initializes a new instance of the <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> class containing the elements of the specified source collection.
		/// </summary>
		/// <param name="value">A <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> with which to initialize the collection.</param>
		public ShowtopicPageAttachmentInfoCollection(ShowtopicPageAttachmentInfoCollection value)	
		{
			this.AddRange(value);
		}
			/// <summary>
			/// Initializes a new instance of the <see cref="ShowtopicPageAttachmentInfoCollectionEnumerator">ShowtopicPageAttachmentInfoCollectionEnumerator</see> class referencing the specified <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> object.
			/// </summary>
			/// <param name="mappings">The <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> to enumerate.</param>
			public ShowtopicPageAttachmentInfoCollectionEnumerator(ShowtopicPageAttachmentInfoCollection mappings)
			{
				_temp =	((IEnumerable)(mappings));
				_enumerator = _temp.GetEnumerator();
			}
Пример #5
0
               /// <summary>
        /// 获取指定条件的帖子DataSet
        /// </summary>
        /// <param name="_postpramsinfo">参数列表</param>
        /// <returns>指定条件的帖子DataSet</returns>
        public static ShowtopicPagePostInfoCollection GetPostList(PostpramsInfo _postpramsinfo, out ShowtopicPageAttachmentInfoCollection attcoll, bool ismoder)
        {

            ShowtopicPagePostInfoCollection postcoll = new ShowtopicPagePostInfoCollection();
            attcoll = new ShowtopicPageAttachmentInfoCollection();

            IDataReader reader;
            StringBuilder pidlist = new StringBuilder();
            if (!_postpramsinfo.Condition.Equals(""))
            {
                reader = DatabaseProvider.GetInstance().GetPostListByCondition(_postpramsinfo, GetPostTableName(_postpramsinfo.Tid));
            }
            else
            {
                reader = DatabaseProvider.GetInstance().GetPostList(_postpramsinfo, GetPostTableName(_postpramsinfo.Tid));
            }



            if (reader != null)
            {
                int allowGetAttach = 0;
                if (_postpramsinfo.Getattachperm.Equals("") || _postpramsinfo.Getattachperm == null)
                {
                    allowGetAttach = _postpramsinfo.CurrentUserGroup.Allowgetattach;
                }
                else
                {
                    if (Forums.AllowGetAttach(_postpramsinfo.Getattachperm, _postpramsinfo.Usergroupid))
                    {
                        allowGetAttach = 1;
                    }

                }







                //序号(楼层)的初值
                int id = (_postpramsinfo.Pageindex - 1) * _postpramsinfo.Pagesize;

                //保存初始的hide值
                int oldHide = _postpramsinfo.Hide;

                //取帖间广告
                Random random = new Random(unchecked((int)DateTime.Now.Ticks));
                int fid = _postpramsinfo.Fid;
                int adcount = Advertisements.GetInPostAdCount("", fid);

                //用户组
                UserGroupInfo tmpGroupInfo;

                while (reader.Read())
                {
                    //当帖子中的posterid字段为0时, 表示该数据出现异常
                    if (Int32.Parse(reader["posterid"].ToString()) == 0)
                    {
                        continue;
                    }

                    ShowtopicPagePostInfo info = new ShowtopicPagePostInfo();
                    info.Pid = Int32.Parse(reader["pid"].ToString());
                    info.Attachment = Int32.Parse(reader["attachment"].ToString());
                    if (info.Attachment > 0)
                    {
                        pidlist.Append(",");
                        pidlist.Append(reader["pid"].ToString());
                    }
                    info.Fid = fid;
                    info.Title = reader["title"].ToString().Trim();
                    info.Layer = Int32.Parse(reader["layer"].ToString());
                    info.Message = reader["message"].ToString().Trim();
                    info.Lastedit = reader["lastedit"].ToString().Trim();
                    info.Postdatetime = reader["postdatetime"].ToString().Trim();

                    info.Poster = reader["poster"].ToString().Trim();
                    info.Posterid = Int32.Parse(reader["posterid"].ToString());
                    info.Invisible = Int32.Parse(reader["invisible"].ToString());
                    info.Usesig = Int32.Parse(reader["usesig"].ToString());
                    info.Htmlon = Int32.Parse(reader["htmlon"].ToString());
                    info.Smileyoff = Int32.Parse(reader["smileyoff"].ToString());
                    info.Parseurloff = Int32.Parse(reader["parseurloff"].ToString());
                    info.Bbcodeoff = Int32.Parse(reader["bbcodeoff"].ToString());
                    info.Rate = Int32.Parse(reader["rate"].ToString());
                    info.Ratetimes = Int32.Parse(reader["ratetimes"].ToString());
                    if (info.Posterid > 0)
                    {
                        info.Nickname = reader["nickname"].ToString().Trim();
                        info.Username = reader["username"].ToString().Trim();
                        info.Groupid = Utils.StrToInt(reader["groupid"], 0);
                        info.Spaceid = Utils.StrToInt(reader["spaceid"], 0);
                        info.Gender = Utils.StrToInt(reader["gender"], 2);
                        info.Bday = reader["bday"].ToString().Trim();
                        info.Showemail = Utils.StrToInt(reader["showemail"], 0);
                        info.Digestposts = Utils.StrToInt(reader["digestposts"], 0);
                        info.Credits = Utils.StrToInt(reader["credits"], 0);
                        info.Extcredits1 = reader["extcredits1"] == DBNull.Value ? 0 : float.Parse(reader["extcredits1"].ToString());
                        info.Extcredits2 = reader["extcredits2"] == DBNull.Value ? 0 : float.Parse(reader["extcredits2"].ToString());
                        info.Extcredits3 = reader["extcredits3"] == DBNull.Value ? 0 : float.Parse(reader["extcredits3"].ToString());
                        info.Extcredits4 = reader["extcredits4"] == DBNull.Value ? 0 : float.Parse(reader["extcredits4"].ToString());
                        info.Extcredits5 = reader["extcredits5"] == DBNull.Value ? 0 : float.Parse(reader["extcredits5"].ToString());
                        info.Extcredits6 = reader["extcredits6"] == DBNull.Value ? 0 : float.Parse(reader["extcredits6"].ToString());
                        info.Extcredits7 = reader["extcredits7"] == DBNull.Value ? 0 : float.Parse(reader["extcredits7"].ToString());
                        info.Extcredits8 = reader["extcredits8"] == DBNull.Value ? 0 : float.Parse(reader["extcredits8"].ToString());
                        info.Posts = Utils.StrToInt(reader["posts"], 0);
                        info.Joindate = reader["joindate"].ToString().Trim();
                        info.Lastactivity = reader["lastactivity"].ToString().Trim();
                        info.Userinvisible = Int32.Parse(reader["invisible"].ToString());
                        info.Avatar = reader["avatar"].ToString();
                        info.Avatarwidth = Utils.StrToInt(reader["avatarwidth"], 0);
                        info.Avatarheight = Utils.StrToInt(reader["avatarheight"], 0);
                        info.Medals = reader["medals"].ToString();
                        info.Signature = reader["signature"].ToString();
                        info.Location = reader["location"].ToString();
                        info.Customstatus = reader["customstatus"].ToString();
                        info.Website = reader["website"].ToString();
                        info.Icq = reader["icq"].ToString();
                        info.Qq = reader["qq"].ToString();
                        info.Msn = reader["msn"].ToString();
                        info.Yahoo = reader["yahoo"].ToString();
                        info.Skype = reader["skype"].ToString();
                        //部分属性需要根据不同情况来赋值

                        //根据用户自己的设置决定是否显示邮箱地址
                        if (info.Showemail == 0)
                        {
                            info.Email = "";
                        }
                        else
                        {
                            info.Email = reader["email"].ToString().Trim();
                        }


                        // 最后活动时间50分钟内的为在线, 否则不在线
                        if (Utils.StrDateDiffMinutes(info.Lastactivity, 50) < 0)
                        {
                            info.Onlinestate = 1;
                        }
                        else
                        {
                            info.Onlinestate = 0;
                        }


                        //作者ID为-1即表明作者为游客, 为了区分会直接公开显示游客发帖时的IP, 这里将IP最后一位修改为*
                        info.Ip = reader["ip"].ToString().Trim();

                        // 勋章
                        if (info.Medals == "")
                        {
                            info.Medals = "";
                        }
                        else
                        {
                            info.Medals = Caches.GetMedalsList(info.Medals);
                        }

                        tmpGroupInfo = UserGroups.GetUserGroupInfo(info.Groupid);
                        info.Stars = tmpGroupInfo.Stars;
                        if (tmpGroupInfo.Color.Equals(""))
                        {
                            info.Status = tmpGroupInfo.Grouptitle;
                        }
                        else
                        {
                            info.Status = string.Format("<span style=\"color:{0}\">{1}</span>", tmpGroupInfo.Color, tmpGroupInfo.Grouptitle);
                        }
                    }
                    else
                    {
                        info.Nickname = "游客";
                        info.Username = "******";
                        info.Groupid = 7;
                        info.Showemail = 0;
                        info.Digestposts = 0;
                        info.Credits = 0;
                        info.Extcredits1 = 0;
                        info.Extcredits2 = 0;
                        info.Extcredits3 = 0;
                        info.Extcredits4 = 0;
                        info.Extcredits5 = 0;
                        info.Extcredits6 = 0;
                        info.Extcredits7 = 0;
                        info.Extcredits8 = 0;
                        info.Posts = 0;
                        info.Joindate = "2006-9-1 1:1:1";
                        info.Lastactivity = "2006-9-1 1:1:1"; ;
                        info.Userinvisible = 0;
                        info.Avatar = "";
                        info.Avatarwidth = 0;
                        info.Avatarheight = 0;
                        info.Medals = "";
                        info.Signature = "";
                        info.Location = "";
                        info.Customstatus = "";
                        info.Website = "";
                        info.Icq = "";
                        info.Qq = "";
                        info.Msn = "";
                        info.Yahoo = "";
                        info.Skype = "";
                        //部分属性需要根据不同情况来赋值
                        info.Email = "";
                        info.Onlinestate = 1;
                        info.Medals = "";

                        info.Ip = reader["ip"].ToString().Trim();
                        if (info.Ip.IndexOf('.') > -1)
                        {
                            info.Ip = info.Ip.Substring(0, info.Ip.LastIndexOf(".") + 1) + "*";
                        }

                        tmpGroupInfo = UserGroups.GetUserGroupInfo(7);
                        info.Stars = tmpGroupInfo.Stars;
                        info.Status = "游客";

                    }
                    //扩展属性
                    id++;
                    info.Id = id;
                    info.Adindex = random.Next(0, adcount);

                    if (!Utils.InArray(info.Groupid.ToString(), "4,5,6"))
                    {
                        //处理帖子内容
                        _postpramsinfo.Smileyoff = info.Smileyoff;
                        _postpramsinfo.Bbcodeoff = info.Bbcodeoff;
                        _postpramsinfo.Parseurloff = info.Parseurloff;
                        _postpramsinfo.Allowhtml = info.Htmlon;
                        _postpramsinfo.Sdetail = info.Message;
                        //校正hide处理
                        if (tmpGroupInfo.Allowhidecode == 0)
                        {
                            _postpramsinfo.Hide = 0;
                        }


                        //先简单判断是否允许使用Discuz!NT代码,如果不允许,效率起见直接不进行代码转换 (虽然UBB.UBBToHTML方法内也进行判断)
                        if (!_postpramsinfo.Ubbmode)
                        {
                            info.Message = UBB.UBBToHTML(_postpramsinfo);
                        }
                        else
                        {
                            info.Message = Utils.HtmlEncode(info.Message);
                        }

                        if (_postpramsinfo.Jammer == 1)
                        {
                            info.Message = ForumUtils.AddJammer(info.Message);
                        }


                        //恢复hide初值
                        _postpramsinfo.Hide = oldHide;
                    }
                    else//发帖人已经被禁止发言
                    {
						if (ismoder)
						{
							info.Message = "<div class='hintinfo'>该用户帖子内容已被屏蔽, 您拥有管理权限, 以下是帖子内容</div>" + info.Message;
						}
						else
						{
							info.Message = "该用户帖子内容已被屏蔽";
						}
                    }

                    postcoll.Add(info);
                }
                reader.Close();

                if (pidlist.Length > 0)
                {
                    pidlist.Remove(0, 1);
                    IDataReader attachreader = DatabaseProvider.GetInstance().GetAttachmentListByPid(pidlist.ToString());
                    if (attachreader != null)
                    {
                        while (attachreader.Read())
                        {
                            ShowtopicPageAttachmentInfo attinfo = new ShowtopicPageAttachmentInfo();
                            //info.Uid = Int32.Parse(reader["uid"].ToString());
                            attinfo.Aid = Int32.Parse(attachreader["aid"].ToString());
                            attinfo.Tid = Int32.Parse(attachreader["tid"].ToString());
                            attinfo.Pid = Int32.Parse(attachreader["pid"].ToString());
                            attinfo.Postdatetime = attachreader["postdatetime"].ToString();
                            attinfo.Readperm = Int32.Parse(attachreader["readperm"].ToString());
                            attinfo.Filename = attachreader["filename"].ToString();
                            attinfo.Description = attachreader["description"].ToString();
                            attinfo.Filetype = attachreader["filetype"].ToString();
                            attinfo.Filesize = Int32.Parse(attachreader["filesize"].ToString());
                            attinfo.Attachment = attachreader["attachment"].ToString();
                            attinfo.Downloads = Int32.Parse(attachreader["downloads"].ToString());
                            attcoll.Add(attinfo);
                        }
                    }
                    attachreader.Close();
                }


                foreach (ShowtopicPagePostInfo info in postcoll)
                {
                    if (info.Groupid != 4 && info.Groupid != 5)
                    {
                        string message = info.Message;
                        if (info.Attachment > 0 || regexAttach.IsMatch(message))
                        {

                            //获取在[hide]标签中的附件id
                            string[] attHidArray = GetHiddenAttachIdList(_postpramsinfo.Sdetail, _postpramsinfo.Hide);

                            for (int i = 0; i < attcoll.Count; i++)
                            {
                                message = GetMessageWithAttachInfo(_postpramsinfo, allowGetAttach, attHidArray, info, attcoll[i], message);
                                if (Utils.InArray(attcoll[i].Aid.ToString(), attHidArray))
                                {
                                    attcoll.RemoveAt(i);
                                }
                            }
                            info.Message = message;

                        }
                    }
                    else
                    {
                        for (int i = 0; i < attcoll.Count; i++)
                        {
                            if (attcoll[i].Pid == info.Pid)
                            {
                                attcoll.RemoveAt(i);
                            }
                        }
                    }
                }
            }

            return postcoll;
        }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> class containing the elements of the specified source collection.
 /// </summary>
 /// <param name="value">A <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> with which to initialize the collection.</param>
 public ShowtopicPageAttachmentInfoCollection(ShowtopicPageAttachmentInfoCollection value)
 {
     this.AddRange(value);
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShowtopicPageAttachmentInfoCollectionEnumerator">ShowtopicPageAttachmentInfoCollectionEnumerator</see> class referencing the specified <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> object.
 /// </summary>
 /// <param name="mappings">The <see cref="ShowtopicPageAttachmentInfoCollection">ShowtopicPageAttachmentInfoCollection</see> to enumerate.</param>
 public ShowtopicPageAttachmentInfoCollectionEnumerator(ShowtopicPageAttachmentInfoCollection mappings)
 {
     _temp       = ((IEnumerable)(mappings));
     _enumerator = _temp.GetEnumerator();
 }