示例#1
0
        public bool AddCredit(long accountId, int credit, string type, string reason)
        {
            CY.UME.Core.Business.Account account;

            if (TryGetAccount(accountId, out account))
            {
                int orgCredit = account.Credit;
                int modifiedCredit = orgCredit + credit;

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

                CreditHistory ch = new 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 = credit;
                ch.Type = type;
                ch.Description = reason;
                ch.Save();
            }

            return false;
        }
示例#2
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LBSubmint_Click(object sender, EventArgs e)
        {
            try
            {
                if (TxtEmail.Text.Length == 0)
                {
                    return;
                }
                log.Info("注册开始");
                if (Session["CaptchaImageText"] == null)
                {
                    ShowAlert("注册失败", "服务器忙,请稍后再试!");
                    return;
                }

                string validateCode = Session["CaptchaImageText"].ToString();
                if (TxtValidCode.Text != validateCode)
                {
                    ShowAlert("注册失败", "验证码错误!");
                    return;
                }
                if (string.IsNullOrEmpty(TxtSudentCode.Text))
                {
                    ShowAlert("注册失败", "学号不能为空");
                    return;
                }
                if (string.IsNullOrEmpty(TxtUserName.Text))
                {
                    ShowAlert("注册失败", "姓名不能为空");
                    return;
                }
                if (TxtUserPassword.Text.Length < 6 ||
                    TxtUserPassword.Text.Length > 20)
                {
                    ShowAlert("注册失败", "密码长度必须在6至20之间");
                    return;
                }
                String ZipRegex = @"/^\w{0,19}$/";
                if (System.Text.RegularExpressions.Regex.IsMatch(TxtUserPassword.Text, ZipRegex))
                {
                    ShowAlert("注册失败", "密码含有非法字符,只能输入数字、字母和\"_\"的组合。");
                    return;
                }
                if (String.Compare(TxtUserPassword.Text.Trim(), TxtUserPasswordAgain.Text.Trim()) != 0)
                {
                    ShowAlert("注册失败", "两次密码输入不一致,请重新输入。");
                    return;
                }
                if (!RBGenderFemale.Checked && !RBGenderMale.Checked)
                {
                    ShowAlert("注册失败", "性别不能为空");
                    return;
                }

                if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0")
                {
                    ;
                }
                else if ( YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0")
                {
                    ShowAlert("提示", "请完善您的生日信息!");
                    return;
                }

                Guid id = new Guid(Request.QueryString["id"]);
                CY.UME.Core.Business.AccountInviteInfo aii = CY.UME.Core.Business.AccountInviteInfo.Load(id);
                if (aii == null)
                {
                    ShowAlert("注册失败", "邀请已失效!");
                    return;
                }

                CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

                CY.UME.Core.Business.Account account = new CY.UME.Core.Business.Account();
                account.Code = TxtSudentCode.Text;
                account.DateCreated = DateTime.Now;
                account.HasAvatar = false;
                account.IsTeacher = false;
                account.Name = TxtUserName.Text;
                account.NickName = string.Empty;
                account.ViewNumber = 0;
                account.Save();

                // extend info
                CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(account.Id);

                if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0")
                {
                    ae.Birthday = UME.Core.Global.MinDateTime;
                }
                else if (YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0")
                {
                    ShowAlert("提示", "请完善您的生日信息!");
                    return;
                }
                else
                {
                    int day = 0, month = 0, year = 0;
                    if (int.TryParse(DayHF.Value, out day))
                        ae.BirthDate = day;
                    if (int.TryParse(MonthHF.Value, out month))
                        ae.BirthMonth = month;
                    if (int.TryParse(YearHF.Value, out year))
                        ae.BirthYear = year;

                    ae.Birthday = new DateTime(year, month, day);//生日
                }
                ae.Email = TxtEmail.Text;
                ae.Gender = RBGenderMale.Checked ? 1 : 0;
                ae.IsEmailChecked = true;
                //ae.LibUserId = 0;
                ae.Password = sh.ComputeMD5Hash(TxtUserPassword.Text);
                ae.UniversityId = CY.Utility.Common.ConvertUtility.ConvertToInt(selUniversity.Value, -1);// 学校
                ae.CollegeId = CY.Utility.Common.ConvertUtility.ConvertToInt(selCollege.Value, -1);// 学院
                ae.GradeId = int.Parse(DDLGrades.SelectedValue);
                ae.Save();

                // add friendship
                CY.UME.Core.Business.Friendship fs = new CY.UME.Core.Business.Friendship();
                fs.AccountId = aii.InviterId;
                fs.DateCreated = DateTime.Now;
                fs.CommunicateNum = 0;
                fs.FriendId = account.Id;
                fs.IsChecked = true;
                fs.Remark = string.Empty;
                fs.Save();

                fs = new CY.UME.Core.Business.Friendship();
                fs.AccountId = account.Id;
                fs.CommunicateNum = 0;
                fs.DateCreated = DateTime.Now;
                fs.FriendId = aii.InviterId;
                fs.IsChecked = true;
                fs.Remark = string.Empty;
                fs.Save();

                aii.IsAccepted = true;
                aii.Save();

                #region 更新邀请人的积分

                int inviteFriendCredit;
                if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount", out inviteFriendCredit) &&
                    (inviteFriendCredit != 0))
                {
                    CY.UME.Core.Business.Account invitor = CY.UME.Core.Business.Account.Load(aii.InviterId);
                    if (invitor != null)
                    {
                        int orgCredit = invitor.Credit;
                        int modifiedCredit = orgCredit + inviteFriendCredit;

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

                        CreditHistory ch = new CreditHistory();
                        ch.AccountId = invitor.Id;
                        ch.DateCreated = DateTime.Now;
                        ch.Id = Guid.NewGuid();
                        ch.InstanceId = aii.Id.ToString();
                        ch.Original = orgCredit;
                        ch.Modified = modifiedCredit;
                        ch.Variation = inviteFriendCredit;
                        ch.Type = "invitefriend";
                        ch.Description = "成功邀请用户 " + account.Name;
                        ch.Save();

                        // 邀请层级效应
                        CY.UME.Core.Business.Account invitor2 = invitor.GetInviter();
                        if (invitor2 != null)
                        {
                            int inviteFriendCredit2;
                            if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount2", out inviteFriendCredit2) &&
                                (inviteFriendCredit2 != 0))
                            {
                                orgCredit = invitor2.Credit;
                                modifiedCredit = orgCredit + inviteFriendCredit2;
                                invitor2.Credit = modifiedCredit;
                                invitor2.Save();

                                ch = new CreditHistory();
                                ch.AccountId = invitor2.Id;
                                ch.DateCreated = DateTime.Now;
                                ch.Id = Guid.NewGuid();
                                ch.InstanceId = aii.Id.ToString();
                                ch.Original = orgCredit;
                                ch.Modified = modifiedCredit;
                                ch.Variation = inviteFriendCredit2;
                                ch.Type = "invitefriend";
                                ch.Description = "所邀请用户 " + invitor.Name + " 成功邀请了 " + account.Name;
                                ch.Save();
                            }
                        }
                    }
                }

                #endregion
                log.Info("注册结束");

                if (Session["user"] != null)
                {
                    Session["user"] = account.Id.ToString();
                }
                else
                {
                    Session.Add("user", account.Id.ToString());
                }

                ShowAlert("注册成功", "恭喜您已经成功注册UME账号,现在系统将引导您至完善个人信息页面");
                ExecuteClientScript("setTimeout(function(){window.location.href='UploadAvatar.aspx?type=firstNum'}, 2000)");
            }
            catch (Exception ex)
            {
                log.Error("用户注册失败:" + ex.Message);
            }
        }
示例#3
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void LB_Next_Click(object sender, EventArgs e)
        {
            if (TxtEmail.Text.Length == 0)
            {
                return;
            }

            CY.UME.Core.Business.SystemLog.SaveLog("Info", "注册开始");

            if (Session["CaptchaImageText"] == null)// 验证码
            {
                ShowAlert("注册失败", "服务器忙,请稍后再试!");
                return;
            }

            string validateCode = Session["CaptchaImageText"].ToString();

            if (TxtValidCode.Text != validateCode)
            {
                ShowAlert("注册失败", "验证码错误!");
                return;
            }
            if (string.IsNullOrEmpty(TxtSudentCode.Text))
            {
                ShowAlert("注册失败", "学号不能为空");
                return;
            }
            if (string.IsNullOrEmpty(TxtUserName.Text))
            {
                ShowAlert("注册失败", "姓名不能为空");
                return;
            }
            if (TxtUserPassword.Text.Length < 6 ||
                TxtUserPassword.Text.Length > 20)
            {
                ShowAlert("注册失败", "密码长度必须在6至20之间");
                return;
            }
            String ZipRegex = @"/^\w{0,19}$/";
            if (System.Text.RegularExpressions.Regex.IsMatch(TxtUserPassword.Text, ZipRegex))
            {
                ShowAlert("注册失败", "密码含有非法字符,只能输入数字、字母和\"_\"的组合。");
                return;
            }
            if (String.Compare(TxtUserPassword.Text.Trim(), TxtUserPasswordAgain.Text.Trim()) != 0)
            {
                ShowAlert("注册失败", "两次密码输入不一致,请重新输入。");
                return;
            }
            if (!RBGenderFemale.Checked && !RBGenderMale.Checked)
            {
                ShowAlert("注册失败", "性别不能为空");
                return;
            }

            if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0")
            {
                ;
            }
            else if (YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0")
            {
                ShowAlert("提示", "请完善您的生日信息!");
                return;
            }

            CY.UME.Core.Business.AccountExtend aeTemp = CY.UME.Core.Business.AccountExtend.Load(TxtEmail.Text.Trim());
            if (aeTemp != null)
            {
                ShowAlert("提示", "该邮箱已被使用!");
                return;
            }

            CY.Security.SecurityHelper sh = new CY.Security.SecurityHelper();

            CY.UME.Core.Business.Account account = new CY.UME.Core.Business.Account();
            account.Code = TxtSudentCode.Text;
            account.DateCreated = DateTime.Now;
            account.HasAvatar = false;
            account.IsTeacher = false;
            account.Name = TxtUserName.Text;
            account.NickName = string.Empty;
            account.ViewNumber = 0;
            account.Save();

            // extend info
            CY.UME.Core.Business.AccountExtend ae = CY.UME.Core.Business.AccountExtend.Load(account.Id);

            if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0")
            {
                ae.Birthday = UME.Core.Global.MinDateTime;
            }
            else
            {
                int day = 0, month = 0, year = 0;
                if (int.TryParse(DayHF.Value, out day))
                    ae.BirthDate = day;
                if (int.TryParse(MonthHF.Value, out month))
                    ae.BirthMonth = month;
                if (int.TryParse(YearHF.Value, out year))
                    ae.BirthYear = year;

                ae.Birthday = new DateTime(year, month, day);//生日
            }
            ae.Email = TxtEmail.Text.Trim();
            ae.Gender = RBGenderMale.Checked ? 1 : 0;
            ae.IsEmailChecked = true;
            //ae.LibUserId = 0;
            ae.Password = sh.ComputeMD5Hash(TxtUserPassword.Text);
            ae.UniversityId = CY.Utility.Common.ConvertUtility.ConvertToInt(HFUniversity.Value, -1);// 学校
            ae.CollegeId = CY.Utility.Common.ConvertUtility.ConvertToInt(HFCollege.Value, -1);// 学院
            ae.GradeId = int.Parse(DDLGrades.SelectedValue);
            ae.IsShow = 0;
            ae.Save();

            try
            {
                /**************************************************废除的代码/*************************************************/
                /************************MySQL数据库同步开始*************************
                CY.UME.Core.Business.Ask_members members = new CY.UME.Core.Business.Ask_members();
                members.Id = account.Id;
                members.Username = ae.Email;
                members.Password = ae.Password;
                //members.Secques = "";
                members.Save();

                CY.UME.Core.Business.Ask_memberfields memberfields = new CY.UME.Core.Business.Ask_memberfields();
                memberfields.Id = account.Id;
                memberfields.Username = ae.Email;
                memberfields.Email = ae.Email;
                memberfields.Nickname = account.NickName;
                memberfields.Realname = account.Name;//HFURLEncodeName.Value;
                memberfields.Gender = ae.Gender;
                memberfields.Birthday = 0;
                memberfields.Score = 200;//后面去改
                memberfields.Save();
                /************************MySQL数据库同步结束*************************/
            }
            catch (Exception ex)
            {
                CY.UME.Core.Business.SystemLog.SaveLog("Error", "用户同步失败:" + ex.Message);
            }

            CY.UME.Core.Business.SystemLog.SaveLog("Info", account.Name + "注册成功");

            if (Session["user"] != null)
            {
                Session["user"] = account.Id.ToString();
            }
            else
            {
                Session.Add("user", account.Id.ToString());
            }
            try
            {
                if (!string.IsNullOrEmpty(Request.QueryString["inviterId"]))
                {
                    long inviterId = CY.Utility.Common.ConvertUtility.ConvertToLong(Request.QueryString["inviterId"], -1);

                    if (inviterId != -1)
                    {
                        Core.Business.Account InviteFriendAccount = Core.Business.Account.Load(inviterId);

                        if (InviteFriendAccount != null)
                        {//邀请用户须存在
                            AccountInviteInfo ai = new AccountInviteInfo();
                            ai.Id = Guid.NewGuid();
                            ai.InviterId = inviterId;
                            ai.InviteeEmail = ae.Email;
                            ai.DateCreated = account.DateCreated;
                            ai.IsAccepted = true;
                            ai.Remark = "从活动过来的";
                            ai.Save();

                            CY.UME.Core.Business.Friendship fs = new Friendship();

                            fs.AccountId = account.Id;
                            fs.DateCreated = DateTime.Now;
                            fs.FriendId = InviteFriendAccount.Id;
                            fs.IsChecked = true;
                            fs.Remark = "活动邀请";
                            fs.Save();

                            CY.UME.Core.Business.Friendship fs2 = new Friendship();

                            fs2.AccountId = InviteFriendAccount.Id;
                            fs2.FriendId = account.Id;
                            fs2.DateCreated = DateTime.Now;
                            fs2.IsChecked = true;
                            fs2.Remark = "活动邀请";
                            fs2.Save();
                        }
                    }
                }
                if (!string.IsNullOrEmpty(Request.QueryString["invId"]))
                {
                    long invId = CY.Utility.Common.ConvertUtility.ConvertToLong(Request.QueryString["invId"], -1);

                    if (invId != -1)
                    {
                        Core.Business.AccountInviteInfo InviteAccount = new AccountInviteInfo();
                        InviteAccount.Id = Guid.NewGuid();
                        InviteAccount.InviterId = invId;
                        InviteAccount.DateCreated = DateTime.Now;
                        InviteAccount.InviteeEmail = ae.Email;
                        InviteAccount.IsAccepted = true;
                        InviteAccount.Save();

                        #region 更新邀请人的积分

                        int inviteFriendCredit;
                        if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount", out inviteFriendCredit) &&
                            (inviteFriendCredit != 0))
                        {
                            CY.UME.Core.Business.Account invitor = CY.UME.Core.Business.Account.Load(invId);
                            if (invitor != null)
                            {
                                CY.UME.Core.Business.Friendship fs = new Friendship();

                                fs.AccountId = account.Id;
                                fs.DateCreated = DateTime.Now;
                                fs.FriendId = invitor.Id;
                                fs.IsChecked = true;
                                fs.Remark = "被链接邀请";
                                fs.Save();

                                CY.UME.Core.Business.Friendship fs2 = new Friendship();

                                fs2.AccountId = invitor.Id;
                                fs2.FriendId = account.Id;
                                fs2.DateCreated = DateTime.Now;
                                fs2.IsChecked = true;
                                fs2.Remark = "链接邀请";
                                fs2.Save();

                                int orgCredit = invitor.Credit;
                                int modifiedCredit = orgCredit + inviteFriendCredit;

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

                                CreditHistory ch = new CreditHistory();
                                ch.AccountId = invitor.Id;
                                ch.DateCreated = DateTime.Now;
                                ch.Id = Guid.NewGuid();
                                ch.InstanceId = invId.ToString();
                                ch.Original = orgCredit;
                                ch.Modified = modifiedCredit;
                                ch.Variation = inviteFriendCredit;
                                ch.Type = "invitefriend";
                                ch.Description = "成功邀请用户 " + account.Name;
                                ch.AssistAccountId = account.Id;
                                ch.Save();

                                // 邀请层级效应
                                CY.UME.Core.Business.Account invitor2 = invitor.GetInviter();
                                if (invitor2 != null)
                                {
                                    int inviteFriendCredit2;
                                    if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditInviteAccount2", out inviteFriendCredit2) &&
                                        (inviteFriendCredit2 != 0))
                                    {
                                        orgCredit = invitor2.Credit;
                                        modifiedCredit = orgCredit + inviteFriendCredit2;
                                        invitor2.Credit = modifiedCredit;
                                        invitor2.Save();

                                        ch = new CreditHistory();
                                        ch.AccountId = invitor2.Id;
                                        ch.DateCreated = DateTime.Now;
                                        ch.Id = Guid.NewGuid();
                                        ch.InstanceId = invId.ToString();
                                        ch.Original = orgCredit;
                                        ch.Modified = modifiedCredit;
                                        ch.Variation = inviteFriendCredit2;
                                        ch.Type = "invitefriend";
                                        ch.Description = "所邀请用户 " + invitor.Name + " 成功邀请了 " + account.Name;
                                        ch.Save();
                                    }
                                }
                            }
                        }

                        #endregion
                    }
                }

            }
            catch (Exception)
            { }

            //ShowAlert("注册成功", "恭喜您已经成功注册UME账号,现在系统将引导您至完善个人信息页面");
            //ExecuteClientScript("setTimeout(function(){window.location.href='UploadAvatar.aspx?type=firstNum'}, 1000)")
            SaveAccountCookie(TxtEmail.Text.Trim(), sh.ComputeMD5Hash(TxtUserPassword.Text));//保存Cookie用于问问吧登录
            Server.Transfer("UploadAvatar.aspx?type=firstNum");
        }
示例#4
0
        private void AddLoginCredit(Account account)
        {
            #region 添加登录积分

            int loginCredit;
            int maxLoginCreditInDay;
            if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditLogin", out loginCredit) &&
                (loginCredit != 0) &&
                CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditLoginMaxInDay", out maxLoginCreditInDay))
            {
                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(
                        "login",
                        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 < maxLoginCreditInDay)
                {
                    loginCredit = (creditsAlreadyGainToday + loginCredit > maxLoginCreditInDay) ? (maxLoginCreditInDay - creditsAlreadyGainToday) : loginCredit;

                    int orgCredit = account.Credit;
                    int modifiedCredit = orgCredit + loginCredit;

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

                    CreditHistory ch = new 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 = loginCredit;
                    ch.Type = "login";
                    ch.Description = "用户登录";
                    ch.Save();
                }
            }
            #endregion
        }
示例#5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            CY.UME.Core.Business.Account account;
            string validateCode = string.Empty;
            string correctCode;
            string mobilePhone;

            #region Validate

            if (context.Session["mobilevalidatecode"] == null ||
                context.Session["mobilephonenum"] == null)
            {
                context.Response.Write("{success: false, msg: '操作超时!'}");
                return;
            }
            correctCode = context.Session["mobilevalidatecode"].ToString();
            mobilePhone = context.Session["mobilephonenum"].ToString();

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

            if (string.IsNullOrEmpty(context.Request.Form["code"]))
            {
                context.Response.Write("{success: false, msg: '验证码不能为空!'}");
                return;
            }
            validateCode = context.Request.Form["code"];

            #endregion

            if (validateCode == correctCode)
            {
                CY.UME.Core.Business.AccountExtend ae = account.ExtendInfo;
                if (ae == null)
                {
                    ae = new CY.UME.Core.Business.AccountExtend();
                    ae.Id = account.Id;
                }

                string orignalPhone = ae.Telephone;
                ae.Telephone = mobilePhone;
                ae.Save();

                #region 绑定手机积分

                if (string.IsNullOrEmpty(orignalPhone))
                {
                    int bindPhoneCredit;
                    if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditBindPhone", out bindPhoneCredit) &&
                        (bindPhoneCredit != 0))
                    {
                        int creditHistoriesCount = CreditHistory.GetCreditHistoryCount(
                                "bindphone",
                                account.Id,
                                new long?(),
                                string.Empty,
                                new DateTime?(),
                                new DateTime?()
                            ); // 由绑定手机而获得的积分次数

                        if (creditHistoriesCount == 0)
                        {
                            int orgCredit = account.Credit;
                            int modifiedCredit = orgCredit + bindPhoneCredit;
                            account.Credit = modifiedCredit;
                            account.Save();

                            CreditHistory ch = new CreditHistory();
                            ch.AccountId = account.Id;
                            ch.DateCreated = DateTime.Now;
                            ch.Id = Guid.NewGuid();
                            ch.InstanceId = "";
                            ch.Original = orgCredit;
                            ch.Modified = modifiedCredit;
                            ch.Variation = bindPhoneCredit;
                            ch.Type = "bindphone";
                            ch.Description = "绑定手机";
                            ch.Save();
                        }
                    }
                }

                #endregion

                context.Response.Write("{success:true}");

                context.Session.Remove("mobilevalidatecode");
                context.Session.Remove("mobilephonenum");
            }
            else
            {
                context.Response.Write("{success: false, msg: '验证码不相符,请重新输入!'}");
            }
        }
示例#6
0
        protected void Save_OnClick(object sender, EventArgs e)
        {
            if (TbxAccountName.Text.Trim().Length == 0)
            {
                Response.Write("<script language='javascript'>alert('请输入用户姓名!');</script>");
                return;
            }

            CY.UME.Core.Business.Account account = CY.UME.Core.Business.Account.Load(SpaceAccount.Id);
            CY.UME.Core.Business.AccountExtend accountExtend = account.ExtendInfo;
            int originalInfoIntegrity = account.GetInfoIntegrity();

            account.Name = TbxAccountName.Text.Trim();//姓名
            account.NickName = TBXNickName.Text.Trim();//昵称

            if (YearHF.Value == "0" && MonthHF.Value == "0" && DayHF.Value == "0")
            {
                accountExtend.Birthday = UME.Core.Global.MinDateTime;
            }
            else if (YearHF.Value == "0" || MonthHF.Value == "0" || DayHF.Value == "0")
            {
                Response.Write("<script language='javascript'>alert('请完善您的生日信息!');</script>");
                return;
            }
            else
            {
                int day = 0, month = 0, year = 0;
                if (int.TryParse(DayHF.Value, out day))
                    accountExtend.BirthDate = day;
                if (int.TryParse(MonthHF.Value, out month))
                    accountExtend.BirthMonth = month;
                if (int.TryParse(YearHF.Value, out year))
                    accountExtend.BirthYear = year;

                accountExtend.Birthday = new DateTime(year, month, day);//生日
            }
            if (RBLGenderMan.Checked)//性别
            {
                accountExtend.Gender = 1;
            }
            else if (RBLGenderWoman.Checked)
            {
                accountExtend.Gender = 0;
            }
            else
            {
                accountExtend.Gender = -1;
            }

            accountExtend.HometownProvinceId = provinceCityHome.ProvinceId;//家乡城市
            accountExtend.HometownCityId = provinceCityHome.CityId;//家乡省份
            accountExtend.ResideCityId = provinceCityAddress.CityId;//所在地城市
            accountExtend.ResideProvinceId = provinceCityAddress.ProvinceId;//所在地省份
            accountExtend.BloodType = DDLBloodType.SelectedValue;//血型

            try
            {
                account.Save();
                accountExtend.Save();

                if (originalInfoIntegrity < 90)
                {
                    int currentInfoIntegrity = account.GetInfoIntegrity();
                    if (currentInfoIntegrity >= 90)
                    {
                        #region 首次完善个人资料,赠送积分

                        int editProfileCredit;
                        if (CY.UME.Core.Business.SystemSetting.TryLoadInt32Setting("CreditAddInfo", out editProfileCredit) &&
                            (editProfileCredit != 0))
                        {
                            int creditHistoriesCount = CreditHistory.GetCreditHistoryCount(
                                "editeprofile",
                                account.Id,
                                new long?(),
                                string.Empty,
                                new DateTime?(),
                                new DateTime?()
                            ); // 由完善资料而获得的积分次数

                            if (creditHistoriesCount == 0)
                            {
                                int orgCredit = account.Credit;
                                int modifiedCredit = orgCredit + editProfileCredit;
                                account.Credit = modifiedCredit;
                                account.Save();

                                CreditHistory ch = new CreditHistory();
                                ch.AccountId = account.Id;
                                ch.DateCreated = DateTime.Now;
                                ch.Id = Guid.NewGuid();
                                ch.InstanceId = "";
                                ch.Original = orgCredit;
                                ch.Modified = modifiedCredit;
                                ch.Variation = editProfileCredit;
                                ch.Type = "editeprofile";
                                ch.Description = "完善个人资料";
                                ch.Save();
                            }
                        }

                        #endregion

                    }
                }

                //Response.Write("<script language='javascript'>alert('您的基本信息更新成功!');</script>");
                LblFinish.Text = "<span style='color:#ff0000;'>你的基本信息更新成功!</span>";
                UserInfoBind(account);
                SpaceAccount = account;
            }
            catch
            {
                throw new Exception("保存失败");
            }
            if (back == "guide")
            {
                Response.Redirect("Guide2.aspx");
            }
        }
        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();

                if (height <= width && width >= 200)
                {
                    height = Convert.ToInt32(width > 200 ? (200f / width) * height : height);
                    width = 200;
                }
                else if (width < height && height > 200)
                {
                    width = Convert.ToInt32(height > 200 ? (200f / height) * width : height);
                    height = 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, 65, 65);//之前是48 x 48 2010.12.21 刘小平
                }

                // 将大图移动到头像目录下
                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;

                        CreditHistory ch = new 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;
            }
        }