コード例 #1
0
        private void SendPM()
        {
            MembershipUser currentUser = Membership.GetUser(_username);

            if (currentUser == null || currentUser.ProviderUserKey == null)
            {
                return;
            }

            string[] toMembers = Regex.Split(newTo.Text, ";");
            foreach (string member in toMembers)
            {
                ProfileCommon  profile   = ProfileCommon.GetUserProfile(member);
                MembershipUser recipient = Membership.GetUser(member, false);
                if (recipient != null && recipient.ProviderUserKey != null)
                {
                    var pm = new PrivateMessageInfo
                    {
                        FromMemberId = (int)currentUser.ProviderUserKey,
                        Read         = 0,
                        Subject      = newSubject.Text,
                        Message      = newMessage.Text,
                        OutBox       = _layout != "none" ? 1 : 0,
                        SentDate     = DateTime.UtcNow.ToForumDateStr(),
                        ToMemberId   = (int)recipient.ProviderUserKey,
                        Mail         = profile.PMEmail == null ? 0 : profile.PMEmail.Value
                    };

                    Snitz.BLL.PrivateMessages.SendPrivateMessage(pm);
                }
            }
            //TODO: Send notify if required
            statusTxt.Text     = Resources.PrivateMessage.PmSent;
            pnlMessage.Visible = false;
        }
コード例 #2
0
ファイル: PrivateMessages.cs プロジェクト: object8421/ichari
        /// <summary>
        /// 获得指定用户的短信息列表
        /// </summary>
        /// <param name="userid">用户ID</param>
        /// <param name="folder">短信息类型(0:收件箱,1:发件箱,2:草稿箱)</param>
        /// <param name="pagesize">每页显示短信息数</param>
        /// <param name="pageindex">当前要显示的页数</param>
        /// <param name="strwhere">筛选条件</param>
        /// <returns>短信息列表</returns>
        public static Discuz.Common.Generic.List <PrivateMessageInfo> GetPrivateMessageCollection(int userid, int folder, int pagesize, int pageindex, int inttype)
        {
            Discuz.Common.Generic.List <PrivateMessageInfo> coll = new Discuz.Common.Generic.List <PrivateMessageInfo>();
            IDataReader reader = DatabaseProvider.GetInstance().GetPrivateMessageList(userid, folder, pagesize, pageindex, inttype);

            if (reader != null)
            {
                while (reader.Read())
                {
                    PrivateMessageInfo info = new PrivateMessageInfo();
                    info.Pmid         = int.Parse(reader["pmid"].ToString());
                    info.Msgfrom      = reader["msgfrom"].ToString();
                    info.Msgfromid    = int.Parse(reader["msgfromid"].ToString());
                    info.Msgto        = reader["msgto"].ToString();
                    info.Msgtoid      = int.Parse(reader["msgtoid"].ToString());
                    info.Folder       = Int16.Parse(reader["folder"].ToString());
                    info.New          = int.Parse(reader["new"].ToString());
                    info.Subject      = reader["subject"].ToString();
                    info.Postdatetime = reader["postdatetime"].ToString();
                    info.Message      = reader["message"].ToString();
                    coll.Add(info);
                }
                reader.Close();
            }
            return(coll);
        }
コード例 #3
0
        private void DisplayMessage(PrivateMessageInfo pm)
        {
            MemberInfo    member = Snitz.BLL.Members.GetMember(pm.FromMemberName);
            ProfileCommon prof   = ProfileCommon.GetUserProfile(pm.FromMemberName);

            if (prof.Gravatar)
            {
                Gravatar avatar = new Gravatar {
                    Email = member.Email
                };
                if (member.AvatarUrl != "")
                {
                    avatar.DefaultImage = member.AvatarUrl;
                }
                phAvatar.Controls.Add(avatar);
            }
            else
            {
                Literal avatar = new Literal {
                    Text = member.AvatarUrl
                };
                phAvatar.Controls.Add(avatar);
            }
            pmRecipients.Text = pm.Subject;
            pmSubject.Visible = false;
            pmFrom.Text       = String.Format("<a href=\"/Account/profile.aspx?user={0}\">{0}</a>", pm.FromMemberName);

            pmTitle.Text     = member.Title;
            pmCountry.Text   = member.Country;
            pmPostcount.Text = member.PostCount.ToString();
            pmDate.Text      = pm.Sent.ToString();

            pmBody.Text             = pm.Message.ParseTags();
            PMViews.ActiveViewIndex = 2;
        }
コード例 #4
0
        protected void btnSend_Click(object sender, EventArgs eventArgs)
        {
            MembershipUser currentUser = Membership.GetUser(username);

            if (currentUser == null || currentUser.ProviderUserKey == null)
            {
                return;
            }

            string[] toMembers = Regex.Split(tbxRecipient.Text, ";");
            foreach (string member in toMembers)
            {
                ProfileCommon  profile   = ProfileCommon.GetUserProfile(member);
                MembershipUser recipient = Membership.GetUser(member, false);
                if (recipient != null && recipient.ProviderUserKey != null)
                {
                    var pm = new PrivateMessageInfo
                    {
                        FromMemberId = (int)currentUser.ProviderUserKey,
                        Read         = 0,
                        Subject      = tbxSubject.Text,
                        Message      = qrMessage.Text,
                        OutBox       = _layout != "none" ? 1 : 0,
                        SentDate     = DateTime.UtcNow.ToForumDateStr(),
                        ToMemberId   = (int)recipient.ProviderUserKey,
                        Mail         = profile.PMEmail == null ? 0 : profile.PMEmail.Value
                    };

                    Snitz.BLL.PrivateMessages.SendPrivateMessage(pm);
                }
            }
            //TODO: Send notify if required
            pmSuccess.Text = Resources.PrivateMessage.PmSent;
            ScriptManager.RegisterStartupScript(this, GetType(), "Startup", _redirectionScript, true);
        }
コード例 #5
0
        /// <summary>创建用户</summary>
        public static UserInfo CreateUser(this HttpContextBase context, GeneralConfigInfo config, IPKSPrincipal principal, bool isAdmin)
        {
            var userInfo = CreateUser(config, principal, isAdmin);

            #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 = userInfo.Joindate;
                privatemessageinfo.Folder       = 0;
                PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0);
            }
            #endregion
            //发送同步数据给应用程序
            Sync.UserRegister(userInfo.Uid, userInfo.Username, userInfo.Password, "");
            //SetUrl("index.aspx");
            //SetShowBackLink(false);
            //SetMetaRefresh(config.Regverify == 0 ? 2 : 5);
            Statistics.ReSetStatisticsCache();
            //if (inviteCode != null)
            //{
            //    Invitation.UpdateInviteCodeSuccessCount(inviteCode.InviteId);
            //    if (config.Regstatus == 3)
            //    {
            //        if (inviteCode.SuccessCount + 1 >= inviteCode.MaxCount)
            //            Invitation.DeleteInviteCode(inviteCode.InviteId);
            //    }
            //}
            var oluserinfo = OnlineUsers.UpdateInfo(config.Passwordkey, config.Onlinetimeout);
            if (config.Regverify == 0)
            {
                UserCredits.UpdateUserCredits(userInfo.Uid);
                //ForumUtils.WriteUserCookie(user, -1, config.Passwordkey);
                OnlineUsers.UpdateAction(oluserinfo.Olid, UserAction.Register.ActionID, 0, config.Onlinetimeout);
                //MsgForward("register_succeed");
                //AddMsgLine("注册成功, 返回登录页");
            }
            else
            {
                if (config.Regverify == 1)
                {
                    //AddMsgLine("注册成功, 请您到您的邮箱中点击激活链接来激活您的帐号");
                }
                else if (config.Regverify == 2)
                {
                    //AddMsgLine("注册成功, 但需要系统管理员审核您的帐户后才可登录使用");
                }
            }
            //ManyouApplications.AddUserLog(userInfo.Uid, UserLogActionEnum.Add);
            return(userInfo);
        }
コード例 #6
0
        public string SendPrivateMessage(string touser, string message, string subject, string layout)
        {
            string         username    = HttpContext.Current.User.Identity.Name;
            MembershipUser currentUser = Membership.GetUser(username);
            ProfileCommon  profile     = ProfileCommon.GetUserProfile(username);

            if (currentUser == null || currentUser.ProviderUserKey == null)
            {
                return(null);
            }

            var pm = new PrivateMessageInfo
            {
                Subject      = subject,
                Message      = message,
                ToMemberId   = Convert.ToInt32(touser),
                FromMemberId = (int)currentUser.ProviderUserKey,
                Read         = 0,
                OutBox       = layout != "none" ? 1 : 0,
                SentDate     = DateTime.UtcNow.ToForumDateStr(),
                Mail         = profile.PMEmail == null ? 0 : profile.PMEmail.Value
            };

            PrivateMessages.SendPrivateMessage(pm);

            //do we need to send an email
            MembershipUser toUser = Membership.GetUser(Convert.ToInt32(touser));

            if (toUser != null && Config.UseEmail)
            {
                ProfileCommon toprofile = ProfileCommon.GetUserProfile(toUser.UserName);
                if (toprofile.PMEmail.HasValue)
                {
                    if (toprofile.PMEmail.Value == 1)
                    {
                        SnitzEmail notification = new SnitzEmail
                        {
                            FromUser = "******",
                            toUser   = new MailAddress(toUser.Email),
                            subject  = Regex.Replace(Config.ForumTitle, @"&\w+;", "") + " - New Private message"
                        };
                        string strMessage = "Hello " + toUser.UserName;
                        strMessage = strMessage + username + " has sent you a private message at " + Config.ForumTitle + "." + Environment.NewLine;
                        if (String.IsNullOrEmpty(subject))
                        {
                            strMessage = strMessage + "Regarding - " + subject + "." + Environment.NewLine + Environment.NewLine;
                        }
                        else
                        {
                            strMessage = strMessage + "With the subject entitled - " + message + "." + Environment.NewLine + Environment.NewLine;
                        }

                        notification.msgBody = strMessage;
                        notification.Send();
                    }
                }
            }
            return(PrivateMessage.PmSent);
        }
コード例 #7
0
        public void Delete(PrivateMessageInfo pm)
        {
            string strSql = "DELETE FROM " + Config.ForumTablePrefix + "PM WHERE M_ID=@PmId";

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, new OleDbParameter("@PmId", OleDbType.Integer)
            {
                Value = pm.Id
            });
        }
コード例 #8
0
        public static void RemoveFromOutBox(int currentPmId)
        {
            IPrivateMessage dal = Factory <IPrivateMessage> .Create("PrivateMessage");

            PrivateMessageInfo pm = GetMessage(currentPmId);

            pm.OutBox = 0;
            dal.Update(pm);
        }
コード例 #9
0
        protected override void ShowPage()
        {
            pagetitle = "撰写短消息";

            if (!IsLogin())
            {
                return;
            }

            if (!CheckPermission())
            {
                return;
            }

            if (DNTRequest.IsPost() && !ForumUtils.IsCrossSitePost())
            {
                if (!CheckPermissionAfterPost())
                {
                    return;
                }

                SendPM();
                if (IsErr())
                {
                    return;
                }
            }

            ShortUserInfo shortUserInfo = Users.GetShortUserInfo(msgtoid);
            string        msttoName     = (shortUserInfo != null) ? shortUserInfo.Username : "";

            msgto = msgtoid > 0 ? msttoName : msgto;

            string action = DNTRequest.GetQueryString("action").ToLower();

            if (action.CompareTo("re") == 0 || action.CompareTo("fw") == 0) //回复或者转发
            {
                if (DNTRequest.GetQueryInt("pmid", -1) != -1)
                {
                    PrivateMessageInfo pm = PrivateMessages.GetPrivateMessageInfo(DNTRequest.GetQueryInt("pmid", -1));
                    if (pm != null && (pm.Msgtoid == userid || pm.Msgfromid == userid))
                    {
                        msgto   = action.CompareTo("re") == 0 ? Utils.HtmlEncode(pm.Msgfrom) : "";
                        subject = Utils.HtmlEncode(action) + ":" + pm.Subject;
                        message = Utils.HtmlEncode("> ") + pm.Message.Replace("\n", "\n> ") + "\r\n\r\n";
                    }
                }
            }

            if (DNTRequest.GetString("operation") == "pmfriend")
            {
                CreatePmFriendMessage();
            }

            newnoticecount = Notices.GetNewNoticeCountByUid(userid);
        }
コード例 #10
0
        /// <summary>
        /// 获得指定ID的短消息的内容
        /// </summary>
        /// <param name="pmid">短消息pmid</param>
        /// <returns>短消息内容</returns>
        public static PrivateMessageInfo GetPrivateMessageInfo(int pmid)
        {
            PrivateMessageInfo privatemessageinfo = null;
            IDataReader        reader             = DatabaseProvider.GetInstance().GetPrivateMessageInfo(pmid);

            if (reader.Read())
            {
                privatemessageinfo = LoadSinglePrivateMessage(reader);
            }

            reader.Close();
            return(privatemessageinfo);
        }
コード例 #11
0
        /// <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());
        }
コード例 #12
0
        protected void ViewMessage(object sender, EventArgs e)
        {
            LinkButton         lnk = (LinkButton)sender;
            PrivateMessageInfo pm  = Snitz.BLL.PrivateMessages.GetMessage(Convert.ToInt32(lnk.CommandArgument));

            DisplayMessage(pm);
            ButtonReply.CommandArgument      = lnk.CommandArgument;
            ButtonReplyQuote.CommandArgument = lnk.CommandArgument;
            ButtonForward.CommandArgument    = lnk.CommandArgument;
            ButtonDelete.CommandArgument     = lnk.CommandArgument;

            SetButtonDisplay();
        }
コード例 #13
0
        protected void ButtonForward_Click(object sender, ImageClickEventArgs e)
        {
            PrivateMessageInfo pm = Snitz.BLL.PrivateMessages.GetMessage(CurrentMessageId);

            pnlMessage.Visible = true;
            dummy.Text         = String.Empty;
            dummy.Visible      = false;
            SetButtonDisplay();
            newTo.Text         = "";
            newTo.Enabled      = true;
            newMessage.Text    = Resources.PrivateMessage.PmForwardedMessage + Environment.NewLine + pm.Message;
            newSubject.Text    = Resources.PrivateMessage.PmViewFwd + pm.Subject;
            newSubject.Enabled = false;
            lblSubject.Visible = true;
        }
コード例 #14
0
        /// <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);
        }
コード例 #15
0
        /// <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);
        }
コード例 #16
0
        protected void ButtonForward_Click(object sender, ImageClickEventArgs e)
        {
            PmMessage.Visible      = true;
            PmMessage.GroupingText = "Forward Message";
            ImageButton        lnk = (ImageButton)sender;
            PrivateMessageInfo pm  = Snitz.BLL.PrivateMessages.GetMessage(Convert.ToInt32(lnk.CommandArgument));

            //DisplayMessage(pm);
            PMViews.ActiveViewIndex = 1;
            SetButtonDisplay();
            tbxRecipient.Text    = "";
            tbxRecipient.Enabled = true;
            qrMessage.Text       = Resources.PrivateMessage.PmForwardedMessage + Environment.NewLine + pm.Message;
            tbxSubject.Text      = Resources.PrivateMessage.PmViewFwd + pm.Subject;
            tbxSubject.Enabled   = false;
            lblSubject.Visible   = true;
            PMControls.Visible   = false;
        }
コード例 #17
0
        public PrivateMessageInfo GetById(int id)
        {
            PrivateMessageInfo pm     = new PrivateMessageInfo();
            string             strSql = "UPDATE " + Config.ForumTablePrefix + "PM SET M_READ=M_READ+1 WHERE M_ID=@MessageId; " +
                                        pmSelect + "WHERE M_ID=@MessageId";

            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnString, CommandType.Text, strSql, new SqlParameter("@MessageId", SqlDbType.Int)
            {
                Value = id
            }))
            {
                while (rdr.Read())
                {
                    pm = BoHelper.CopyPrivateMessageToBO(rdr);
                }
            }
            return(pm);
        }
コード例 #18
0
        protected void ViewSentMessage(object sender, EventArgs e)
        {
            var lnk = (LinkButton)sender;
            PrivateMessageInfo pm = Snitz.BLL.PrivateMessages.GetMessage(Convert.ToInt32(lnk.CommandArgument));

            pm.FromMember = Snitz.BLL.Members.GetMember(pm.FromMemberId);

            if (pm.FromMember.ProfileData != null && pm.FromMember.ProfileData.Gravatar == 1)
            {
                string avatar = String.Format("{0}/Avatars/{1}", Common.GetSiteRoot(), String.IsNullOrEmpty(pm.FromMember.Avatar) ? "default.gif" : pm.FromMember.Avatar);

                var gravatar = new Gravatar {
                    Email = pm.FromMember.Email
                };
                if (avatar != "")
                {
                    gravatar.DefaultImage = avatar;
                }
                phAvatar.Controls.Add(gravatar);
            }
            else
            {
                var avatar = new Literal {
                    Text = pm.FromMember.AvatarUrl
                };
                phAvatar.Controls.Add(avatar);
            }
            PMViews.ActiveViewIndex = 2;
            pmRecipients.Text       = "To: " + pm.ToMemberName;
            pmFrom.Text             = String.Format("<a href=\"/Account/profile.aspx?user={0}\">{0}</a>", pm.FromMemberName);
            pmTitle.Text            = pm.FromMember.Title;
            pmCountry.Text          = pm.FromMember.Country;
            pmPostcount.Text        = pm.FromMember.PostCount.ToString();
            pmDate.Text             = SnitzTime.TimeAgoTag(pm.Sent, true, pm.FromMember);
            pmSubject.Visible       = true;
            pmSubject.Text          = pm.Subject;
            pmBody.Text             = pm.Message.ParseTags();
            SetButtonDisplay();
            ButtonReply.Visible      = false;
            ButtonReplyQuote.Visible = false;
            ButtonForward.Visible    = false;
            ButtonDelete.Visible     = false;
        }
コード例 #19
0
        public void Update(PrivateMessageInfo message)
        {
            string strSql = "UPDATE " + Config.ForumTablePrefix + "PM SET M_SUBJECT=@Subject,M_FROM=@FromUser,M_TO=@ToUser,M_SENT=@SentDate,M_MESSAGE=@Message,M_READ=M_READ+1,M_MAIL=@Email,M_OUTBOX=@Outbox " +
                            "WHERE M_ID=@PmId";
            List <OleDbParameter> parms = new List <OleDbParameter>
            {
                new OleDbParameter("@PmId", OleDbType.Integer)
                {
                    Value = message.Id
                },
                new OleDbParameter("@Subject", OleDbType.VarChar)
                {
                    Value = message.Subject
                },
                new OleDbParameter("@FromUser", OleDbType.Integer)
                {
                    Value = message.FromMemberId
                },
                new OleDbParameter("@ToUser", OleDbType.Integer)
                {
                    Value = message.ToMemberId
                },
                new OleDbParameter("@SentDate", OleDbType.VarChar)
                {
                    Value = message.SentDate
                },
                new OleDbParameter("@Message", OleDbType.VarChar)
                {
                    Value = message.Message
                },
                new OleDbParameter("@Email", OleDbType.VarChar)
                {
                    Value = message.Mail
                },
                new OleDbParameter("@Outbox", OleDbType.Integer)
                {
                    Value = message.OutBox
                }
            };

            SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray());
        }
コード例 #20
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            if (cmbPMRecipients.SelectedIndex == -1)
            {
                lbChatMessages.Items.Add("No player selected!");
                MessageColors.Add(Color.White);
                return;
            }

            if (String.IsNullOrEmpty(tbChatMessage.Text))
            {
                lbChatMessages.Items.Add("Type your message into the field next to the Send button.");
                MessageColors.Add(Color.White);
                return;
            }

            string recipient = cmbPMRecipients.Items[cmbPMRecipients.SelectedIndex].ToString();
            CnCNetData.ConnectionBridge.SendChatMessage(recipient, -1, tbChatMessage.Text);
            lbChatMessages.Items.Add("[" + DateTime.Now.ToShortTimeString() + "] " + ProgramConstants.CNCNET_PLAYERNAME + ": " + tbChatMessage.Text);
            MessageColors.Add(lbChatMessages.ForeColor);

            lbChatMessages.SelectedIndex = lbChatMessages.Items.Count - 1;
            lbChatMessages.SelectedIndex = -1;

            int index = CnCNetData.PMInfos.FindIndex(c => c.UserName == recipient);

            if (index == -1)
            {
                PrivateMessageInfo pmInfo = new PrivateMessageInfo();
                pmInfo.UserName = recipient;
                pmInfo.Messages.Add(new MessageInfo(lbChatMessages.ForeColor, tbChatMessage.Text));
                pmInfo.IsSelfSent.Add(true);
                CnCNetData.PMInfos.Add(pmInfo);
            }
            else
            {
                CnCNetData.PMInfos[index].Messages.Add(new MessageInfo(lbChatMessages.ForeColor, tbChatMessage.Text));
                CnCNetData.PMInfos[index].IsSelfSent.Add(true);
            }

            tbChatMessage.Text = "";
        }
コード例 #21
0
        protected void gvDNTMessage_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                PrivateMessageInfo pm = e.Row.DataItem as PrivateMessageInfo;

                Literal   ltrlNew         = e.Row.FindControl("ltrlNew") as Literal;
                Label     lblPostdatetime = e.Row.FindControl("lblPostdatetime") as Label;
                HyperLink hlShowPM        = e.Row.FindControl("hlShowPM") as HyperLink;

                if (pm.New == 1)
                {
                    e.Row.CssClass = "SelectedRow";
                }

                if (ltrlNew != null)
                {
                    if (pm.New == 1)
                    {
                        ltrlNew.Text = "<div class=\"ASC_New\" title=\"未读\"></div>";
                    }
                    else if (pm.New == 0)
                    {
                        ltrlNew.Text = "<div class=\"ASC_Old\" title=\"已读\"></div>";
                    }
                    else
                    {
                        ltrlNew.Text = string.Empty;
                    }
                }

                if (lblPostdatetime != null)
                {
                    lblPostdatetime.Text = Convert.ToDateTime(pm.Postdatetime).ToString("yyyy-MM-dd HH:mm:ss");
                }

                if (hlShowPM != null)
                {
                    hlShowPM.NavigateUrl = string.Format("{0}usercpshowpm.aspx?pmid={1}", Request.ApplicationPath, pm.Pmid.ToString());
                }
            }
        }
コード例 #22
0
        /// <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());
        }
コード例 #23
0
ファイル: BOHelper.cs プロジェクト: mfcharaf/SnitzDotNet
        public static PrivateMessageInfo CopyPrivateMessageToBO(SqlDataReader rdr)
        {
            PrivateMessageInfo pm = new PrivateMessageInfo
            {
                Id           = rdr.GetInt32(0),
                Subject      = rdr.SafeGetString(1),
                FromMemberId = rdr.GetInt32(2),
                ToMemberId   = rdr.GetInt32(3),
                SentDate     = rdr.SafeGetString(4),
                Message      = rdr.SafeGetString(5),
                Count        = rdr.SafeGetString(6),
                Read         = rdr.GetInt32(7),
                //Mail = Convert.ToInt32(rdr.SafeGetString(8)),
                OutBox         = rdr.SafeGetInt16(9),
                ToMemberName   = rdr.SafeGetString(10),
                FromMemberName = rdr.SafeGetString(11)
            };

            pm.Sent = pm.SentDate.ToDateTime();
            return(pm);
        }
コード例 #24
0
        public int Add(PrivateMessageInfo message)
        {
            string strSql = "INSERT INTO " + Config.ForumTablePrefix + "PM (M_SUBJECT,M_FROM,M_TO,M_SENT,M_MESSAGE,M_READ,M_MAIL,M_OUTBOX) VALUES " +
                            "(@Subject,@FromUser,@ToUser,@SentDate,@Message,0,@Email,@Outbox)";
            List <OleDbParameter> parms = new List <OleDbParameter>
            {
                new OleDbParameter("@Subject", OleDbType.VarChar)
                {
                    Value = message.Subject
                },
                new OleDbParameter("@FromUser", OleDbType.Integer)
                {
                    Value = message.FromMemberId
                },
                new OleDbParameter("@ToUser", OleDbType.Integer)
                {
                    Value = message.ToMemberId
                },
                new OleDbParameter("@SentDate", OleDbType.VarChar)
                {
                    Value = message.SentDate
                },
                new OleDbParameter("@Message", OleDbType.VarChar)
                {
                    Value = message.Message
                },
                new OleDbParameter("@Email", OleDbType.VarChar)
                {
                    Value = message.Mail
                },
                new OleDbParameter("@Outbox", OleDbType.Integer)
                {
                    Value = message.OutBox
                }
            };

            var res = SqlHelper.ExecuteScalar(SqlHelper.ConnString, CommandType.Text, strSql, parms.ToArray());

            return(Convert.ToInt32(res));
        }
コード例 #25
0
        private void AddNewRec_Click(object sender, EventArgs e)
        {
            #region 添加公共消息

            if (subject.Text == "")
            {
                base.RegisterStartupScript("", GetMessageScript("公共消息标题不能为空"));
                return;
            }
            if (message.Text == "")
            {
                base.RegisterStartupScript("", GetMessageScript("公共消息内容不能为空"));
                return;
            }

            try
            {
                PrivateMessageInfo pm = new PrivateMessageInfo();
                pm.Message      = message.Text;
                pm.Subject      = subject.Text;
                pm.Msgto        = "";
                pm.Msgtoid      = 0;
                pm.Msgfrom      = "";
                pm.Msgfromid    = 0;
                pm.New          = 1;
                pm.Postdatetime = DateTime.Now.ToString();
                PrivateMessages.CreatePrivateMessage(pm, 0);
                BindData();
                DNTCache.GetCacheService().RemoveObject("/Forum/AnnouncePrivateMessageCount");
                base.RegisterStartupScript("PAGE", "window.location.href='global_announceprivatemessage.aspx';");
                return;
            }
            catch
            {
                base.RegisterStartupScript("", GetMessageScript("无法更新数据库."));
                return;
            }

            #endregion
        }
コード例 #26
0
ファイル: Users.cs プロジェクト: xslonglianxia/DiscuzNT
        /// <summary>
        /// 获取指定用户组的用户并向其发送短信息
        /// </summary>
        /// <param name="groupidlist">用户组</param>
        /// <param name="topNumber">获取前N条记录</param>
        /// <param name="start_uid">大于该uid的用户记录</param>
        /// <param name="msgfrom">谁发的短消息</param>
        /// <param name="msguid">发短消息人的UID</param>
        /// <param name="folder">短消息文件夹</param>
        /// <param name="subject">主题</param>
        /// <param name="postdatetime">发送时间</param>
        /// <param name="message">短消息内容</param>
        /// <returns></returns>
        public static int SendPMByGroupidList(string groupidlist, int topnumber, ref int start_uid, string msgfrom, int msguid, int folder, string subject, string postdatetime, string message)
        {
            DataTable dt = Data.Users.GetUserListByGroupid(groupidlist, topnumber, start_uid);

            foreach (DataRow dr in dt.Rows)
            {
                PrivateMessageInfo pm = new PrivateMessageInfo();
                pm.Msgfrom      = msgfrom.Replace("'", "''");
                pm.Msgfromid    = msguid;
                pm.Msgto        = dr["username"].ToString().Replace("'", "''");
                pm.Msgtoid      = Convert.ToInt32(dr["uid"].ToString());
                pm.Folder       = folder;
                pm.Subject      = subject;
                pm.Postdatetime = postdatetime;
                pm.Message      = message;
                pm.New          = 1;//标记为未读
                PrivateMessages.CreatePrivateMessage(pm, 0);

                start_uid = pm.Msgtoid;
            }
            return(dt.Rows.Count);
        }
コード例 #27
0
        public static PrivateMessageInfo CopyPrivateMessageToBO(SqlDataReader rdr)
        {
            //M_ID,M_SUBJECT,M_FROM,M_TO,M_SENT,M_MESSAGE,M_PMCOUNT,M_READ,M_MAIL,M_OUTBOX

            PrivateMessageInfo pm = new PrivateMessageInfo()
            {
                Id             = rdr.GetInt32(0),
                Subject        = rdr.SafeGetString(1),
                FromMemberId   = rdr.GetInt32(2),
                ToMemberId     = rdr.GetInt32(3),
                SentDate       = rdr.SafeGetString(4),
                Message        = rdr.SafeGetString(5),
                Count          = rdr.SafeGetString(6),
                Read           = rdr.GetInt32(7),
                Mail           = rdr.SafeGetString(8),
                OutBox         = rdr.GetInt32(9),
                ToMemberName   = rdr.SafeGetString(10),
                FromMemberName = rdr.SafeGetString(11)
            };

            pm.Sent = pm.SentDate.ToDateTime();
            return(pm);
        }
コード例 #28
0
        private void ShowMessage(string path)
        {
            PrivateMessageInfo pm      = Snitz.BLL.PrivateMessages.GetMessage(CurrentMessageId);
            string             display = "";

            display += "<div class='pm-message-header'><b>" + pm.Subject + "</b><br/>";
            display += String.Format("<a href=\"/Account/profile.aspx?user={0}\">{0}</a>", pm.FromMemberName);
            display += " " + pm.Sent + "</div>";
            display += "<p>" + pm.Message.ParseTags() + "</p>";

            dummy.Text         = display;
            pnlMessage.Visible = false;
            PmOptions.Visible  = false;
            dummy.Visible      = true;

            SetButtonDisplay();
            if (path.Contains("SentItems"))
            {
                ButtonDelMsg.Visible     = false;
                ButtonReply.Visible      = false;
                ButtonReplyQuote.Visible = false;
            }
        }
コード例 #29
0
ファイル: PrivateMessages.cs プロジェクト: object8421/ichari
        /// <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);
        }
コード例 #30
0
        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
        }
コード例 #31
0
        /// <summary>
        /// 发送通知
        /// </summary>
        /// <returns></returns>
        public string Send()
        {
            if (Signature != GetParam("sig").ToString())
            {
                ErrorCode = (int)ErrorType.API_EC_SIGNATURE;
                return("");
            }

            //如果是桌面程序则需要验证用户身份
            if (this.App.ApplicationType == (int)ApplicationType.DESKTOP)
            {
                if (Uid < 1)
                {
                    ErrorCode = (int)ErrorType.API_EC_SESSIONKEY;
                    return("");
                }
            }

            if (CallId <= LastCallId)
            {
                ErrorCode = (int)ErrorType.API_EC_CALLID;
                return("");
            }

            if (!CheckRequiredParams("subject,message,to_ids"))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }
            string ids = GetParam("to_ids").ToString();

            if (!CheckRequiredParams("to_ids") || !Utils.IsNumericArray(ids.Split(',')))
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }

            if ((!CheckRequiredParams("from_id") || !Utils.IsNumeric(GetParam("from_id"))) && Uid < 1)
            {
                ErrorCode = (int)ErrorType.API_EC_PARAM;
                return("");
            }
            int fromId = TypeConverter.ObjectToInt(GetParam("from_id"), Uid);

            string message = UBB.ParseUrl(Utils.EncodeHtml(GetParam("message").ToString()));

            string[] to_ids = ids.Split(',');

            string successfulIds = string.Empty;

            foreach (string id in to_ids)
            {
                if (TypeConverter.StrToInt(id) < 1)
                {
                    continue;
                }
                PrivateMessageInfo pm = new PrivateMessageInfo();
                pm.Folder       = 0;
                pm.Message      = message;
                pm.Msgfrom      = Discuz.Forum.Users.GetShortUserInfo(fromId).Username;
                pm.Msgfromid    = fromId;
                pm.Msgto        = "";//可能需要查询具体的收件人姓名
                pm.Msgtoid      = TypeConverter.StrToInt(id);
                pm.New          = 1;
                pm.Postdatetime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                pm.Subject      = GetParam("subject").ToString();

                successfulIds += (PrivateMessages.CreatePrivateMessage(pm, 0) > 0) ? (id + ",") : "";
            }
            successfulIds = successfulIds.Length > 0 ? successfulIds.Remove(successfulIds.Length - 1) : successfulIds;

            if (Format == FormatType.JSON)
            {
                return(string.Format("\"{0}\"", successfulIds));
            }

            MessageSendResponse nsr = new MessageSendResponse();

            nsr.Result = successfulIds;
            return(SerializationHelper.Serialize(nsr));
        }
コード例 #32
0
        /// <summary>
        /// Executed when someone sends a private message to the user.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="sender">The sender of the message.</param>
        private void Instance_PrivateMessageParsed(string message, string sender)
        {
            if (this.InvokeRequired)
            {
                // Necessary for thread-safety
                PrivateMessageParsedCallback d = new PrivateMessageParsedCallback(Instance_PrivateMessageParsed);
                this.BeginInvoke(d, message, sender);
                return;
            }

            int index = CnCNetData.PMInfos.FindIndex(c => c.UserName == sender);
            if (index == -1)
            {
                // If the isn't in the private conversation list, add the user to it
                PrivateMessageInfo pmInfo = new PrivateMessageInfo();
                pmInfo.UserName = sender;
                pmInfo.Messages.Add(new MessageInfo(cPmOtherUserColor, message));
                pmInfo.IsSelfSent.Add(false);
                CnCNetData.PMInfos.Add(pmInfo);
            }
            else
            {
                // If we've talked with the user before, just add the message itself to the list of messages
                // we've had with that user
                CnCNetData.PMInfos[index].Messages.Add(new MessageInfo(cPmOtherUserColor, message));
                CnCNetData.PMInfos[index].IsSelfSent.Add(false);
            }

            if (!CnCNetData.isPMWindowOpen)
            {
                if (gameInProgress)
                {
                    // If a game is in progress, tell the user that they received a private message
                    // so they are aware of checking it out later
                    MessageInfos[currentChannelId].Add(new MessageInfo(Color.White,
                        "You've received a private message from " + sender));
                    AddChannelMessageToListBox(currentChannelId);
                }
                else
                {
                    // If a game isn't in progress, open the PrivateMessageForm
                    PrivateMessageForm pmWindow = new PrivateMessageForm(cPmOtherUserColor, sender);
                    pmWindow.Show();
                    CnCNetData.isPMWindowOpen = true;
                }
            }
        }
コード例 #33
0
        /// <summary>
        /// Executed when a private message is sent from the PrivateMessageForm.
        /// </summary>
        /// <param name="message">The message.</param>
        /// <param name="receiver">The receiver of the message.</param>
        private void Instance_PrivateMessageSent(string message, string receiver)
        {
            if (this.InvokeRequired)
            {
                // Necessary for thread-safety
                PrivateMessageSentCallback d = new PrivateMessageSentCallback(Instance_PrivateMessageSent);
                this.BeginInvoke(d, message, receiver);
                return;
            }

            int index = CnCNetData.PMInfos.FindIndex(c => c.UserName == receiver);
            if (index == -1)
            {
                PrivateMessageInfo pmInfo = new PrivateMessageInfo();
                pmInfo.UserName = receiver;
                pmInfo.Messages.Add(new MessageInfo(cDefaultChatColor, message));
                pmInfo.IsSelfSent.Add(true);
                CnCNetData.PMInfos.Add(pmInfo);
            }
            else
            {
                CnCNetData.PMInfos[index].Messages.Add(new MessageInfo(cDefaultChatColor, message));
                CnCNetData.PMInfos[index].IsSelfSent.Add(true);
            }

            if (!CnCNetData.isPMWindowOpen)
            {
                PrivateMessageForm pmWindow = new PrivateMessageForm(cDefaultChatColor, receiver);
                pmWindow.Show();
                CnCNetData.isPMWindowOpen = true;
            }

            CnCNetData.ConnectionBridge.SendMessage("PRIVMSG " + receiver + " " + message);
        }