Пример #1
0
        public static string OfflineMessage(string username)
        {
            NetTalk.BLL.Message          MsgApi  = new NetTalk.BLL.Message();
            List <NetTalk.DAL.TbMessage> MsgList = MsgApi.ListOffline(username);

            if (MsgList.Count > 0)
            {
                string result = "";
                foreach (NetTalk.DAL.TbMessage msg in MsgList)
                {
                    result += Create(msg.TbUsers1.Username, username, msg.MessageText, msg.MessageHTML, msg.MessageDate);
                }
                return(result);
            }
            else
            {
                return(string.Empty);
            }
        }
Пример #2
0
        public static void SendMessage(string fromuser, Message msg)
        {
            string text = null, html = null;

            if (msg.Html != null)
            {
                if (msg.Html.Body != null)
                {
                    if (!string.IsNullOrEmpty(msg.Html.Body.InnerHtml))
                    {
                        html = msg.Html.Body.InnerHtml;
                    }
                }
            }

            if (!string.IsNullOrEmpty(msg.Body))
            {
                text = msg.Body;
            }

            int cindex = -1;

            if (msg.To != null)
            {
                ThreadTools.Users.Online.IsAuthenticated(msg.To.User, out cindex);
            }

            if (cindex > -1)
            {
                ThreadTools.Users.Online[cindex].Send(msg);
            }

            if (!string.IsNullOrEmpty(text))
            {
                int findex;
                ThreadTools.Users.Online.IsAuthenticated(fromuser, out findex);

                NetTalk.BLL.Message api = new NetTalk.BLL.Message();
                api.Insert(fromuser, msg.To.User, text, html, ThreadTools.Users.Online[findex].IPAddress, (cindex > -1));
            }
        }