Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int threadID = _Request.Get<int>("threadID", Method.Get, 0);

            if (threadID < 1)
                ShowError(new InvalidParamError("threadID").Message);

            thread = PostBOV5.Instance.GetThread(threadID);
            if (thread == null)
                ShowError("该主题不存在或者已被删除!");

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(thread.ForumID);
            if (thread.PostUserID != MyUserID && (!permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents)))
            {
                if (!thread.IsBuyed(My))
                {
                    ShowError("您还没有购买此主题,不能查看购买记录!");
                }
            }

            TradePoint = ForumPointAction.Instance.GetUserPoint(thread.PostUserID, ForumPointValueType.SellThread, thread.ForumID);

            int pageNumber = _Request.Get<int>("page",Method.Get,1);

            ExchangeList = PostBOV5.Instance.GetThreadExchanges(threadID, pageNumber, pageSize, out totalCount, out totalMoney);

            WaitForFillSimpleUsers<ThreadExchange>(ExchangeList);

            SetPager("list", null, pageNumber, pageSize, totalCount);
        }
 public NotEnoughPointBuyAttachment(string target, UserPoint point, int price, int myPoint)
     : base(target)
 {
     Point = point;
     Price = price;
     MyPoint = myPoint;
 }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int threadID = _Request.Get<int>("threadID", Method.Get, 0);

            if (threadID < 1)
                ShowError(new InvalidParamError("threadID").Message);

            int pageNumber = _Request.Get<int>("page",Method.Get,1);

            ThreadType realType;
            PostBOV5.Instance.GetQuestionWithReplies(threadID, pageNumber, pageSize, true, false, out question, out PostList, out realType);

            if(realType!= ThreadType.Question)
                ShowError("该主题不是问题帖");

            if (question == null)
                ShowError("该问题不存在或者已被删除!");

            if (question.IsClosed)
                ShowError("该问题已经结束");

            if (MyUserID != question.PostUserID)
            {
                if (!AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(question.ForumID).Can(My, ManageForumPermissionSetNode.ActionWithTarget.FinalQuestion, question.PostUserID))
                    ShowError("您不能结" + UserBO.Instance.GetUser(question.PostUserID, GetUserOption.WithAll).Name + "的帖子");

            }

            TradePoint = ForumPointAction.Instance.GetUserPoint(question.PostUserID, ForumPointValueType.QuestionReward, question.ForumID);

            WaitForFillSimpleUsers<PostV5>(PostList, 1);

            PostIDs = StringUtil.Split2<int>(_Request.Get("postids", Method.Get, string.Empty));

            SetPager("list", null, pageNumber, pageSize, question.TotalReplies + 1);


            if (_Request.IsClick("finalButton"))
            {
                processSubmit();
            }

        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int attachmentID = _Request.Get<int>("attachmentID", Method.Get, 0);

            if (attachmentID < 1)
                ShowError(new InvalidParamError("attachmentID").Message);

            attachment = PostBOV5.Instance.GetAttachment(attachmentID, false);
            if (attachment == null)
                ShowError("该附件不存在或者已被删除!");

            PostV5 post = PostBOV5.Instance.GetPost(attachment.PostID, false);
            if (post == null)
            {
                ShowError("该附件不存在或者已被删除!");
            }

            ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID);
            if (post.UserID != MyUserID && (!permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents)))
            {
                if (!attachment.IsBuyed(My))
                {
                    ShowError("您还没有购买此附件,不能查看购买记录!");
                }
            }

            TradePoint = ForumPointAction.Instance.GetUserPoint(post.UserID, ForumPointValueType.SellAttachment, post.ForumID);

            int pageNumber = _Request.Get<int>("page",Method.Get,1);

            ExchangeList = PostBOV5.Instance.GetAttachmentExchanges(attachmentID, pageNumber, pageSize, out totalCount, out totalMoney);

            WaitForFillSimpleUsers<AttachmentExchange>(ExchangeList);

            SetPager("list", null, pageNumber, pageSize, totalCount);
        }
Esempio n. 5
0
        public UserPointCollection GetDefaultUserPoints()
        {
            UserPointCollection tempPoints = new UserPointCollection();
            UserPoint point = new UserPoint();
            point.Type = UserPointType.Point1;
            point.Enable = true;
            point.Display = true;
            point.Name = "金钱";
            point.InitialValue = 1000;
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point2;
            point.Enable = true;
            point.Display = true;
            point.Name = "威望";
            point.InitialValue = 100;
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point3;
            point.Enable = false;
            point.Name = "积分3";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point4;
            point.Enable = false;
            point.Name = "积分4";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point5;
            point.Enable = false;
            point.Name = "积分5";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point6;
            point.Enable = false;
            point.Name = "积分6";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point7;
            point.Enable = false;
            point.Name = "积分7";
            tempPoints.Add(point);

            point = new UserPoint();
            point.Type = UserPointType.Point8;
            point.Enable = false;
            point.Name = "积分8";
            tempPoints.Add(point);
            return tempPoints;
        }
Esempio n. 6
0
 public UserPoint GetUserPoint(UserPointType userPointType)
 {
     if (userPointType == UserPointType.GeneralPoint)
     {
         UserPoint point = new UserPoint();
         point.Name = GeneralPointName;
         point.UnitName = string.Empty;
         point.Type = userPointType;
         point.Enable = true;
         point.Display = DisplayGeneralPoint;
         return point;
     }
     foreach (UserPoint userPoint in UserPoints)
     {
         if (userPointType == userPoint.Type)
             return userPoint;
     }
     return null;
 }
Esempio n. 7
0
        public string CreateUserPay(User operatorUser, string orderNo, byte payment, UserPointType payType, int payValue, string submitIp)
        {
            if (operatorUser == User.Guest)
            {
                ThrowError(new NotLoginError());
                return(null);
            }

            UserPoint userPoint = AllSettings.Current.PointSettings.GetUserPoint(payType);

            if (userPoint.Enable == false)
            {
                ThrowError(new CustomError("", "您要充值的积分“" + userPoint.Name + "”未启用"));
                return(null);
            }

            decimal orderAmount = 0;
            bool    hasRule     = false;

            foreach (PointRechargeRule rule in AllSettings.Current.PointSettings.PointRechargeRules)
            {
                if (rule.UserPointType == payType)
                {
                    if (rule.Enable == false)
                    {
                        ThrowError(new CustomError("", "您不能对该积分进行充值"));
                        return(null);
                    }
                    if (payValue < rule.MinValue)
                    {
                        ThrowError(new CustomError("", "一次最少需要充值" + rule.MinValue + userPoint.UnitName + userPoint.Name));
                        return(null);
                    }

                    decimal temp = (decimal)rule.Money * payValue / rule.Point;

                    //保留两位小数  进一法
                    temp = temp - (decimal)0.005;
                    if (temp == (decimal)0.005)
                    {
                        temp = (decimal)0.006;
                    }

                    orderAmount = decimal.Round(temp, 2);
                    if (rule.Money * payValue * 100 % rule.Point > 0)
                    {
                        orderAmount = orderAmount + (decimal)0.01;
                    }


                    hasRule = true;
                    break;
                }
            }

            if (hasRule == false)
            {
                ThrowError(new CustomError("", "管理员未设置可充值的积分"));
                return(null);
            }

            string payTypeName = userPoint.Name;


            string payUrl = string.Empty;
            int    userID = operatorUser.UserID;

            //充值方式
            switch (payment)
            {
            case 1:
                if (AllSettings.Current.PaySettings.EnableAlipay == false)
                {
                    ThrowError(new CustomError("", "管理员已关闭支付宝充值方式"));
                    return(null);
                }
                payUrl = Alipay(userID, orderNo, orderAmount, payment, (byte)payType, payTypeName, payValue, submitIp);
                break;

            case 2:
                if (AllSettings.Current.PaySettings.EnableTenpay == false)
                {
                    ThrowError(new CustomError("", "管理员已关闭财付通充值方式"));
                    return(null);
                }
                payUrl = Tenpay(userID, orderNo, orderAmount, payment, (byte)payType, payTypeName, payValue, submitIp);
                break;

            case 3:
                if (AllSettings.Current.PaySettings.Enable99Bill == false)
                {
                    ThrowError(new CustomError("", "管理员已关闭快钱充值方式"));
                    return(null);
                }
                payUrl = _99Bill(userID, orderNo, orderAmount, payment, (byte)payType, payTypeName, payValue, submitIp);
                break;

            default:
                ThrowError(new CustomError("payment", "没有选择支付方式"));
                break;
            }
            return(payUrl);
        }
        public void createUser()
        {
            IEncourageStrategy <int> strategy2;

            this.API.SpeItems[7, 1] = this.API.GetNodeText(this.API.SpeItems[7, 0]);
            if (!this.CheckUserName() || !this.CheckUserEmail())
            {
                return;
            }
            this.API.PrepareData(true);
            UserInfo usersInfo = new UserInfo();

            usersInfo.Question = this.API.SpeItems[8, 1];
            usersInfo.Answer   = StringHelper.MD5(this.API.SpeItems[9, 1]);
            usersInfo.Email    = this.API.SpeItems[7, 1];
            string str = DataSecurity.MakeRandomString(10);

            usersInfo.LastPassword = str;
            ContacterInfo contacterInfo = new ContacterInfo();

            contacterInfo.TrueName    = this.API.SpeItems[11, 1];
            contacterInfo.Country     = "";
            contacterInfo.Province    = "";
            contacterInfo.City        = "";
            contacterInfo.Address     = this.API.SpeItems[0x12, 1];
            contacterInfo.ZipCode     = this.API.SpeItems[0x13, 1];
            contacterInfo.OfficePhone = this.API.SpeItems[0x11, 1];
            contacterInfo.HomePhone   = "";
            contacterInfo.Mobile      = this.API.SpeItems[0x10, 1];
            contacterInfo.Fax         = "";
            contacterInfo.Homepage    = this.API.SpeItems[20, 1];
            contacterInfo.Email       = this.API.SpeItems[7, 1];
            contacterInfo.QQ          = this.API.SpeItems[14, 1];
            contacterInfo.Msn         = this.API.SpeItems[15, 1];
            contacterInfo.Icq         = "";
            contacterInfo.Yahoo       = "";
            contacterInfo.UC          = "";
            contacterInfo.Aim         = "";
            contacterInfo.IdCard      = "";
            if (this.API.SpeItems[12, 1] == "1")
            {
                this.API.SpeItems[12, 1] = "Female";
            }
            else if (this.API.SpeItems[12, 1] == "0")
            {
                this.API.SpeItems[12, 1] = "Male";
            }
            else
            {
                this.API.SpeItems[12, 1] = "Secrecy";
            }
            contacterInfo.Sex            = (UserSexType)Enum.Parse(typeof(UserSexType), this.API.SpeItems[12, 1]);
            contacterInfo.Marriage       = UserMarriageType.Secrecy;
            contacterInfo.Income         = -1;
            contacterInfo.Education      = -1;
            contacterInfo.Company        = "";
            contacterInfo.Department     = "";
            contacterInfo.ClientId       = 0;
            contacterInfo.ParentId       = 0;
            contacterInfo.CreateTime     = DateTime.Now;
            contacterInfo.Owner          = "";
            contacterInfo.UserType       = ContacterType.EnterpriceMainContacter;
            contacterInfo.UpdateTime     = DateTime.Now;
            contacterInfo.UserName       = Users.UserNamefilter(this.API.SpeItems[5, 1]);
            contacterInfo.Phs            = "";
            contacterInfo.Birthday       = string.IsNullOrEmpty(this.API.SpeItems[13, 1]) ? null : new DateTime?(Convert.ToDateTime(this.API.SpeItems[13, 1]));
            contacterInfo.Position       = "";
            usersInfo.UserName           = Users.UserNamefilter(this.API.SpeItems[5, 1]);
            usersInfo.UserPassword       = StringHelper.MD5(this.API.SpeItems[6, 1]);
            usersInfo.GroupId            = this.userSiteConfig.GroupId;
            usersInfo.JoinTime           = DateTime.Now;
            usersInfo.RegTime            = DateTime.Now;
            usersInfo.UserExp            = (int)this.userSiteConfig.PresentExp;
            usersInfo.UserPoint          = 0;
            usersInfo.IsInheritGroupRole = true;
            usersInfo.Status             = UserStatus.None;
            if (this.userSiteConfig.EmailCheckReg)
            {
                usersInfo.Status   = UserStatus.WaitValidateByEmail;
                usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10);
            }
            if (this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin;
            }
            if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail;
            }
            usersInfo.EndTime = new DateTime?(DateTime.Now);
            usersInfo.Balance = 0M;
            if (!Users.Add(usersInfo, contacterInfo))
            {
                this.API.FoundErr = true;
                this.API.ErrMsg   = "注册失败!";
                return;
            }
            if (this.userSiteConfig.PresentMoney != 0.0)
            {
                IEncourageStrategy <decimal> strategy = new UserMoney();
                strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱");
            }
            if (this.userSiteConfig.PresentValidNum == 0)
            {
                goto Label_05C6;
            }
            int howMany = 0;

            if (this.userSiteConfig.PresentValidNum == -1)
            {
                howMany = 0x270f;
            }
            else
            {
                switch (this.userSiteConfig.PresentValidUnit)
                {
                case 1:
                    howMany = this.userSiteConfig.PresentValidNum;
                    goto Label_059B;

                case 2:
                    howMany = this.userSiteConfig.PresentValidNum * 30;
                    goto Label_059B;

                case 3:
                    howMany = this.userSiteConfig.PresentValidNum * 0x16d;
                    goto Label_059B;
                }
                howMany = this.userSiteConfig.PresentValidNum;
            }
            Label_059B:
            strategy2 = new UserDate();
            strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期");
            Label_05C6:
            if (this.userSiteConfig.PresentPoint != 0)
            {
                IEncourageStrategy <int> strategy3 = new UserPoint();
                strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券");
            }
            if (this.userSiteConfig.EmailCheckReg)
            {
                MailInfo mailInfo = new MailInfo();
                mailInfo.IsBodyHtml = true;
                mailInfo.FromName   = SiteConfig.SiteInfo.SiteName;
                List <MailAddress> list = new List <MailAddress>();
                list.Add(new MailAddress(usersInfo.Email));
                mailInfo.MailToAddressList = list;
                mailInfo.MailBody          = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum);
                mailInfo.Subject           = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码";
                SendMail.Send(mailInfo);
            }
            if (usersInfo.Status == UserStatus.None)
            {
                UserPrincipal principal = new UserPrincipal();
                principal.UserName     = usersInfo.UserName;
                principal.LastPassword = usersInfo.LastPassword;
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, DateTime.Now, DateTime.Now.AddMinutes(60.0), false, principal.SerializeToString());
                string     str2   = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str2);
                cookie.HttpOnly = true;
                cookie.Path     = FormsAuthentication.FormsCookiePath;
                cookie.Secure   = FormsAuthentication.RequireSSL;
                base.Response.Cookies.Add(cookie);
            }
        }
Esempio n. 9
0
 public void AddPoint(UserPoint up, string name)
 {
     Points[NPoints]           = up;
     VectorStartNames[NPoints] = name;
     NPoints++;
 }
 public bool Add(UserPoint userPoint)
 {
     _mydb.UserPoint.Add(userPoint);
     return(true);
 }
Esempio n. 11
0
        /// <summary>
        /// 用户通过积分购买邀请码
        /// </summary>
        /// <param name="buyNumber"></param>
        public void BuyInviteSerial(AuthUser operatorUser, int buyCount)
        {
            if (buyCount <= 0)
            {
                ThrowError(new InviteSerialCountFormatError("buyCount", buyCount.ToString()));
                return;
            }
            if (operatorUser.UserID <= 0)
            {
                ThrowError(new NotLoginError());
                return;
            }

            InvitationSettings invitationSettings = AllSettings.Current.InvitationSettings;

            if (invitationSettings.InviteMode == InviteMode.Close ||
                invitationSettings.InviteMode == InviteMode.InviteLinkOptional ||
                invitationSettings.InviteMode == InviteMode.InviteLinkRequire
                )
            {
                ThrowError(new InviteSerialDisableError());
                return;
            }

            if (operatorUser.NeedInputInviteSerial)
            {
                ThrowError(new CustomError("operatorUser", "您的账号本身尚未输入邀请码,您不具备购买邀请码的资格"));
                return;
            }

            if (!CanBuyInviteSerial(operatorUser))
            {
                ThrowError(new NoPermissionManageInviteSerialError());
                return;
            }

            DateTime ExpiresDate;

            if (AllSettings.Current.InvitationSettings.InviteEffectiveHours <= 0)
            {
                ExpiresDate = DateTime.MaxValue;
            }
            else
            {
                ExpiresDate = DateTimeUtil.Now.AddHours(AllSettings.Current.InvitationSettings.InviteEffectiveHours);
            }

            //连续购买数量检查
            if (AllSettings.Current.InvitationSettings.Interval != InviteBuyInterval.Disable &&
                (AllSettings.Current.InvitationSettings.InviteSerialBuyCount < buyCount ||
                 InviteDao.Instance.CheckOverFlowBuyCount(operatorUser.UserID
                                                          , AllSettings.Current.InvitationSettings.Interval
                                                          , AllSettings.Current.InvitationSettings.InviteSerialBuyCount
                                                          )))
            {
                ThrowError(new InviteSerialBuyOverflow(AllSettings.Current.InvitationSettings.InviteSerialBuyCount,
                                                       AllSettings.Current.InvitationSettings.Interval));
                return;
            }

            UserPointType type = invitationSettings.PointFieldIndex;

            UserPoint point = AllSettings.Current.PointSettings.GetUserPoint(type);

            if (!point.Enable)
            {
                ThrowError(new BuyInviteSerialPointNotEnableError(point.Name));
                return;
            }

            int[] points = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };


            points[(int)type] = 0 - invitationSettings.IntiveSerialPoint * buyCount;

            if (UserBO.Instance.UpdateUserPoints(operatorUser.UserID, false, true, points, "邀请", string.Concat("购买", buyCount, "个邀请码每个" + invitationSettings.IntiveSerialPoint)))
            {
                string remark = string.Format("花费{0}{1}{2}购买", AllSettings.Current.InvitationSettings.IntiveSerialPoint, point.UnitName, point.Name);
                InviteDao.Instance.BuyInviteSerial(operatorUser.UserID, buyCount, ExpiresDate, remark);
            }
        }
Esempio n. 12
0
 public ActionResult SubmitPoints(UserPoint up)
 {
     _db.AddPoints(up);
     return Json(new { success = "Registered Success and mail sent" });
 }
Esempio n. 13
0
        private void ProcessBuyAttachment()
        {
            if (IsLogin == false)
            {
                ShowError("您还没有登陆,不能购买附件!");
            }
            else
            {
                Attachment tempAttachment = null;
                MaxLabs.bbsMax.FileSystem.PhysicalFile phyFile = null;
                if (tempAttachmentID <= 0)
                {
                    ShowError(new InvalidParamError("attachmentID"));
                }
                else
                {
                    tempAttachment = PostBOV5.Instance.GetAttachment(tempAttachmentID);

                    if (tempAttachment == null)
                    {
                        ShowError("该附件不存在,可能被移动或被删除!");
                    }
                    //diskFile = zzbird.Common.Disk.DiskManager.GetDiskFile(tempAttachment.DiskFileID);
                    phyFile = FileManager.GetFile(tempAttachment.FileID);
                }
                if (phyFile == null)
                {
                    ShowError("该附件不存在,可能被移动或被删除!");
                }

                if (MyUserID == tempAttachment.UserID || tempAttachment.Price == 0)
                {
                    ShowError("该附件您不需要购买!");
                }
                if (!tempAttachment.IsBuyed(My))//没购买过
                {
                    int trade = Math.Abs(tempAttachment.Price);

                    PostV5 post = PostBOV5.Instance.GetPost(tempAttachment.PostID, false);
                    if (post == null)
                    {
                        ShowError("该附件不存在,可能被移动或被删除!");
                    }

                    UserPoint tradePoint = ForumPointAction.Instance.GetUserPoint(tempAttachment.UserID, ForumPointValueType.SellAttachment, post.ForumID);

                    if (tradePoint == null)
                    {
                        ShowError("系统交易积分错误!");
                    }

                    using (ErrorScope es = new ErrorScope())
                    {
                        bool success = UserBO.Instance.TradePoint(MyUserID, tempAttachment.UserID, tempAttachment.Price, tradePoint.Type, false, true, null);
                        if (success == false)
                        {
                            es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                            {
                                if (error is UserPointOverMinValueError)
                                {
                                    UserPointOverMinValueError tempError = (UserPointOverMinValueError)error;
                                    NotEnoughPointBuyAttachment notEnoughPointBuyAttachment = new NotEnoughPointBuyAttachment("", tempError.UserPoint, tempAttachment.Price, My.ExtendedPoints[(int)tempError.UserPoint.Type]);
                                    ShowError(notEnoughPointBuyAttachment);
                                }
                                else
                                {
                                    ShowError(error.Message);
                                }
                            });
                        }
                        else
                        {
                            //创建交易记录
                            if (!PostBOV5.Instance.CreateAttachmentExchange(tempAttachment.AttachmentID, MyUserID, tempAttachment.Price))
                            {
                                ShowError("购买成功,创建交易记录失败!");
                            }
                            else
                            {
                                //下载
                                //更新userprofile
                                if (My.BuyedAttachments.ContainsKey(tempAttachment.AttachmentID))
                                {
                                    My.BuyedAttachments[tempAttachment.AttachmentID] = true;
                                }

                                //Thread.FirstPost = null;
                                ShowSuccess("购买成功,现在可以查看、下载或收藏!", true);
                            }
                        }
                    }
                }
                else
                {
                    ShowError("您已经购买此附件,无需再次购买!");
                }
            }
        }
 private void AddBankroll(int paymentLogId)
 {
     if (!BankrollItem.ExistsPaymentLog(paymentLogId))
     {
         PaymentLogInfo paymentLogById = PaymentLog.GetPaymentLogById(paymentLogId);
         if (!paymentLogById.IsNull)
         {
             IEncourageStrategy <decimal> strategy = new UserMoney();
             int      userId          = 0;
             UserInfo usersByUserName = new UserInfo(true);
             if (!string.IsNullOrEmpty(paymentLogById.UserName))
             {
                 usersByUserName = Users.GetUsersByUserName(paymentLogById.UserName);
                 userId          = usersByUserName.UserId;
                 if (userId > 0)
                 {
                     strategy.IncreaseForUsers(userId.ToString(), paymentLogById.MoneyPay, "", false, "");
                     BankrollItemInfo bankrollItemInfo = new BankrollItemInfo();
                     bankrollItemInfo.UserName     = paymentLogById.UserName;
                     bankrollItemInfo.Money        = paymentLogById.MoneyPay;
                     bankrollItemInfo.MoneyType    = 3;
                     bankrollItemInfo.EBankId      = paymentLogById.PlatformId;
                     bankrollItemInfo.OrderId      = paymentLogById.OrderId;
                     bankrollItemInfo.PaymentId    = paymentLogId;
                     bankrollItemInfo.Remark       = "在线支付单号:" + paymentLogById.PaymentNum;
                     bankrollItemInfo.DateAndTime  = DateTime.Now;
                     bankrollItemInfo.CurrencyType = 1;
                     bankrollItemInfo.ClientId     = usersByUserName.ClientId;
                     BankrollItem.Add(bankrollItemInfo);
                 }
             }
             if (paymentLogById.OrderId > 0)
             {
                 OrderInfo orderById = Order.GetOrderById(paymentLogById.OrderId);
                 if (!orderById.IsNull)
                 {
                     decimal d = 0M;
                     if (orderById.MoneyTotal > orderById.MoneyReceipt)
                     {
                         if ((orderById.MoneyTotal - orderById.MoneyReceipt) > paymentLogById.MoneyPay)
                         {
                             if (SiteConfig.ShopConfig.EnablePartPay)
                             {
                                 d = paymentLogById.MoneyPay;
                                 orderById.MoneyReceipt += paymentLogById.MoneyPay;
                             }
                         }
                         else
                         {
                             d = orderById.MoneyTotal - orderById.MoneyReceipt;
                             orderById.MoneyReceipt = orderById.MoneyTotal;
                         }
                         orderById.Status = OrderStatus.Confirmed;
                         Order.Update(orderById);
                     }
                     if (d > 0M)
                     {
                         strategy.IncreaseForUsers(userId.ToString(), -d, "", false, "");
                         BankrollItemInfo info5 = new BankrollItemInfo();
                         info5.UserName     = usersByUserName.UserName;
                         info5.ClientId     = usersByUserName.ClientId;
                         info5.Money        = -d;
                         info5.MoneyType    = 4;
                         info5.EBankId      = 0;
                         info5.OrderId      = orderById.OrderId;
                         info5.PaymentId    = 0;
                         info5.Remark       = "支付订单费用,订单号:" + orderById.OrderNum;
                         info5.DateAndTime  = DateTime.Now;
                         info5.CurrencyType = 1;
                         BankrollItem.Add(info5);
                     }
                 }
             }
             else if (paymentLogById.Point > 0)
             {
                 IEncourageStrategy <int> strategy2 = new UserPoint();
                 strategy2.IncreaseForUsers(userId.ToString(), paymentLogById.Point, "购买" + SiteConfig.UserConfig.PointName, true, "");
                 BankrollItemInfo info6 = new BankrollItemInfo();
                 info6.UserName     = usersByUserName.UserName;
                 info6.ClientId     = usersByUserName.ClientId;
                 info6.Money        = (paymentLogById.MoneyPay > 0M) ? (-1M * paymentLogById.MoneyPay) : paymentLogById.MoneyPay;
                 info6.MoneyType    = 4;
                 info6.EBankId      = 0;
                 info6.OrderId      = 0;
                 info6.PaymentId    = 0;
                 info6.Remark       = "购买" + SiteConfig.UserConfig.PointName + ",购买数:" + paymentLogById.Point.ToString() + SiteConfig.UserConfig.PointUnit;
                 info6.DateAndTime  = new DateTime?(DateTime.Now);
                 info6.CurrencyType = 1;
                 BankrollItem.Add(info6);
                 if (usersByUserName.UserId > 0)
                 {
                     strategy.IncreaseForUsers(usersByUserName.UserId.ToString(), -(paymentLogById.MoneyPay), "", false, "");
                 }
             }
         }
     }
 }
Esempio n. 15
0
 public PayOnlineState UpdateOrder(string paymentNum, decimal amount, string eBankInfo, int status, string remark, bool updateDeliverStatus, bool updateOrderStatus)
 {
     if (Convert.ToString(PEContext.Current.Context.Session["PaymentNum"]) != paymentNum)
     {
         PEContext.Current.Context.Session["PaymentNum"] = paymentNum;
         StringBuilder payOnlineMessage = new StringBuilder(0x40);
         paymentNum = DataSecurity.FilterBadChar(paymentNum);
         eBankInfo  = DataSecurity.FilterBadChar(eBankInfo);
         remark     = DataSecurity.FilterBadChar(remark);
         PayOnlineState state = this.UpdatePaymentLog(paymentNum, amount, eBankInfo, status, remark);
         if (state != PayOnlineState.Ok)
         {
             PEContext.Current.Context.Session["PaymentNum"] = "";
             return(state);
         }
         if (!updateDeliverStatus)
         {
             PEContext.Current.Context.Session["PaymentNum"] = "";
             return(PayOnlineState.Ok);
         }
         bool doUpdate = !BankrollItem.ExistsPaymentLog(this.m_PaymentLogId);
         if (!doUpdate)
         {
             PEContext.Current.Context.Session["PaymentNum"] = "";
             return(PayOnlineState.AccountPaid);
         }
         bool isok = false;
         IEncourageStrategy <decimal> strategy = new UserMoney();
         if (updateOrderStatus)
         {
             if (this.m_UserId > 0)
             {
                 strategy.IncreaseForUsers(this.m_UserId.ToString(), this.m_MoneyReceipt, "", false, "");
             }
             BankrollItemInfo bankrollItemInfo = new BankrollItemInfo();
             bankrollItemInfo.UserName     = this.m_UserName;
             bankrollItemInfo.ClientId     = this.m_ClientID;
             bankrollItemInfo.Money        = this.m_MoneyReceipt;
             bankrollItemInfo.MoneyType    = 3;
             bankrollItemInfo.EBankId      = this.m_PlatformId;
             bankrollItemInfo.OrderId      = this.m_OrderInfo.OrderId;
             bankrollItemInfo.PaymentId    = this.m_PaymentLogId;
             bankrollItemInfo.Remark       = "在线支付单号:" + paymentNum;
             bankrollItemInfo.DateAndTime  = new DateTime?(DateTime.Now);
             bankrollItemInfo.CurrencyType = 1;
             isok = BankrollItem.Add(bankrollItemInfo);
         }
         if (this.m_OrderInfo.IsNull)
         {
             if (this.m_Point > 0)
             {
                 IEncourageStrategy <int> strategy2 = new UserPoint();
                 strategy2.IncreaseForUsers(this.m_UserId.ToString(), this.m_Point, "购买" + SiteConfig.UserConfig.PointName, true, "");
                 BankrollItemInfo info2 = new BankrollItemInfo();
                 info2.UserName     = this.m_UserName;
                 info2.ClientId     = this.m_ClientID;
                 info2.Money        = (this.m_MoneyReceipt > 0M) ? (-1M * this.m_MoneyReceipt) : this.m_MoneyReceipt;
                 info2.MoneyType    = 4;
                 info2.EBankId      = 0;
                 info2.OrderId      = this.m_OrderInfo.OrderId;
                 info2.PaymentId    = 0;
                 info2.Remark       = "购买" + SiteConfig.UserConfig.PointName + ",购买数:" + this.m_Point.ToString() + SiteConfig.UserConfig.PointUnit;
                 info2.DateAndTime  = new DateTime?(DateTime.Now);
                 info2.CurrencyType = 1;
                 isok = BankrollItem.Add(info2);
                 if (this.m_UserId > 0)
                 {
                     isok = strategy.IncreaseForUsers(this.m_UserId.ToString(), -(this.m_MoneyReceipt), "", false, "");//将decimal.op_UnaryNegation
                 }
             }
             PEContext.Current.Context.Session["PaymentNum"] = "";
             if (!isok)
             {
                 return(PayOnlineState.Fail);
             }
             return(PayOnlineState.Ok);
         }
         if (updateDeliverStatus && ((this.m_OrderInfo.MoneyTotal - this.m_OrderInfo.MoneyReceipt) <= this.m_MoneyReceipt))
         {
             this.m_OrderInfo.EnableDownload = true;
             isok = Order.Update(this.m_OrderInfo);
         }
         if ((this.m_OrderInfo.MoneyReceipt < this.m_OrderInfo.MoneyTotal) && updateOrderStatus)
         {
             bool flag3 = false;
             if ((this.m_OrderInfo.MoneyTotal - this.m_OrderInfo.MoneyReceipt) <= this.m_MoneyReceipt)
             {
                 this.m_MoneyPayout            = this.m_OrderInfo.MoneyTotal - this.m_OrderInfo.MoneyReceipt;
                 this.m_OrderInfo.MoneyReceipt = this.m_OrderInfo.MoneyTotal;
                 flag3 = true;
             }
             else if (SiteConfig.ShopConfig.EnablePartPay)
             {
                 this.m_MoneyPayout             = this.m_MoneyReceipt;
                 this.m_OrderInfo.MoneyReceipt += this.m_MoneyReceipt;
                 flag3 = true;
             }
             if (flag3)
             {
                 if (this.m_OrderInfo.Status <= OrderStatus.WaitForConfirm)
                 {
                     this.m_OrderInfo.Status = OrderStatus.Confirmed;
                 }
                 isok = Order.Update(this.m_OrderInfo);
                 BankrollItemInfo info3 = new BankrollItemInfo();
                 info3.UserName     = this.m_UserName;
                 info3.ClientId     = this.m_ClientID;
                 info3.Money        = (this.m_MoneyPayout > 0M) ? (-1M * this.m_MoneyPayout) : this.m_MoneyPayout;
                 info3.MoneyType    = 4;
                 info3.EBankId      = 0;
                 info3.OrderId      = this.m_OrderInfo.OrderId;
                 info3.PaymentId    = 0;
                 info3.Remark       = "支付订单费用,订单号:" + this.m_OrderInfo.OrderNum;
                 info3.DateAndTime  = new DateTime?(DateTime.Now);
                 info3.CurrencyType = 1;
                 isok = BankrollItem.Add(info3);
                 if (this.m_UserId > 0)
                 {
                     isok = strategy.IncreaseForUsers(this.m_UserId.ToString(), -(this.m_MoneyPayout), "", false, "");//将decimal.op_UnaryNegation改为了-
                 }
                 payOnlineMessage.Append("同时已经为您的订单编号为 " + this.m_OrderInfo.OrderNum + " 的订单支付了 " + this.m_MoneyPayout.ToString("N2") + "元。<br />");
             }
             else
             {
                 payOnlineMessage.Append("您的支付金额小于订单金额,不能对订单进行支付,资金已经打入您的帐户中做为预付款。<br />");
                 updateDeliverStatus = false;
             }
         }
         if (updateDeliverStatus)
         {
             this.ShowCardInfo(payOnlineMessage, doUpdate, isok);
         }
         payOnlineMessage.Append("<a href='../User/Shop/ShowOrder.aspx?OrderId=" + this.m_OrderInfo.OrderId.ToString() + "'>点此查看订单信息</a>");
         this.m_Message = payOnlineMessage.ToString();
         PEContext.Current.Context.Session["PaymentNum"] = "";
         if (!isok)
         {
             return(PayOnlineState.Fail);
         }
     }
     return(PayOnlineState.Ok);
 }
Esempio n. 16
0
        //public static bool UpdateUsersPoint<T1, T2>(Dictionary<int,Dictionary<PointActionType,T1> actions)
        //{
        //}

        /*
         * public static bool UpdateUsersPointValue<T>(Dictionary<int, int> userPoints, string type, T actionType, TryUpdateUserPointCallback beforeUpdate, TryUpdateUserPointCallback2 beforeUpdate2) where T : struct
         * {
         *  using (BbsContext context = new BbsContext())
         *  {
         *      context.BeginTransaction();
         *      try
         *      {
         *
         *          bool updatePoint = true;
         *          if (beforeUpdate2 != null)
         *          {
         *              updatePoint = beforeUpdate2(TryUpdateUserPointState.CheckSucceed, out userPoints);
         *          }
         *          else if (beforeUpdate != null)
         *              updatePoint = beforeUpdate(TryUpdateUserPointState.CheckSucceed);
         *
         *          if (updatePoint)
         *          {
         *              bool success = true;
         *              foreach (KeyValuePair<int, int> pair in userPoints)
         *              {
         *                  success = UpdateUserPointValue<T>(pair.Key, type, actionType, pair.Value, null);
         *                  if (!success)
         *                      break;
         *              }
         *              if (success)
         *              {
         *                  context.CommitTransaction();
         *                  return true;
         *              }
         *          }
         *          context.RollbackTransaction();
         *          return false;
         *      }
         *      catch (Exception ex)
         *      {
         *          context.RollbackTransaction();
         *          throw ex;
         *      }
         *  }
         *  return true;
         * }
         *
         */
        public static bool UpdateUserPointValue <T>(int userId, string type, T actionType, int nodeID, int value, TryUpdateUserPointCallback beforeUpdate) where T : struct
        {
            PointAction pointAction;
            UserPoint   userPoint = GetUserPoint <T>(userId, type, actionType, nodeID, out pointAction);

            int?minRemaining, maxValue;
            int minValue;


            pointAction.GetActionPointValueSetting(actionType.ToString(), userId, out minRemaining, out minValue, out maxValue);


            int absValue = Math.Abs(value);

            if (absValue < minValue)//小于最低值
            {
                Context.ThrowError <UserPointTradeMinValueError>(new UserPointTradeMinValueError("UserPointTradeMinValueError", userPoint.Name, absValue, minValue));
                if (beforeUpdate != null)
                {
                    beforeUpdate(TryUpdateUserPointState.CheckFailed);
                }
                return(false);
            }
            if (maxValue != null && absValue > maxValue.Value)//大于最高值
            {
                Context.ThrowError <UserPointTradeMaxValueError>(new UserPointTradeMaxValueError("UserPointTradeMaxValueError", userPoint.Name, absValue, maxValue.Value));
                if (beforeUpdate != null)
                {
                    beforeUpdate(TryUpdateUserPointState.CheckFailed);
                }
                return(false);
            }

            PointActionItemAttribute attribute = GetPointActionItemAttribute(type, actionType, true);

            if (attribute == null)
            {
                if (beforeUpdate != null)
                {
                    beforeUpdate(TryUpdateUserPointState.CheckFailed);
                }
                return(false);
            }

            if (attribute.IgnoreTax == false)
            {
                value = GetPointValue(value);
            }

            User user = UserBO.Instance.GetUser(userId);


            int[] points = new int[Consts.PointCount];
            points[(int)userPoint.Type] = value;

            PointActionItemAttribute tempAttribute;

            if (minRemaining != null && minRemaining.Value > userPoint.MinValue)
            {
                int[] minValues = new int[8];
                minValues[(int)userPoint.Type] = minRemaining.Value;
                lock (user.UpdateUserPointLocker)
                {
                    int point;
                    int result = UserBO.Instance.CheckUserPoint(userId, true, false, points, minValues, null, out point);
                    if (result != 0)
                    {
                        int remaning = point + value;
                        Context.ThrowError <UserPointTradeRemainingError>(new UserPointTradeRemainingError("UserPointTradeRemainingError", userPoint.Name, remaning, minRemaining.Value));
                        if (beforeUpdate != null)
                        {
                            beforeUpdate(TryUpdateUserPointState.CheckFailed);
                        }
                        return(false);
                    }
                }

                if (beforeUpdate != null)
                {
                    bool success = beforeUpdate(TryUpdateUserPointState.CheckSucceed);
                    if (success == false)
                    {
                        return(false);
                    }
                }

                beforeUpdate = null;

                //由于上面已经检查过积分 所以下面不再检查
                tempAttribute = new PointActionItemAttribute(attribute.ActionName, false, false, attribute.IgnoreTax, attribute.IsShowInList);
            }
            else
            {
                tempAttribute = attribute;
            }

            /*
             * lock (user.UpdateUserPointLocker)
             * {
             *  if (minRemaining != null && minRemaining.Value > userPoint.MinValue)
             *  {
             *      int remaning = user.ExtendedPoints[(int)userPoint.Type] + value;
             *      if (remaning < minRemaining.Value)//交易后小于最低余额
             *      {
             *          Context.ThrowError<UserPointTradeRemainingError>(new UserPointTradeRemainingError("UserPointTradeRemainingError", userPoint.Name, remaning, minRemaining.Value));
             *          if (beforeUpdate != null)
             *          {
             *              beforeUpdate(TryUpdateUserPointState.CheckFailed);
             *          }
             *          return false;
             *      }
             *  }
             * }
             */

            return(UpdateUserPoints(userId, points, 1, beforeUpdate, tempAttribute, tempAttribute.ActionName, tempAttribute.ActionName));
        }
Esempio n. 17
0
 private void GetSellAttachmentPointSetting()
 {
     int? maxValue, minRemain;
     int minValue;
     m_SellAttachmentPoint = ForumPointAction.Instance.GetUserPoint(MyUserID, ForumPointValueType.SellAttachment, Forum.ForumID, out minRemain, out minValue, out maxValue);
     m_SellAttachmentPointMaxValue = maxValue;
     m_SellAttachmentPointMinValue = minValue;
 }
Esempio n. 18
0
        protected void BtnRegister_Click(object sender, EventArgs e)
        {
            IEncourageStrategy <int> strategy2;

            if (!this.userSiteConfig.EnableUserReg)
            {
                return;
            }
            if (!this.Page.IsValid)
            {
                return;
            }
            this.CheckUserName();
            this.CheckEmail();
            UserInfo usersInfo = new UserInfo();

            usersInfo.Email          = this.TxtEmail.Text;
            usersInfo.FaceWidth      = 0;
            usersInfo.FaceHeight     = 0;
            usersInfo.PrivacySetting = 0;
            ContacterInfo contacterInfo = new ContacterInfo();

            contacterInfo.Sex            = (UserSexType)Enum.Parse(typeof(UserSexType), "0");
            contacterInfo.Marriage       = (UserMarriageType)Enum.Parse(typeof(UserMarriageType), "0");
            contacterInfo.Income         = -1;
            contacterInfo.Education      = -1;
            contacterInfo.ClientId       = 0;
            contacterInfo.ParentId       = 0;
            contacterInfo.CreateTime     = DateTime.Now;
            contacterInfo.Owner          = "";
            contacterInfo.UserType       = ContacterType.EnterpriceMainContacter;
            contacterInfo.UpdateTime     = DateTime.Now;
            contacterInfo.UserName       = Users.UserNamefilter(this.TxtRegUserName.Text);
            contacterInfo.Birthday       = null;
            usersInfo.UserName           = Users.UserNamefilter(this.TxtRegUserName.Text);
            usersInfo.UserPassword       = StringHelper.MD5(this.TxtRegPassword.Text);
            usersInfo.GroupId            = this.userSiteConfig.GroupId;
            usersInfo.JoinTime           = DateTime.Now;
            usersInfo.RegTime            = DateTime.Now;
            usersInfo.UserExp            = (int)this.userSiteConfig.PresentExp;
            usersInfo.UserPoint          = 0;
            usersInfo.IsInheritGroupRole = true;
            usersInfo.Status             = UserStatus.None;
            string str = DataSecurity.MakeRandomString(10);

            usersInfo.LastPassword = str;
            if (this.userSiteConfig.EmailCheckReg)
            {
                usersInfo.Status   = UserStatus.WaitValidateByEmail;
                usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10);
            }
            if (this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin;
            }
            if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail;
            }
            usersInfo.EndTime = new DateTime?(DateTime.Now);
            usersInfo.Balance = 0M;
            string str2 = "";

            if (ApiData.IsAPiEnable())
            {
                str2 = ApiFunction.RegUser(usersInfo.UserName, this.TxtRegPassword.Text, usersInfo.Question, usersInfo.Answer, usersInfo.Email, contacterInfo.TrueName, contacterInfo.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Province, contacterInfo.City, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage);
                if (str2 != "true")
                {
                    DynamicPage.WriteErrMsg(str2 + "<br><li>注册失败!</li>");
                }
                str2 = ApiFunction.RegLogOn(usersInfo.UserName, this.TxtRegPassword.Text, "1");
            }
            if (!Users.Add(usersInfo, contacterInfo))
            {
                DynamicPage.WriteErrMsg("<li>注册失败!</li>");
                return;
            }
            if (this.userSiteConfig.PresentMoney != 0.0)
            {
                IEncourageStrategy <decimal> strategy = new UserMoney();
                strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱");
            }
            if (this.userSiteConfig.PresentValidNum == 0)
            {
                goto Label_03EF;
            }
            int howMany = 0;

            if (this.userSiteConfig.PresentValidNum == -1)
            {
                howMany = 0x270f;
            }
            else
            {
                switch (this.userSiteConfig.PresentValidUnit)
                {
                case 1:
                    howMany = this.userSiteConfig.PresentValidNum;
                    goto Label_03C4;

                case 2:
                    howMany = this.userSiteConfig.PresentValidNum * 30;
                    goto Label_03C4;

                case 3:
                    howMany = this.userSiteConfig.PresentValidNum * 0x16d;
                    goto Label_03C4;
                }
                howMany = this.userSiteConfig.PresentValidNum;
            }
            Label_03C4:
            strategy2 = new UserDate();
            strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期");
Label_03EF:
            if (this.userSiteConfig.PresentPoint != 0)
            {
                IEncourageStrategy <int> strategy3 = new UserPoint();
                strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券");
            }
            if (this.userSiteConfig.EmailCheckReg)
            {
                MailInfo mailInfo = new MailInfo();
                mailInfo.IsBodyHtml = true;
                mailInfo.FromName   = SiteConfig.SiteInfo.SiteName;
                List <MailAddress> list = new List <MailAddress>();
                list.Add(new MailAddress(usersInfo.Email));
                mailInfo.MailToAddressList = list;
                mailInfo.MailBody          = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + base.BasePath + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum);
                mailInfo.Subject           = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码";
                if (SendMail.Send(mailInfo) == MailState.Ok)
                {
                    DynamicPage.WriteSuccessMsg("<li>注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!</li>" + str2, "../Default.aspx");
                }
                else
                {
                    DynamicPage.WriteSuccessMsg("<li>注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!</li>" + str2, "../Default.aspx");
                }
            }
            string str3 = "";

            if (this.userSiteConfig.EnableRegCompany)
            {
                str3 = "<li><a href='/Company/RegCompany.aspx'>继续注册企业?</a></li>";
            }
            if (usersInfo.Status == UserStatus.None)
            {
                bool     isPersistent = false;
                DateTime now          = DateTime.Now;
                DateTime expiration   = DateTime.Now;
                isPersistent = false;
                expiration   = now.AddDays(1.0);
                UserPrincipal principal = new UserPrincipal();
                principal.UserName     = usersInfo.UserName;
                principal.LastPassword = usersInfo.LastPassword;
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, now, expiration, isPersistent, principal.SerializeToString());
                string     str4   = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str4);
                if (isPersistent)
                {
                    cookie.Expires = expiration;
                }
                cookie.HttpOnly = true;
                cookie.Path     = FormsAuthentication.FormsCookiePath;
                cookie.Secure   = FormsAuthentication.RequireSSL;
                base.Response.Cookies.Add(cookie);
                this.Session["UserName"] = usersInfo.UserName;
            }
            if (SiteConfig.ShopConfig.IsPayPassword)
            {
                BasePage.ResponseRedirect("../User/RegisterPayPassword.aspx?Url=FastRegister");
            }
            else
            {
                DynamicPage.WriteSuccessMsg("<li>注册成功!" + str3 + "</li>" + str2, "../Shop/Payment.aspx");
            }
        }
Esempio n. 19
0
 private bool UserPointEmpty(UserPoint _point)
 {
     return(_point.Ammor == 0 && _point.Live == 0 && _point.Keys.Count == 0 && _point.DoorToOpen.Count == 0);
 }
 public void AddPoints(UserPoint rf)
 {
     _db.UserPoints.Add(rf);
     _db.SaveChanges();
 }
Esempio n. 21
0
        public ActionResult StartGame(ReOrderData newdata)
        {
            List <SelectListItem> selection   = Session["CallNumbers"] as List <SelectListItem>;
            List <int>            userResults = new List <int>();
            List <int>            sortedList  = new List <int>();

            int Attempt = int.Parse(Session["AttemptNumber"].ToString());


            ReOrderData reorder = new ReOrderData();

            reorder.Options = selection;



            for (int i = 0; i < 10; i++)
            {
                List <String> Provided     = new List <String>();
                List <String> UserSelected = new List <String>();

                Provided     = selection[i].Text.Split('.').ToList();
                UserSelected = selection[int.Parse(newdata.Results.ToList().ElementAt(i))].Text.Split('.').ToList();

                String generatedValue = Provided[0] + Provided[1];
                String selectedValue  = UserSelected[0] + UserSelected[1];

                userResults.Add(int.Parse(selectedValue));
                sortedList.Add(int.Parse(generatedValue));
            }

            sortedList.Sort();
            reorder.IsBatchCorrect = true;

            for (int i = 0; i < 10; i++)
            {
                if (sortedList[i] != userResults[i])
                {
                    reorder.IsBatchCorrect = false;
                }
            }

            if (reorder.IsBatchCorrect)
            {
                Session["AttemptNumber"] = 1;
                if (Attempt == 1)
                {
                    string    userid = User.Identity.GetUserId();
                    UserPoint up     = context.UserPoints.Where(a => a.UserId.Equals(userid)).FirstOrDefault();
                    reorder.PointAwarded = true;

                    if (up != null)
                    {
                        up.TotalPoints = int.Parse(up.TotalPoints.ToString()) + 1;
                        context.SaveChanges();
                    }
                    else
                    {
                        UserPoint point = new UserPoint();

                        point.UserId      = userid;
                        point.TotalPoints = 1;

                        context.UserPoints.Add(point);
                        context.SaveChanges();
                    }
                    var details = new { Attempt = Attempt, Correct = false, Reload = false, PointAwarded = true };

                    return(Json(details));
                }

                var test = new { Attempt = Attempt, Correct = true, Reload = false, PointAwarded = false };

                return(Json(test));
            }
            else
            {
                if (Attempt == 3)
                {
                    var test = new { Attempt = 1, Correct = false, Reload = true, PointAwarded = false };
                    return(Json(test));
                }
                else
                {
                    Attempt++;
                    Session["AttemptNumber"] = Attempt;
                    reorder.Options          = selection;
                    var test = new { Attempt = Attempt, Correct = false, Reload = false, PointAwarded = false };

                    return(Json(test));
                }
            }
        }
Esempio n. 22
0
 public void AddPoint(UserPoint up)
 {
     Points[NPoints]           = up;
     VectorStartNames[NPoints] = "";
     NPoints++;
 }
Esempio n. 23
0
 protected int GetUserPointValue(User user, UserPoint up)
 {
     return(user.ExtendedPoints[(int)up.Type]);
 }
Esempio n. 24
0
        static void Main(string[] args)
        {
            bool   notdone      = true;
            string username     = "";
            string password     = "";
            string command      = "";
            string secretPhrase = "";
            string welcome      = "Welcome to " + Constants.ProgramName;
            string message      = welcome;

            UsersContext uctx   = new UsersContext();
            UserContext  ucUser = null;

            while (notdone)
            {
                BoardContext.Initialize();

                DisplaySplash(message);

                Console.WriteLine(" Using the Properties dialog on the top-left menu:");
                Console.WriteLine(" 1. On the Fonts tab, set your Font Size to 12");
                Console.WriteLine(" 2. On the Layouts tab, set your Window Height and Width to 66 rows x 66 columns (minimum)");
                Console.WriteLine();
                Console.Write("Username: "******"";
                Console.Write("Password: "******"*");
                    }
                    else
                    {
                        if (key.Key == ConsoleKey.Backspace && password.Length > 0)
                        {
                            password = password.Substring(0, (password.Length - 1));
                            Console.Write("\b \b");
                        }
                    }
                }while (key.Key != ConsoleKey.Enter);
                Console.WriteLine();

                // Reference: https://stackoverflow.com/questions/3404421/password-masking-console-application
                secretPhrase = "";
                Console.Write("Secret Phrase: ");
                do
                {
                    key = Console.ReadKey(true);
                    if (key.Key != ConsoleKey.Backspace && key.Key != ConsoleKey.Enter)
                    {
                        secretPhrase += key.KeyChar;
                        Console.Write("*");
                    }
                    else
                    {
                        if (key.Key == ConsoleKey.Backspace && secretPhrase.Length > 0)
                        {
                            secretPhrase = secretPhrase.Substring(0, (secretPhrase.Length - 1));
                            Console.Write("\b \b");
                        }
                    }
                }while (key.Key != ConsoleKey.Enter);
                Console.WriteLine();

                if (username.Length >= 1 && password.Length >= 1 && secretPhrase.Length >= 1)
                {
                    byte[] encodedUsername;
                    byte[] encodedPassword;

                    if (username == "100")
                    {
                        encodedUsername = Encoding.ASCII.GetBytes(username);
                        encodedPassword = Encoding.ASCII.GetBytes(password);
                    }
                    else
                    {
                        encodedUsername = Helpers.GetHash(username);
                        encodedPassword = Helpers.GetHash(username + password + secretPhrase);
                    }
                    password     = "";
                    secretPhrase = "";
                    //Console.WriteLine("user: "******"user.eu.true: " + encodedUsername.ToHexString());
                    //Console.WriteLine("user.ep.true: " + encodedPassword.ToHexString());

                    UserCredentials uc = Contract.GetUserCredentials(encodedUsername);
                    if (uc == null)
                    {
                        //Console.WriteLine("User '" + username + "' not found");
                        string response = "";
                        while (response != "YES" && response != "NO")
                        {
                            string text = "'" + username + "' was not found in the User Directory. Do you want to register as new user [YES or NO]?";
                            //Console.WriteLine(text);
                            //response = Console.ReadLine();
                        }
                        if (response == "NO")
                        {
                            //Console.WriteLine("NO:  " + username);
                            //Console.ReadLine();
                            notdone = true;
                        }
                        else // YES - add user
                        {
                            bool success = Contract.AddUser(encodedUsername, encodedPassword);
                            //Console.WriteLine("YES: " + username);
                            //Console.WriteLine("YES.eu: " + Encoding.ASCII.GetString(uc.encodedUsername));
                            //Console.WriteLine("YES.ep: " + Encoding.ASCII.GetString(uc.encodedPassword));
                            ucUser  = new UserContext(username, encodedUsername, encodedPassword);
                            message = "The account for '" + username + "' is being created.  Try to login in minute or so.";
                            //Console.ReadLine();
                            notdone = true;
                        }
                    }
                    else // found user - check password
                    {
                        //Console.WriteLine("User '" + username + "' found");
                        //Console.WriteLine("uc.ep:   " + uc.encodedPassword.ToHexString() + " " + uc.encodedPassword.ToHexString().Length.ToString());
                        //Console.WriteLine("user.ep: " + encodedPassword.ToHexString() + " " + encodedPassword.ToHexString().Length.ToString());
                        if (uc.encodedPassword.SequenceEqual(encodedPassword))
                        {
                            //Console.WriteLine("User " + username + " password matches");

                            ucUser = new UserContext(username, encodedUsername, encodedPassword);
                            UserPoint[] pointsUser     = Contract.GetAllPoints(ucUser.EncodedUsername);
                            bool        firstPointUser = true;
                            foreach (UserPoint up in pointsUser)
                            {
                                if (firstPointUser)
                                {
                                    ucUser.AddPoint(up, username);
                                    firstPointUser = false;
                                }
                                else
                                {
                                    ucUser.AddPoint(up);
                                }
                            }
                            uctx.uc.Add(username, ucUser);
                            notdone = false;
                        }
                        else
                        {
                            message = "The password for '" + username + "' does not match";
                            //Console.WriteLine("User " + username + " password does not match");
                            //Console.WriteLine("uc.ep:   " + uc.encodedPassword.ToHexString());
                            //Console.WriteLine("user.ep: " + encodedPassword.ToHexString());
                        }
                        //Console.ReadLine();
                    }
                }
            }

            UserContext ucHedge = new UserContext("Hedge", "Hedge", "Hedge");

            UserPoint[] pointsHedge = new UserPoint[] { new UserPoint {
                                                            x = 20, y = 2
                                                        }, new UserPoint {
                                                            x = 40, y = 100
                                                        } };
            bool firstPoint = true;

            foreach (UserPoint up in pointsHedge)
            {
                if (firstPoint)
                {
                    ucHedge.AddPoint(up, "Hedge");
                    firstPoint = false;
                }
                else
                {
                    ucHedge.AddPoint(up);
                }
            }
            uctx.uc.Add("Hedge", ucHedge);

            UserContext ucWall = new UserContext("Wall", "Wall", "Wall");

            UserPoint[] pointsWall = new UserPoint[] { new UserPoint {
                                                           x = 2, y = 3
                                                       }, new UserPoint {
                                                           x = 30, y = 5
                                                       } };
            firstPoint = true;
            foreach (UserPoint up in pointsWall)
            {
                if (firstPoint)
                {
                    ucWall.AddPoint(up, "Wall");
                    firstPoint = false;
                }
                else
                {
                    ucWall.AddPoint(up);
                }
            }
            uctx.uc.Add("Wall", ucWall);

            UserContext uc100 = new UserContext("100", "100", "100");

            UserPoint[] points100 = Contract.GetAllPoints(uc100.EncodedUsername);
            firstPoint = true;
            foreach (UserPoint up in points100)
            {
                if (firstPoint)
                {
                    uc100.AddPoint(up, "User 100");
                    firstPoint = false;
                }
                else
                {
                    uc100.AddPoint(up);
                }
            }
            uctx.uc.Add("100", uc100);

            BoardContext.DrawVectors(ucHedge, '*');
            BoardContext.DrawVectors(ucWall, '.');
            BoardContext.DrawVectors(uc100, '+');

            notdone = true;
            welcome = "Welcome " + ucUser.Username + "\t(" + BitConverter.ToString(ucUser.EncodedUsername).Replace("-", "") + ")";
            message = welcome;
            while (notdone)
            {
                BoardContext.DrawBoard(message);

                Console.Write("Commmand: ");
                command = Console.ReadLine();
                string[] parts = command.Trim().Split(' ');
                if (parts.Length == 0)
                {
                    message = Constants.helpMessage;
                    continue;
                }
                message = welcome;
                string verb = parts[0];
                switch (verb)
                {
                case "add":     // Add point
                {
                    if (parts.Length != 3)
                    {
                        message = "Wrong number of parameters (" + parts.Length.ToString() + ").  Use: add x y";
                    }
                    else
                    {
                        int _x = -1;
                        int _y = -1;
                        Int32.TryParse(parts[1], out _x);
                        Int32.TryParse(parts[2], out _y);
                        if (_x < 0 || _x >= Constants.NCOLS || _y < 0 || _y >= Constants.NROWS)
                        {
                            message  = "0 < X < " + Constants.NCOLS.ToString();
                            message += " and 0 < Y < " + Constants.NROWS.ToString() + ".";
                            break;
                        }
                        UserPoint up = new UserPoint {
                            x = _x, y = _y
                        };
                        Contract.AddPoint(ucUser.EncodedUsername, up);
                        message = "Adding point ( " + _x.ToString() + ", " + _y.ToString() + ")";
                        //Console.ReadLine();
                    }
                    break;
                }

                case "delete":
                {
                    break;
                }

                case "get":
                {
                    break;
                }

                case "exit":
                {
                    notdone = false;
                    break;
                }

                case "help":
                {
                    message = Constants.helpMessage;
                    break;
                }

                default:
                {
                    message = Constants.helpMessage;
                    UserPoint[] pointsUser     = Contract.GetAllPoints(ucUser.EncodedUsername);
                    bool        firstPointUser = true;
                    foreach (UserPoint up in pointsUser)
                    {
                        if (firstPointUser)
                        {
                            ucUser.AddPoint(up, username);
                            firstPointUser = false;
                        }
                        else
                        {
                            ucUser.AddPoint(up);
                        }
                    }
                    break;
                }
                }
                BoardContext.DrawVectors(ucUser, '#');
            }
            Console.WriteLine();
            Console.WriteLine("Press Enter to exit...");
            Console.ReadLine();
        }
Esempio n. 25
0
        private void SaveUserPoints()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("maxValue", "minValue", "InitialValue", "name");
            string type = _Request.Get("type", Method.Get, string.Empty);

            UserPointCollection userPoints = new UserPointCollection();
            int i = 0;
            foreach (UserPoint tempUserPoint in AllSettings.Current.PointSettings.UserPoints)
            {
                int pointID = (int)tempUserPoint.Type;
                UserPoint userPoint = new UserPoint();
                userPoint.Enable = _Request.Get<bool>("enable." + pointID, Method.Post, false);
                userPoint.Display = _Request.Get<bool>("display." + pointID, Method.Post, false);
                int value;
                string valueString = _Request.Get("maxValue."+pointID,Method.Post,string.Empty);
                if(valueString == string.Empty)
                {
                    userPoint.MaxValue = int.MaxValue;
                }
                else if(int.TryParse(valueString,out value))
                {
                    userPoint.MaxValue = value;
                }
                else
                {
                    msgDisplay.AddError("maxValue", i, Lang_Error.User_UserPointMaxValueFormatError);
                }

                valueString = _Request.Get("minValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.MinValue = 0;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.MinValue = value;
                }
                else
                {
                    msgDisplay.AddError("minValue", i, Lang_Error.User_UserPointMinValueFormatError);
                }

                valueString = _Request.Get("InitialValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.InitialValue = 0;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.InitialValue = value;
                }
                else
                {
                    msgDisplay.AddError("InitialValue", i, Lang_Error.User_UserPointInitialValueFormatError);
                }

                userPoint.UnitName = _Request.Get("unitName." + pointID, Method.Post, string.Empty);
                userPoint.Name = _Request.Get("name." + pointID, Method.Post, string.Empty);
                userPoint.Type = tempUserPoint.Type;

                userPoints.Add(userPoint);

                i++;
            }

            if (msgDisplay.HasAnyError())
                return;


            try
            {
                using (ErrorScope errorScope = new ErrorScope())
                {
                    if (!PointActionManager.UpdateUserPointSetting(userPoints))
                    {
                        errorScope.CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error.TatgetName, error.TargetLine, error.Message);
                        });
                    }
                    else
                    {
                        PostBOV5.Instance.ClearShowChargePointLinks(); 
                    }
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
Esempio n. 26
0
 public IHttpActionResult Update(int id, [FromBody] UserPoint userPoint)
 {
     return(Ok(_userPointService.Update(id, userPoint) ? JsonStatus.UpdateSuccess(userPoint) : JsonStatus.UpdateFaild()));
 }
Esempio n. 27
0
        public static void ConvertPoints()
        {

            string sql = @"

IF EXISTS (SELECT * FROM sysobjects WHERE [type] = N'U' AND [name] = N'bbsMax_ExtendedPoints') AND EXISTS (SELECT * FROM [sysobjects] WHERE [type]='U' AND [name]='bbsMax_ExtendedPoints') BEGIN
    SELECT * FROM bbsMax_ExtendedPoints;
END
ELSE
    SELECT -9999 AS PointID;

IF EXISTS (SELECT * FROM sysobjects WHERE [type] = N'U' AND [name] = N'System_bbsMax_Settings') AND EXISTS (SELECT * FROM [sysobjects] WHERE [type]='U' AND [name]='System_bbsMax_Settings') BEGIN
    SELECT * FROM System_bbsMax_Settings;
END
ELSE
    SELECT '-9999' AS Catalog;

";
            PointSettings pointSetting = new PointSettings();

            UserPointCollection points = new UserPointCollection();

            Dictionary<int, bool> allowImports = new Dictionary<int, bool>();
            Dictionary<int, bool> allowExports = new Dictionary<int, bool>();
            Dictionary<int, int> ratios = new Dictionary<int, int>();

            int exchangeMinBalance = 0;
            double exchangeTax = 0.2;
            int tradePointID = 0;
            double tradingTax = 0.2;
            int transferMinBalance = 0;
            using (SqlConnection connection = new SqlConnection(Settings.Current.IConnectionString))
            {
                connection.Open();
                SqlCommand command = new SqlCommand(sql, connection);
                command.CommandTimeout = 60;
                try
                {
                    using (SqlDataReader reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int pointID = reader.GetInt32(reader.GetOrdinal("PointID"));

                            if (pointID == -9999)
                                return;

                            if (pointID > 0 && pointID < 9)
                            {
                                pointID = pointID - 1;

                                if (allowExports.ContainsKey(pointID))
                                    continue;

                                UserPoint userPoint = new UserPoint();

                                allowExports.Add(pointID, reader.GetBoolean(reader.GetOrdinal("AllowExport")));
                                allowImports.Add(pointID, reader.GetBoolean(reader.GetOrdinal("AllowImport")));
                                ratios.Add(pointID, reader.GetInt32(reader.GetOrdinal("Ratio")));

                                userPoint.Type = (MaxLabs.bbsMax.Enums.UserPointType)pointID;
                                userPoint.Name = reader.GetString(reader.GetOrdinal("PointName"));
                                userPoint.UnitName = reader.GetString(reader.GetOrdinal("PointUnit"));
                                userPoint.InitialValue = reader.GetInt32(reader.GetOrdinal("DefaultPoint"));
                                userPoint.Display = reader.GetBoolean(reader.GetOrdinal("IsPublic"));
                                userPoint.Enable = reader.GetBoolean(reader.GetOrdinal("IsEnabled"));
                                userPoint.MaxValue = reader.GetInt32(reader.GetOrdinal("MaxValue"));
                                userPoint.MinValue = reader.GetInt32(reader.GetOrdinal("MinValue"));

                                points.Add(userPoint);
                            }
                        }

                        if (reader.NextResult())
                        {
                            string pointformula = string.Empty;
                            while (reader.Read())
                            {
                                string catalog = reader.GetString(reader.GetOrdinal("Catalog"));
                                if (catalog == "-9999")
                                    break;

                                if (string.Compare(catalog, "PointSetting", true) == 0)
                                {
                                    string key = reader.GetString(reader.GetOrdinal("SettingKey"));
                                    string value = reader.GetString(reader.GetOrdinal("SettingValue"));
                                    try
                                    {
                                        switch (key.ToLower())
                                        {
                                            case "exchangeminbalance": exchangeMinBalance = int.Parse(value); break;
                                            case "exchangetax": exchangeTax = double.Parse(value); break;
                                            case "tradepointid": tradePointID = int.Parse(value) - 1; break;
                                            case "tradingtax": tradingTax = double.Parse(value); break;
                                            case "transferminbalance": transferMinBalance = int.Parse(value); break;
                                            case "pointname": pointSetting.GeneralPointName = value; break;
                                            case "pointformula": pointformula = value; break;
                                            default: break;
                                        }
                                    }
                                    catch { }
                                }
                            }
                            if (string.IsNullOrEmpty(pointformula) == false)
                                pointSetting.GeneralPointExpression = GetGeneralPointExpression(pointformula);

                        }
                    }

                    pointSetting.UserPoints = points;


                    if (allowImports.Count > 0)
                    {
                        //�һ�����
                        PointExchangeProportionCollection ExchangeProportions = new PointExchangeProportionCollection();

                        for (int i = 0; i < 8; i++)
                        {
                            if (ratios.ContainsKey(i))
                            {
                                ExchangeProportions.Add((UserPointType)i, ratios[i] == 0 ? 1 : ratios[i]);
                            }
                            else
                                ExchangeProportions.Add((UserPointType)i, 1);
                        }

                        pointSetting.ExchangeProportions = ExchangeProportions;

                        //�һ�����
                        PointExchangeRuleCollection PointExchangeRules = new PointExchangeRuleCollection();

                        foreach (KeyValuePair<int, bool> pair in allowImports)
                        {
                            if (pair.Value)//�������
                            {
                                foreach (KeyValuePair<int, bool> tempPair in allowExports)
                                {
                                    if (tempPair.Key == pair.Key)
                                        continue;

                                    if (tempPair.Value)//����ҳ�
                                    {
                                        PointExchangeRule rule = new PointExchangeRule();
                                        rule.PointType = (UserPointType)tempPair.Key;
                                        rule.TargetPointType = (UserPointType)pair.Key;
                                        try
                                        {
                                            rule.TaxRate = (int)(exchangeTax * 100);
                                        }
                                        catch { }

                                        PointExchangeRules.Add(rule);
                                    }
                                }
                            }
                        }

                        pointSetting.PointExchangeRules = PointExchangeRules;
                        try
                        {
                            pointSetting.TradeRate = (int)(tradingTax * 100);
                        }
                        catch { }

                        //PointTransferRuleCollection PointTransferRules = new PointTransferRuleCollection();
                        //PointTransferRule tRule = new PointTransferRule();
                        //tRule.CanTransfer = true;
                        //try
                        //{
                        //    tRule.PointType = (UserPointType)tradePointID;
                        //}
                        //catch
                        //{
                        //}
                        //tRule.TaxRate = pointSetting.TradeRate;

                        //PointTransferRules.Add(tRule);
                        //pointSetting.PointTransferRules = PointTransferRules;

                        pointSetting.PointTransferRules = new PointTransferRuleCollection();
                        pointSetting.PointIcons = new PointIconCollection();
                    }

                    sql = @"
UPDATE bx_Settings SET [Value] = @PointString WHERE TypeName = 'MaxLabs.bbsMax.Settings.PointSettings' AND [Key] = '*';
IF @@ROWCOUNT = 0
    INSERT INTO bx_Settings ([Key], [Value], [TypeName]) VALUES ('*', @PointString, 'MaxLabs.bbsMax.Settings.PointSettings');


DROP TABLE bbsMax_ExtendedPoints;
";
                    command.CommandText = sql;

                    SqlParameter param = new SqlParameter("@PointString", SqlDbType.NText);
                    param.Value = pointSetting.ToString();
                    command.Parameters.Add(param);

                    command.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    CreateLog(ex);
                    throw new Exception("������չ��������ʧ��" + ex.Message + sql);
                }
                finally
                {
                    connection.Close();
                }
            }


        }
Esempio n. 28
0
        private void ProcessBuyThread()
        {
            BasicThread thread = PostBOV5.Instance.GetThread(threadID);

            bool success;

            if (IsLogin == false)
            {
                ShowError("您还没有登陆,不能购买!");
            }
            else if (thread.Price < 1)
            {
                ShowError("该主题不需要购买");
            }
            else if (thread.PostUserID == MyUserID)
            {
                ShowError("自己的主题不需要购买");
            }
            else if (thread.IsBuyed(My))
            {
                ShowError("您已经购买过该主题");
            }
            else
            {
                UserPoint tradePoint = ForumPointAction.Instance.GetUserPoint(thread.PostUserID, ForumPointValueType.SellThread, thread.ForumID);
                if (tradePoint == null)
                {
                    ShowError("系统没有设置交易积分!");
                }

                using (ErrorScope es = new ErrorScope())
                {
                    success = UserBO.Instance.TradePoint(MyUserID, thread.PostUserID, thread.Price, tradePoint.Type, false, true, null);
                    if (success == false)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            if (error is UserPointOverMinValueError)
                            {
                                UserPointOverMinValueError tempError            = (UserPointOverMinValueError)error;
                                NotEnoughPointBuyThread notEnoughPointBuyThread = new NotEnoughPointBuyThread("", tempError.UserPoint, thread.Price, My.ExtendedPoints[(int)tempError.UserPoint.Type]);
                                ShowError(notEnoughPointBuyThread);
                            }
                            else
                            {
                                ShowError(error.Message);
                            }
                        });
                    }
                    else
                    {
                        try
                        {
                            success = PostBOV5.Instance.CreateThreadExchange(thread.ThreadID, MyUserID, thread.Price);
                            if (success)
                            {
                                PostBOV5.Instance.SetThreadBuyedInCache(My, threadID, true);
                            }
                            else
                            {
                                ShowError("创建交易记录失败!");
                            }
                        }
                        catch (Exception ex)
                        {
                            ShowError(ex.Message);
                        }
                    }

                    if (success)
                    {
                        ShowSuccess("购买成功!", true);
                    }
                }
            }
        }
Esempio n. 29
0
        public RedeemBalanceModel PointRedeem(PointsRedeemModel model)
        {
            string passcode = entities.Users.Where(x => x.Passcode == model.Passcode).Select(x => x.Passcode).FirstOrDefault();

            if (passcode != null)
            {
                var data  = entities.Users.Where(x => x.UserID == model.UserID).FirstOrDefault();
                var data1 = entities.AspNetUsers.Where(x => x.Id == model.UserID).FirstOrDefault();
                GeneralFunctions general = new GeneralFunctions();
                if (data.CurrentPoint >= model.PointsWithdraw && general.PointReddemValueCheck(model.PointsWithdraw))
                {
                    EaningHeadModel earningHeads = new EaningHeadModel();
                    var             jsonFilePath = HttpContext.Current.Server.MapPath("~/Models/JsonFile/LevelEarningMasterUser.json");
                    using (StreamReader r = new StreamReader(jsonFilePath))
                    {
                        string json = r.ReadToEnd();
                        earningHeads = JsonConvert.DeserializeObject <EaningHeadModel>(json);
                    }
                    //Insert User Point Table
                    UserPoint Point = new UserPoint()
                    {
                        UserID          = model.UserID,
                        TransactionDate = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00),
                        PointsWithdraw  = model.PointsWithdraw,
                        PointsEarned    = 0,
                        Description     = "Point Withdrawal in Account",
                        CreatedDate     = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00)
                    };
                    entities.UserPoints.Add(Point);
                    entities.SaveChanges();

                    //Insert Transaction Table
                    double           balance          = model.PointsWithdraw * earningHeads.PointAmount;
                    GeneralFunctions generalFunctions = new GeneralFunctions();
                    balance = Convert.ToDouble(generalFunctions.GetDecimalvalue(balance.ToString()));
                    var         uniqueKey   = $"{data.UserID}~{DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00).ToString("dd-MM-yyy")}~Earning";
                    Transaction transaction = new Transaction()
                    {
                        UserID = model.UserID,
                        transactionDateTime = DateTime.UtcNow.AddHours(5.00).AddMinutes(30.00),
                        UniqueKey           = uniqueKey,
                        paymentStatus       = "points",
                        amount          = balance,
                        comment         = "Point Withdrawal in Your Current Balance",
                        username        = data.Name,
                        mobilenumber    = data1.UserName,
                        ConvertedPoints = model.PointsWithdraw
                    };
                    entities.Transactions.Add(transaction);
                    entities.SaveChanges();
                    return(new RedeemBalanceModel()
                    {
                        RedeemBalance = balance,
                        State = "True"
                    });
                }
                else
                {
                    return(new RedeemBalanceModel()
                    {
                        RedeemBalance = 0,
                        State = "insufficient"
                    });
                }
            }
            else
            {
                return(new RedeemBalanceModel()
                {
                    RedeemBalance = 0,
                    State = "Passcode"
                });
            }
        }
Esempio n. 30
0
 protected int GetPointRank(UserPoint up)
 {
     return(RankInfos["Point_" + (((int)up.Type) + 1)]);
 }
Esempio n. 31
0
 protected bool IsShowChargePointLink(UserPoint point)
 {
     return PostBOV5.Instance.IsShowChargePointLink(point);
 }
Esempio n. 32
0
 protected int GetPointIndex(UserPoint up)
 {
     return((int)up.Type);
 }
Esempio n. 33
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int?id = _Request.Get <int>("id");

            m_IsEdit = id != null;

            if (m_IsEdit)
            {
                this.m_Prop = PropBO.Instance.GetPropByID(id.Value);

                this.m_PropType = PropBO.GetPropType(this.m_Prop.PropType);
            }
            else
            {
                this.m_Prop = new Prop();

                this.m_PropType = PropBO.GetPropType(_Request.Get("proptype"));
            }

            if (m_PropType == null)
            {
                ShowError("道具类型不存在");
            }

            if (_Request.IsClick("save"))
            {
                MessageDisplay md = CreateMessageDisplay(
                    "icon", "name", "description",
                    "price", "pricetype",
                    "packagesize", "totalnumber", "allowexchange",
                    "autoreplenish", "replenishnumber", "replenishtimespan"
                    );

                this.m_Prop.Icon = _Request.Get("icon");

                //默认为猪头卡的图片
                if (string.IsNullOrEmpty(this.m_Prop.Icon))
                {
                    this.m_Prop.Icon = "~/max-assets/icon-prop/4.gif";
                }

                this.m_Prop.Name = _Request.Get("name");

                if (string.IsNullOrEmpty(this.m_Prop.Name))
                {
                    md.AddError("name", "道具名称不能为空");
                }

                this.m_Prop.Description = _Request.Get("description");

                if (string.IsNullOrEmpty(this.m_Prop.Description))
                {
                    md.AddError("description", "道具描述不能为空");
                }

                int?sortOrder = _Request.Get <int>("SortOrder");

                if (sortOrder == null)
                {
                    md.AddError("SortOrder", "道具排序必须填写");
                }
                else if (sortOrder.Value < 0)
                {
                    md.AddError("SortOrder", "道具排序必须大于或等于0");
                }
                else
                {
                    this.m_Prop.SortOrder = sortOrder.Value;
                }

                int?price = _Request.Get <int>("price");

                if (price == null)
                {
                    md.AddError("price", "道具价格必须填写");
                }
                else if (price.Value <= 0)
                {
                    md.AddError("price", "道具价格必须大于0");
                }
                else
                {
                    this.m_Prop.Price = price.Value;
                }

                if (m_IsEdit == false)
                {
                    this.m_Prop.PropType = _Request.Get("proptype");
                }

                this.m_Prop.PropParam = m_PropType.GetPropParam(Request);

                int?priceType = _Request.Get <int>("pricetype");

                if (priceType == null)
                {
                    md.AddError("pricetype", "道具售价类型不能为空");
                }
                else
                {
                    this.m_Prop.PriceType = priceType.Value;
                }

                int?packageSize = _Request.Get <int>("packagesize");

                if (packageSize == null)
                {
                    md.AddError("packagesize", "道具重量必须填写");
                }
                else
                {
                    this.m_Prop.PackageSize = packageSize.Value;
                }

                int?totalNumber = _Request.Get <int>("totalnumber");

                if (totalNumber == null)
                {
                    md.AddError("totalnumber", "道具总数必须填写");
                }
                else if (totalNumber <= 0)
                {
                    md.AddError("totalnumber", "道具总数必须大于0");
                }
                else
                {
                    this.m_Prop.TotalNumber = totalNumber.Value;
                }

                bool?allowExchange = _Request.Get <bool>("allowexchange");

                if (allowExchange == null)
                {
                    md.AddError("allowexchange", "道具是否允许出售和赠送必须设置");
                }
                else
                {
                    this.m_Prop.AllowExchange = allowExchange.Value;
                }

                bool?autoReplenish = _Request.Get <bool>("autoreplenish");

                if (autoReplenish == null)
                {
                    md.AddError("autoreplenish", "道具是否自动补货必须设置");
                }
                else
                {
                    this.m_Prop.AutoReplenish = autoReplenish.Value;
                }

                int?replenishLimit = _Request.Get <int>("ReplenishLimit");

                if (replenishLimit == null)
                {
                    md.AddError("ReplenishLimit", "道具补货阀值必须设置");
                }
                else if (replenishLimit.Value < 0)
                {
                    md.AddError("ReplenishLimit", "道具补货阀值必须大于等于0");
                }
                else
                {
                    this.m_Prop.ReplenishLimit = replenishLimit.Value;
                }

                int?replenishNumber = _Request.Get <int>("replenishnumber");

                if (replenishNumber == null)
                {
                    md.AddError("replenishnumber", "道具自动补货数量必须填写");
                }
                else
                {
                    this.m_Prop.ReplenishNumber = replenishNumber.Value;
                }

                int?replenishTimespan = _Request.Get <int>("replenishtimespan");

                if (replenishTimespan == null)
                {
                    md.AddError("replenishtimespan", "道具自动补货周期必须设置");
                }
                else
                {
                    this.m_Prop.ReplenishTimeSpan = replenishTimespan.Value;
                }

                BuyPropCondition condition = new BuyPropCondition();

                this.m_Prop.BuyCondition = condition;

                condition.UserGroupIDs = StringUtil.Split2 <Guid>(_Request.Get("BuyCondition.groups", Method.Post, string.Empty));

                int?totalPoint = _Request.Get <int>("BuyCondition.totalPoint");

                if (totalPoint != null && totalPoint.Value > 0)
                {
                    condition.TotalPoint = totalPoint.Value;
                }

                UserPointCollection allPoints = AllSettings.Current.PointSettings.UserPoints;

                int[] points = new int[allPoints.Count];

                for (int i = 0; i < points.Length; i++)
                {
                    UserPoint point = allPoints[i];

                    if (point.Enable)
                    {
                        int?value = _Request.Get <int>("BuyCondition." + point.Type);

                        if (value != null)
                        {
                            points[i] = value.Value;
                        }
                        else
                        {
                            points[i] = 0;
                        }
                    }
                    else
                    {
                        points[i] = 0;
                    }
                }

                condition.Points = points;

                int?totalPosts = _Request.Get <int>("BuyCondition.totalPosts");

                if (totalPosts != null && totalPosts.Value > 0)
                {
                    condition.TotalPosts = totalPosts.Value;
                }

                int?onlineTime = _Request.Get <int>("BuyCondition.onlinetime");

                if (onlineTime != null && onlineTime.Value > 0)
                {
                    condition.OnlineTime = onlineTime.Value;
                }

                condition.ReleatedMissionIDs = StringUtil.Split2 <int>(_Request.Get("BuyCondition.releatedmissionids", Method.Post, string.Empty));

                if (md.HasAnyError())
                {
                    return;
                }

                using (ErrorScope es = new ErrorScope())
                {
                    if (m_IsEdit)
                    {
                        PropBO.Instance.UpdateProp(
                            m_Prop.PropID,
                            m_Prop.Icon,
                            m_Prop.Name,
                            price.Value,
                            priceType.Value,
                            m_Prop.PropType,
                            m_Prop.PropParam,
                            m_Prop.Description,
                            packageSize.Value,
                            totalNumber.Value,
                            allowExchange.Value,
                            autoReplenish.Value,
                            replenishNumber.Value,
                            replenishTimespan.Value,
                            replenishLimit.Value,
                            condition,
                            sortOrder.Value
                            );
                    }
                    else
                    {
                        PropBO.Instance.CreateProp(
                            m_Prop.Icon,
                            m_Prop.Name,
                            price.Value,
                            priceType.Value,
                            m_Prop.PropType,
                            m_Prop.PropParam,
                            m_Prop.Description,
                            packageSize.Value,
                            totalNumber.Value,
                            allowExchange.Value,
                            autoReplenish.Value,
                            replenishNumber.Value,
                            replenishTimespan.Value,
                            replenishLimit.Value,
                            condition,
                            sortOrder.Value
                            );
                    }

                    if (es.HasError)
                    {
                        es.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            md.AddError(error);
                        });
                    }
                    else
                    {
                        JumpTo("interactive/manage-prop.aspx?page=" + _Request.Get("page"));
                    }
                }
            }
        }
Esempio n. 34
0
        // Reference: https://stackoverflow.com/questions/11678693/all-cases-covered-bresenhams-line-algorithm
        public static List <UserPoint> GetLinePoints(UserPoint p1, UserPoint p2)
        {
            List <UserPoint> pointList = new List <UserPoint>();

            int _dx = (int)(p2.x) - (int)p1.x;
            int _dy = (int)(p2.y) - (int)p1.y;

            int swaps = 0;

            if (_dy > _dx)
            {
                Swap(ref _dx, ref _dy);
                swaps = 1;
            }

            int a = Math.Abs(_dy);
            int b = -Math.Abs(_dx);

            double d  = 2 * a + b;
            int    _x = (int)p1.x;
            int    _y = (int)p1.y;

            //color_track = Color.Blue;
            //Check_Pixel(ref area, new Point(x, y));
            pointList.Clear();
            pointList.Add(new UserPoint {
                x = _x, y = _y
            });

            int s = 1;
            int q = 1;

            if (p1.x > p2.x)
            {
                q = -1;
            }
            if (p1.y > p2.y)
            {
                s = -1;
            }

            for (int k = 0; k < _dx; k++)
            {
                if (d >= 0)
                {
                    d  = 2 * (a + b) + d;
                    _y = _y + s;
                    _x = _x + q;
                }
                else
                {
                    if (swaps == 1)
                    {
                        _y = _y + s;
                    }
                    else
                    {
                        _x = _x + q;
                    }
                    d = 2 * a + d;
                }
                //Check_Pixel(ref area, new Point(x, y));
                pointList.Add(new UserPoint {
                    x = _x, y = _y
                });
            }

            return(pointList);
        }
Esempio n. 35
0
 protected int GetPointIndex( UserPoint up )
 {
     return (int)up.Type;
 }
Esempio n. 36
0
        private void SaveUserPoints()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("maxValue", "minValue", "InitialValue", "name");
            string         type       = _Request.Get("type", Method.Get, string.Empty);

            UserPointCollection userPoints = new UserPointCollection();
            int i = 0;

            foreach (UserPoint tempUserPoint in AllSettings.Current.PointSettings.UserPoints)
            {
                int       pointID   = (int)tempUserPoint.Type;
                UserPoint userPoint = new UserPoint();
                userPoint.Enable  = _Request.Get <bool>("enable." + pointID, Method.Post, false);
                userPoint.Display = _Request.Get <bool>("display." + pointID, Method.Post, false);
                int    value;
                string valueString = _Request.Get("maxValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.MaxValue = int.MaxValue;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.MaxValue = value;
                }
                else
                {
                    msgDisplay.AddError("maxValue", i, Lang_Error.User_UserPointMaxValueFormatError);
                }

                valueString = _Request.Get("minValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.MinValue = 0;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.MinValue = value;
                }
                else
                {
                    msgDisplay.AddError("minValue", i, Lang_Error.User_UserPointMinValueFormatError);
                }

                valueString = _Request.Get("InitialValue." + pointID, Method.Post, string.Empty);
                if (valueString == string.Empty)
                {
                    userPoint.InitialValue = 0;
                }
                else if (int.TryParse(valueString, out value))
                {
                    userPoint.InitialValue = value;
                }
                else
                {
                    msgDisplay.AddError("InitialValue", i, Lang_Error.User_UserPointInitialValueFormatError);
                }

                userPoint.UnitName = _Request.Get("unitName." + pointID, Method.Post, string.Empty);
                userPoint.Name     = _Request.Get("name." + pointID, Method.Post, string.Empty);
                userPoint.Type     = tempUserPoint.Type;

                userPoints.Add(userPoint);

                i++;
            }

            if (msgDisplay.HasAnyError())
            {
                return;
            }


            try
            {
                using (ErrorScope errorScope = new ErrorScope())
                {
                    if (!PointActionManager.UpdateUserPointSetting(userPoints))
                    {
                        errorScope.CatchError <ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error.TatgetName, error.TargetLine, error.Message);
                        });
                    }
                    else
                    {
                        PostBOV5.Instance.ClearShowChargePointLinks();
                    }
                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }
Esempio n. 37
0
        protected void BtnRegStep2_Click(object sender, EventArgs e)
        {
            IEncourageStrategy <int> strategy2;

            if (!this.userSiteConfig.EnableUserReg)
            {
                return;
            }
            if (!this.Page.IsValid)
            {
                return;
            }
            this.CheckUserName();
            this.CheckEmail();
            this.CheckCode();
            this.CheckQAofReg();
            UserInfo usersInfo = new UserInfo();

            usersInfo.Question       = this.TxtQuestion.Text;
            usersInfo.Answer         = StringHelper.MD5(this.TxtAnswer.Text);
            usersInfo.Email          = this.TxtEmail.Text;
            usersInfo.UserFace       = this.TxtUserFace.Text;
            usersInfo.FaceWidth      = DataConverter.CLng(this.TxtFaceWidth.Text);
            usersInfo.FaceHeight     = DataConverter.CLng(this.TxtFaceHeight.Text);
            usersInfo.Sign           = this.TxtSign.Text;
            usersInfo.PrivacySetting = DataConverter.CLng(this.DropPrivacy.SelectedValue);
            string str = DataSecurity.MakeRandomString(10);

            usersInfo.LastPassword = str;
            ContacterInfo contacterInfo = new ContacterInfo();

            contacterInfo.TrueName    = this.TxtTrueName.Text;
            contacterInfo.Country     = this.Region.Country;
            contacterInfo.Province    = this.Region.Province;
            contacterInfo.City        = this.Region.City;
            contacterInfo.Address     = this.TxtAddress.Text;
            contacterInfo.ZipCode     = this.TxtZipCode.Text;
            contacterInfo.OfficePhone = this.TxtOfficePhone.Text;
            contacterInfo.HomePhone   = this.TxtHomePhone.Text;
            contacterInfo.Mobile      = this.TxtMobile.Text;
            contacterInfo.Fax         = this.TxtFax.Text;
            contacterInfo.Homepage    = this.TxtHomepage.Text;
            contacterInfo.Email       = this.TxtEmail.Text;
            contacterInfo.QQ          = this.TxtQQ.Text;
            contacterInfo.Msn         = this.TxtMSN.Text;
            contacterInfo.Icq         = this.TxtICQ.Text;
            contacterInfo.Yahoo       = this.TxtYahoo.Text;
            contacterInfo.UC          = this.TxtUC.Text;
            contacterInfo.Aim         = this.TxtAim.Text;
            contacterInfo.IdCard      = this.TxtIDCard.Text;
            contacterInfo.Sex         = (UserSexType)Enum.Parse(typeof(UserSexType), this.DropSex.SelectedValue);
            contacterInfo.Marriage    = (UserMarriageType)Enum.Parse(typeof(UserMarriageType), DataConverter.CLng(this.DropMarriage.SelectedValue).ToString());
            if (this.GetDisplayStyle("Income") != "none")
            {
                contacterInfo.Income = DataConverter.CLng(this.DropIncome.SelectedValue);
            }
            else
            {
                contacterInfo.Income = -1;
            }
            contacterInfo.Education      = -1;
            contacterInfo.Company        = this.TxtCompany.Text;
            contacterInfo.Department     = this.TxtDepartment.Text;
            contacterInfo.ClientId       = 0;
            contacterInfo.ParentId       = 0;
            contacterInfo.CreateTime     = DateTime.Now;
            contacterInfo.Owner          = "";
            contacterInfo.UserType       = ContacterType.EnterpriceMainContacter;
            contacterInfo.UpdateTime     = DateTime.Now;
            contacterInfo.UserName       = Users.UserNamefilter(this.TxtUserName.Text);
            contacterInfo.Phs            = this.TxtPHS.Text;
            contacterInfo.Birthday       = string.IsNullOrEmpty(this.TxtBirthday.Text) ? null : new DateTime?(this.TxtBirthday.Date);
            contacterInfo.Position       = this.TxtPosTitle.Text;
            usersInfo.UserName           = Users.UserNamefilter(this.TxtUserName.Text);
            usersInfo.UserPassword       = StringHelper.MD5(this.TxtPassword.Text);
            usersInfo.GroupId            = this.userSiteConfig.GroupId;
            usersInfo.JoinTime           = DateTime.Now;
            usersInfo.RegTime            = DateTime.Now;
            usersInfo.UserExp            = (int)this.userSiteConfig.PresentExp;
            usersInfo.UserPoint          = 0;
            usersInfo.IsInheritGroupRole = true;
            usersInfo.Status             = UserStatus.None;
            if (this.userSiteConfig.EmailCheckReg)
            {
                usersInfo.Status   = UserStatus.WaitValidateByEmail;
                usersInfo.CheckNum = DataSecurity.MakeRandomString("abcdefghijklmnopqrstuvwxyz0123456789_", 10);
            }
            if (this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin;
            }
            if (this.userSiteConfig.EmailCheckReg && this.userSiteConfig.AdminCheckReg)
            {
                usersInfo.Status = UserStatus.WaitValidateByAdmin | UserStatus.WaitValidateByEmail;
            }
            usersInfo.EndTime = new DateTime?(DateTime.Now);
            usersInfo.Balance = 0M;
            string str2 = "";

            if (ApiData.IsAPiEnable())
            {
                str2 = ApiFunction.RegUser(usersInfo.UserName, this.TxtPassword.Text, usersInfo.Question, usersInfo.Answer, usersInfo.Email, contacterInfo.TrueName, contacterInfo.Sex.ToString(), contacterInfo.Birthday.ToString(), contacterInfo.QQ, contacterInfo.Msn, contacterInfo.Mobile, contacterInfo.OfficePhone, contacterInfo.Province, contacterInfo.City, contacterInfo.Address, contacterInfo.ZipCode, contacterInfo.Homepage);
                if (str2 != "true")
                {
                    DynamicPage.WriteErrMsg(str2 + "<br><li>注册失败!</li>");
                }
                str2 = ApiFunction.RegLogOn(usersInfo.UserName, this.TxtPassword.Text, "1");
            }
            if (!Users.Add(usersInfo, contacterInfo))
            {
                DynamicPage.WriteErrMsg("<li>注册失败!</li>");
                return;
            }
            if (this.userSiteConfig.PresentMoney != 0.0)
            {
                IEncourageStrategy <decimal> strategy = new UserMoney();
                strategy.IncreaseForUsers(usersInfo.UserId.ToString(), (decimal)this.userSiteConfig.PresentMoney, "注册时赠送的金钱", true, "注册时赠送的金钱");
            }
            if (this.userSiteConfig.PresentValidNum == 0)
            {
                goto Label_0665;
            }
            int howMany = 0;

            if (this.userSiteConfig.PresentValidNum == -1)
            {
                howMany = 0x270f;
            }
            else
            {
                switch (this.userSiteConfig.PresentValidUnit)
                {
                case 1:
                    howMany = this.userSiteConfig.PresentValidNum;
                    goto Label_063A;

                case 2:
                    howMany = this.userSiteConfig.PresentValidNum * 30;
                    goto Label_063A;

                case 3:
                    howMany = this.userSiteConfig.PresentValidNum * 0x16d;
                    goto Label_063A;
                }
                howMany = this.userSiteConfig.PresentValidNum;
            }
            Label_063A:
            strategy2 = new UserDate();
            strategy2.IncreaseForUsers(usersInfo.UserId.ToString(), howMany, "注册时赠送有效期", true, "注册时赠送有效期");
            Label_0665:
            if (this.userSiteConfig.PresentPoint != 0)
            {
                IEncourageStrategy <int> strategy3 = new UserPoint();
                strategy3.IncreaseForUsers(usersInfo.UserId.ToString(), this.userSiteConfig.PresentPoint, "注册时赠送点券", true, "注册时赠送点券");
            }
            if (this.userSiteConfig.EmailCheckReg)
            {
                MailInfo mailInfo = new MailInfo();
                mailInfo.IsBodyHtml = true;
                mailInfo.FromName   = SiteConfig.SiteInfo.SiteName;
                List <MailAddress> list = new List <MailAddress>();
                list.Add(new MailAddress(usersInfo.Email));
                mailInfo.MailToAddressList = list;
                mailInfo.MailBody          = this.userSiteConfig.EmailOfRegCheck.Replace("{$CheckNum}", usersInfo.CheckNum).Replace("{$CheckUrl}", base.Request.Url.GetLeftPart(UriPartial.Authority) + base.BasePath + "User/RegisterCheck.aspx?UserName="******"&CheckNum=" + usersInfo.CheckNum);
                mailInfo.Subject           = SiteConfig.SiteInfo.SiteName + "网站会员注册验证码";
                if (SendMail.Send(mailInfo) == MailState.Ok)
                {
                    DynamicPage.WriteSuccessMsg("<li>注册验证码已成功发送到你的注册邮箱,请到邮箱查收并验证!</li>" + str2, "../Default.aspx");
                }
                else
                {
                    DynamicPage.WriteSuccessMsg("<li>注册成功,但发送验证邮件失败,请检查邮件地址是否正确,或与网站管理员联系!</li>" + str2, "../Default.aspx");
                }
            }
            string str3 = "";

            if (this.userSiteConfig.EnableRegCompany)
            {
                str3 = "<li><a href='Company/RegCompany.aspx'>继续注册企业?</a></li>";
            }
            if (usersInfo.Status == UserStatus.None)
            {
                UserPrincipal principal = new UserPrincipal();
                principal.UserName     = usersInfo.UserName;
                principal.LastPassword = usersInfo.LastPassword;
                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, usersInfo.UserName, DateTime.Now, DateTime.Now.AddMinutes(60.0), false, principal.SerializeToString());
                string     str4   = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str4);
                cookie.HttpOnly = true;
                cookie.Path     = FormsAuthentication.FormsCookiePath;
                cookie.Secure   = FormsAuthentication.RequireSSL;
                base.Response.Cookies.Add(cookie);
            }
            if (SiteConfig.ShopConfig.IsPayPassword)
            {
                BasePage.ResponseRedirect("RegisterPayPassword.aspx?Url=Register");
            }
            else
            {
                DynamicPage.WriteSuccessMsg("<li>注册成功!" + str3 + "</li>" + str2, "Default.aspx");
            }
        }