예제 #1
0
        private void bind(string AccountName, string startTime, string endTime, string Description, bool isTrue)
        {
            CY.UME.Core.PagingInfo pagingInfo = new CY.UME.Core.PagingInfo();
            pagingInfo.CurrentPage = AspNetPager1.CurrentPageIndex;
            pagingInfo.PageSize = AspNetPager1.PageSize = SetCurrentPageSize.CurrentPageSize;

            CY.UME.Core.Business.CreditHistory ch = new CY.UME.Core.Business.CreditHistory();

            IList<CY.UME.Core.Business.CreditHistory> creditHistoryList = CY.UME.Core.Business.CreditHistory.GetAllCreditHistory(
                AccountName,
                CY.Utility.Common.ConvertUtility.ConvertToDateTime(startTime),
                CY.Utility.Common.ConvertUtility.ConvertToDateTime(endTime), Description, pagingInfo);//查询

            if (creditHistoryList.Count >= 1)
            {
                if (isTrue)
                {
                    AspNetPager1.RecordCount = CY.UME.Core.Business.CreditHistory.GetCreditHistoryCount(
                        AccountName,
                        CY.Utility.Common.ConvertUtility.ConvertToDateTime(startTime),
                        CY.Utility.Common.ConvertUtility.ConvertToDateTime(endTime), Description);//绑定总条数
                }

                AspNetPager1.Visible = true;
                Repeater2.Visible = false;
                Repeater1.Visible = true;
                Repeater1.DataSourceID = "";
                Repeater1.DataSource = creditHistoryList;
                Repeater1.DataBind();
            }
            else
            {
                Repeater1.Visible = false;
                Repeater2.Visible = true;

                Repeater2.DataSourceID = "";
                Repeater2.DataSource = BindNoData("暂无数据");
                Repeater2.DataBind();
                AspNetPager1.Visible = false;
            }
        }
예제 #2
0
        protected void AddTopic_OnClick(object sender, EventArgs e)
        {
            if (TBXTopicName.Text.Trim().Length == 0)
            {
                ShowAlert("提示", "话题名不能为空");
                return;
            }
            else if (TBXTopicName.Text.Trim().Length > 100)
            {
                ShowAlert("提示", "话题名长度不能超过100");
                return;
            }
            if (type == "add")
            {
                int groupId = 0;
                if (ViewState["GroupId"] == null || !int.TryParse(ViewState["GroupId"].ToString(), out groupId))
                {
                    throw new Exception("参数错误");
                }

                CY.UME.Core.Business.Group group = CY.UME.Core.Business.Group.Load(groupId);

                if (group == null)
                {
                    throw new Exception("参数错误");
                }

                CY.UME.Core.Business.Topic topic = new CY.UME.Core.Business.Topic();

                topic.Id = System.Guid.NewGuid();
                topic.Title = TBXTopicName.Text.Trim();

                topic.Content = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
                topic.DateCreated = DateTime.Now;
                topic.IP = CY.Utility.Common.RequestUtility.ClientIP;
                topic.Level = 0;
                topic.ReplyNum = 0;
                topic.AccountId = CurrentAccount.Id;
                topic.LastReplyDate = topic.DateCreated;
                topic.LastAuthorId = CurrentAccount.Id;

                topic.Save();

                CY.UME.Core.Business.TopicExtend te = new CY.UME.Core.Business.TopicExtend();

                te.AccountId = topic.AccountId;
                te.Id = topic.Id;
                te.InstanceId = group.Id.ToString();
                te.Type = "group";

                te.Save();

                //发送通知
                CurrentAccount.SendNoticeToAllFriendAndFollower("pubtopic","发表了新话题", topic.Id.ToString());

                #region 添加积分

                int addTopicCredit;
                if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditAddTopic", out addTopicCredit) &&
                    (addTopicCredit != 0))
                {
                    DateTime now = DateTime.Now;
                    DateTime startOfDay = new DateTime(now.Year, now.Month, now.Day);
                    int crediteGainCountTodayInSpecificalTopic = CY.UME.Core.Business.CreditHistory.GetCreditHistoryCount(
                        "addtopic", group.CreatorId, CurrentAccount.Id, topic.Id.ToString(), startOfDay, startOfDay.AddDays(1)); // TODO

                    if (crediteGainCountTodayInSpecificalTopic == 0)
                    {
                        CY.UME.Core.Business.Account creator = CY.UME.Core.Business.Account.Load(group.CreatorId);

                        if (creator != null)
                        {
                            int orgCredit = creator.Credit;
                            int modifiedCredit = orgCredit + addTopicCredit;
                            creator.Credit = modifiedCredit;
                            creator.Save();

                            CY.UME.Core.Business.CreditHistory ch = new CY.UME.Core.Business.CreditHistory();
                            ch.AccountId = creator.Id;
                            ch.DateCreated = DateTime.Now;
                            ch.Id = Guid.NewGuid();
                            ch.InstanceId = topic.Id.ToString();
                            ch.Original = orgCredit;
                            ch.Modified = modifiedCredit;
                            ch.Variation = addTopicCredit;
                            ch.Type = "addtopic";
                            ch.AssistAccountId = CurrentAccount.Id;
                            ch.Description = "用户 " + CurrentAccount.Name + "发表了话题 "+topic.Title;
                            ch.Save();
                        }
                    }
                }
                #endregion

                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '发起成功' });window.location.href='Topic.aspx?groupId=" + group.Id + "'</script>");
            }
            else if (type == "edit")
            {
                CY.UME.Core.Business.Topic topic = CY.UME.Core.Business.Topic.Load(topicId);

                topic.Title = TBXTopicName.Text.Trim();
                topic.Content = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
                topic.DateCreated = DateTime.Now;
                topic.IP = CY.Utility.Common.RequestUtility.ClientIP;
                topic.AccountId = CurrentAccount.Id;
                topic.LastAuthorId = CurrentAccount.Id;
                topic.Save();
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>cy.ume.ui.window({ title: '提示', content: '编辑成功' });window.location.href='TopicDetailInfo.aspx?TopicId=" + topicId + "'</script>");
            }
        }
예제 #3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            CY.UME.Core.Business.Account account;
            string bigImgPath, smallImgPath, imgExtention, imgName;
            string sitePath = CY.Utility.Common.SiteUtility.CurSitePath;

            String Id = context.Request.QueryString["accountId"].ToString();

            long accountId = CY.Utility.Common.ConvertUtility.ConvertToInt(Id, -1);

            #region -Validation and Get Basic Data-

            //account = CY.UME.Core.Global.GetCurrentAccount();
            account = CY.UME.Core.Business.Account.Load(accountId);
            if (account == null)
            {
                context.Response.Write("{success: false, msg: '用户登录超时,请重新登录!'}");
                return;
            }

            // post data
            bigImgPath = context.Request.Form["bigImgPath"];
            smallImgPath = context.Request.Form["smallImgPath"];
            imgExtention = context.Request.Form["imgExtention"];
            imgName = context.Request.Form["imgName"];
            if (string.IsNullOrEmpty(bigImgPath) ||
                string.IsNullOrEmpty(smallImgPath) ||
                string.IsNullOrEmpty(imgExtention))
            {
                context.Response.Write("{success: false, msg: '参数错误'}");
                return;
            }

            if (!File.Exists(sitePath + bigImgPath))
            {
                context.Response.Write("{success: false, msg: '照片不存在'}");
                return;
            }
            if (!File.Exists(sitePath + smallImgPath))
            {
                context.Response.Write("{success: false, msg: '小头像不存在'}");
                return;
            }
            #endregion

            CY.UME.Core.Business.Album avatarAlbum = account.GetMyAvatarAlbum();
            if (avatarAlbum == null)
            {
                avatarAlbum = new CY.UME.Core.Business.Album();
                avatarAlbum.AccountId = account.Id;
                avatarAlbum.DateCreated = DateTime.Now;
                avatarAlbum.IsAvatar = true;
                avatarAlbum.LastModifiedTime = avatarAlbum.DateCreated;
                avatarAlbum.Name = "头像相册";
                avatarAlbum.Save();
            }

            // 相册目录为: 网站根目录 + /Content/Avatar/ + 用户标识
            string avatarRelativePath = "/Content/Avatar/" + account.Id + "/";
            DirectoryInfo di = new DirectoryInfo(sitePath + avatarRelativePath); // 相册目录
            if (!di.Exists)
            {
                di.Create();
            }

            string uniqueId = Guid.NewGuid().ToString("N");

            string bImgName = uniqueId + "_big" + imgExtention;
            string mImgName = uniqueId + "_mid" + imgExtention;
            string sImgName = uniqueId + "_small" + imgExtention;

            try
            {
                Bitmap bmp = new Bitmap(sitePath + bigImgPath);
                int width = bmp.Width;
                int height = bmp.Height;

                bmp.Dispose();

                height = Convert.ToInt32(width > 200 ? (200f / width) * height : height);
                width = 200;

                // 将大图片压缩为中等缩略图
                using (StreamReader reader = new StreamReader(sitePath + bigImgPath))
                {
                    CY.Utility.Common.ImageUtility.ThumbAsJPG(reader.BaseStream, di.FullName + mImgName, width, height);
                }
                // 将小头像从120*120压缩到48*48
                using (StreamReader reader = new StreamReader(sitePath + smallImgPath))
                {
                    CY.Utility.Common.ImageUtility.ThumbAsJPG(reader.BaseStream, di.FullName + sImgName, 48, 48);
                }

                // 将大图移动到头像目录下
                FileInfo fi = new FileInfo(sitePath + bigImgPath);
                fi.MoveTo(di.FullName + bImgName);

                try
                {
                    // File.Delete(sitePath + bigImgPath);
                    File.Delete(sitePath + smallImgPath);
                }
                catch
                {
                    ;
                }

                // 添加照片记录
                CY.UME.Core.Business.Picture picture = new CY.UME.Core.Business.Picture();
                picture.AlbumId = avatarAlbum.Id;
                picture.BigPath = avatarRelativePath + bImgName;
                picture.DateCreated = DateTime.Now;
                picture.MiddlePath = avatarRelativePath + mImgName;
                picture.Name = imgName;
                picture.Remark = string.Empty;
                picture.SmallPath = avatarRelativePath + sImgName;
                picture.Save();

                if (!account.HasAvatar)
                {
                    account.HasAvatar = true;

                    #region 积分

                    int uploadAvatarCredit;
                    if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditUploadAvatar", out uploadAvatarCredit) &&
                        (uploadAvatarCredit != 0))
                    {
                        int orgCredit = account.Credit;
                        int modifiedCredit = orgCredit + uploadAvatarCredit;
                        account.Credit = modifiedCredit;

                        CY.UME.Core.Business.CreditHistory ch = new CY.UME.Core.Business.CreditHistory();
                        ch.AccountId = account.Id;
                        ch.DateCreated = DateTime.Now;
                        ch.Id = Guid.NewGuid();
                        ch.InstanceId = "";
                        ch.Original = orgCredit;
                        ch.Modified = modifiedCredit;
                        ch.Variation = uploadAvatarCredit;
                        ch.Type = "uploadavatar";
                        ch.Description = "上传头像";
                        ch.Save();
                    }

                    #endregion

                    account.Save();
                }

                //添加通知
                //account.SendNoticeToAllFriend("picture", "更新了头像", picture.Id.ToString());

                context.Response.Write("{success: true}");
                return;
            }
            catch
            {
                context.Response.Write("{success: false, msg: '保存头像失败'}");
                return;
            }
        }
예제 #4
0
        /// <summary>
        /// 用户签到
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

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

            if (account == null)
            {
                context.Response.Write("{success:false,msg:'请先登陆'}");
                return;
            }

            try
            {
                CY.UME.Core.Business.AccountOperation ao = new CY.UME.Core.Business.AccountOperation();

                if (account != null)
                {
                    ao.AccountId = account.Id;
                    ao.AccountName = account.Name;
                }

                ao.Email = account.Email;//Email一直都有
                ao.DateCreated = DateTime.Now;
                ao.Type = "SignIn";
                ao.IP = CY.Utility.Common.RequestUtility.ClientIP;
                ao.Remark = "用户签到。";

                if (account.Id <= 0)
                {//操作保存失败
                    ao.IsSuccess = 0;
                    ao.Save();

                    context.Response.Write("{success:false,msg:'登陆超时,请重新登陆。'}");
                    return;
                }
                else
                {//保存成功,加积分。
                    int SignInCredit;
                    if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditSignIn", out SignInCredit) && (SignInCredit != 0))
                    {
                        DateTime now = DateTime.Now;
                        DateTime startOfDay = new DateTime(now.Year, now.Month, now.Day);
                        // 获取用户当日内由登录而获得的积分
                        int creditsAlreadyGainToday;
                        List<CY.UME.Core.Business.CreditHistory> creditHistories = CY.UME.Core.Business.CreditHistory.GetCreditHistory(
                                "SignIn",
                                account.Id,
                                new long?(),
                                string.Empty,
                                startOfDay,
                                startOfDay.AddDays(1),
                                new CY.UME.Core.PagingInfo
                                {
                                    CurrentPage = 1,
                                    PageSize = int.MaxValue
                                }
                            );
                        creditsAlreadyGainToday = creditHistories.Sum<CY.UME.Core.Business.CreditHistory>(ch => ch.Variation);
                        if (creditsAlreadyGainToday < 1)
                        {
                            int orgCredit = account.Credit;
                            int modifiedCredit = orgCredit + SignInCredit;

                            account.Credit = modifiedCredit;
                            account.Save();

                            CY.UME.Core.Business.CreditHistory ch = new CY.UME.Core.Business.CreditHistory();
                            ch.AccountId = account.Id;
                            ch.DateCreated = DateTime.Now;
                            ch.Id = Guid.NewGuid();
                            ch.InstanceId = account.Id.ToString();
                            ch.Original = orgCredit;
                            ch.Modified = modifiedCredit;
                            ch.Variation = SignInCredit;
                            ch.Type = "SignIn";
                            ch.Description = "用户签到";
                            ch.Save();

                            ao.IsSuccess = 1;
                            ao.Save();

                            context.Response.Write("{success:true,msg:'签到成功'}");
                            return;
                        }
                        else
                        {
                            ao.IsSuccess = 0;
                            ao.Save();

                            context.Response.Write("{success:true,msg:'每天只能签到一次'}");
                            return;
                        }
                    }
                }
            }
            catch
            {
                context.Response.Write("{success:false,msg:'系统忙,请稍后再试'}");
                return;
            }
        }
예제 #5
0
        private void SendTopicPermission(CY.UME.Core.Business.Group group)
        {
            CY.UME.Core.Business.Topic topic = new CY.UME.Core.Business.Topic();

            topic.Id = System.Guid.NewGuid();
            topic.Title = TBXTopicName.Text.Trim();

            topic.Content = CY.Utility.Common.RequestUtility.GetFormString("wysiwyg");
            topic.DateCreated = DateTime.Now;
            topic.IP = CY.Utility.Common.RequestUtility.ClientIP;
            topic.Level = 0;
            topic.ReplyNum = 0;
            topic.AccountId = CurrentAccount.Id;
            topic.LastReplyDate = topic.DateCreated;
            topic.LastAuthorId = CurrentAccount.Id;

            topic.Save();

            CY.UME.Core.Business.TopicExtend te = new CY.UME.Core.Business.TopicExtend();

            string pubType = "pubtopic";

            te.AccountId = topic.AccountId;
            te.Id = topic.Id;

            int.TryParse(Request.QueryString["activeID"], out activeId);
            if (activeId == 0)
            {//群组话题
                te.InstanceId = group.Id.ToString();
                te.Type = "group";
                pubType = "pubtopic";
            }
            else
            {//活动话题
                te.InstanceId = activeId.ToString();
                te.Type = "active";
                pubType = "activeTopic";
            }

            te.Save();

            //发送通知
            CurrentAccount.SendNoticeToAllFriendAndFollower(pubType, "发表了新话题", topic.Id.ToString());

            #region 添加积分

            int addTopicCredit;
            if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditAddTopic", out addTopicCredit) &&
                (addTopicCredit != 0) && (1 == 2))//2010.12.26 由于效率太低,暂时不用了
            {
                DateTime now = DateTime.Now;
                DateTime startOfDay = new DateTime(now.Year, now.Month, now.Day);
                int crediteGainCountTodayInSpecificalTopic = CY.UME.Core.Business.CreditHistory.GetCreditHistoryCount(
                    "addtopic", group.CreatorId, CurrentAccount.Id, topic.Id.ToString(), startOfDay, startOfDay.AddDays(1)); // TODO

                if (crediteGainCountTodayInSpecificalTopic == 0)
                {
                    CY.UME.Core.Business.Account creator = CY.UME.Core.Business.Account.Load(group.CreatorId);

                    if (creator != null)
                    {
                        int orgCredit = creator.Credit;
                        int modifiedCredit = orgCredit + addTopicCredit;
                        creator.Credit = modifiedCredit;
                        creator.Save();

                        CY.UME.Core.Business.CreditHistory ch = new CY.UME.Core.Business.CreditHistory();
                        ch.AccountId = creator.Id;
                        ch.DateCreated = DateTime.Now;
                        ch.Id = Guid.NewGuid();
                        ch.InstanceId = topic.Id.ToString();
                        ch.Original = orgCredit;
                        ch.Modified = modifiedCredit;
                        ch.Variation = addTopicCredit;
                        ch.Type = "addtopic";
                        ch.AssistAccountId = CurrentAccount.Id;
                        ch.Description = "用户 " + CurrentAccount.Name + "发表了话题 " + topic.Title;
                        ch.Save();
                    }
                }
            }
            #endregion

            if (pubType == "pubtopic")
            { //群组
                base.ShowAlert("提示", "发起话题成功<span>3</span>秒后将自动跳转。", true, "Topic.aspx?groupId=" + group.Id, true);
            }
            else
            {//活动
                base.ShowAlert("提示", "发起话题成功<span>3</span>秒后将自动跳转。", true, "Topic.aspx?activeid=" + activeId, true);
                //Page.ClientScript.RegisterClientScriptBlock(GetType(), "", "<script>alert('发起成功');window.location.href='Topic.aspx?groupId=" + group.Id + "'</script>");
            }
        }