Ejemplo n.º 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string phone;
            string content;

            if (string.IsNullOrEmpty(context.Request.QueryString["MobilePhones"]) ||
                string.IsNullOrEmpty(context.Request.QueryString["Content"]))
            {
                return;
            }
            phone = context.Request.QueryString["MobilePhones"];

            System.Text.Encoding encoding = System.Text.Encoding.GetEncoding("GB18030");

            Type t = context.Request.GetType();
            System.Reflection.PropertyInfo property = t.GetProperty("QueryStringBytes",
                System.Reflection.BindingFlags.Instance
                | System.Reflection.BindingFlags.IgnoreCase | System.Reflection.BindingFlags.NonPublic);
            byte[] queryBytes = (byte[])property.GetValue(context.Request, null);
            string q = HttpUtility.UrlDecode(queryBytes, encoding);

            int conStartIndex = q.IndexOf("&Content=") + 9;
            int conEndIndex = q.IndexOf("&ExNumber=");

            if (conStartIndex < 9 || conEndIndex < 0)
            {
                return;
            }

            content = q.Substring(conStartIndex, conEndIndex - conStartIndex);

            CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.LoadByTel(phone);
            if (ae == null)
            {
                return;
            }

            CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(ae.Id);
            if (account == null)
            {
                return;
            }

            CY.UME.Core.Business.MiniBlog miniBlog =account.PubMiniBlog(content, "");

            //保存miniBlogExtend
            CY.UME.Core.Business.MiniBlogExtend miniBlogExtend = new CY.UME.Core.Business.MiniBlogExtend();

            miniBlogExtend.Id = miniBlog.Id;
            miniBlogExtend.IsPhoneSended = true;
            miniBlogExtend.AccountId = miniBlog.AccountId;
            miniBlogExtend.IsMsgReceived = true;

            miniBlogExtend.Save();

            //发送短信提示
            string identityCode;
            CY.UME.Core.Global.TrySendMessage(phone, account.Name + ",你的状态已更新!", out identityCode);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 添加微博
        /// </summary>
        /// <param name="context"></param>
        /// <returns>0登录失败 -1 请求失败 -2异常错误 </returns>
        public string AddMiniBlog(HttpContext context)
        {
            string email = String.Empty;
            string password = String.Empty;
            string title = String.Empty;
            string content = String.Empty;

            #region validate
            if (context.Request.QueryString["email"] == null
                || context.Request.QueryString["password"] == null
                || context.Request.QueryString["Content"] == null)
            {
                return "-1";
            }

            content = context.Request.QueryString["Content"].ToString();
            email = context.Request.QueryString["email"].ToString();

            CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(email);

            if (ae == null)
            {
                return "0";
            }

            CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(ae.Id);

            if (account == null)
            {
                return "0";
            }

            #endregion

            try
            {
                CY.UME.Core.Business.MiniBlog miniBlog = account.PubMiniBlog(CY.Utility.Common.StringUtility.HTMLEncode(content), String.Empty);

                CY.UME.Core.Business.MiniBlogExtend mbe = new CY.UME.Core.Business.MiniBlogExtend();

                mbe.AccountId = miniBlog.AccountId;
                mbe.Id = miniBlog.Id;
                mbe.IsMsgReceived = true;
                mbe.IsPhoneSended = true;

                mbe.Save();

                return miniBlog.Id.ToString();
            }
            catch
            {
                return "-2";
            }
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            long Id = CY.Utility.Common.ConvertUtility.ConvertToInt(context.Request.QueryString["Id"], -1);
            String content = context.Request.QueryString["Content"].ToString().Trim();
            bool isMsgReceived = true;//邮件是否验证通过

            if (Id == -1)
            {
                context.Response.Write("{success:false,msg:'参数错误:Id=" + context.Request.QueryString["Id"] + "'}");
                return;
            }

            string picture = "";

            if (content.Length == 0)
            {
                context.Response.Write("{success:false,msg:'发表内容不能为空'}");
                return;
            }

            content = CY.Utility.Common.StringUtility.HTMLDecode(content);

            if (context.Request.Form["picture"] != null && context.Request.Form["picture"].ToString().Trim() != "null")
            {
                picture = context.Request.Form["picture"].ToString();
            }
            try
            {
                CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(Id);

                if (account == null)
                {
                    context.Response.Write("{success:false, msg:'用户不存在 Id=" + context.Request.QueryString["Id"] + "'}");
                    return;
                }

                content = Utility.Common.StringUtility.HTMLEncode(content);

                content = Regex.Replace(content, @"(http:\/\/[\w.]+\/?)([^\u4e00-\u9fa5|\u0020]*)", "<a href=\"$1$2\">$1$2</a>", RegexOptions.IgnoreCase | RegexOptions.Multiline);

                CY.UME.Core.Business.MiniBlog miniBlog = account.PubMiniBlog(content, Utility.Common.RequestUtility.ClientIP);

                CY.UME.Core.Business.MiniBlogExtend miniBlogExtend = new CY.UME.Core.Business.MiniBlogExtend();

                miniBlogExtend.IsPhoneSended = false;
                miniBlogExtend.AccountId = miniBlog.AccountId;
                miniBlogExtend.Id = miniBlog.Id;
                miniBlogExtend.IsMsgReceived = isMsgReceived;
                if (!String.IsNullOrEmpty(picture))
                {
                    miniBlogExtend.ImgPath = picture;
                }
                /********************第一天活动**************************/
                if (context.Request.QueryString["mfd"] != null)
                {
                    string isFirstDayParam = context.Request.Form["mfd"].ToString();
                    if (isFirstDayParam == "myfirstday")
                    {
                        miniBlogExtend.ActivityId = "myfirstday";
                    }
                }
                /********************第一天活动结束************************/
                miniBlogExtend.Save();

                context.Response.Write("{success:true,msg:'发布成功'}");
            }
            catch
            {
                context.Response.Write("{success:false,msg:'服务器忙,请稍后再试'}");
            }
        }
Ejemplo n.º 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string strAccountId = String.Empty;
            string content = String.Empty;
            bool isMsgReceived = false;
            string picture = "";
            string video = String.Empty;

            strAccountId = context.Request.Form["accountId"].ToString();
            content = context.Request.Form["content"].ToString().Trim();

            long accountId = 0;

            if (!long.TryParse(strAccountId, out accountId) ||
                context.Request.Form["content"] == null)
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

            if (context.Request.Form["isMsgReceived"] != null)
            {//邮箱是否通过验证
                bool.TryParse(context.Request.Form["isMsgReceived"].ToString(), out isMsgReceived);
            }

            if (content.Length == 0)
            {
                context.Response.Write("{success:false,msg:'发表内容不能为空'}");
                return;
            }
            if (context.Request.Form["picture"] != null && context.Request.Form["picture"].ToString().Trim() != "null")
            {//图片
                picture = context.Request.Form["picture"].ToString();
            }
            if (context.Request.Form["video"] != null && context.Request.Form["video"].ToString().Trim() != "null")
            {//视屏
                video = context.Request.Form["video"].ToString();
            }

            try
            {
                CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(accountId);

                if (account == null)
                {
                    context.Response.Write("{success:false, msg:'用户不存在'}");
                    return;
                }

                content = Utility.Common.StringUtility.HTMLEncode(content);

                CY.UME.Core.Business.MiniBlog miniBlog = account.PubMiniBlog(content, Utility.Common.RequestUtility.ClientIP);

                #region 微博关键字开始
                /**************************************************废除的代码/*************************************************

                content = Regex.Replace(content, @"(http:\/\/[\w.]+\/?)([^\u4e00-\u9fa5|\u0020]*)", "<a href=\"$1$2\">$1$2</a>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
                string Reg = @"#[^#]*#";
                MatchCollection Matches = Regex.Matches(content, Reg);
                //int len = Matches.Count;

                foreach (Match NextMatch in Matches)
                {
                    String KeyWorld = NextMatch.Value.Substring(1, NextMatch.Value.Length - 2);

                    CY.UME.Core.Business.KeyWords keyWords = CY.UME.Core.Business.KeyWords.Load(KeyWorld);

                    if (keyWords == null)
                    {//如果关键字不存在则添加
                        CY.UME.Core.Business.KeyWords kw = new CY.UME.Core.Business.KeyWords();

                        kw.KeyWord = KeyWorld;

                        kw.Save();
                    }
                    else
                    {//存在则计算出现次数
                        CY.UME.Core.Business.KeyWords kw = CY.UME.Core.Business.KeyWords.Load(keyWords.Id);

                        kw.Count += 1;

                        kw.Save();
                    }
                }*/
                 #endregion

                CY.UME.Core.Business.MiniBlogExtend miniBlogExtend = new CY.UME.Core.Business.MiniBlogExtend();

                miniBlogExtend.IsPhoneSended = false;
                miniBlogExtend.AccountId = miniBlog.AccountId;
                miniBlogExtend.Id = miniBlog.Id;
                miniBlogExtend.IsMsgReceived = isMsgReceived;
                if (!String.IsNullOrEmpty(picture))
                {
                    miniBlogExtend.ImgPath = picture;
                }
                if (!String.IsNullOrEmpty(video))
                {
                    miniBlogExtend.Video = video;
                }
                /********************第一天活动**************************/
                if (context.Request.QueryString["mfd"] != null)
                {
                    string isFirstDayParam = context.Request.Form["mfd"].ToString();
                    if (isFirstDayParam == "myfirstday")
                    {
                        miniBlogExtend.ActivityId = "myfirstday";
                    }
                }
                /********************第一天活动结束************************/
                miniBlogExtend.Save();
                CY.UME.Core.PagingInfo pinfo = new CY.UME.Core.PagingInfo();
                pinfo.PageSize = 1;
                pinfo.CurrentPage = 1;
                List<CY.UME.Core.Business.Notice> notice = CY.UME.Core.Business.Notice.GetTopNotice("miniblog", false, pinfo);
                context.Response.Write("{success:true,Id:" + miniBlog.Id + ",DatePublish:'" + miniBlog.DatePublish.ToString("HH:mm tt") + "',AccountId:'" + miniBlog.AccountId + "',NoticeId:'" + notice[0].Id + "'}");
            }
            catch
            {
                context.Response.Write("{success:false,msg:'服务器忙,请稍后再试'}");
            }
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            CY.UME.Core.Business.Account account;
            CY.UME.Core.Business.MiniBlog miniBlog;
            long miniBlogId = 0;
            string content = String.Empty;
            string strReplyedId = String.Empty;

            #region validate
            if (context.Request.Form["MiniBlogId"] == null ||
                !long.TryParse(context.Request.Form["MiniBlogId"].ToString(), out miniBlogId))
            {
                context.Response.Write("{success:false,msg:'操作失败'}");
                return;
            }

            if (context.Request.Form["Content"] != null)
            {
                content = context.Request.Form["Content"].ToString().Trim();
                content = Utility.Common.StringUtility.HTMLEncode(content);
                content = Regex.Replace(content, @"(http:\/\/[\w.]+\/?)([^\u4e00-\u9fa5|\u0020]*)", "<a href=\"$1$2\">$1$2</a>", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            }

            if (context.Request.Form["strReplyedMinBlogId"] != null)
            {
                strReplyedId = context.Request.Form["strReplyedMinBlogId"].ToString().Trim();
            }

            account = CY.UME.Core.Global.GetCurrentAccount();

            if (account == null)
            {
                context.Response.Write("{success:false,msg:'登录超时失败'}");
                return;
            }

            miniBlog = CY.UME.Core.Business.MiniBlog.Load(miniBlogId);

            if (miniBlog == null)
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

            if (account.Id == miniBlog.AccountId)
            {
                context.Response.Write("{success:false,msg:'不能转发自己的博文'}");
                return;
            }

            CY.UME.Core.Business.Account accountRefered = CY.UME.Core.Business.Account.Load(miniBlog.AccountId);

            if (accountRefered == null)
            {
                context.Response.Write("{success:false,msg:'您无法转发该篇博文'}");
                return;
            }

            if (miniBlog.HasTransedByThisAccount(account))
            {
                context.Response.Write("{success:false,msg:'您已经转发过该篇博文'}");
                return;
            }
            #endregion
            try
            {
                CY.UME.Core.Business.MiniBlog newMiniBlog = new CY.UME.Core.Business.MiniBlog();

                newMiniBlog.AccountId = account.Id;
                newMiniBlog.Content = content;
                newMiniBlog.DatePublish = DateTime.Now;
                newMiniBlog.IP = CY.Utility.Common.RequestUtility.ClientIP;

                newMiniBlog.Save();

                string imgPath = String.Empty;
                string flashPath = String.Empty;
                CY.UME.Core.Business.MiniBlogExtend miniBlogExtend = CY.UME.Core.Business.MiniBlogExtend.Load(miniBlog.Id);
                if (miniBlogExtend != null)
                {
                    imgPath = miniBlogExtend.ImgPath;
                    flashPath = miniBlogExtend.Video;
                }

                CY.UME.Core.Business.MiniBlogExtend newMiniBlogExtend = new CY.UME.Core.Business.MiniBlogExtend();

                newMiniBlogExtend.AccountId = newMiniBlog.AccountId;
                newMiniBlogExtend.Id = newMiniBlog.Id;
                newMiniBlogExtend.ImgPath = imgPath;
                newMiniBlogExtend.Video = flashPath;
                newMiniBlogExtend.IsMsgReceived = false;
                newMiniBlogExtend.IsPhoneSended = false;
                newMiniBlogExtend.ReferedId = miniBlog.Id;
                newMiniBlogExtend.ReferedName = accountRefered.Name;
                newMiniBlogExtend.ReferedAuthorId = accountRefered.Id;
                newMiniBlogExtend.TransferedNum = 0;

                newMiniBlogExtend.Save();

                account.SendNoticeToAllFriendAndFollower("miniblog", "转发了一篇微博", newMiniBlog.Id.ToString());

                CY.UME.Core.Business.Notice notice = new CY.UME.Core.Business.Notice();

                notice.AccountId = newMiniBlogExtend.AccountId;
                notice.AuthorId = newMiniBlogExtend.AccountId;
                notice.Content = "转发了一篇微博";
                notice.DateCreated = DateTime.Now;
                notice.InstanceId = newMiniBlogExtend.Id.ToString();
                notice.IsReaded = false;
                notice.Type = "miniblog";
                notice.Save();

                #region Reply
                string strReplyedIdTemp = String.Empty;
                string[] arrReplyedId = strReplyedId.Split(',');

                for (int i = 0; i < arrReplyedId.Length; i++)
                {
                    strReplyedIdTemp = arrReplyedId[i];

                    long replyedId = 0;
                    if (long.TryParse(strReplyedIdTemp, out replyedId))
                    {
                        CY.UME.Core.Business.MiniBlog replyedMiniBlog = CY.UME.Core.Business.MiniBlog.Load(replyedId);

                        if (replyedMiniBlog != null)
                        {
                            CY.UME.Core.Business.MiniBlogComment mbc = new CY.UME.Core.Business.MiniBlogComment();

                            mbc.AccountId = replyedMiniBlog.AccountId;
                            mbc.AuthorId = account.Id;
                            mbc.Content = content;
                            mbc.DateCreated = DateTime.Now;
                            mbc.IP = Utility.Common.RequestUtility.ClientIP;
                            mbc.InstanceId = replyedMiniBlog.Id;

                            mbc.Save();

                            CY.UME.Core.Business.Notice noticeTemp = new CY.UME.Core.Business.Notice();

                            noticeTemp.AccountId = replyedMiniBlog.AccountId;
                            noticeTemp.AuthorId = mbc.AuthorId;
                            noticeTemp.Content = "评论了您的微博";
                            noticeTemp.DateCreated = DateTime.Now;
                            noticeTemp.InstanceId = replyedId.ToString();
                            noticeTemp.IsReaded = false;
                            noticeTemp.Type = "miniblogreply";

                            noticeTemp.Save();
                        }
                    }
                }
                #endregion

                context.Response.Write("{success:true}");
            }
            catch
            {
                context.Response.Write("{success:false,msg:'服务器忙,请稍后再试'}");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 0登录失败 -1 请求失败 -2异常错误 -3该微博不存在或已被删除 -4 您无法转发自己的微博
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public string TransferMiniBlog(HttpContext context)
        {
            long miniBlogId = 0;
            string email = String.Empty;
            CY.UME.Core.Business.AccountExtend accountExtend;
            CY.UME.Core.Business.MiniBlog miniBlog;
            CY.UME.Core.Business.Account account;

            #region validate
            if (context.Request.QueryString["email"] == null
                || context.Request.QueryString["MiniBlogId"] == null
                || !long.TryParse(context.Request.QueryString["MiniBlogId"].ToString(), out miniBlogId))
            {
                return "-1";
            }
            email = context.Request.QueryString["email"].ToString();

            accountExtend = CY.UME.Core.Business.AccountExtend.Load(email);

            if (accountExtend == null)
            {
                return "-1";
            }

            account = CY.UME.Core.Business.Account.Load(accountExtend.Id);

            miniBlog = CY.UME.Core.Business.MiniBlog.Load(miniBlogId);

            if (miniBlog == null)
            {
                return "-3";
            }

            if (miniBlog.AccountId == accountExtend.Id)
            {
                return "-4";
            }

            CY.UME.Core.Business.Account refAccount = CY.UME.Core.Business.Account.Load(miniBlog.AccountId);

            #endregion

            CY.UME.Core.Business.MiniBlog newMiniBlog = new CY.UME.Core.Business.MiniBlog();

            newMiniBlog.AccountId = accountExtend.Id;
            newMiniBlog.Content = miniBlog.Content;
            newMiniBlog.DatePublish = DateTime.Now;
            newMiniBlog.IP = CY.Utility.Common.RequestUtility.ClientIP;

            newMiniBlog.Save();

            string imgPath = String.Empty;
            CY.UME.Core.Business.MiniBlogExtend miniBlogExtend = CY.UME.Core.Business.MiniBlogExtend.Load(miniBlog.Id);
            if (miniBlogExtend != null)
            {
                imgPath = miniBlogExtend.ImgPath;
            }

            CY.UME.Core.Business.MiniBlogExtend newMiniBlogExtend = new CY.UME.Core.Business.MiniBlogExtend();

            newMiniBlogExtend.AccountId = newMiniBlog.AccountId;
            newMiniBlogExtend.Id = newMiniBlog.Id;
            newMiniBlogExtend.ImgPath = imgPath;
            newMiniBlogExtend.IsMsgReceived = false;
            newMiniBlogExtend.IsPhoneSended = false;
            newMiniBlogExtend.ReferedId = miniBlog.Id;
            newMiniBlogExtend.ReferedName = refAccount == null ? "用户已被删除" : refAccount.Name;
            newMiniBlogExtend.TransferedNum = 0;

            newMiniBlogExtend.Save();

            account.SendNoticeToAllFriendAndFollower("miniblog", "转发了一篇微博", newMiniBlog.Id.ToString());

            return newMiniBlog.Id.ToString();
        }