示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["blogId"] == null)
            {
                throw new Exception("参数错误");
            }
            else
            {
                long blogId = 0;
                if (long.TryParse(Request.QueryString["blogId"].ToString(), out blogId))
                {
                    blog = CY.UME.Core.Business.Blog.Load(blogId); //获取博客信息

                    if (blog == null)
                    {
                        throw new Exception("访问页面不存在");
                    }

                    //if (!blog.CheckViewPermission(CurrentAccount))
                    //{
                    //    throw new Exception("您无权访问该页面");
                    //}

                    long spaceId = blog.AccountId;
                    SpaceAccount = CY.UME.Core.Business.Account.Load(spaceId);
                    blogComments = CY.UME.Core.Business.BlogComment.GetAllBlogCommentsByBlogId(blog); //获取博客评论信息

                    CY.UME.Core.PagingInfo pagingInfo = new CY.UME.Core.PagingInfo();
                    pagingInfo.CurrentPage = 1;
                    pagingInfo.PageSize = 10;
                    IList<CY.UME.Core.Business.Blog> Blogs =
                        CY.UME.Core.Business.Blog.GetTopBlogsByAccountId(SpaceAccount, pagingInfo, blog.ViewSet);
                    blogBriefList.Blogs = Blogs;
                    blogBriefList.spaceAccount = SpaceAccount;

                    //增加博客阅读数
                    if (CurrentAccount != null &&
                        blog.AccountId != (CurrentAccount == null ? SpaceAccount.Id : base.CurrentAccount.Id))
                    {
                        CY.UME.Core.Business.Blog.AddBlogViewNum(blog.Id);
                    }
                    SetTitle(blog.Subject);
                    HF_AccountId.Value = spaceId.ToString();
                    HF_BlogId.Value = blogId.ToString();
                    blog_HiddenTotalRecords.Value = Blogs.Count.ToString();
                    blog_HiddenReplyTotalRecords.Value = blogComments.Count.ToString();

                }
                else
                {
                    throw new Exception("参数错误");
                }
                UserInfo1.SpaceAccount = SpaceAccount;
            }
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            string strAccountId = context.Request.Form["accountId"].ToString();
            string content = context.Request.Form["content"].ToString();
            string title = context.Request.Form["title"].ToString();
            long accoutId = 0;
            if (!long.TryParse(strAccountId, out accoutId))
            {
                context.Response.Write("{success:false,msg:参数不合法}");
                return;
            }

            CY.UME.Core.Business.Blog blog;
            CY.UME.Core.Business.Account account;

            try
            {
                blog = new CY.UME.Core.Business.Blog();
                account = CY.UME.Core.Business.Account.Load(accoutId);

                if (account == null)
                {
                    context.Response.Write("{success:false,msg='用户登录超时'}");
                    return;
                }
                blog.AccountId = accoutId;
                blog.AccountName = account.Name;
                content = Utility.Common.StringUtility.HTMLEncode(content);
                content = content.Replace("\n", "<br />");
                blog.BlogContent = content;
                blog.DateCreated = DateTime.Now;
                blog.IP = CY.Utility.Common.RequestUtility.ClientIP;
                blog.NoReply = true;
                blog.ReplyNum = 0;
                blog.Subject = title;
                blog.TraceNum = 0;
                blog.TypeId = 0;
                blog.ViewNum = 0;
                blog.ViewSet = 0;
                blog.Save();

                account.SendNoticeToAllFriendAndFollower("blog", "发表了新日志", blog.Id.ToString()); //添加通知

                context.Response.Write("{success:true,msg:'发表新日志成功!'}");
            }
            catch (Exception ex)
            {
                context.Response.Write("success:false,msg:'" + ex.Message + "'");
            }
        }
示例#3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";
            long id = 0;

            #region validate
            if (context.Request.Form["Id"] == null
                || !long.TryParse(context.Request.Form["Id"].ToString(),out id))
            {
                context.Response.Write("{success:false,msg:'参数错误'}");
                return;
            }

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

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

            try
            {
                CY.UME.Core.Business.BlogType blogType = CY.UME.Core.Business.BlogType.Load(id);

                if (blogType != null)
                {
                    if (account.Id != blogType.AccountId)
                    {
                        context.Response.Write("{success:false,msg:'您无权执行该操作'}");
                        return;
                    }

                    CY.UME.Core.Business.Blog blog = new CY.UME.Core.Business.Blog();

                    blog.UpdateBlogTypeByTypeId(0, blogType.Id);

                    blogType.DeleteOnSave();

                    blogType.Save();
                }

                context.Response.Write("{success:true}");
            }
            catch
            {
                context.Response.Write("{success:false,msg:'删除失败'}");
            }
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetTitle("日志 ");

            long spaceId = 0, type = -1;

            if (Request.QueryString["SpaceId"] == null)
            {
                SpaceAccount = CurrentAccount;
            }
            else if (long.TryParse(Request.QueryString["SpaceId"].ToString(), out spaceId))
            {
                SpaceAccount = CY.UME.Core.Business.Account.Load(spaceId);
            }
            else
            {
                SpaceAccount = CurrentAccount;
            }

            if (Request.QueryString["Type"] != null)
            {
                long.TryParse(Request.QueryString["Type"].ToString(), out type);
            }

            if (!IsPostBack)
            {
                this.VisitorList.CurrentAccount = base.CurrentAccount;

                CY.UME.Core.PagingInfo pagingInfo = new CY.UME.Core.PagingInfo();
                pagingInfo.CurrentPage = 1;
                pagingInfo.PageSize = 6;
                int BlogCount = 0;

                int viewSet;

                if (CurrentAccount != null && CurrentAccount.Id == SpaceAccount.Id)
                {
                    viewSet = 0;
                }
                else if (CurrentAccount != null && CurrentAccount.HasFriendshipWith(SpaceAccount))
                {
                    viewSet = 1;
                }
                else
                {
                    viewSet = 2;
                }

                CY.UME.Core.Business.Blog blog = new CY.UME.Core.Business.Blog();

                BlogCount = blog.GetCountByAccountIdAndTypeAndViewSet(SpaceAccount, viewSet, type);
                blog_HiddenTotalRecords.Value = BlogCount.ToString();
                blog_HiddenPageSize.Value = pagingInfo.PageSize.ToString();
                blog_HiddenViewSet.Value = viewSet.ToString();
                blog_HiddenType.Value = type.ToString();
                blog_CurrentAccount.Value = CurrentAccount.Id.ToString();
                blog_HiddenSiteUrl.Value = SiteUrl;
                blogFollower.CurrentFollower = SpaceAccount;
                IList<CY.UME.Core.Business.Blog> BlogList = blog.GetBlogsByAccountIdAndTypeAndViewSet(SpaceAccount, pagingInfo, viewSet, type);

                //BindType();
                //selType.Value = type.ToString();

                foreach (CY.UME.Core.Business.Blog b in BlogList)
                {
                    string strContent = CY.Utility.Common.StringUtility.NoHTML(b.BlogContent);

                    strContent = Server.HtmlDecode(strContent);
                    strContent = strContent.Replace("\r\n", "");

                    strContent = CY.Utility.Common.StringUtility.CutString(strContent.Trim(), 400, "...");

                    strContent = strContent.Replace("&", "&amp;");
                    b.BlogContent = strContent;

                    b.Subject = Server.HtmlEncode(
                        CY.Utility.Common.StringUtility.CutString(b.Subject, 30, "...")
                        );
                }

                RP_BlogList.DataSourceID = "";
                RP_BlogList.DataSource = BlogList;
                RP_BlogList.DataBind();

                UserInfo1.SpaceAccount = SpaceAccount;

                //blogList.SpaceAccount = SpaceAccount;
                //blogList.CurrentAccount = CurrentAccount;
                //blogList.Blogs = Blogs;

                //blogBriefList.Blogs = Blogs;
                //blogBriefList.spaceAccount = SpaceAccount;
            }
        }
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            CY.UME.Core.Business.Account spaceAccount;
            int pageSize;
            int pageNum;
            long spaceAccountId = 0, type = -1;
            int viewSet;

            if (!CY.Utility.Common.ParseUtility.TryParseInt64(context.Request.Form["spaceAccountId"], out spaceAccountId) || !CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["pageSize"], out pageSize) ||
                !CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["pageNum"], out pageNum) || !CY.Utility.Common.ParseUtility.TryParseInt32(context.Request.Form["viewSet"], out viewSet))
            {
                context.Response.Write("{success: false, msg: '参数错误!'}");
                return;
            }

            if (context.Request.Form["type"] != null)
            {
                long.TryParse(context.Request.Form["type"].ToString(), out type);
            }

            try
            {
                StringBuilder sb = new StringBuilder();

                if (spaceAccountId > 0)
                {
                    spaceAccount = CY.UME.Core.Business.Account.Load(spaceAccountId);

                    if (spaceAccount == null)
                    {
                        context.Response.Write("{success: false, msg: '参数错误!'}");
                        return;
                    }
                    CY.UME.Core.PagingInfo pagingInfo = new CY.UME.Core.PagingInfo();
                    pagingInfo.CurrentPage = pageNum;
                    pagingInfo.PageSize = pageSize;

                    CY.UME.Core.Business.Blog blog = new CY.UME.Core.Business.Blog();

                    IList<CY.UME.Core.Business.Blog> blogList = blog.GetBlogsByAccountIdAndTypeAndViewSet(spaceAccount, pagingInfo, viewSet, type);

                    sb.Append("{success: true, blogs: [");

                    foreach (CY.UME.Core.Business.Blog a in blogList)
                    {
                        sb.Append("{Id: ");
                        sb.Append(a.Id);
                        sb.Append(", AccountId: '");
                        sb.Append(a.AccountId);
                        sb.Append("', AccountName:'");
                        sb.Append(a.AccountName);
                        sb.Append("',Title:");
                        sb.Append(CY.Utility.Common.JavaScriptUtility.ToEscapedJavaScriptString(a.Subject));
                        sb.Append(",ViewNum: ");
                        sb.Append(a.ViewNum);
                        sb.Append(",ReplyNum: ");
                        sb.Append(a.ReplyNum);
                        sb.Append(",Type:");
                        sb.Append(CY.Utility.Common.JavaScriptUtility.ToEscapedJavaScriptString(a.GetTypeNameByBlogId()));
                        sb.Append(",DateCreated:'");
                        sb.Append(a.DateCreated);
                        sb.Append("',Content:'");

                        // Constantine Modified
                        string strContent = CY.Utility.Common.StringUtility.StripHtml(a.BlogContent);

                        strContent = context.Server.HtmlDecode(strContent);
                        strContent = strContent.Replace("\r\n", "");
                        strContent = CY.Utility.Common.StringUtility.CutString(strContent.Trim(), 400, "...");

                        strContent = strContent.Replace("&", "&amp;");
                        strContent = CY.Utility.Common.StringUtility.EscapeString(strContent);

                        sb.Append(strContent);

                        sb.Append("'},");

                    }
                    if (blogList.Count > 0)
                    {
                        sb.Remove(sb.Length - 1, 1);
                    }
                    sb.Append("]}");

                    context.Response.Write(sb.ToString());
                }
            }
            catch
            {
                context.Response.Clear();
                context.Response.Write("{success: false, msg: '服务器忙,请稍后再试!'}");
            }
        }
示例#6
0
        protected void AddBlog_OnClick(object sender, EventArgs e)
        {
            if (TBXTitle.Text.Trim().Length > 100)
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('标题长度不能超过100个字符');</script>");
                return;
            }

            try
            {
                long typeId = 0;

                long.TryParse(HiddenTypeId.Value, out typeId);

                if (blog != null && isEdit)
                {
                    // 修改日志
                    blog.BlogContent = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
                    blog.ViewSet = CY.Utility.Common.ConvertUtility.ConvertToInt(Secret.Value, 0);
                    blog.Subject = TBXTitle.Text.Trim();
                    blog.TypeId = typeId;
                    blog.Save();
                }
                else
                {
                    blog = new CY.UME.Core.Business.Blog();
                    blog.BlogContent = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
                    blog.AccountId = CurrentAccount.Id;
                    blog.AccountName = CurrentAccount.Name;
                    blog.DateCreated = DateTime.Now;
                    blog.IP = Utility.Common.RequestUtility.ClientIP;
                    blog.NoReply = true;
                    blog.Subject = TBXTitle.Text.Trim();
                    blog.TypeId = typeId;
                    blog.ViewSet = CY.Utility.Common.ConvertUtility.ConvertToInt(Secret.Value, 0);

                    blog.Save();

                    string noticContent = TBXNoticeInfo.Text.Trim();

                    if (noticContent.Length == 0)
                    {
                        noticContent = "发表了新日志";
                    }

                    if (CBMagic.Checked)
                    {
                        noticContent = "<span class=\"magic\">" + noticContent;
                        noticContent += "</span>";
                    }

                    CurrentAccount.SendNoticeToAllFriendAndFollower("blog", noticContent, blog.Id.ToString());
                }
                string url = "'Blog.aspx?spaceAccountId=" + blog.Id + "'";
                /**************************第一天活动*************************************/
                if (ViewState["IsFirstDay"] != null)
                {
                    string isFirstDayParam = ViewState["IsFirstDay"].ToString();
                    if (isFirstDayParam == "myfirstday")
                    {
                        //将该日志添加到我的第一天活动
                        CY.UME.Core.Business.BlogExtend blogExtend = new CY.UME.Core.Business.BlogExtend();

                        blogExtend.AccountId = blog.AccountId;
                        blogExtend.ActivityId = "myfirstday";
                        blogExtend.Id = blog.Id;

                        blogExtend.Save();

                        //url =SiteUrl+ "/FindPersonActivity/MyFirstDay.aspx";
                    }
                    else
                    {
                        Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('参数有误,添加失败');</script>");
                        return;
                    }
                }
                /************************第一天活动结束***********************************/
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('添加成功');window.location.href=" + url + ";</script>");
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('" + ex.Message + "');</script>");
            }
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SetTitle("写日志");

            long blogId = 0;

            if (!string.IsNullOrEmpty(Request.QueryString["blogId"]) &&
                long.TryParse(Request.QueryString["blogId"], out blogId))
            {
                blog = CY.UME.Core.Business.Blog.Load(blogId);

                if (blog != null)
                {
                    if (blog.AccountId != CurrentAccount.Id)
                    {
                        throw new SystemException("你无权对此日志进行修改");
                    }

                    isEdit = true;

                    if (!Page.IsPostBack)
                    {
                        TBXTitle.Text = blog.Subject;
                        wysiwyg.Value = blog.BlogContent;
                        Secret.Value = blog.ViewSet.ToString();
                        selType.Value = blog.TypeId.ToString();
                        HiddenTypeId.Value = selType.Value;
                        BindType();
                    }
                }
                else
                {
                    throw new SystemException("日志不存在");
                }
            }
            else
            {
                if (!IsPostBack)
                {
                    /*********************第一天活动************************/
                    if (Request.QueryString["mfd"] == null)
                    {
                        ViewState["IsFirstDay"] = null;
                    }
                    else
                    {
                        ViewState["IsFirstDay"] = Server.UrlDecode(Request.QueryString["mfd"].ToString());
                    }

                    BindType();
                    HiddenTypeId.Value = "0";
                    /***********************第一天活动结束*****************/
                }
            }
            HF_CurrentAccount.Value = CurrentAccount.Id.ToString();
            HF_IsEdit.Value = isEdit.ToString();
            HF_BlogId.Value = blogId.ToString();
            HF_SiteUrl.Value = SiteUrl;
        }