protected void SubmitButton_Click(object sender, EventArgs e)
        {
            SendMessageInfo sendMessage = new SendMessageInfo();

            sendMessage.Title      = this.Title.Text;
            sendMessage.Content    = this.Content.Text;
            sendMessage.Date       = RequestHelper.DateNow;
            sendMessage.ToUserID   = RequestHelper.GetIntsForm("UserIDList");
            sendMessage.ToUserName = RequestHelper.GetForm <string>("UserNameList");
            sendMessage.UserID     = 0;
            sendMessage.UserName   = string.Empty;
            sendMessage.IsAdmin    = 1;
            base.CheckAdminPower("AddSendMessage", PowerCheckType.Single);
            int id = SendMessageBLL.AddSendMessage(sendMessage);

            string[] strArray  = sendMessage.ToUserID.Split(new char[] { ',' });
            string[] strArray2 = sendMessage.ToUserName.Split(new char[] { ',' });
            for (int i = 0; i < strArray.Length; i++)
            {
                ReceiveMessageInfo receiveMessage = new ReceiveMessageInfo();
                receiveMessage.Title        = sendMessage.Title;
                receiveMessage.Content      = sendMessage.Content;
                receiveMessage.Date         = sendMessage.Date;
                receiveMessage.IsRead       = 0;
                receiveMessage.IsAdmin      = 1;
                receiveMessage.FromUserID   = 0;
                receiveMessage.FromUserName = string.Empty;
                receiveMessage.UserID       = Convert.ToInt32(strArray[i]);
                receiveMessage.UserName     = strArray2[i];
                ReceiveMessageBLL.AddReceiveMessage(receiveMessage);
            }
            AdminLogBLL.AddAdminLog(ShopLanguage.ReadLanguage("AddRecord"), ShopLanguage.ReadLanguage("SendMessage"), id);
            AdminBasePage.Alert(ShopLanguage.ReadLanguage("AddOK"), RequestHelper.RawUrl);
        }
Exemple #2
0
        private void GetDistributorsByNames(IList <string> distributorIds, string productIds)
        {
            string productNameByProductIds = "";
            int    sumcount = 0;

            if (!string.IsNullOrEmpty(productIds))
            {
                productNameByProductIds = ProductHelper.GetProductNameByProductIds(productIds, out sumcount);
                IList <Distributor>        list               = new List <Distributor>();
                IList <SendMessageInfo>    sendMessageList    = new List <SendMessageInfo>();
                IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>();
                IList <int> userids = new List <int>();
                foreach (string str2 in distributorIds)
                {
                    userids.Add(Convert.ToInt32(str2));
                }
                foreach (Distributor distributor in NoticeHelper.GetDistributorsByNames(userids))
                {
                    SendMessageInfo    item  = new SendMessageInfo();
                    ReceiveMessageInfo info2 = new ReceiveMessageInfo();
                    item.Addressee      = info2.Addressee = distributor.Username;
                    item.Addresser      = info2.Addresser = "admin";
                    item.Title          = info2.Title = "供应商转移了" + sumcount + "个商品的产品线";
                    item.PublishContent = info2.PublishContent = "尊敬各位分销商,有如下商品已被供应商转移了产品线:" + productNameByProductIds;
                    sendMessageList.Add(item);
                    receiveMessageList.Add(info2);
                }
                if (sendMessageList.Count > 0)
                {
                    NoticeHelper.SendMessage(sendMessageList, receiveMessageList);
                }
            }
        }
Exemple #3
0
        /// <summary> A special version of SendMessage which can send multiple values to target function. You must send
        /// exact value types in the order the target function expects them to be. This will grab the first function from
        /// each component with the given name so be sure to use unique names else use the 2nd variation of this function. </summary>
        public void SendMessage(string functionName, params object[] values)
        {
            SendMessageInfo sendMessageInfo = null;

            if (!this.sendMessageCache.TryGetValue(functionName, out sendMessageInfo))
            {
                sendMessageInfo = new SendMessageInfo();
                this.sendMessageCache.Add(functionName, sendMessageInfo);
                Component[] components = base.gameObject.GetComponents <Component>();
                Debug.Log(components.Length);
                for (int i = 0; i < components.Length; i++)
                {
                    MethodInfo method = components[i].GetType().GetMethod(functionName, BindingFlags.Instance | BindingFlags.Public);
                    if (method != null)
                    {
                        sendMessageInfo.mi.Add(new BloxMemberInfo(method, null));
                        sendMessageInfo.target.Add(components[i]);
                    }
                }
            }
            for (int j = 0; j < sendMessageInfo.target.Count; j++)
            {
                sendMessageInfo.mi[j].Invoke(sendMessageInfo.target[j], values);
            }
        }
Exemple #4
0
        protected override void PageLoad()
        {
            base.PageLoad();
            int queryString = RequestHelper.GetQueryString <int>("ID");

            this.sendMessage = SendMessageBLL.ReadSendMessage(queryString, base.UserID);
        }
        protected void btnReplyReplyReceivedMessages_Click(object sender, EventArgs e)
        {
            SendMessageInfo    target = new SendMessageInfo();
            ReceiveMessageInfo receivedMessageToAdminInfo = SubsiteCommentsHelper.GetReceivedMessageToAdminInfo(this.receiveMessageId);

            target.Title            = this.txtReplyTitle.Text;
            target.PublishContent   = this.txtContes.Text.Trim();
            target.ReceiveMessageId = new long?(this.receiveMessageId);
            target.Addresser        = HiContext.Current.User.Username;
            target.Addressee        = receivedMessageToAdminInfo.Addresser;
            ValidationResults results = Hishop.Components.Validation.Validation.Validate <SendMessageInfo>(target, new string[] { "ValSendMessage" });
            string            msg     = string.Empty;

            if (!results.IsValid)
            {
                foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                {
                    msg = msg + Formatter.FormatErrorMessage(result.Message);
                }
                this.ShowMsg(msg, false);
            }
            else if (SubsiteCommentsHelper.ReplyMessageToAdmin(target))
            {
                this.ShowMsg("成功回复客户消息", true);
                this.BindReplyReceivedMessages();
                this.txtReplyTitle.Text = string.Empty;
                this.txtContes.Text     = string.Empty;
            }
            else
            {
                this.ShowMsg("回复客户消息失败", false);
            }
        }
Exemple #6
0
        protected void btnReplyReplyReceivedMessages_Click(object sender, EventArgs e)
        {
            SendMessageInfo    target         = new SendMessageInfo();
            ReceiveMessageInfo receiveMessage = NoticeHelper.GetReceiveMessage(receiveMessageId);

            target.Title            = txtTitle.Text;
            target.PublishContent   = txtContes.Text;
            target.ReceiveMessageId = new long?(receiveMessageId);
            target.Addresser        = "admin";
            target.Addressee        = receiveMessage.Addresser;
            ValidationResults results = Hishop.Components.Validation.Validation.Validate <SendMessageInfo>(target, new string[] { "ValSendMessage" });
            string            msg     = string.Empty;

            if (!results.IsValid)
            {
                foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                {
                    msg = msg + Formatter.FormatErrorMessage(result.Message);
                }
                ShowMsg(msg, false);
            }
            else if (NoticeHelper.ReplyMessage(target))
            {
                txtTitle.Text  = "";
                txtContes.Text = "";
                ShowMsg("成功回复客户消息", true);
                BindReplyReceivedMessages();
                txtTitle.Text  = string.Empty;
                txtContes.Text = string.Empty;
            }
            else
            {
                ShowMsg("回复客户消息失败", false);
            }
        }
Exemple #7
0
        void btnReplyReceivedMessage_Click(object sender, EventArgs e)
        {
            string str = "";

            if (string.IsNullOrEmpty(this.txtReplyTitle.Text) || (this.txtReplyTitle.Text.Length > 60))
            {
                str = str + Formatter.FormatErrorMessage("标题不能为空,长度限制在1-60个字符内");
            }
            if (string.IsNullOrEmpty(this.txtReplyContent.Text) || (this.txtReplyContent.Text.Length > 300))
            {
                str = str + Formatter.FormatErrorMessage("内容不能为空,长度限制在1-300个字符内");
            }
            if (!string.IsNullOrEmpty(str))
            {
                this.ShowMessage(str, false);
            }
            else
            {
                SendMessageInfo reply = new SendMessageInfo();
                reply.Addresser        = HiContext.Current.User.Username;
                reply.Addressee        = CommentsHelper.GetReceiveMessage(this.receiveMessageId).Addresser;
                reply.Title            = this.txtReplyTitle.Text;
                reply.PublishContent   = this.txtReplyContent.Text;
                reply.PublishDate      = DateTime.Now;
                reply.ReceiveMessageId = new long?(this.receiveMessageId);
                if (CommentsHelper.ReplyMessage(reply))
                {
                    this.ShowMessage("回复成功", true);
                }
                else
                {
                    this.ShowMessage("回复失败", false);
                }
            }
        }
Exemple #8
0
        private void GetDistributorsByNames(Dictionary <int, IList <string> > distributorIds)
        {
            IList <Distributor>        list               = new List <Distributor>();
            IList <SendMessageInfo>    sendMessageList    = new List <SendMessageInfo>();
            IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>();
            IList <int> userids = new List <int>();

            foreach (int num in distributorIds.Keys)
            {
                userids.Add(num);
            }
            foreach (Distributor distributor in NoticeHelper.GetDistributorsByNames(userids))
            {
                int            count = distributorIds[distributor.UserId].Count;
                IList <string> list5 = distributorIds[distributor.UserId];
                string         str   = "尊敬各位分销商,有如下商品已被取消铺货: ";
                foreach (string str2 in list5)
                {
                    str = str + str2 + " ";
                }
                SendMessageInfo    item  = new SendMessageInfo();
                ReceiveMessageInfo info2 = new ReceiveMessageInfo();
                item.Addressee      = info2.Addressee = distributor.Username;
                item.Addresser      = info2.Addresser = "admin";
                item.Title          = info2.Title = "取消了" + count + "个商品的铺货";
                item.PublishContent = info2.PublishContent = str;
                sendMessageList.Add(item);
                receiveMessageList.Add(info2);
            }
            if (sendMessageList.Count > 0)
            {
                NoticeHelper.SendMessage(sendMessageList, receiveMessageList);
            }
        }
Exemple #9
0
 public void UpdateSendMessage(SendMessageInfo sendMessage)
 {
     SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@title", SqlDbType.NVarChar), new SqlParameter("@content", SqlDbType.NText) };
     pt[0].Value = sendMessage.ID;
     pt[1].Value = sendMessage.Title;
     pt[2].Value = sendMessage.Content;
     ShopMssqlHelper.ExecuteNonQuery(ShopMssqlHelper.TablePrefix + "UpdateSendMessage", pt);
 }
        public ActionResult SendTextMessage()
        {
            var MessageInfo = new SendMessageInfo();

            MessageInfo.RecieverAddress = "*****@*****.**";
            MessageInfo.RecieverName    = "David Cashion";

            return(View(MessageInfo));  //Returns the MessageInfo to the SendTextMessage view
        }
Exemple #11
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected override void PageLoad()
        {
            base.PageLoad();
            user          = UserBLL.ReadUserMore(base.UserID);
            userGradeName = UserGradeBLL.ReadUserGradeCache(base.GradeID).Name;

            int id = RequestHelper.GetQueryString <int>("ID");

            sendMessage = SendMessageBLL.ReadSendMessage(id, base.UserID);
        }
        public bool SendMessage(Message message, IntPtr option)
        {
            var info = new SendMessageInfo
            {
                Option = option,
            };

            ((IPlugin)this).GetPluginId(out info.Product, out info.ID);

            return(NativeMethods.MQ_SendMessage((int)message, ref info));
        }
Exemple #13
0
        public override bool InsertSendMessage(SendMessageInfo message)
        {
            DbCommand sqlStringCommand = database.GetSqlStringCommand("Insert into Hishop_SendedMessages(Addresser,Addressee,Title,PublishContent,PublishDate,ReceiveMessageId) values(@Addresser,@Addressee,@Title,@PublishContent,@PublishDate,@ReceiveMessageId)");

            database.AddInParameter(sqlStringCommand, "Addresser", DbType.String, message.Addresser);
            database.AddInParameter(sqlStringCommand, "Addressee", DbType.String, message.Addressee);
            database.AddInParameter(sqlStringCommand, "Title", DbType.String, message.Title);
            database.AddInParameter(sqlStringCommand, "PublishContent", DbType.String, message.PublishContent);
            database.AddInParameter(sqlStringCommand, "PublishDate", DbType.DateTime, DateTime.Now);
            database.AddInParameter(sqlStringCommand, "ReceiveMessageId", DbType.Int64, message.ReceiveMessageId);
            return(database.ExecuteNonQuery(sqlStringCommand) > 0);
        }
Exemple #14
0
        /// <summary>
        /// 发送微信文本消息
        /// </summary>
        /// <param name="wxid"></param>
        /// <param name="content"></param>
        public static void SendWechatMessage(string wxid, string content)
        {
            int    size     = Marshal.SizeOf <SendMessageInfo>();
            IntPtr pAddress = Marshal.AllocHGlobal(size);
            var    message  = new SendMessageInfo();

            message.wxid    = wxid;
            message.content = content;
            Marshal.StructureToPtr(message, pAddress, false);
            SendWechatHelper(WM_SendTextMessage, pAddress, size);
            Marshal.FreeHGlobal(pAddress);
        }
Exemple #15
0
 public int AddSendMessage(SendMessageInfo sendMessage)
 {
     SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@title", SqlDbType.NVarChar), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@date", SqlDbType.DateTime), new SqlParameter("@toUserID", SqlDbType.NText), new SqlParameter("@toUserName", SqlDbType.NText), new SqlParameter("@userID", SqlDbType.Int), new SqlParameter("@userName", SqlDbType.NVarChar), new SqlParameter("@isAdmin", SqlDbType.Int) };
     pt[0].Value = sendMessage.Title;
     pt[1].Value = sendMessage.Content;
     pt[2].Value = sendMessage.Date;
     pt[3].Value = sendMessage.ToUserID;
     pt[4].Value = sendMessage.ToUserName;
     pt[5].Value = sendMessage.UserID;
     pt[6].Value = sendMessage.UserName;
     pt[7].Value = sendMessage.IsAdmin;
     return(Convert.ToInt32(ShopMssqlHelper.ExecuteScalar(ShopMssqlHelper.TablePrefix + "AddSendMessage", pt)));
 }
Exemple #16
0
        public override bool InsertSendMessage(SendMessageInfo message)
        {
            Distributor user             = Users.GetUser(HiContext.Current.SiteSettings.UserId.Value, false) as Distributor;
            DbCommand   sqlStringCommand = database.GetSqlStringCommand("Insert into distro_SendedMessages(Addresser,Addressee,Title,PublishContent,PublishDate,ReceiveMessageId) values(@Addresser,@Addressee,@Title,@PublishContent,@PublishDate,@ReceiveMessageId)");

            database.AddInParameter(sqlStringCommand, "Addresser", DbType.String, message.Addresser);
            database.AddInParameter(sqlStringCommand, "Addressee", DbType.String, user.Username);
            database.AddInParameter(sqlStringCommand, "Title", DbType.String, message.Title);
            database.AddInParameter(sqlStringCommand, "PublishContent", DbType.String, message.PublishContent);
            database.AddInParameter(sqlStringCommand, "PublishDate", DbType.DateTime, DateTime.Now);
            database.AddInParameter(sqlStringCommand, "ReceiveMessageId", DbType.Int64, message.ReceiveMessageId);
            return(database.ExecuteNonQuery(sqlStringCommand) > 0);
        }
Exemple #17
0
        void BindSendMessage()
        {
            if (string.IsNullOrEmpty(this.Page.Request.QueryString["SendMessageId"]))
            {
                base.GotoResourceNotFound();
            }
            SendMessageInfo sendedMessage = CommentsHelper.GetSendedMessage(long.Parse(this.Page.Request.QueryString["SendMessageId"]));

            this.litAddresser.Text = HiContext.Current.User.Username;
            this.litTitle.Text     = sendedMessage.Title;
            this.litDate.Time      = sendedMessage.PublishDate;
            this.litContent.Text   = sendedMessage.PublishContent;
        }
Exemple #18
0
        public override SendMessageInfo GetSendedMessage(long sendMessageId)
        {
            SendMessageInfo info             = null;
            DbCommand       sqlStringCommand = database.GetSqlStringCommand("SELECT * FROM Hishop_SendedMessages WHERE SendMessageId=@SendMessageId");

            database.AddInParameter(sqlStringCommand, "SendMessageId", DbType.Int64, sendMessageId);
            using (IDataReader reader = database.ExecuteReader(sqlStringCommand))
            {
                if (reader.Read())
                {
                    info = DataMapper.PopulateSendMessage(reader);
                }
            }
            return(info);
        }
Exemple #19
0
        /// <summary>
        /// 返送短信
        /// </summary>
        protected void SendUserMessage()
        {
            string result       = string.Empty;
            string userIDList   = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("UserIDList"));
            string userNameList = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("UserNameList"));
            string title        = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Title"));
            string content      = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Content"));

            if (userNameList == string.Empty || title == string.Empty || content == string.Empty)
            {
                result = "请填写完整的信息";
            }
            else
            {
                //添加发件箱
                SendMessageInfo sendMessage = new SendMessageInfo();
                sendMessage.Title      = title;
                sendMessage.Content    = content;
                sendMessage.Date       = RequestHelper.DateNow;
                sendMessage.ToUserID   = userIDList;
                sendMessage.ToUserName = userNameList;
                sendMessage.UserID     = base.UserID;
                sendMessage.UserName   = base.UserName;
                sendMessage.IsAdmin    = (int)BoolType.False;
                SendMessageBLL.AddSendMessage(sendMessage);
                //添加收件箱
                string[] userIDArray   = userIDList.Split(',');
                string[] userNameArray = userNameList.Split(',');
                for (int i = 0; i < userIDArray.Length; i++)
                {
                    ReceiveMessageInfo receiveMessage = new ReceiveMessageInfo();
                    receiveMessage.Title        = title;
                    receiveMessage.Content      = content;
                    receiveMessage.Date         = RequestHelper.DateNow;
                    receiveMessage.IsRead       = (int)BoolType.False;
                    receiveMessage.IsAdmin      = (int)BoolType.False;
                    receiveMessage.FromUserID   = base.UserID;
                    receiveMessage.FromUserName = base.UserName;
                    receiveMessage.UserID       = Convert.ToInt32(userIDArray[i]);
                    receiveMessage.UserName     = userNameArray[i];
                    ReceiveMessageBLL.AddReceiveMessage(receiveMessage);
                }
            }
            ResponseHelper.Write(result);
            ResponseHelper.End();
        }
Exemple #20
0
 public void PrepareSendMessageModel(SqlDataReader dr, List <SendMessageInfo> sendMessageList)
 {
     while (dr.Read())
     {
         SendMessageInfo item = new SendMessageInfo();
         item.ID         = dr.GetInt32(0);
         item.Title      = dr[1].ToString();
         item.Content    = dr[2].ToString();
         item.Date       = dr.GetDateTime(3);
         item.ToUserID   = dr[4].ToString();
         item.ToUserName = dr[5].ToString();
         item.UserID     = dr.GetInt32(6);
         item.UserName   = dr[7].ToString();
         item.IsAdmin    = dr.GetInt32(8);
         sendMessageList.Add(item);
     }
 }
Exemple #21
0
        protected void SendUserMessage()
        {
            string content = string.Empty;
            string str2    = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("UserIDList"));
            string str3    = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("UserNameList"));
            string str4    = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Title"));
            string str5    = StringHelper.AddSafe(RequestHelper.GetQueryString <string>("Content"));

            if (((str3 == string.Empty) || (str4 == string.Empty)) || (str5 == string.Empty))
            {
                content = "请填写完整的信息";
            }
            else
            {
                SendMessageInfo sendMessage = new SendMessageInfo();
                sendMessage.Title      = str4;
                sendMessage.Content    = str5;
                sendMessage.Date       = RequestHelper.DateNow;
                sendMessage.ToUserID   = str2;
                sendMessage.ToUserName = str3;
                sendMessage.UserID     = base.UserID;
                sendMessage.UserName   = base.UserName;
                sendMessage.IsAdmin    = 0;
                SendMessageBLL.AddSendMessage(sendMessage);
                string[] strArray  = str2.Split(new char[] { ',' });
                string[] strArray2 = str3.Split(new char[] { ',' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    ReceiveMessageInfo receiveMessage = new ReceiveMessageInfo();
                    receiveMessage.Title        = str4;
                    receiveMessage.Content      = str5;
                    receiveMessage.Date         = RequestHelper.DateNow;
                    receiveMessage.IsRead       = 0;
                    receiveMessage.IsAdmin      = 0;
                    receiveMessage.FromUserID   = base.UserID;
                    receiveMessage.FromUserName = base.UserName;
                    receiveMessage.UserID       = Convert.ToInt32(strArray[i]);
                    receiveMessage.UserName     = strArray2[i];
                    ReceiveMessageBLL.AddReceiveMessage(receiveMessage);
                }
            }
            ResponseHelper.Write(content);
            ResponseHelper.End();
        }
        public static bool ReplyMessageToAdmin(SendMessageInfo reply)
        {
            IList <SendMessageInfo>    sendMessageList    = new List <SendMessageInfo>();
            IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>();
            ReceiveMessageInfo         item = new ReceiveMessageInfo();

            item.Addressee      = reply.Addressee;
            item.Addresser      = reply.Addresser;
            item.Title          = reply.Title;
            item.PublishContent = reply.PublishContent;
            item.PublishDate    = DateTime.Now;
            sendMessageList.Add(reply);
            receiveMessageList.Add(item);
            if (SendMessageToAdmin(sendMessageList, receiveMessageList) > 0)
            {
                SubsiteCommentsProvider.Instance().PostMessageToAdminLastTime(reply.ReceiveMessageId.Value, item.PublishDate);
            }
            return(true);
        }
        private void SendLoop()
        {
            while (this.isActive)
            {
                SendMessageInfo msg = this.sendQueue.Take();

                try
                {
                    if (this.socket.Poll(Timeout.Infinite, SelectMode.SelectWrite))
                    {
                        this.socket.SendTo(msg.Buffer, 0, msg.Buffer.Length, SocketFlags.None, msg.Recipient);
                    }
                }
                catch (Exception e)
                {
                    this.Logger.WriteError("Error in loop while sending: " + e.Message);
                    Thread.Sleep(1);
                }
            }
        }
Exemple #24
0
        void btnRefer_Click(object sender, EventArgs e)
        {
            string str = "";

            if (string.IsNullOrEmpty(this.txtTitle.Text) || (this.txtTitle.Text.Length > 60))
            {
                str = str + Formatter.FormatErrorMessage("标题不能为空,长度限制在1-60个字符内");
            }
            if (string.IsNullOrEmpty(this.txtContent.Text) || (this.txtContent.Text.Length > 300))
            {
                str = str + Formatter.FormatErrorMessage("内容不能为空,长度限制在1-300个字符内");
            }
            if (!string.IsNullOrEmpty(str))
            {
                this.ShowMessage(str, false);
            }
            else
            {
                IList <SendMessageInfo>    sendMessageList    = new List <SendMessageInfo>();
                IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>();
                SendMessageInfo            item  = new SendMessageInfo();
                ReceiveMessageInfo         info2 = new ReceiveMessageInfo();
                item.Addresser      = info2.Addresser = HiContext.Current.User.Username;
                item.Addressee      = info2.Addressee = "admin";
                item.Title          = info2.Title = this.txtTitle.Text.Replace("~", "");
                item.PublishContent = info2.PublishContent = this.txtContent.Text.Replace("~", "");
                sendMessageList.Add(item);
                receiveMessageList.Add(info2);
                this.txtTitle.Text   = string.Empty;
                this.txtContent.Text = string.Empty;
                if (CommentsHelper.SendMessage(sendMessageList, receiveMessageList) > 0)
                {
                    this.ShowMessage("发送信息成功", true);
                }
                else
                {
                    this.ShowMessage("发送信息失败", true);
                }
            }
        }
Exemple #25
0
        public async Task <ResponseInfo> SendMessage(SendMessageInfo messageInfo, CancellationTokenSource cts = null)
        {
            if (_client != null)
            {
                if (!_localCts.IsValueCreated)
                {
                    _localCts.Value = cts ?? new CancellationTokenSource(Timeout.Infinite);
                }
                try
                {
                    var response = await _client.SendMessageAsync(messageInfo, deadline : DateTime.UtcNow.AddSeconds(10), cancellationToken : _localCts.Value.Token);

                    return(response);
                }
                catch (Exception ex)
                {
                    HandleException(ex);
                }
                return(null);
            }
            throw (new GrpcException(GrpcErrorCode.NullClient));
        }
 private void btnRefer_Click(object sender, EventArgs e)
 {
     if (this.ValidateValues())
     {
         string             str            = this.txtTitle.Text.Trim();
         string             str2           = this.txtContent.Text.Trim();
         SendMessageInfo    message        = new SendMessageInfo();
         ReceiveMessageInfo receiveMessage = new ReceiveMessageInfo();
         message.Addressee      = receiveMessage.Addressee = "admin";
         message.Addresser      = receiveMessage.Addresser = HiContext.Current.User.Username;
         message.Title          = receiveMessage.Title = str;
         message.PublishContent = receiveMessage.PublishContent = str2;
         if (!SubsiteCommentsHelper.InsertSendMessageToAdmin(message, receiveMessage))
         {
             this.ShowMsg("发送失败", false);
         }
         else
         {
             this.ShowMsg("发送成功", true);
         }
     }
 }
Exemple #27
0
        /// <summary>
        /// 提交数据
        /// </summary>
        protected override void PostBack()
        {
            int id = RequestHelper.GetForm <int>("ID");

            receiveMessage = ReceiveMessageBLL.ReadReceiveMessage(id, base.UserID);
            if (receiveMessage.ID > 0 && receiveMessage.IsAdmin == (int)BoolType.False)
            {
                // 发送信息
                SendMessageInfo sendMessage = new SendMessageInfo();
                sendMessage.Title      = "回复:" + receiveMessage.Title;
                sendMessage.Content    = StringHelper.AddSafe(RequestHelper.GetForm <string>("Content"));
                sendMessage.Date       = RequestHelper.DateNow;
                sendMessage.ToUserID   = receiveMessage.FromUserID.ToString();
                sendMessage.ToUserName = receiveMessage.FromUserName;
                sendMessage.UserID     = base.UserID;
                sendMessage.UserName   = base.UserName;
                sendMessage.IsAdmin    = (int)BoolType.False;
                int sid = SendMessageBLL.AddSendMessage(sendMessage);
                //接受信息
                ReceiveMessageInfo tempReceiveMessage = new ReceiveMessageInfo();
                receiveMessage.ID               = RequestHelper.GetQueryString <int>("ID");
                tempReceiveMessage.Title        = sendMessage.Title;
                tempReceiveMessage.Content      = sendMessage.Content;
                tempReceiveMessage.Date         = sendMessage.Date;
                tempReceiveMessage.IsRead       = (int)BoolType.False;
                tempReceiveMessage.IsAdmin      = (int)BoolType.False;
                tempReceiveMessage.FromUserID   = base.UserID;
                tempReceiveMessage.FromUserName = base.UserName;
                tempReceiveMessage.UserID       = receiveMessage.FromUserID;
                tempReceiveMessage.UserName     = receiveMessage.FromUserName;
                ReceiveMessageBLL.AddReceiveMessage(tempReceiveMessage);
                ScriptHelper.AlertFront("回复成功", "/User/MessageDetail.aspx?ID=" + sid);
            }
            else
            {
                ScriptHelper.AlertFront("出现错误", "/User/ReadMessage.aspx?ID=" + id);
            }
        }
Exemple #28
0
        protected override void PostBack()
        {
            int form = RequestHelper.GetForm <int>("ID");

            this.receiveMessage = ReceiveMessageBLL.ReadReceiveMessage(form, base.UserID);
            if ((this.receiveMessage.ID > 0) && (this.receiveMessage.IsAdmin == 0))
            {
                SendMessageInfo sendMessage = new SendMessageInfo();
                sendMessage.Title      = "回复:" + this.receiveMessage.Title;
                sendMessage.Content    = StringHelper.AddSafe(RequestHelper.GetForm <string>("Content"));
                sendMessage.Date       = RequestHelper.DateNow;
                sendMessage.ToUserID   = this.receiveMessage.FromUserID.ToString();
                sendMessage.ToUserName = this.receiveMessage.FromUserName;
                sendMessage.UserID     = base.UserID;
                sendMessage.UserName   = base.UserName;
                sendMessage.IsAdmin    = 0;
                SendMessageBLL.AddSendMessage(sendMessage);
                ReceiveMessageInfo receiveMessage = new ReceiveMessageInfo();
                this.receiveMessage.ID      = RequestHelper.GetQueryString <int>("ID");
                receiveMessage.Title        = sendMessage.Title;
                receiveMessage.Content      = sendMessage.Content;
                receiveMessage.Date         = sendMessage.Date;
                receiveMessage.IsRead       = 0;
                receiveMessage.IsAdmin      = 0;
                receiveMessage.FromUserID   = base.UserID;
                receiveMessage.FromUserName = base.UserName;
                receiveMessage.UserID       = this.receiveMessage.FromUserID;
                receiveMessage.UserName     = this.receiveMessage.FromUserName;
                ReceiveMessageBLL.AddReceiveMessage(receiveMessage);
                ScriptHelper.Alert("回复成功", "/User/ReadMessage.aspx?ID=" + form);
            }
            else
            {
                ScriptHelper.Alert("出现错误", "/User/ReadMessage.aspx?ID=" + form);
            }
        }
Exemple #29
0
        public SendMessageInfo ReadSendMessage(int id, int userID)
        {
            SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int), new SqlParameter("@userID", SqlDbType.Int) };
            pt[0].Value = id;
            pt[1].Value = userID;
            SendMessageInfo info = new SendMessageInfo();

            using (SqlDataReader reader = ShopMssqlHelper.ExecuteReader(ShopMssqlHelper.TablePrefix + "ReadSendMessage", pt))
            {
                if (reader.Read())
                {
                    info.ID         = reader.GetInt32(0);
                    info.Title      = reader[1].ToString();
                    info.Content    = reader[2].ToString();
                    info.Date       = reader.GetDateTime(3);
                    info.ToUserID   = reader[4].ToString();
                    info.ToUserName = reader[5].ToString();
                    info.UserID     = reader.GetInt32(6);
                    info.UserName   = reader[7].ToString();
                    info.IsAdmin    = reader.GetInt32(8);
                }
            }
            return(info);
        }
        private void btnSendToRank_Click(object sender, EventArgs e)
        {
            IList <Distributor>        list               = new List <Distributor>();
            IList <SendMessageInfo>    sendMessageList    = new List <SendMessageInfo>();
            IList <ReceiveMessageInfo> receiveMessageList = new List <ReceiveMessageInfo>();

            if (rdoName.Checked)
            {
                if (string.IsNullOrEmpty(txtDistributorNames.Text.Trim()))
                {
                    ShowMsg("请输入您要发送的用户", false);
                    return;
                }
                IList <string> names    = new List <string>();
                string[]       strArray = txtDistributorNames.Text.Trim().Replace("\r\n", "\n").Replace("\n", "*").Split(new char[] { '*' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    if (IsMembers(strArray[i]))
                    {
                        names.Add(strArray[i]);
                    }
                }
                foreach (Distributor distributor in NoticeHelper.GetDistributorsByNames(names))
                {
                    SendMessageInfo    item  = new SendMessageInfo();
                    ReceiveMessageInfo info2 = new ReceiveMessageInfo();
                    item.Addressee      = info2.Addressee = distributor.Username;
                    item.Addresser      = info2.Addresser = "admin";
                    item.Title          = info2.Title = MessageTitle;
                    item.PublishContent = info2.PublishContent = Content;
                    sendMessageList.Add(item);
                    receiveMessageList.Add(info2);
                    if (chkIsSendEmail.Checked)
                    {
                        string str;
                        Messenger.SendMail(MessageTitle, Content, distributor.Email, HiContext.Current.SiteSettings, out str);
                    }
                }
                if (sendMessageList.Count <= 0)
                {
                    ShowMsg("没有要发送的对象", false);
                    return;
                }
                NoticeHelper.SendMessage(sendMessageList, receiveMessageList);
                ShowMsg(string.Format("成功给{0}个用户发送了消息.", sendMessageList.Count), true);
            }
            if (rdoRank.Checked)
            {
                foreach (Distributor distributor2 in NoticeHelper.GetDistributorsByRank(rankList.SelectedValue))
                {
                    SendMessageInfo    info3 = new SendMessageInfo();
                    ReceiveMessageInfo info4 = new ReceiveMessageInfo();
                    info3.Addressee      = info4.Addressee = distributor2.Username;
                    info3.Addresser      = info4.Addresser = "admin";
                    info3.Title          = info4.Title = MessageTitle;
                    info3.PublishContent = info4.PublishContent = Content;
                    sendMessageList.Add(info3);
                    receiveMessageList.Add(info4);
                    if (chkIsSendEmail.Checked)
                    {
                        string str2;
                        Messenger.SendMail(MessageTitle, Content, distributor2.Email, HiContext.Current.SiteSettings, out str2);
                    }
                }
                if (sendMessageList.Count > 0)
                {
                    NoticeHelper.SendMessage(sendMessageList, receiveMessageList);
                    ShowMsg(string.Format("成功给{0}个用户发送了消息.", sendMessageList.Count), true);
                }
                else
                {
                    ShowMsg("没有要发送的对象", false);
                }
            }
        }