/// <summary> /// Copies the elements of the specified <see cref="PrivateMessageInfo">PrivateMessageInfo</see> array to the end of the collection. /// </summary> /// <param name="value">An array of type <see cref="PrivateMessageInfo">PrivateMessageInfo</see> containing the Components to add to the collection.</param> public void AddRange(PrivateMessageInfo[] value) { for (int i = 0; (i < value.Length); i = (i + 1)) { this.Add(value[i]); } }
/// <summary> /// 创建短消息 /// </summary> /// <param name="privatemessageinfo">短消息内容</param> /// <param name="savetosentbox">设置短消息是否在发件箱保留(0为不保留, 1为保留)</param> /// <returns>短消息在数据库中的pmid</returns> public static int CreatePrivateMessage(PrivateMessageInfo privatemessageinfo, int savetosentbox) { int pmid = DatabaseProvider.GetInstance().CreatePrivateMessage(privatemessageinfo, savetosentbox); if (Users.appDBCache && Users.IUserService != null) { UserInfo userInfo = Users.IUserService.GetUserInfo(privatemessageinfo.Msgtoid); if (userInfo != null) { userInfo.Newpmcount = userInfo.Newpmcount + 1; userInfo.Newpm = 1; Users.IUserService.UpdateUser(userInfo); } } return pmid; }
private void BatchSendSM_Click(object sender, EventArgs e) { #region 批量短消息发送 if (this.CheckCookie()) { string groupidlist = Usergroups.GetSelectString(","); if (groupidlist == "") { base.RegisterStartupScript("", "<script>alert('请您先选取相关的用户组,再点击提交按钮');</script>"); return; } int percount = Discuz.Common.Utils.StrToInt(postcountpercircle.Text, 100); //每多少记录为一次等待 int count = 0; //当前记录数 //foreach (DataRow dr in DbHelper.ExecuteDataset("SELECT [uid] ,[username] From [" + BaseConfigs.GetTablePrefix + "users] WHERE [groupid] IN(" + groupidlist + ")").Tables[0].Rows) foreach (DataRow dr in Users.GetUserListByGroupidList(groupidlist).Rows) { //DbHelper.ExecuteNonQuery("INSERT INTO [" + BaseConfigs.GetTablePrefix + "pms] (msgfrom,msgfromid,msgto,msgtoid,folder,new,subject,postdatetime,message) VALUES ('" + this.username.Replace("'", "''") + "','" + this.userid.ToString() + "','" + dr["username"].ToString().Replace("'", "''") + "','" + dr["uid"].ToString() + "','" + folder.SelectedValue + "','1','" + subject.Text + "','" + postdatetime.Text + "','" + message.Text + "')"); //DbHelper.ExecuteNonQuery("UPDATE [" + BaseConfigs.GetTablePrefix + "users] SET [newpmcount]=[newpmcount]+1 WHERE [uid] =" + dr["uid"].ToString()); //Discuz.Data.DatabaseProvider.GetInstance().SendPMToUser(username.Replace("'", "''"), userid, dr["username"].ToString().Replace("'", "''"), Convert.ToInt32(dr["uid"].ToString()), int.Parse(folder.SelectedValue), subject.Text, Convert.ToDateTime(postdatetime.Text), message.Text); PrivateMessageInfo pm = new PrivateMessageInfo(); pm.Msgfrom = username.Replace("'", "''"); pm.Msgfromid = userid; pm.Msgto = dr["username"].ToString().Replace("'", "''"); pm.Msgtoid = Convert.ToInt32(dr["uid"].ToString()); pm.Folder = int.Parse(folder.SelectedValue); pm.Subject = subject.Text; pm.Postdatetime = postdatetime.Text; pm.Message = message.Text; pm.New = 1;//标记为未读 PrivateMessages.CreatePrivateMessage(pm, 0); if (count >= percount) { Thread.Sleep(500); count = 0; } count++; } base.RegisterStartupScript("PAGE", "window.location.href='global_sendSMtogroup.aspx';"); } #endregion }
/// <summary> /// 获得指定ID的短消息的内容 /// </summary> /// <param name="pmid">短消息pmid</param> /// <returns>短消息内容</returns> public static PrivateMessageInfo GetPrivateMessageInfo(int pmid) { PrivateMessageInfo __privatemessageinfo = new PrivateMessageInfo(); IDataReader reader = DatabaseProvider.GetInstance().GetPrivateMessageInfo(pmid); if(reader.Read()) { __privatemessageinfo.Pmid = pmid; __privatemessageinfo.Msgfrom = reader["msgfrom"].ToString(); __privatemessageinfo.Msgfromid = int.Parse(reader["msgfromid"].ToString()); __privatemessageinfo.Msgto = reader["msgto"].ToString(); __privatemessageinfo.Msgtoid = int.Parse(reader["msgtoid"].ToString()); __privatemessageinfo.Folder = Int16.Parse(reader["folder"].ToString()); __privatemessageinfo.New = int.Parse(reader["new"].ToString()); __privatemessageinfo.Subject = reader["subject"].ToString(); __privatemessageinfo.Postdatetime = reader["postdatetime"].ToString(); __privatemessageinfo.Message = reader["message"].ToString(); reader.Close(); return __privatemessageinfo; } reader.Close(); return null; }
private void BatchSendSM_Click(object sender, EventArgs e) { #region 批量短消息发送 if (this.CheckCookie()) { groupidlist = Usergroups.GetSelectString(","); if (groupidlist == "") { base.RegisterStartupScript("", "<script>alert('请您先选取相关的用户组,再点击提交按钮');</script>"); return; } #if EntLib if (RabbitMQConfigs.GetConfig() != null && RabbitMQConfigs.GetConfig().SendShortMsg.Enable)//当开启errlog错误日志记录功能时 { PrivateMessageInfo pm = new PrivateMessageInfo() { Msgfrom = username.Replace("'", "''"), Msgfromid = userid, Folder = int.Parse(folder.SelectedValue), Subject = subject.Text, Postdatetime = Discuz.Common.Utils.GetDateTime(),//获取发送消息的系统时间 Message = message.Text, New = 1//标记为未读 }; Discuz.EntLib.ServiceBus.SendShortMsgClientHelper.GetSendShortMsgClient().AsyncSendShortMsgByUserGroup(groupidlist, pm); return; } #endif ClientScript.RegisterStartupScript(this.GetType(), "Page", "<script>submit_Click();</script>"); } #endregion }
/// <summary> /// 创建短消息 /// </summary> /// <param name="privatemessageinfo">短消息内容</param> /// <param name="savetosentbox">设置短消息是否在发件箱保留(0为不保留, 1为保留)</param> /// <returns>短消息在数据库中的pmid</returns> public static int CreatePrivateMessage(PrivateMessageInfo privatemessageinfo, int savetosentbox) { return Discuz.Data.PrivateMessages.CreatePrivateMessage(privatemessageinfo, savetosentbox); }
/// <summary> /// Gets the index in the collection of the specified <see cref="PrivateMessageInfoCollection">PrivateMessageInfoCollection</see>, if it exists in the collection. /// </summary> /// <param name="value">The <see cref="PrivateMessageInfoCollection">PrivateMessageInfoCollection</see> to locate in the collection.</param> /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns> public int IndexOf(PrivateMessageInfo value) { return(this.List.IndexOf(value)); }
/// <summary> /// 在论坛注册一个新用户并绑定 /// </summary> private void RegisterAndBind() { if (userid > 0) { AddErrLine("当前已有用户登录,无法注册"); return; } if (config.Regstatus < 1 || cloudconfig.Allowconnectregister == 0) { AddErrLine("论坛当前禁止新的QQ会员登录"); return; } string tmpUserName = DNTRequest.GetString(config.Antispamregisterusername); string email = DNTRequest.GetString(config.Antispamregisteremail).Trim().ToLower(); string tmpBday = DNTRequest.GetString("bday").Trim(); string errorMessage = ""; if (!Users.PageValidateUserName(tmpUserName, out errorMessage) || !Users.PageValidateEmail(email, false, out errorMessage)) { AddErrLine(errorMessage); return; } //用户注册模板中,生日可以单独用一个名为bday的文本框, 也可以分别用bday_y bday_m bday_d三个文本框, 用户可不填写 if (!Utils.IsDateString(tmpBday) && !string.IsNullOrEmpty(tmpBday)) { AddErrLine("生日格式错误, 如果不想填写生日请置空"); return; } //如果用户名符合注册规则, 则判断是否已存在 if (Users.GetUserId(tmpUserName) > 0) { AddErrLine("请不要重复提交!"); return; } //读取当前用户的OPENID信息 userconnectinfo = DiscuzCloud.GetUserConnectInfo(openid); if (userconnectinfo == null || userconnectinfo.Uid > 0) { AddErrLine("Connect信息异常,登录失败,请尝试再次登录"); return; } UserBindConnectLog bindLog = DiscuzCloud.GetUserConnectBindLog(userconnectinfo.OpenId); if (cloudconfig.Maxuserbindcount != 0 && bindLog != null && (bindLog.Type != 1 && bindLog.BindCount >= cloudconfig.Maxuserbindcount)) { AddErrLine("当前QQ用户解绑次数过多,无法绑定新注册的用户"); return; } UserInfo userInfo = CreateUser(tmpUserName, email, tmpBday); userconnectinfo.Uid = userInfo.Uid; DiscuzCloud.UpdateUserConnectInfo(userconnectinfo); if (bindLog == null) { bindLog = new UserBindConnectLog(); bindLog.OpenId = userconnectinfo.OpenId; bindLog.Uid = userconnectinfo.Uid; bindLog.Type = 1; bindLog.BindCount = 1; DiscuzCloud.CreateUserConnectBindLog(bindLog); } else { bindLog.BindCount++; bindLog.Uid = userconnectinfo.Uid; bindLog.Type = 1; DiscuzCloud.UpdateUserConnectBindLog(bindLog); } #region 发送欢迎信息 if (config.Welcomemsg == 1) { // 收件箱 PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); privatemessageinfo.Message = config.Welcomemsgtxt; privatemessageinfo.Subject = "欢迎您的加入! (请勿回复本信息)"; privatemessageinfo.Msgto = userInfo.Username; privatemessageinfo.Msgtoid = userInfo.Uid; privatemessageinfo.Msgfrom = PrivateMessages.SystemUserName; privatemessageinfo.Msgfromid = 0; privatemessageinfo.New = 1; privatemessageinfo.Postdatetime = Utils.GetDateTime(); privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); } #endregion //发送同步数据给应用程序 Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, ""); //如果用户选择使用QZone头像 if (cloudconfig.Allowuseqzavater == 1 && DNTRequest.GetString("use_qzone_avatar") == "1") { QZoneAvatar qz = new QZoneAvatar(); qz.AsyncGetAvatar(userconnectinfo); } SetUrl("index.aspx"); SetShowBackLink(false); //如果不是需要管理员审核的注册,页面延时刷新为2秒,否则是5秒 SetMetaRefresh(config.Regverify != 2 ? 2 : 5); Statistics.ReSetStatisticsCache(); if (config.Regverify != 2) { CreditsFacade.UpdateUserCredits(userInfo.Uid); ForumUtils.WriteUserCookie(userInfo, -1, config.Passwordkey); Utils.WriteCookie("bindconnect", "true");//将当前登录用户是否绑定QQ互联的状态设置为true OnlineUsers.UpdateAction(olid, UserAction.Register.ActionID, 0, config.Onlinetimeout); AddMsgLine("QQ登录成功,继续浏览"); } else { AddMsgLine("QQ数据绑定完成, 但需要系统管理员审核您的帐户后才可登录使用"); } notifyscript = GetNotifyScript(userconnectinfo, userInfo.Username, userInfo.Bday, userInfo.Gender, userInfo.Email, userInfo.Showemail, DNTRequest.GetInt("useqqavatar", 2), "register"); }
public void Register() { SetShowBackLink(true); InviteCodeInfo inviteCode = allowinvite ? ValidateInviteInfo() : null; if (IsErr()) return; string tmpUserName = DNTRequest.GetString(config.Antispamregisterusername); string email = config.Regverify == 1 ? verifyinfo.Email : DNTRequest.GetString(config.Antispamregisteremail).Trim().ToLower(); string tmpBday = DNTRequest.GetString("bday").Trim(); if (tmpBday == "") { tmpBday = string.Format("{0}-{1}-{2}", DNTRequest.GetString("bday_y").Trim(), DNTRequest.GetString("bday_m").Trim(), DNTRequest.GetString("bday_d").Trim()); } tmpBday = (tmpBday == "--" ? "" : tmpBday); ValidateUserInfo(tmpUserName, email, tmpBday); if (IsErr()) return; //如果用户名符合注册规则, 则判断是否已存在 if (Users.GetUserId(tmpUserName) > 0) { AddErrLine("请不要重复提交!"); return; } UserInfo userInfo = CreateUser(tmpUserName, email, tmpBday); //如果开启邮箱验证注册,删除邮箱验证请求信息 if (config.Regverify == 1) Users.DeleteVerifyRegisterInfo(verifyinfo.RegId); //若使用了邀请码,更新邀请码相关信息 if (inviteCode != null) { Invitation.UpdateInviteCodeSuccessCount(inviteCode.InviteId); if (config.Regstatus == 3) { if (inviteCode.SuccessCount + 1 >= inviteCode.MaxCount) Invitation.DeleteInviteCode(inviteCode.InviteId); } } #region 发送欢迎信息 if (config.Welcomemsg == 1) { // 收件箱 PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); privatemessageinfo.Message = config.Welcomemsgtxt; privatemessageinfo.Subject = "欢迎您的加入! (请勿回复本信息)"; privatemessageinfo.Msgto = userInfo.Username; privatemessageinfo.Msgtoid = userInfo.Uid; privatemessageinfo.Msgfrom = PrivateMessages.SystemUserName; privatemessageinfo.Msgfromid = 0; privatemessageinfo.New = 1; privatemessageinfo.Postdatetime = Utils.GetDateTime(); privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); } #endregion //发送同步数据给应用程序 Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, ""); SetUrl("index.aspx"); SetShowBackLink(false); //如果不是需要管理员审核的注册,页面延时刷新为2秒,否则是5秒 SetMetaRefresh(config.Regverify != 2 ? 2 : 5); Statistics.ReSetStatisticsCache(); if (config.Regverify != 2) { CreditsFacade.UpdateUserCredits(userInfo.Uid); ForumUtils.WriteUserCookie(userInfo, -1, config.Passwordkey); OnlineUsers.UpdateAction(olid, UserAction.Register.ActionID, 0, config.Onlinetimeout); MsgForward("register_succeed"); AddMsgLine("注册成功, 返回登录页"); } else { AddMsgLine("注册成功, 但需要系统管理员审核您的帐户后才可登录使用"); } agree = "yes"; }
/// <summary> /// Gets a value indicating whether the collection contains the specified <see cref="PrivateMessageInfoCollection">PrivateMessageInfoCollection</see>. /// </summary> /// <param name="value">The <see cref="PrivateMessageInfoCollection">PrivateMessageInfoCollection</see> to search for in the collection.</param> /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns> public bool Contains(PrivateMessageInfo value) { return(this.List.Contains(value)); }
public int Add(PrivateMessageInfo value) { return this.List.Add(value); }
/// <summary> /// 注册用户 /// </summary> /// <returns></returns> public string Register() { string returnStr = string.Empty; if (Signature != GetParam("sig").ToString()) { ErrorCode = (int)ErrorType.API_EC_SIGNATURE; return returnStr; } if (CallId <= LastCallId) { ErrorCode = (int)ErrorType.API_EC_CALLID; return returnStr; } if (!CheckRequiredParams("user_name,password,email")) { ErrorCode = (int)ErrorType.API_EC_PARAM; return returnStr; } if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)//如果是桌面程序则不允许此方法 { if (Uid < 1 || Discuz.Forum.UserGroups.GetUserGroupInfo(Discuz.Forum.Users.GetShortUserInfo(Uid).Groupid).Radminid != 1) { ErrorCode = (int)ErrorType.API_EC_PERMISSION_DENIED; return ""; } } else if (Uid > 0)//已经登录的用户不能再注册 { ErrorCode = (int)ErrorType.API_EC_USER_ONLINE; return returnStr; } string username = GetParam("user_name").ToString(); string password = GetParam("password").ToString(); string email = GetParam("email").ToString(); bool isMD5Passwd = GetParam("password_format") != null && GetParam("password_format").ToString() == "md5" ? true : false; //用户名不符合规范 if (!CheckUsername(username)) { ErrorCode = (int)ErrorType.API_EC_USERNAME_ILLEGAL; return returnStr; } if (Discuz.Forum.Users.GetUserId(username) != 0)//如果用户名符合注册规则, 则判断是否已存在 { ErrorCode = (int)ErrorType.API_EC_USER_ALREADY_EXIST; return returnStr; } if (!isMD5Passwd && password.Length < 6) { ErrorCode = (int)ErrorType.API_EC_PARAM; return returnStr; } if (!CheckEmail(email)) { ErrorCode = (int)ErrorType.API_EC_EMAIL; return returnStr; } UserInfo userInfo = new UserInfo(); userInfo.Username = username; userInfo.Nickname = string.Empty; userInfo.Password = isMD5Passwd ? password : Utils.MD5(password); userInfo.Secques = string.Empty; userInfo.Gender = 0; userInfo.Adminid = 0; userInfo.Groupexpiry = 0; userInfo.Extgroupids = ""; userInfo.Regip = DNTRequest.GetIP(); userInfo.Joindate = Utils.GetDateTime(); userInfo.Lastip = DNTRequest.GetIP(); userInfo.Lastvisit = Utils.GetDateTime(); userInfo.Lastactivity = Utils.GetDateTime(); userInfo.Lastpost = Utils.GetDateTime(); userInfo.Lastpostid = 0; userInfo.Lastposttitle = ""; userInfo.Posts = 0; userInfo.Digestposts = 0; userInfo.Oltime = 0; userInfo.Pageviews = 0; userInfo.Credits = 0; userInfo.Extcredits1 = Scoresets.GetScoreSet(1).Init; userInfo.Extcredits2 = Scoresets.GetScoreSet(2).Init; userInfo.Extcredits3 = Scoresets.GetScoreSet(3).Init; userInfo.Extcredits4 = Scoresets.GetScoreSet(4).Init; userInfo.Extcredits5 = Scoresets.GetScoreSet(5).Init; userInfo.Extcredits6 = Scoresets.GetScoreSet(6).Init; userInfo.Extcredits7 = Scoresets.GetScoreSet(7).Init; userInfo.Extcredits8 = Scoresets.GetScoreSet(8).Init; userInfo.Email = email; userInfo.Bday = string.Empty; userInfo.Sigstatus = 0; userInfo.Tpp = 0; userInfo.Ppp = 0; userInfo.Templateid = 0; userInfo.Pmsound = 0; userInfo.Showemail = 0; userInfo.Salt = "0"; int receivepmsetting = Config.Regadvance == 0 ? 7 : 1; userInfo.Newsletter = (ReceivePMSettingType)receivepmsetting; userInfo.Invisible = 0; userInfo.Newpm = Config.Welcomemsg == 1 ? 1 : 0; userInfo.Medals = ""; userInfo.Accessmasks = 0; userInfo.Website = string.Empty; userInfo.Icq = string.Empty; userInfo.Qq = string.Empty; userInfo.Yahoo = string.Empty; userInfo.Msn = string.Empty; userInfo.Skype = string.Empty; userInfo.Location = string.Empty; userInfo.Customstatus = string.Empty; userInfo.Bio = string.Empty; userInfo.Signature = string.Empty; userInfo.Sightml = string.Empty; userInfo.Authtime = Utils.GetDateTime(); //邮箱激活链接验证 if (Config.Regverify == 1) { userInfo.Authstr = ForumUtils.CreateAuthStr(20); userInfo.Authflag = 1; userInfo.Groupid = 8; Emails.DiscuzSmtpMail(username, email, string.Empty, userInfo.Authstr); } //系统管理员进行后台验证 else if (Config.Regverify == 2) { userInfo.Authstr = string.Empty; userInfo.Groupid = 8; userInfo.Authflag = 1; } else { userInfo.Authstr = ""; userInfo.Authflag = 0; userInfo.Groupid = UserCredits.GetCreditsUserGroupId(0).Groupid; } userInfo.Realname = string.Empty; userInfo.Idcard = string.Empty; userInfo.Mobile = string.Empty; userInfo.Phone = string.Empty; if (Config.Passwordmode > 1 && PasswordModeProvider.GetInstance() != null) { userInfo.Uid = PasswordModeProvider.GetInstance().CreateUserInfo(userInfo); } else { userInfo.Uid = Discuz.Forum.Users.CreateUser(userInfo); } if (Config.Welcomemsg == 1) { PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); // 收件箱 privatemessageinfo.Message = Config.Welcomemsgtxt; privatemessageinfo.Subject = "欢迎您的加入! (请勿回复本信息)"; privatemessageinfo.Msgto = userInfo.Username; privatemessageinfo.Msgtoid = userInfo.Uid; privatemessageinfo.Msgfrom = PrivateMessages.SystemUserName; privatemessageinfo.Msgfromid = 0; privatemessageinfo.New = 1; privatemessageinfo.Postdatetime = Utils.GetDateTime(); privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); } Statistics.ReSetStatisticsCache(); //信息同步通知不会发向当前请求接口的应用程序,所以此处应保留,以支持论坛向其他关联应用程序发送通知 Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, ApiKey); UserCredits.UpdateUserCredits(userInfo.Uid); if (Format == FormatType.JSON) return string.Format("\"{0}\"", userInfo.Uid); RegisterResponse rr = new RegisterResponse(); rr.Uid = userInfo.Uid; return SerializationHelper.Serialize(rr); }
public void Remove(PrivateMessageInfo value) { List.Remove(value); }
/// <summary> /// Initializes a new instance of the <see cref="PrivateMessageInfoCollection">PrivateMessageInfoCollection</see> class containing the specified array of <see cref="PrivateMessageInfo">PrivateMessageInfo</see> Components. /// </summary> /// <param name="value">An array of <see cref="PrivateMessageInfo">PrivateMessageInfo</see> Components with which to initialize the collection. </param> public PrivateMessageInfoCollection(PrivateMessageInfo[] value) { this.AddRange(value); }
public void Insert(int index, PrivateMessageInfo value) { List.Insert(index, value); }
/// <summary> /// Gets the index in the collection of the specified <see cref="PrivateMessageInfoCollection">PrivateMessageInfoCollection</see>, if it exists in the collection. /// </summary> /// <param name="value">The <see cref="PrivateMessageInfoCollection">PrivateMessageInfoCollection</see> to locate in the collection.</param> /// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns> public int IndexOf(PrivateMessageInfo value) { return this.List.IndexOf(value); }
public static void SendMessage(int clubID, string userName, ClubSysMessageType messageType, params string[] para) { var userID = Users.GetUserId(userName); var club = ClubLogic.GetClubInfo(clubID); PrivateMessageInfo pm; switch (messageType) { case ClubSysMessageType.ApplyClub: foreach (var aID in ConfigGlobal.PluginAdmin) { pm = new PrivateMessageInfo(); pm.Msgfrom = ClubSysAdminName; pm.Msgfromid = 0; pm.Folder = 0; pm.Message = string.Format(ApplyClub_Message, userName, club.FullName); pm.Msgtoid = Convert.ToInt32(aID); pm.Msgto = Users.GetUserInfo(aID).Username.Trim(); pm.New = 1; pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pm.Subject = string.Format(ApplyClub_Subject, userName); PrivateMessages.CreatePrivateMessage(pm, 0); } break; case ClubSysMessageType.ApplyJoinClub: var users = ClubLogic.GetClubLeads(clubID); foreach (var userClub in users) { pm = new PrivateMessageInfo(); pm.Msgfrom = ClubSysAdminName; pm.Msgfromid = 0; pm.Folder = 0; pm.Message = string.Format(ApplyJoinClub_Message, userName, club.FullName); pm.Msgto = userClub.UserName; pm.Msgtoid = userClub.Userid.Value; pm.New = 1; pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pm.Subject = string.Format(ApplyJoinClub_Subject, userName); PrivateMessages.CreatePrivateMessage(pm, 0); } break; case ClubSysMessageType.ApproveClub: if (club != null) { var result = "通过"; if (!club.IsActive.Value) result = "驳回"; pm = new PrivateMessageInfo(); pm.Msgfrom = ClubSysAdminName; pm.Msgfromid = 0; pm.Folder = 0; pm.Message = string.Format(ApproveClub_Message, club.FullName, result); pm.Msgto = club.CreatorUserName; pm.Msgtoid = club.CreatorUid.Value; pm.New = 1; pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pm.Subject = ApproveClub_Subject; PrivateMessages.CreatePrivateMessage(pm, 0); } break; case ClubSysMessageType.ApproveJoinClub: pm = new PrivateMessageInfo(); pm.Msgfrom = ClubSysAdminName; pm.Msgfromid = 0; pm.Folder = 0; pm.Message = string.Format(ApproveJoinClub_Message, club.FullName); pm.Msgto = userName; pm.Msgtoid = userID; pm.New = 1; pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pm.Subject = ApproveJoinClub_Subject; PrivateMessages.CreatePrivateMessage(pm, 0); break; case ClubSysMessageType.LeaveClub: pm = new PrivateMessageInfo(); pm.Msgfrom = ClubSysAdminName; pm.Msgfromid = 0; pm.Folder = 0; pm.Message = string.Format(LeaveClub_Message, club.FullName); pm.Msgto = userName; pm.Msgtoid = userID; pm.New = 1; pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pm.Subject = LeaveClub_Subject; PrivateMessages.CreatePrivateMessage(pm, 0); break; case ClubSysMessageType.MandatoryLeaveClub: pm = new PrivateMessageInfo(); pm.Msgfrom = ClubSysAdminName; pm.Msgfromid = 0; pm.Folder = 0; pm.Message = string.Format(MandatoryLeaveClub_Message, club.FullName); pm.Msgto = userName; pm.Msgtoid = userID; pm.New = 1; pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pm.Subject = MandatoryLeaveClub_Subject; PrivateMessages.CreatePrivateMessage(pm, 0); break; case ClubSysMessageType.RejectJoinClub: pm = new PrivateMessageInfo(); pm.Msgfrom = ClubSysAdminName; pm.Msgfromid = 0; pm.Folder = 0; pm.Message = string.Format(RejectJoinClub_Message, club.FullName); pm.Msgto = userName; pm.Msgtoid = userID; pm.New = 1; pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pm.Subject = RejectJoinClub_Subject; PrivateMessages.CreatePrivateMessage(pm, 0); break; case ClubSysMessageType.TransferExtcredit: pm = new PrivateMessageInfo(); pm.Msgfrom = para[0]; pm.Msgfromid = Users.GetUserId(para[0]); pm.Folder = 0; pm.Message = string.Format(TransferExtcredit_Message, para[0], para[1], para[2]); pm.Msgto = userName; pm.Msgtoid = userID; pm.New = 1; pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pm.Subject = string.Format(TransferExtcredit_Subject, club.FullName); PrivateMessages.CreatePrivateMessage(pm, 0); break; default: break; } }
protected override void ShowPage() { pagetitle = "用户注册"; if (userid != -1) { SetUrl(BaseConfigs.GetForumPath); SetMetaRefresh(); SetShowBackLink(false); AddMsgLine("不能重复注册用户"); ispost = true; createuser = "******"; agree = "yes"; return; } if (config.Regstatus != 1) { AddErrLine("论坛当前禁止新用户注册"); return; } #region 用户IP判断 string msg = Users.CheckRegisterDateDiff(DNTRequest.GetIP()); if (msg != null) { AddErrLine(msg); return; } //if (config.Regctrl > 0) //{ // ShortUserInfo userinfo = Users.GetShortUserInfoByIP(DNTRequest.GetIP()); // if (userinfo != null) // { // int Interval = Utils.StrDateDiffHours(userinfo.Joindate, config.Regctrl); // if (Interval <= 0) // { // AddErrLine("抱歉, 系统设置了IP注册间隔限制, 您必须在 " + (Interval * -1) + " 小时后才可以注册"); // return; // } // } //} //if (config.Ipregctrl.Trim() != "") //{ // string[] regctrl = Utils.SplitString(config.Ipregctrl, "\n"); // if (Utils.InIPArray(DNTRequest.GetIP(), regctrl)) // { // ShortUserInfo userinfo = Users.GetShortUserInfoByIP(DNTRequest.GetIP()); // if (userinfo != null) // { // int Interval = Utils.StrDateDiffHours(userinfo.Joindate, 72); // if (Interval < 0) // { // AddErrLine("抱歉, 系统设置了特殊IP注册限制, 您必须在 " + (Interval * -1) + " 小时后才可以注册"); // return; // } // } // } //} #endregion //如果提交了用户注册信息... if (!Utils.StrIsNullOrEmpty(createuser) && ispost) { SetShowBackLink(true); string tmpUsername = DNTRequest.GetString("username"); string email = DNTRequest.GetString("email").Trim().ToLower(); string tmpBday = DNTRequest.GetString("bday").Trim(); if (tmpBday == "") { tmpBday = string.Format("{0}-{1}-{2}", DNTRequest.GetString("bday_y").Trim(), DNTRequest.GetString("bday_m").Trim(), DNTRequest.GetString("bday_d").Trim()); } tmpBday = (tmpBday == "--" ? "" : tmpBday); ValidateUserInfo(tmpUsername, email, tmpBday); if (IsErr()) return; //如果用户名符合注册规则, 则判断是否已存在 if (Users.GetUserId(tmpUsername) > 0) { AddErrLine("请不要重复提交!"); return; } UserInfo userinfo = CreateUser(tmpUsername, email, tmpBday); #region 发送欢迎信息 if (config.Welcomemsg == 1) { // 收件箱 PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); privatemessageinfo.Message = config.Welcomemsgtxt; privatemessageinfo.Subject = "欢迎您的加入! (请勿回复本信息)"; privatemessageinfo.Msgto = userinfo.Username; privatemessageinfo.Msgtoid = userinfo.Uid; privatemessageinfo.Msgfrom = PrivateMessages.SystemUserName; privatemessageinfo.Msgfromid = 0; privatemessageinfo.New = 1; privatemessageinfo.Postdatetime = Utils.GetDateTime(); privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); } #endregion SetUrl("index.aspx"); SetShowBackLink(false); SetMetaRefresh(config.Regverify == 0 ? 2 : 5); Statistics.ReSetStatisticsCache(); if (config.Regverify == 0) { UserCredits.UpdateUserCredits(userinfo.Uid); ForumUtils.WriteUserCookie(userinfo, -1, config.Passwordkey); OnlineUsers.UpdateAction(olid, UserAction.Register.ActionID, 0, config.Onlinetimeout); AddMsgLine("注册成功, 返回登录页"); } else { if (config.Regverify == 1) AddMsgLine("注册成功, 请您到您的邮箱中点击激活链接来激活您的帐号"); else if (config.Regverify == 2) AddMsgLine("注册成功, 但需要系统管理员审核您的帐户后才可登陆使用"); } agree = "yes"; } }
/// <summary> /// ��������Ϣ /// </summary> /// <param name="__privatemessageinfo">����Ϣ����</param> /// <param name="savetosentbox">���ö���Ϣ�Ƿ��ڷ����䱣��(0Ϊ������, 1Ϊ����)</param> /// <returns>����Ϣ�����ݿ��е�pmid</returns> public int CreatePrivateMessage(PrivateMessageInfo pminfo, int savetosentbox) { System.Diagnostics.Debug.WriteLine("CreatePrivateMessage(PrivateMessageInfo pminfo, int savetosentbox)"); if (pminfo.Folder != 0) { pminfo.Msgfrom = pminfo.Msgto; } else { DbHelper.ExecuteNonQuery(CommandType.Text, string.Format("UPDATE `{0}users` SET `newpmcount`=`newpmcount`+1,`newpm`=1 WHERE `uid`={1}", BaseConfigs.GetTablePrefix, pminfo.Msgtoid)); } DbParameter[] parms = { DbHelper.MakeInParam("@pmid",DbType.Int32,4,pminfo.Pmid), DbHelper.MakeInParam("@msgfrom",DbType.String,20,pminfo.Msgfrom), DbHelper.MakeInParam("@msgfromid",DbType.Int32,4,pminfo.Msgfromid), DbHelper.MakeInParam("@msgto",DbType.String,20,pminfo.Msgto), DbHelper.MakeInParam("@msgtoid",DbType.Int32,4,pminfo.Msgtoid), DbHelper.MakeInParam("@folder",DbType.Int16,2,pminfo.Folder), DbHelper.MakeInParam("@new",DbType.Int32,4,pminfo.New), DbHelper.MakeInParam("@subject",DbType.String,80,pminfo.Subject), DbHelper.MakeInParam("@postdatetime",DbType.DateTime,8,DateTime.Parse(pminfo.Postdatetime)), DbHelper.MakeInParam("@message",DbType.String,0,pminfo.Message) }; string sql = string.Format("INSERT INTO `{0}pms` (`msgfrom`,`msgfromid`,`msgto`,`msgtoid`,`folder`,`new`,`subject`,`postdatetime`,`message`) VALUES (@msgfrom,@msgfromid,@msgto,@msgtoid,@folder,@new,@subject,@postdatetime,@message);select last_insert_rowid() AS pmid", BaseConfigs.GetTablePrefix); int pmid = Utils.StrToInt(DbHelper.ExecuteScalar(CommandType.Text, sql, parms).ToString(), -1); if (savetosentbox == 1 && pminfo.Folder == 0) { DbHelper.ExecuteNonQuery(CommandType.Text, string.Format("INSERT INTO `{0}pms` (`msgfrom`,`msgfromid`,`msgto`,`msgtoid`,`folder`,`new`,`subject`,`postdatetime`,`message`) VALUES(@msgfrom,@msgfromid,@msgto,@msgtoid,1,@new,@subject,@postdatetime,@message)", BaseConfigs.GetTablePrefix), parms); } return pmid; }
protected void btnSubmit_Click(object sender, EventArgs e) { //validate user id and user name var awardUserID = int.Parse(tbUserID.Text); var sUser = Users.GetShortUserInfo(awardUserID); var awardUserName = tbUserName.Text; if (awardUserName == sUser.Username.Trim()) { //process the award float cashIncrement = 0; float rp = 0; Guid? videoGuid = null; var AwardNotes = string.Empty; //precheck if (tbCash.Text.Trim() != string.Empty) { if (!float.TryParse(tbCash.Text.Trim(), out cashIncrement)) { ClientScript.RegisterClientScriptBlock(typeof (string), "invalidCash", "alert('枪手币格式无法转换!');", true); return; } } if (tbRP.Text.Trim() != string.Empty) { if (!float.TryParse(tbRP.Text.Trim(), out rp)) { ClientScript.RegisterClientScriptBlock(typeof (string), "invalidRP", "alert('RP格式无法转换!');", true); return; } } if (tbVideoGuid.Text.Trim() != string.Empty) { try { videoGuid = new Guid(tbVideoGuid.Text); } catch { ClientScript.RegisterClientScriptBlock(typeof (string), "invalidGuid", "alert('Guid格式无法转换!');", true); return; } } if (tbNotes.Text.Trim() != string.Empty) { AwardNotes = tbNotes.Text; } //is actually something awarded? var realAwarded = false; var awardMessageBody = "您获得奖励"; //add cash if (cashIncrement != 0) { Users.UpdateUserExtCredits(awardUserID, 2, cashIncrement); awardMessageBody += $" 枪手币+{cashIncrement}"; realAwarded = true; } //add rp if (rp != 0) { Users.UpdateUserExtCredits(awardUserID, 4, rp); awardMessageBody += $" RP+{rp}, "; realAwarded = true; } //add card if (!string.IsNullOrEmpty(lstPlayer.SelectedValue) && lstPlayer.SelectedValue != Guid.Empty.ToString()) { PlayerStrip.AddCard(awardUserID, awardUserName, new Guid(lstPlayer.SelectedValue), cbCardActive.Checked); awardMessageBody += $" 球星卡一张({(cbCardActive.Checked ? string.Empty : "未")}激活)"; realAwarded = true; } //add video if (videoGuid != null) { if (cbVideoActive.Checked) { //active //UserVideo.InsertActiveVideo(awardUserID, awardUserName, videoGuid.Value); var uv = new UserVideo(); uv.UserID = awardUserID; uv.UserName = awardUserName; uv.VideoGuid = videoGuid.Value; uv.ActiveDate = DateTime.Now; uv.UserDesc = string.Empty; uv.IsPublic = false; uv.Insert(); } else { //inactive PlayerStrip.AddCard(awardUserID, awardUserName, null, false); } awardMessageBody += $" 视频卡一张({(cbVideoActive.Checked ? string.Empty : "未")}激活)"; realAwarded = true; } if (!string.IsNullOrEmpty(AwardNotes)) { awardMessageBody += $" 奖励原因:{AwardNotes}"; } if (realAwarded) { PlayerLog.LogHistory(awardUserID, awardUserName, PlayerHistoryType.Award, new AwardDesc(cashIncrement, rp, (!string.IsNullOrEmpty(lstPlayer.SelectedValue) && lstPlayer.SelectedValue != Guid.Empty.ToString()), videoGuid != null).Generate()); var pm = new PrivateMessageInfo(); pm.Msgfrom = ClubSysPrivateMessage.ClubSysAdminName; pm.Msgfromid = 0; pm.Folder = 0; pm.Message = awardMessageBody; pm.Msgto = awardUserName; pm.Msgtoid = awardUserID; pm.New = 1; pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); pm.Subject = "ACN球会系统奖励(请勿回复此系统信息)"; PrivateMessages.CreatePrivateMessage(pm, 0); ClientScript.RegisterClientScriptBlock(typeof (string), "succeed", "alert('成功颁奖!');", true); } } else { ClientScript.RegisterClientScriptBlock(typeof (string), "alert", "alert('用户ID与用户名不匹配!');", true); } InitDropDownList(); }
protected override void ShowPage() { pagetitle = "撰写短消息"; if (userid == -1) { AddErrLine("你尚未登录"); return; } user = Discuz.Forum.Users.GetUserInfo(userid); if (!CheckPermission()) { return; } if (DNTRequest.IsPost()) { if (!CheckPermissionAfterPost()) { return; } #region 创建并发送短消息 PrivateMessageInfo pm = new PrivateMessageInfo(); string curdatetime = Utils.GetDateTime(); // 收件箱 if (useradminid == 1) { pm.Message = Utils.HtmlEncode(DNTRequest.GetString("message")); pm.Subject = Utils.HtmlEncode(DNTRequest.GetString("subject")); } else { pm.Message = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("message"))); pm.Subject = Utils.HtmlEncode(ForumUtils.BanWordFilter(DNTRequest.GetString("subject"))); } if (ForumUtils.HasBannedWord(pm.Message) || ForumUtils.HasBannedWord(pm.Subject)) { //HasBannedWord 指定的字符串中是否含有禁止词汇 AddErrLine("对不起, 您提交的内容包含不良信息, 因此无法提交, 请返回修改!"); return; } if (ForumUtils.HasAuditWord(pm.Message) || ForumUtils.HasAuditWord(pm.Subject)) { AddErrLine("对不起, 您提交的内容包含不良信息, 因此无法提交, 请返回修改!"); return; } pm.Message = ForumUtils.BanWordFilter(pm.Message); pm.Subject = ForumUtils.BanWordFilter(pm.Subject); pm.Msgto = DNTRequest.GetString("msgto"); pm.Msgtoid = msgtoid; pm.Msgfrom = username; pm.Msgfromid = userid; pm.New = 1; pm.Postdatetime = curdatetime; if (!DNTRequest.GetString("savetousercpdraftbox").Equals("")) { // 检查发送人的短消息是否已超过发送人用户组的上限 if (PrivateMessages.GetPrivateMessageCount(userid, -1) >= usergroupinfo.Maxpmnum) { AddErrLine("抱歉,您的短消息已达到上限,无法保存到草稿箱"); return; } // 只将消息保存到草稿箱 pm.Folder = 2; if (UserCredits.UpdateUserCreditsBySendpms(base.userid) == -1) { AddErrLine("您的金币不足, 不能发送短消息"); return; } pm.Pmid = PrivateMessages.CreatePrivateMessage(pm, 0); //发送邮件通知 if (DNTRequest.GetString("emailnotify") == "on") { SendNotifyEmail(Discuz.Forum.Users.GetUserInfo(msgtoid).Email.Trim(), pm); } SetUrl("usercpdraftbox.aspx"); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("已将消息保存到草稿箱"); } else if (!DNTRequest.GetString("savetosentbox").Equals("")) { // 检查接收人的短消息是否已超过接收人用户组的上限 UserInfo touser = Discuz.Forum.Users.GetUserInfo(msgtoid); //管理组不受接收人短消息上限限制 int radminId = UserGroups.GetUserGroupInfo(usergroupid).Radminid; if (!(radminId > 0 && radminId <= 3) && PrivateMessages.GetPrivateMessageCount(msgtoid, -1) >= UserGroups.GetUserGroupInfo(touser.Groupid).Maxpmnum) { AddErrLine("抱歉,接收人的短消息已达到上限,无法接收"); return; } if (!Utils.InArray(Convert.ToInt32(touser.Newsletter).ToString(), "2,3,6,7")) { AddErrLine("抱歉,接收人拒绝接收短消息"); return; } // 检查发送人的短消息是否已超过发送人用户组的上限 if (PrivateMessages.GetPrivateMessageCount(userid, -1) >= usergroupinfo.Maxpmnum) { AddErrLine("抱歉,您的短消息已达到上限,无法保存到发件箱"); return; } // 发送消息且保存到发件箱 pm.Folder = 0; if (UserCredits.UpdateUserCreditsBySendpms(base.userid) == -1) { AddErrLine("您的金币不足, 不能发送短消息"); return; } pm.Pmid = PrivateMessages.CreatePrivateMessage(pm, 1); //发送邮件通知 if (DNTRequest.GetString("emailnotify") == "on") { SendNotifyEmail(touser.Email.Trim(), pm); } // 更新在线表中的用户最后发帖时间 OnlineUsers.UpdatePostPMTime(olid); SetUrl("usercpsentbox.aspx"); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("发送完毕, 且已将消息保存到发件箱"); } else { UserInfo touser = Discuz.Forum.Users.GetUserInfo(msgtoid); // 检查接收人的短消息是否已超过接收人用户组的上限,管理组不受接收人短消息上限限制 int radminId = UserGroups.GetUserGroupInfo(usergroupid).Radminid; if (!(radminId > 0 && radminId <=3) && PrivateMessages.GetPrivateMessageCount(msgtoid, -1) >= UserGroups.GetUserGroupInfo(touser.Groupid).Maxpmnum) { AddErrLine("抱歉,接收人的短消息已达到上限,无法接收"); return; } if (!Utils.InArray(Convert.ToInt32(touser.Newsletter).ToString(), "2,3,6,7")) { AddErrLine("抱歉,接收人拒绝接收短消息"); return; } // 发送消息但不保存到发件箱 pm.Folder = 0; if (UserCredits.UpdateUserCreditsBySendpms(base.userid) == -1) { AddErrLine("您的金币不足, 不能发送短消息"); return; } pm.Pmid = PrivateMessages.CreatePrivateMessage(pm, 0); //发送邮件通知 if (DNTRequest.GetString("emailnotify") == "on") { SendNotifyEmail(touser.Email.Trim(), pm); } SetUrl("usercpinbox.aspx"); SetMetaRefresh(); SetShowBackLink(true); AddMsgLine("发送完毕"); } #endregion } msgto = Utils.HtmlEncode(DNTRequest.GetString("msgto")); msgtoid = DNTRequest.GetInt("msgtoid", 0); if (msgtoid > 0) { msgto = Discuz.Forum.Users.GetUserName(msgtoid).Trim(); } subject = Utils.HtmlEncode(DNTRequest.GetString("subject")); message = Utils.HtmlEncode(DNTRequest.GetString("message")); string action = DNTRequest.GetQueryString("action").ToLower(); if (action.CompareTo("re") == 0 || action.CompareTo("fw") == 0) //回复或者转发 { int pmid = DNTRequest.GetQueryInt("pmid", -1); if (pmid != -1) { PrivateMessageInfo pm = PrivateMessages.GetPrivateMessageInfo(pmid); if (pm != null) { if (pm.Msgtoid == userid || pm.Msgfromid == userid) { if (action.CompareTo("re") == 0) { msgto = Utils.HtmlEncode(pm.Msgfrom); } else { msgto = ""; } subject = Utils.HtmlEncode(action) + ":" + pm.Subject; message = Utils.HtmlEncode("> ") + pm.Message.Replace("\n", "\n> ") + "\r\n\r\n"; } } } } }
private bool DoOperations(ForumInfo forum, AdminGroupInfo admininfo, int reasonpm) { string operationName = ""; string next = DNTRequest.GetFormString("next"); string referer = DNTRequest.GetFormString("referer"); DataTable dt = null; #region DoOperation string reason = DNTRequest.GetString("reason"); if (operation != "identify") { if (reason.Equals("")) { AddErrLine("操作原因不能为空"); return false; } else { if (reason.Length > 200) { AddErrLine("操作原因不能多于200个字符"); return false; } } } if ("delete,highlight,close,movecategory".IndexOf(operation) == -1) { AddErrLine("未知的操作参数"); return false; } //执行提交操作 if (next.Trim() != "") referer = string.Format("goodsadmin.aspx?action={0}&categoryid={1}&goodsid={2}", next, categoryid, goodslist); else referer = string.Format(base.ShowGoodsListAspxRewrite(categoryid, 1)); #region switch operation switch (operation) { case "delete": operationName = "删除商品"; if (!DoDeleteOperation(forum)) return false; break; case "highlight": //设置高亮 operationName = "设置高亮"; if (!DoHighlightOperation()) return false; break; case "close": operationName = "关闭商品/取消"; if (!DoCloseOperation()) return false; break; case "movecategory": operationName = "移动商品"; if (!DoMoveOperation()) return false; break; default: operationName = "未知操作"; break; } #endregion if (next.CompareTo("") == 0) AddMsgLine("管理操作成功,现在将转入商品列表"); else AddMsgLine("管理操作成功,现在将转入后续操作"); dt = Goods.GetGoodsList(goodslist); if (config.Modworkstatus == 1) { if (dt != null) { foreach (DataRow dr in dt.Rows) { AdminModeratorLogs.InsertLog(this.userid.ToString(), username, usergroupid.ToString(), this.usergroupinfo.Grouptitle, Utils.GetRealIP(), Utils.GetDateTime(), this.forumid.ToString(), this.forumname, dr["goodsid"].ToString(), dr["title"].ToString(), operationName, reason); if (reasonpm == 1) { int posterid = Utils.StrToInt(dr["selleruid"], -1); if (posterid != -1) //是游客,管理操作就不发短消息了 { if (PrivateMessages.GetPrivateMessageCount(posterid, -1) < UserGroups.GetUserGroupInfo(Users.GetShortUserInfo(posterid).Groupid).Maxpmnum) { PrivateMessageInfo __privatemessageinfo = new PrivateMessageInfo(); string curdatetime = Utils.GetDateTime(); // 收件箱 __privatemessageinfo.Message = Utils.HtmlEncode( string.Format( "这是由论坛系统自动发送的通知短消息。\r\n以下您所发表的商品被 {0} {1} 执行 {2} 操作。\r\n\r\n商品: {3} \r\n操作理由: {4}\r\n\r\n如果您对本管理操作有异议,请与我取得联系。", Utils.RemoveHtml(this.usergroupinfo.Grouptitle), username, operationName, dr["title"].ToString().Trim(), reason)); __privatemessageinfo.Subject = Utils.HtmlEncode("您发表的商品被执行管理操作"); __privatemessageinfo.Msgto = dr["seller"].ToString(); __privatemessageinfo.Msgtoid = posterid; __privatemessageinfo.Msgfrom = username; __privatemessageinfo.Msgfromid = userid; __privatemessageinfo.New = 1; __privatemessageinfo.Postdatetime = curdatetime; __privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(__privatemessageinfo, 0); } } } } dt.Dispose(); } } //执行完某一操作后转到后续操作 SetUrl(referer); if (next != string.Empty) HttpContext.Current.Response.Redirect(BaseConfigs.GetForumPath + referer, false); else AddScript("window.setTimeout('redirectURL()', 2000);function redirectURL() {window.location='" + referer + "';}"); SetShowBackLink(false); #endregion return true; }
public int Add(PrivateMessageInfo value) { return(this.List.Add(value)); }
/// <summary> /// 加载单个短消息对象 /// </summary> /// <param name="reader"></param> /// <returns></returns> private static PrivateMessageInfo LoadSinglePrivateMessage(IDataReader reader) { PrivateMessageInfo info = new PrivateMessageInfo(); info.Pmid = TypeConverter.StrToInt(reader["pmid"].ToString()); info.Msgfrom = reader["msgfrom"].ToString(); info.Msgfromid = TypeConverter.StrToInt(reader["msgfromid"].ToString()); info.Msgto = reader["msgto"].ToString(); info.Msgtoid = TypeConverter.StrToInt(reader["msgtoid"].ToString()); info.Folder = TypeConverter.StrToInt(reader["folder"].ToString()); info.New = TypeConverter.StrToInt(reader["new"].ToString()); info.Subject = reader["subject"].ToString(); info.Postdatetime = reader["postdatetime"].ToString(); info.Message = reader["message"].ToString(); return info; }
/// <summary> /// Gets a value indicating whether the collection contains the specified <see cref="PrivateMessageInfoCollection">PrivateMessageInfoCollection</see>. /// </summary> /// <param name="value">The <see cref="PrivateMessageInfoCollection">PrivateMessageInfoCollection</see> to search for in the collection.</param> /// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns> public bool Contains(PrivateMessageInfo value) { return this.List.Contains(value); }
/// <summary> /// 发送邮件通知 /// </summary> /// <param name="email">接收人邮箱</param> /// <param name="privatemessageinfo">短消息对象</param> public void SendNotifyEmail(string email, PrivateMessageInfo pm) { string jumpurl = "http://" + DNTRequest.GetCurrentFullHost() + "/usercpshowpm.aspx?pmid=" + pm.Pmid; System.Text.StringBuilder sb_body = new System.Text.StringBuilder("# 论坛短消息: <a href=\"" + jumpurl + "\" target=\"_blank\">" + pm.Subject + "</a>"); //发送人邮箱 string cur_email = Discuz.Forum.Users.GetShortUserInfo(userid).Email.Trim(); sb_body.Append("\r\n"); sb_body.Append("\r\n"); sb_body.Append(pm.Message); sb_body.Append("\r\n<hr/>"); sb_body.Append("作 者:" + pm.Msgfrom); sb_body.Append("\r\n"); sb_body.Append("Email:<a href=\"mailto:" + cur_email + "\" target=\"_blank\">" + cur_email + "</a>"); sb_body.Append("\r\n"); sb_body.Append("URL:<a href=\"" + jumpurl + "\" target=\"_blank\">" + jumpurl + "</a>"); sb_body.Append("\r\n"); sb_body.Append("时 间:" + pm.Postdatetime); Emails.SendEmailNotify(email, "[" + config.Forumtitle + "短消息通知]" + pm.Subject, sb_body.ToString()); }
/// <summary> /// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index. /// </summary> /// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param> /// <param name="index">The index of the array at which to begin inserting.</param> public void CopyTo(PrivateMessageInfo[] array, int index) { this.List.CopyTo(array, index); }
private void PassApply_Click(object sender, EventArgs e) { if (DNTRequest.GetString("uid") != "") { string uidlist = DNTRequest.GetString("uid"); foreach(string uid in uidlist.Split(',')) { Discuz.Data.DatabaseProvider.GetInstance().UpdateUserSpaceId(Convert.ToInt32(uid)); //string sql = "UPDATE [" + BaseConfigs.GetTablePrefix + "users] SET [spaceid]=ABS([spaceid]) WHERE [uid]=" + uid; //sql += ";SELECT [spaceid] FROM [" + BaseConfigs.GetTablePrefix + "users] WHERE [uid]=" + uid; //int spceid = (int)AdminDatabase.ExecuteScalar(sql); int tabid = Spaces.GetNewTabId(Convert.ToInt32(uid)); TabInfo tab = new TabInfo(); tab.TabID = tabid; tab.UserID = Convert.ToInt32(uid); tab.DisplayOrder = 0; tab.TabName = "首页"; tab.IconFile = ""; tab.Template = "template_25_75.htm"; Spaces.AddTab(tab); //sql = "INSERT INTO [" + BaseConfigs.GetTablePrefix + "spacetabs] ([uid],[displayorder], [tabname], [iconfile],[template]) VALUES(" + uid + ",0,'默认','','template_25_75.htm');SELECT SCOPE_IDENTITY()"; //int tabid = Utils.StrToInt(AdminDatabase.ExecuteScalar(sql),0); Spaces.AddLocalModule("builtin_calendarmodule.xml",int.Parse(uid),tabid,1); Spaces.AddLocalModule("builtin_statisticmodule.xml", int.Parse(uid), tabid, 1); Spaces.AddLocalModule("builtin_postlistmodule.xml", int.Parse(uid), tabid, 2); if (spaceConfig.Spacegreeting != string.Empty) { SpacePostInfo spacepostsinfo = new SpacePostInfo(); spacepostsinfo.Title = string.Format("欢迎使用 {0} {1}", config.Forumtitle, config.Spacename); spacepostsinfo.Content = spaceConfig.Spacegreeting; spacepostsinfo.Category = string.Empty; spacepostsinfo.PostStatus = 1; spacepostsinfo.CommentStatus = 0; spacepostsinfo.Postdatetime = DateTime.Now; spacepostsinfo.Author = username; spacepostsinfo.Uid = Utils.StrToInt(uid, -1); spacepostsinfo.PostUpDateTime = DateTime.Now; spacepostsinfo.Commentcount = 0; DbProvider.GetInstance().AddSpacePost(spacepostsinfo); } ///添加最新主题到日志 List<TopicInfo> list = Topics.GetTopicsByUserId(userid, 1, config.Topictoblog, 0, 0); foreach (TopicInfo mytopic in list) { int pid = Posts.GetFirstPostId(mytopic.Tid); PostInfo post = Posts.GetPostInfo(mytopic.Tid, pid); if (post != null && post.Message.Trim() != string.Empty) { SpacePostInfo spacepost = new SpacePostInfo(); spacepost.Author = username; string content = Posts.GetPostMessageHTML(post, new AttachmentInfo[0]); spacepost.Category = ""; spacepost.Content = content; spacepost.Postdatetime = DateTime.Now; spacepost.PostStatus = 1; spacepost.PostUpDateTime = DateTime.Now; spacepost.Title = post.Title; spacepost.Uid = Utils.StrToInt(uid, -1); ; DbProvider.GetInstance().AddSpacePost(spacepost); } } //短信通知用户个人空间已经开通 PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); ShortUserInfo userInfo = Users.GetShortUserInfo(Convert.ToInt32(uid)); privatemessageinfo.Msgto = userInfo == null ? "" : userInfo.Username; privatemessageinfo.Msgtoid = Convert.ToInt32(uid); privatemessageinfo.Postdatetime = Utils.GetDateTime(); privatemessageinfo.Message = "恭喜您,您的" + config.Spacename + "已经被管理员" + username + "开通!"; privatemessageinfo.Subject = "恭喜,您的" + config.Spacename + "已经开通"; privatemessageinfo.Msgfrom = username; privatemessageinfo.Msgfromid = userid; privatemessageinfo.New = 1; privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); //AdminDatabase.ExecuteNonQuery("INSERT INTO [" + BaseConfigs.GetTablePrefix + "pms] (msgfrom,msgfromid,msgto,msgtoid,folder,new,subject,postdatetime,message) VALUES ('" + username + "','" + userid + "','" + msgto.Replace("'", "''") + "','" + uid + "','0','1','" + subject + "','" + curdatetime + "','" + message + "')"); //AdminDatabase.ExecuteNonQuery("UPDATE [" + BaseConfigs.GetTablePrefix + "users] SET [newpmcount]=[newpmcount]+1 WHERE [uid] =" + uid); } base.RegisterStartupScript( "PAGE", "window.location.href='space_spaceapplymanage.aspx';"); } else { base.RegisterStartupScript( "", "<script>alert('请选择要开通的空间!');window.location.href='space_spaceapplymanage.aspx';</script>"); } }
/// <summary> /// 发送邮件通知 /// </summary> /// <param name="email">接收人邮箱</param> /// <param name="privatemessageinfo">短消息对象</param> public void SendNotifyEmail(string email, PrivateMessageInfo pm) { string jumpurl = string.Format("http://{0}/usercpshowpm.aspx?pmid={1}", DNTRequest.GetCurrentFullHost(), pm.Pmid); StringBuilder sb_body = new StringBuilder("# 论坛短消息: <a href=\"" + jumpurl + "\" target=\"_blank\">" + pm.Subject + "</a>"); //发送人邮箱 sb_body.AppendFormat("\r\n\r\n{0}\r\n<hr/>", pm.Message); sb_body.AppendFormat("作 者:{0}\r\n", pm.Msgfrom); sb_body.AppendFormat("Email:<a href=\"mailto:{0}\" target=\"_blank\">{0}</a>\r\n", Users.GetShortUserInfo(userid).Email.Trim()); sb_body.AppendFormat("URL:<a href=\"{0}\" target=\"_blank\">{0}</a>\r\n", jumpurl); sb_body.AppendFormat("时 间:{0}", pm.Postdatetime); Emails.SendEmailNotify(email, "[" + config.Forumtitle + "短消息通知]" + pm.Subject, sb_body.ToString()); }
/// <summary> /// 创建短消息 /// </summary> /// <param name="__privatemessageinfo">短消息内容</param> /// <param name="savetosentbox">设置短消息是否在发件箱保留(0为不保留, 1为保留)</param> /// <returns>短消息在数据库中的pmid</returns> public int CreatePrivateMessage(PrivateMessageInfo privateMessageInfo, int saveToSentBox) { DbParameter[] parms = { DbHelper.MakeInParam("@pmid",(DbType)SqlDbType.Int,4,privateMessageInfo.Pmid), DbHelper.MakeInParam("@msgfrom",(DbType)SqlDbType.NVarChar,20,privateMessageInfo.Msgfrom), DbHelper.MakeInParam("@msgfromid",(DbType)SqlDbType.Int,4,privateMessageInfo.Msgfromid), DbHelper.MakeInParam("@msgto",(DbType)SqlDbType.NVarChar,20,privateMessageInfo.Msgto), DbHelper.MakeInParam("@msgtoid",(DbType)SqlDbType.Int,4,privateMessageInfo.Msgtoid), DbHelper.MakeInParam("@folder",(DbType)SqlDbType.SmallInt,2,privateMessageInfo.Folder), DbHelper.MakeInParam("@new",(DbType)SqlDbType.Int,4,privateMessageInfo.New), DbHelper.MakeInParam("@subject",(DbType)SqlDbType.NVarChar,80,privateMessageInfo.Subject), DbHelper.MakeInParam("@postdatetime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(privateMessageInfo.Postdatetime)), DbHelper.MakeInParam("@message",(DbType)SqlDbType.NText,0,privateMessageInfo.Message), DbHelper.MakeInParam("@savetosentbox",(DbType)SqlDbType.Int,4,saveToSentBox) }; return TypeConverter.ObjectToInt( DbHelper.ExecuteScalar(CommandType.StoredProcedure, string.Format("{0}createpm", BaseConfigs.GetTablePrefix), parms), -1); }
private void MessagePost(DataRow dr, string operationName, string subjecttype, string reason) { int posterid = Utils.StrToInt(dr["posterid"], -1); if (posterid == -1) //是游客,管理操作就不发短消息了 return; string titlemsg = ""; switch (operation) { case "delete": titlemsg = "ID:" + dr["tid"].ToString(); break; case "banpost": titlemsg = GetOperatePostUrl(int.Parse(dr["tid"].ToString()), "[点击进入被屏蔽的帖子所在主题]"); break; case "delposts": titlemsg = GetOperatePostUrl(int.Parse(dr["tid"].ToString()), "[点击进入被删除的帖子所在主题]"); break; default: titlemsg = GetOperatePostUrl(int.Parse(dr["tid"].ToString()), dr["title"].ToString().Trim()); break; } PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo(); // 收件箱 privatemessageinfo.Message = Utils.HtmlEncode(string.Format( "这是由论坛系统自动发送的通知短消息。\r\n以下您所发表的{7}被 {0} {1} 执行 {2} 操作。\r\n\r\n{7}: {3} \r\n发表时间: {4}\r\n所在论坛: {5}\r\n操作理由: {6}\r\n\r\n如果您对本管理操作有异议,请与我取得联系。", Utils.RemoveHtml(this.usergroupinfo.Grouptitle), username, operationName, titlemsg, dr["postdatetime"].ToString(), this.forumname, reason, subjecttype)); privatemessageinfo.Subject = Utils.HtmlEncode(string.Format("您发表的{0}被执行管理操作", subjecttype)); privatemessageinfo.Msgto = dr["poster"].ToString(); privatemessageinfo.Msgtoid = posterid; privatemessageinfo.Msgfrom = username; privatemessageinfo.Msgfromid = userid; privatemessageinfo.New = 1; privatemessageinfo.Postdatetime = Utils.GetDateTime(); privatemessageinfo.Folder = 0; PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0); }
/// <summary> /// 创建短消息 /// </summary> /// <param name="__privatemessageinfo">短消息内容</param> /// <param name="savetosentbox">设置短消息是否在发件箱保留(0为不保留, 1为保留)</param> /// <returns>短消息在数据库中的pmid</returns> public int CreatePrivateMessage(PrivateMessageInfo __privatemessageinfo, int savetosentbox) { IDataParameter[] prams = { DbHelper.MakeInParam("@pmid",(DbType)SqlDbType.Int,4,__privatemessageinfo.Pmid), DbHelper.MakeInParam("@msgfrom",(DbType)SqlDbType.NVarChar,20,__privatemessageinfo.Msgfrom), DbHelper.MakeInParam("@msgfromid",(DbType)SqlDbType.Int,4,__privatemessageinfo.Msgfromid), DbHelper.MakeInParam("@msgto",(DbType)SqlDbType.NVarChar,20,__privatemessageinfo.Msgto), DbHelper.MakeInParam("@msgtoid",(DbType)SqlDbType.Int,4,__privatemessageinfo.Msgtoid), DbHelper.MakeInParam("@folder",(DbType)SqlDbType.SmallInt,2,__privatemessageinfo.Folder), DbHelper.MakeInParam("@new",(DbType)SqlDbType.Int,4,__privatemessageinfo.New), DbHelper.MakeInParam("@subject",(DbType)SqlDbType.NVarChar,80,__privatemessageinfo.Subject), DbHelper.MakeInParam("@postdatetime",(DbType)SqlDbType.DateTime,8,DateTime.Parse(__privatemessageinfo.Postdatetime)), DbHelper.MakeInParam("@message",(DbType)SqlDbType.NText,0,__privatemessageinfo.Message), DbHelper.MakeInParam("@savetosentbox",(DbType)SqlDbType.Int,4,savetosentbox) }; return Utils.StrToInt(DbHelper.ExecuteScalar(CommandType.StoredProcedure, BaseConfigs.GetTablePrefix + "createpm", prams).ToString(), -1); }
private void BatchSendSM_Click(object sender, EventArgs e) { #region ��������Ϣ���� if (this.CheckCookie()) { string groupidlist = Usergroups.GetSelectString(","); if (groupidlist == "") { base.RegisterStartupScript("", "<script>alert('������ѡȡ��ص��û���,�ٵ���ύ��ť');</script>"); return; } #if EntLib if (RabbitMQConfigs.GetConfig() != null && RabbitMQConfigs.GetConfig().SendShortMsg.Enable)//������errlog������־��¼����ʱ { PrivateMessageInfo pm = new PrivateMessageInfo() { Msgfrom = username.Replace("'", "''"), Msgfromid = userid, Folder = int.Parse(folder.SelectedValue), Subject = subject.Text, Postdatetime = Discuz.Common.Utils.GetDateTime(),//��ȡ������Ϣ��ϵͳʱ�� Message = message.Text, New = 1//���Ϊδ�� }; Discuz.EntLib.ServiceBus.SendShortMsgClientHelper.GetSendShortMsgClient().AsyncSendShortMsgByUserGroup(groupidlist, pm); } #else int percount = Discuz.Common.Utils.StrToInt(postcountpercircle.Text, 100); //ÿ���ټ�¼Ϊһ�εȴ� int count = 0; //��ǰ��¼�� //foreach (DataRow dr in DbHelper.ExecuteDataset("SELECT [uid] ,[username] From [" + BaseConfigs.GetTablePrefix + "users] WHERE [groupid] IN(" + groupidlist + ")").Tables[0].Rows) foreach (DataRow dr in Users.GetUserListByGroupidList(groupidlist).Rows) { //DbHelper.ExecuteNonQuery("INSERT INTO [" + BaseConfigs.GetTablePrefix + "pms] (msgfrom,msgfromid,msgto,msgtoid,folder,new,subject,postdatetime,message) VALUES ('" + this.username.Replace("'", "''") + "','" + this.userid.ToString() + "','" + dr["username"].ToString().Replace("'", "''") + "','" + dr["uid"].ToString() + "','" + folder.SelectedValue + "','1','" + subject.Text + "','" + postdatetime.Text + "','" + message.Text + "')"); //DbHelper.ExecuteNonQuery("UPDATE [" + BaseConfigs.GetTablePrefix + "users] SET [newpmcount]=[newpmcount]+1 WHERE [uid] =" + dr["uid"].ToString()); //Discuz.Data.DatabaseProvider.GetInstance().SendPMToUser(username.Replace("'", "''"), userid, dr["username"].ToString().Replace("'", "''"), Convert.ToInt32(dr["uid"].ToString()), int.Parse(folder.SelectedValue), subject.Text, Convert.ToDateTime(postdatetime.Text), message.Text); PrivateMessageInfo pm = new PrivateMessageInfo(); pm.Msgfrom = username.Replace("'", "''"); pm.Msgfromid = userid; pm.Msgto = dr["username"].ToString().Replace("'", "''"); pm.Msgtoid = Convert.ToInt32(dr["uid"].ToString()); pm.Folder = int.Parse(folder.SelectedValue); pm.Subject = subject.Text; pm.Postdatetime = postdatetime.Text; pm.Message = message.Text; pm.New = 1;//���Ϊδ�� PrivateMessages.CreatePrivateMessage(pm, 0); if (count >= percount) { Thread.Sleep(500); count = 0; } count++; } #endif base.RegisterStartupScript("PAGE", "window.location.href='global_sendSMtogroup.aspx';"); } #endregion }