Example #1
0
        private static string textMsg(string text, int MessageId)
        {
            JObject jObject = new JObject();

            jObject.Add("text", text);
            WeiboHelper.UpdateMessage(new MessageInfo
            {
                SenderDate    = System.DateTime.Now,
                SenderMessage = text,
                Status        = 2,
                MessageId     = MessageId
            });
            return(jObject.ToString());
        }
Example #2
0
        private static string textMsg(string text, int MessageId)
        {
            JObject obj2 = new JObject();

            obj2.Add("text", (JToken)text);
            MessageInfo messageInfo = new MessageInfo {
                SenderDate    = DateTime.Now,
                SenderMessage = text,
                Status        = 2,
                MessageId     = MessageId
            };

            WeiboHelper.UpdateMessage(messageInfo);
            return(obj2.ToString());
        }
Example #3
0
        private static string articleMsg(string display_name, string summary, string image, string url, string ArticleId, int MessageId)
        {
            JObject obj2 = new JObject();
            string  str  = "[";

            if (summary == "")
            {
                summary = display_name;
            }
            string str3 = str;

            str = str3 + "{'display_name':'" + display_name + "','summary':'" + summary + "','image':'" + image + "','url':'" + url + "'},";
            if (!string.IsNullOrEmpty(ArticleId) && (int.Parse(ArticleId) > 0))
            {
                IList <ArticleItemsInfo> articleItems = ArticleHelper.GetArticleItems(int.Parse(ArticleId));
                if (articleItems.Count > 0)
                {
                    foreach (ArticleItemsInfo info in articleItems)
                    {
                        string title = "";
                        if (info.Content.Trim() == "")
                        {
                            title = info.Title;
                        }
                        string str4 = str;
                        str = str4 + "{\"display_name\": \"" + info.Title + "\",\"summary\":\"" + title + "\",\"image\":\"http://" + Globals.DomainName + info.ImageUrl + "\",\"url\":\"" + info.Url + "\"},";
                    }
                }
            }
            MessageInfo messageInfo = new MessageInfo {
                SenderDate  = DateTime.Now,
                DisplayName = display_name,
                Summary     = summary,
                Image       = image,
                Url         = url,
                ArticleId   = int.Parse(ArticleId),
                Status      = 2,
                MessageId   = MessageId
            };

            WeiboHelper.UpdateMessage(messageInfo);
            str = str.Substring(0, str.Length - 1) + "]";
            obj2.Add("articles", (JToken)str);
            return(obj2.ToString());
        }
Example #4
0
        public void sendmessage(HttpContext context)
        {
            global::ControlPanel.WeiBo.WeiBo bo = new global::ControlPanel.WeiBo.WeiBo();
            string  type        = context.Request["msgtype"];
            string  str2        = context.Request["SenderId"];
            string  s           = context.Request["MessageId"];
            string  msgtype     = context.Request["msgtype"];
            string  displayname = context.Request["displayname"];
            string  summary     = context.Request["summary"];
            string  image       = context.Request["image"];
            string  url         = context.Request["url"];
            string  content     = context.Request["Content"];
            string  articleId   = context.Request["ArticleId"];
            string  data        = this.SendToUIDMessage(msgtype, displayname, summary, image, url, content, articleId);
            string  json        = bo.sendmessage(type, str2, data);
            JObject obj2        = JObject.Parse(json);

            if ((obj2["result"] != null) && (obj2["result"].ToString() == "true"))
            {
                MessageInfo messageInfo = new MessageInfo();
                if (!string.IsNullOrEmpty(articleId))
                {
                    messageInfo.ArticleId = int.Parse(articleId);
                }
                messageInfo.DisplayName   = displayname;
                messageInfo.Summary       = summary;
                messageInfo.SenderMessage = content;
                messageInfo.Url           = url;
                messageInfo.Image         = image;
                messageInfo.SenderDate    = DateTime.Now;
                messageInfo.MessageId     = int.Parse(s);
                messageInfo.Status        = 1;
                WeiboHelper.UpdateMessage(messageInfo);
            }
            context.Response.Write(json);
        }
Example #5
0
        public void sendmessage(System.Web.HttpContext context)
        {
            WeiBo   weiBo       = new WeiBo();
            string  type        = context.Request["msgtype"];
            string  receiver_id = context.Request["SenderId"];
            string  s           = context.Request["MessageId"];
            string  msgtype     = context.Request["msgtype"];
            string  text        = context.Request["displayname"];
            string  summary     = context.Request["summary"];
            string  image       = context.Request["image"];
            string  url         = context.Request["url"];
            string  text2       = context.Request["Content"];
            string  text3       = context.Request["ArticleId"];
            string  data        = this.SendToUIDMessage(msgtype, text, summary, image, url, text2, text3);
            string  text4       = weiBo.sendmessage(type, receiver_id, data);
            JObject jObject     = JObject.Parse(text4);

            if (jObject["result"] != null && jObject["result"].ToString() == "true")
            {
                MessageInfo messageInfo = new MessageInfo();
                if (!string.IsNullOrEmpty(text3))
                {
                    messageInfo.ArticleId = int.Parse(text3);
                }
                messageInfo.DisplayName   = text;
                messageInfo.Summary       = summary;
                messageInfo.SenderMessage = text2;
                messageInfo.Url           = url;
                messageInfo.Image         = image;
                messageInfo.SenderDate    = System.DateTime.Now;
                messageInfo.MessageId     = int.Parse(s);
                messageInfo.Status        = 1;
                WeiboHelper.UpdateMessage(messageInfo);
            }
            context.Response.Write(text4);
        }
Example #6
0
        private static string articleMsg(string display_name, string summary, string image, string url, string ArticleId, int MessageId)
        {
            new JObject();
            string text = "[";

            if (summary == "")
            {
                summary = display_name;
            }
            string text2 = text;

            text = string.Concat(new string[]
            {
                text2,
                "{\"display_name\":\"",
                Globals.String2Json(display_name),
                "\",\"summary\":\"",
                Globals.String2Json(summary),
                "\",\"image\":\"",
                image,
                "\",\"url\":\"",
                url,
                "\"},"
            });
            if (!string.IsNullOrEmpty(ArticleId) && int.Parse(ArticleId) > 0)
            {
                System.Collections.Generic.IList <ArticleItemsInfo> articleItems = ArticleHelper.GetArticleItems(int.Parse(ArticleId));
                if (articleItems.Count > 0)
                {
                    foreach (ArticleItemsInfo current in articleItems)
                    {
                        string s = "";
                        if (current.Content.Trim() == "")
                        {
                            s = current.Title;
                        }
                        string text3 = text;
                        text = string.Concat(new string[]
                        {
                            text3,
                            "{\"display_name\": \"",
                            Globals.String2Json(current.Title),
                            "\",\"summary\":\"",
                            Globals.String2Json(s),
                            "\",\"image\":\"http://",
                            Globals.DomainName,
                            current.ImageUrl,
                            "\",\"url\":\"",
                            current.Url,
                            "\"},"
                        });
                    }
                }
            }
            WeiboHelper.UpdateMessage(new MessageInfo
            {
                SenderDate  = System.DateTime.Now,
                DisplayName = display_name,
                Summary     = summary,
                Image       = image,
                Url         = url,
                ArticleId   = int.Parse(ArticleId),
                Status      = 2,
                MessageId   = MessageId
            });
            text  = text.Substring(0, text.Length - 1);
            text += "]";
            return("{\"articles\":" + text.ToString() + "}");
        }