Ejemplo n.º 1
0
        public override bool TakeAction()
        {
            var cacheSet = new GameDataCacheSet <UserQueue>();
            List <UserQueue> userQueueList = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            foreach (UserQueue queue in userQueueList)
            {
                if (queue != null)
                {
                    int npcCount = new ConfigCacheSet <PlotNPCInfo>().FindAll(m => m.PlotID == plotID).Count;
                    //战斗次数
                    int totalBattleNum = (int)Math.Floor((double)(queue.TotalColdTime - queue.DoRefresh()) / PlotInfo.BattleSpeedNum);
                    int turnsNum       = totalBattleNum / npcCount;
                    int battleNum      = totalBattleNum % npcCount;
                    //没发生战斗或上未通关都返还精力
                    //if (turnsNum == 0 || battleNum > 0)
                    //{
                    //    ContextUser.EnergyNum = ContextUser.EnergyNum.Addition(PlotInfo.BattleEnergyNum, short.MaxValue);
                    //}
                    cacheSet.Delete(queue);
                }
            }

            if (ContextUser.UserStatus == UserStatus.SaoDang)
            {
                ContextUser.ResetSweepPool(0);
                ContextUser.UserStatus = UserStatus.Normal;
                //ContextUser.Update();
            }
            return(true);
        }
Ejemplo n.º 2
0
        private void DoAccelerateQueue(int goldNum, int coldTime, int timing, int totalTime)
        {
            //获取加速后的所需的精力
            int npcCount  = new ConfigCacheSet <PlotNPCInfo>().FindAll(m => m.PlotID == plotID).Count;
            int battleNum = PlotHelper.GetBattleNum(coldTime);
            int turnsNum  = PlotHelper.GetTurnsNum(npcCount, battleNum);
            int energyNum = turnsNum * PlotInfo.BattleEnergyNum;

            ContextUser.RemoveEnergyNum((short)energyNum);
            ContextUser.UseGold    = MathUtils.Addition(ContextUser.UseGold, goldNum, int.MaxValue);
            ContextUser.UserStatus = UserStatus.Normal;
            //ContextUser.Update();

            int totalTurnsNum = PlotHelper.GetTurnsNum(npcCount, PlotHelper.GetBattleNum(totalTime));
            int tempNum       = PlotHelper.GetBattleNum(timing);
            int sweepCount    = PlotHelper.GetTurnsNum(npcCount, tempNum);
            int timesNum      = PlotHelper.GetTimesNum(npcCount, tempNum);

            sweepCount = sweepCount == 0 ? 1 : sweepCount;

            for (int i = sweepCount; i <= totalTurnsNum; i++)
            {
                int j = 1;
                if (i == sweepCount)
                {
                    j = timesNum;
                }
                for (; j <= npcCount; j++)
                {
                    //TrumpAbilityAttack.CombatTrumpLift(ContextUser.UserID);
                    PlotHelper.DoPlotSweepPrize(ContextUser.UserID, plotID, i, j, npcCount);
                }
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            string connectionString = "server=xxx;database=xx;user=xx;password=xx"; //ejemplo de conexion

            var userContext = new ContextUser(connectionString);

            userContext.getUsuarios();
        }
Ejemplo n.º 4
0
        public ActionResult AfterExternalLoginCallBack(string username, string email, string providerKey, string provider, string prfileurl, string fullname)
        {
            var cu = new ContextUser
            {
                OUser = new user
                {
                    Username = username,
                    Email    = email
                },
                EnumRole   = EnumUserRole.Volunteer,
                GoogleId   = provider == "Google" ? providerKey : null,
                LinkedInId = provider == "LinkedIn" ? providerKey : null,
                FullName   = fullname,
                ProfileUrl = prfileurl
            };


            FormsAuthentication.SetAuthCookie(username, false);
            var repository = new VolunteerRepository();
            volunteer_profile oVoluntee = null;

            Session["user"] = cu;
            if (provider == "Google")
            {
                oVoluntee = repository.Get().FirstOrDefault(x => x.GoogleSigninId == providerKey);
            }
            else if (provider == "user")
            {
                oVoluntee = repository.Get().FirstOrDefault(x => x.UserId == int.Parse(providerKey));
            }
            else
            {
                oVoluntee = repository.Get().FirstOrDefault(x => x.LinkedInSignInId == providerKey);
            }
            if (oVoluntee != null)
            {
                cu.OUser.Id     = oVoluntee.Id;
                Session["user"] = cu;
                if (oVoluntee.IsApprovedAtLevel1 != null && oVoluntee.IsApprovedAtLevel1.Value &&
                    oVoluntee.IsApprovedAtLevel2 != null && oVoluntee.IsApprovedAtLevel2.Value &&
                    oVoluntee.IsApprovedAtLevel3 != null && oVoluntee.IsApprovedAtLevel3.Value &&
                    !oVoluntee.OTAttendenceForVolunteer)
                {
                    return(RedirectToAction("Edit", "Supervisor", new { id = oVoluntee.RowGuid }));
                }
                if (oVoluntee.OTAttendenceForVolunteer)
                {
                    return(RedirectToAction("Index", "Session"));
                }
                return(RedirectToAction("VolunteerProfile", "Volunteer"));
            }
            return(RedirectToAction("VolunteerProfile", "Volunteer"));
        }
Ejemplo n.º 5
0
        public override bool TakeAction()
        {
            ErrorCode = _ops;
            int goldNum = ConfigEnvSet.GetInt("SparePart.PropertyGoldNum");

            if (_ops == 1)
            {
                ErrorInfo = string.Format(LanguageManager.GetLang().St1216_EnableSpartProperty, goldNum, _position);
            }
            else if (_ops == 2)
            {
                if (ContextUser.GoldNum < goldNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                if (ContextUser.EnableSpareProperty(_sparepartID, out _sparePart))
                {
                    ContextUser.UseGold = MathUtils.Addition(ContextUser.UseGold, goldNum);
                    //ContextUser.Update();
                    var          itempackage = UserItemPackage.Get(ContextUser.UserID);
                    UserItemInfo userItem    = itempackage.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(_sparePart.UserItemID));
                    if (userItem != null && userItem.ItemStatus.Equals(ItemStatus.YongBing))
                    {
                        var userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(ContextUser.UserID, userItem.GeneralID);
                        if (userGeneral != null)
                        {
                            userGeneral.RefreshMaxLife();
                        }
                    }
                }
                else
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
            }
            return(true);
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseCors(options => options
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        .AllowCredentials()
                        );

            app.Use(async(context, next) =>
            {
                if (context.Request.Query.ContainsKey("channel"))
                {
                    var name = context.Request.Query["channel"];
                    var user = ContextUser.Create(name);
                    context.Request.Query = context.Request.Query.Where(val => val.Key != "username") as IQueryCollection;
                    context.User          = user;
                }
                await next.Invoke();
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseMvc();

            app.UseSignalR(routes =>
            {
                routes.MapHub <UpdateHub>("/updater");
            });
        }
Ejemplo n.º 7
0
 public ExecuteHandler(ContextUser context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Ejemplo n.º 8
0
        public ActionResult VolunteerProfile(volunteer_profile volunteer, HttpPostedFileBase file)
        {
            var cu         = Session["user"] as ContextUser;
            var repository = new VolunteerRepository();
            volunteer_profile oVolunteer = null;

            if (cu != null)
            {
                oVolunteer = repository.GetByGoogleId(cu.GoogleId) ?? repository.GetByLinkedInId(cu.LinkedInId);
            }

            if (oVolunteer == null)
            {
                oVolunteer            = new volunteer_profile();
                oVolunteer.CreatedAt  = DateTime.Now;
                oVolunteer.CreatedBy  = 1;
                oVolunteer.FirstLogin = true;
                oVolunteer.RowGuid    = Guid.NewGuid();
            }
            else
            {
                oVolunteer.UpdatedAt = DateTime.Now;
                oVolunteer.UpdatedBy = 1;
            }
            oVolunteer.NationalID             = volunteer.NationalID;
            oVolunteer.VolunteerName          = volunteer.VolunteerName;
            oVolunteer.GoogleSigninId         = cu != null ? cu.GoogleId : "";
            oVolunteer.LinkedInSignInId       = cu != null ? cu.LinkedInId : "";
            oVolunteer.VolunteerEmail         = volunteer.VolunteerEmail;
            oVolunteer.VolunteerMobile        = volunteer.VolunteerMobile;
            oVolunteer.Gender                 = volunteer.Gender;
            oVolunteer.DateOfBirth            = volunteer.DateOfBirth;
            oVolunteer.AcademicQualification  = volunteer.AcademicQualification;
            oVolunteer.AcademicQualification1 = volunteer.AcademicQualification1;
            oVolunteer.AcademicQualification2 = volunteer.AcademicQualification2;
            oVolunteer.CompanyName            = volunteer.CompanyName;
            oVolunteer.VolunteerExperince1    = volunteer.VolExp == "Yes" ? string.Join(",", volunteer.SelectedExp == null ? new string[] { } : volunteer.SelectedExp) : "";
            oVolunteer.Telephone              = volunteer.Telephone;
            oVolunteer.Region                 = volunteer.Region;
            oVolunteer.City = volunteer.City;
            oVolunteer.VolunteerActivity1 = volunteer.VolunteerActivity1;
            oVolunteer.VolunteerActivity2 = volunteer.VolunteerActivity2;
            oVolunteer.VolunteerActivity3 = volunteer.VolunteerActivity3;
            oVolunteer.HasTOTCertificate  = volunteer.HasTOTCertificate;
            oVolunteer.OtherCertificate1  = volunteer.OtherCertificate1;
            oVolunteer.OtherCertificate2  = volunteer.OtherCertificate2;
            oVolunteer.OtherCertificate3  = volunteer.OtherCertificate3;
            oVolunteer.City = volunteer.City;
            if (file != null)
            {
                string fileName = "~/Uploads/ImageLibrary/" + Guid.NewGuid() + Path.GetExtension(file.FileName);
                string filePath = Server.MapPath(fileName);
                file.SaveAs(filePath);
                oVolunteer.PhotoPath = fileName;
            }
            oVolunteer.LinkedIn          = volunteer.LinkedIn;
            oVolunteer.IsProfileComplete = true;
            if (oVolunteer.Id > 0)
            {
                repository.Put(oVolunteer.Id, oVolunteer);
            }
            else
            {
                var userRole = new RoleRepository().Get().Where(x => x.Code == (int)EnumUserRole.Volunteer)
                               .FirstOrDefault();
                string password = Membership.GeneratePassword(8, 4);
                oVolunteer.user = new user()
                {
                    RowGuid          = Guid.NewGuid(),
                    Email            = oVolunteer.VolunteerEmail,
                    Username         = oVolunteer.VolunteerEmail,
                    RegistrationDate = DateTime.Now,
                    FirstName        = oVolunteer.VolunteerName,
                    RoleId           = userRole.Id,
                    CreatedAt        = DateTime.Now,
                    ValidFrom        = DateTime.Now,
                    FirstLogin       = false,
                    IsMobileVerified = false,
                    IsEmailVerified  = false,
                    CreatedBy        = cu != null ? cu.OUser.Id : 0,
                    Password         = EncryptionKeys.Encrypt(password)
                };
                string             url             = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Account/Login";
                var                bogusController = Util.CreateController <EmailTemplateController>();
                EmailTemplateModel emodel          =
                    new EmailTemplateModel
                {
                    Title         = "Volunteer Registration",
                    RedirectUrl   = url,
                    VolunteerName = oVolunteer.VolunteerName
                };
                string body =
                    Util.RenderViewToString(bogusController.ControllerContext, "VolunteerRegister", emodel);
                EmailSender.SendSupportEmail(body, oVolunteer.VolunteerEmail);

                repository.Post(oVolunteer);

                cu = new ContextUser
                {
                    OUser = new user
                    {
                        Username = oVolunteer.VolunteerName,
                        Email    = oVolunteer.VolunteerEmail,
                        Id       = oVolunteer.UserId
                    },
                    EnumRole   = EnumUserRole.Volunteer,
                    FullName   = "",
                    ProfileUrl = ""
                };
                Session["user"] = cu;
            }
            if (Request["editprofile"] != null)
            {
                return(RedirectToAction("VolunteerProfile", new { editprofile = true }));
            }

            return(RedirectToAction("VolunteerProfile"));
        }
Ejemplo n.º 9
0
        public ActionResult Login(LoginViewModel model, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (Request["button"] != null)
            {
                return(RedirectToAction("VolunteerProfile", "volunteer"));
            }

            var a          = 0;
            var repository = new AccountRepository();
            var user       = repository.Get().FirstOrDefault(x => x.Username == model.Username.Trim() && !x.IsLocked);

            if (user == null)
            {
                var participantRepo = new ParticipiantRepository();
                var participant     = participantRepo.Get().FirstOrDefault(x => x.NationalID == model.Username && x.isActive);
                if (participant != null)
                {
                    user = participant.user;
                }
            }
            if (user != null)
            {
                var password1 = EncryptionKeys.Decrypt(user.Password);
                var password  = EncryptionKeys.Encrypt(model.Password);
                if (user.Password.Equals(password))
                {
                    var    role     = new RoleRepository().Get(user.RoleId);
                    var    enumRole = (EnumUserRole)role.Code;
                    string route    = Request.Form["route"];
                    if (route == "manager" && enumRole != EnumUserRole.SuperAdmin)
                    {
                        return(RedirectToAction("Admin", new { error = true }));
                    }
                    if (route != "manager" && enumRole == EnumUserRole.SuperAdmin)
                    {
                        return(RedirectToAction("Login", new { error = true }));
                    }
                    if (enumRole == EnumUserRole.Coordinator)
                    {
                    }
                    var cu = new ContextUser
                    {
                        OUser     = user,
                        EnumRole  = enumRole,
                        Role      = role,
                        PhotoPath = "/img/avatars/admin.png"
                    };

                    Session["user"] = cu;
                    FormsAuthentication.SetAuthCookie(user.Username, false);
                    //var claims = new List<Claim>();
                    //claims.Add(new Claim(ClaimTypes.NameIdentifier, user.Username));
                    //claims.Add(new Claim(ClaimTypes.Name, user.FirstName));
                    //claims.Add(new Claim(ClaimTypes.Email, user.Email));
                    //claims.Add(new Claim(ClaimTypes.Role, userRole.ToString("g")));
                    //claims.Add(new Claim(ClaimTypes.Sid, user.Id.ToString()));

                    //var id = new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie);

                    //var ctx = Request.GetOwinContext();
                    //var authenticationManager = ctx.Authentication;
                    //authenticationManager.SignIn(id);


                    return(RedirectToPortal(enumRole, user));
                }
            }

            string route1 = Request.Form["route"];

            if (route1 == "manager")
            {
                return(RedirectToAction("Admin", new { error = true }));
            }
            if (route1 != "manager")
            {
                return(RedirectToAction("Login", new { error = true }));
            }

            return(View(model));

            //// This doesn't count login failures towards account lockout
            //// To enable password failures to trigger account lockout, change to shouldLockout: true
            //var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout: false);
            //switch (result)
            //{
            //    case SignInStatus.Success:
            //        return RedirectToLocal(returnUrl);
            //    case SignInStatus.LockedOut:
            //        return View("Lockout");
            //    case SignInStatus.RequiresVerification:
            //        return RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe });
            //    case SignInStatus.Failure:
            //    default:
            //        ModelState.AddModelError("", "Invalid login attempt.");
            //        return View(model);
            //}
        }
Ejemplo n.º 10
0
 public ExecuteHandler(ContextUser context, IConfiguration config)
 {
     _context       = context;
     _configuration = config;
 }
Ejemplo n.º 11
0
        public override bool TakeAction()
        {
            UserQueue userQueue = null;
            int       energyNum;
            int       coleTime  = GetSweepColdTime(out energyNum);
            short     surEnergy = MathUtils.Addition(ContextUser.EnergyNum, ContextUser.SurplusEnergy, short.MaxValue);

            if ((ContextUser.EnergyNum == 0 && ContextUser.SurplusEnergy == 0) || surEnergy < energyNum)
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return(false);
            }
            int goldNum = GetGoldNum(out userQueue);

            if (goldNum == 0)
            {
                return(false);
            }
            if (ops == 1)
            {
                //提示晶石操作
                ErrorCode = ops;
                ErrorInfo = string.Format(LanguageManager.GetLang().St4008_Tip, goldNum);
            }
            else if (ops == 2)
            {
                //使用晶石确认操作
                int userGoldNum = ContextUser.GoldNum;
                if (userGoldNum < goldNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St_GoldNotEnough;
                    return(false);
                }
                //晶石扫荡
                if (userQueue != null)
                {
                    DoAccelerateQueue(goldNum, userQueue.DoRefresh(), userQueue.GetTiming(), userQueue.TotalColdTime);
                    //加速完清除队列
                    var queueCacheSet = new PersonalCacheStruct <UserQueue>();
                    queueCacheSet.Delete(userQueue);
                    ContextUser.ResetSweepPool(0);
                    //ContextUser.Update();
                }
                else
                {
                    //清除扫荡池
                    var sweepCacheSet = new PersonalCacheStruct <UserSweepPool>();
                    List <UserSweepPool> sweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID);
                    foreach (UserSweepPool sweepPool in sweepPoolList)
                    {
                        if (sweepPool != null)
                        {
                            sweepCacheSet.Delete(sweepPool);
                        }
                    }
                    var itemList = UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao);
                    if (itemList.Count >= ContextUser.GridNum)
                    {
                        this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                        this.ErrorInfo = LanguageManager.GetLang().St4007_BeiBaoTimeOut;
                        return(false);
                    }
                    DoAccelerateQueue(goldNum, coleTime, 0, coleTime);
                }
                DateTime startDate = userQueue != null ? userQueue.Timing : DateTime.Now;
                UserLogHelper.AppenRaidsLog(ContextUser.UserID, 2, startDate, DateTime.Now, (short)GetSweepEnergy(out energyNum), goldNum);
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            return(true);
        }
Ejemplo n.º 12
0
        public override bool TakeAction()
        {
            List <PlotNPCInfo> plotNPCInfoList = new ConfigCacheSet <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);

            npcCount = (short)plotNPCInfoList.Count;
            var cacheSet = new GameDataCacheSet <UserQueue>();
            List <UserQueue> userQueueList = cacheSet.FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            if (userQueueList.Count > 0)
            {
                UserQueue userQueue = userQueueList[0];
                coldTime = userQueue.DoRefresh();
                if (coldTime == 0)
                {
                    cacheSet.Delete(userQueue);
                    ContextUser.ResetSweepPool(0);
                    ContextUser.UserStatus = UserStatus.Normal;
                    //ContextUser.Update();
                }
                int tempNum = PlotHelper.GetBattleNum(userQueue.GetTiming()) + 1;
                if (npcCount > 0)
                {
                    turnsNum = PlotHelper.GetTurnsNum(npcCount, tempNum);
                    timesNum = PlotHelper.GetTimesNum(npcCount, tempNum);
                }
                //PlotHelper.CheckSweepCount(npcCount, userQueue.GetTiming(), out turnsNum, out battleNum);

                //if (battleNum >= npcCount)
                //{
                //    turnsNum = turnsNum + 1;
                //}
                //else
                //{
                //    battleNum = battleNum + 1;
                //}
            }
            userItemCount = (short)UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao).Count;
            plotInfo      = new ConfigCacheSet <PlotInfo>().FindKey(plotID);
            if (plotInfo == null)
            {
                return(false);
            }
            foreach (PlotNPCInfo npcInfo in plotNPCInfoList)
            {
                if (npcInfo == null)
                {
                    continue;
                }
                List <PlotEmbattleInfo> embattleInfoList = new ConfigCacheSet <PlotEmbattleInfo>().FindAll(m => m.PlotNpcID == npcInfo.PlotNpcID);
                foreach (PlotEmbattleInfo embattleInfo in embattleInfoList)
                {
                    if (monsterDict.ContainsKey(embattleInfo.MonsterID))
                    {
                        if (monsterNumDict.ContainsKey(embattleInfo.MonsterID))
                        {
                            monsterNumDict[embattleInfo.MonsterID] = monsterNumDict[embattleInfo.MonsterID] + 1;
                        }
                    }
                    else
                    {
                        MonsterInfo monsterInfo = new ConfigCacheSet <MonsterInfo>().FindKey(embattleInfo.MonsterID);
                        if (monsterInfo != null)
                        {
                            monsterDict.Add(embattleInfo.MonsterID, monsterInfo);
                            monsterNumDict.Add(embattleInfo.MonsterID, 1);
                        }
                    }
                }
            }
            return(true);
        }
Ejemplo n.º 13
0
 public ExecuteHandler(ContextUser context)
 {
     _context = context;
 }
Ejemplo n.º 14
0
 public TasksController(ContextUser context)
 {
     _context = context;
 }
Ejemplo n.º 15
0
        public override bool TakeAction()
        {
            int sportsIndex;

            if (int.TryParse(userSportsID, out sportsIndex))
            {
                var tempList = ContextUser.GetSportsCombat();
                if (tempList.Count > 0 && sportsIndex < tempList.Count)
                {
                    sportsIndex        = MathUtils.Addition(sportsIndex, 1);
                    _uSportsCombat     = tempList[tempList.Count - sportsIndex] ?? new SportsCombat();
                    _combatProcessList = _uSportsCombat.CombatProcess ?? new CombatProcessContainer();

                    _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0);

                    if (_combatProcessList.DefenseList.Count > 0)
                    {
                        _npcTalPriority = CombatHelper.TotalPriorityNum(_combatProcessList.DefenseList[0].UserID, 0);
                    }
                }
            }
            else if (!string.IsNullOrEmpty(toUserID))
            {
                UserHelper.ChechDailyRestrain(ContextUser.UserID);
                if (ContextUser.UserID == toUserID)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
                if (GetChallGeNum(ContextUser.UserID) <= 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St5107_ChallGeNumFull;
                    return(false);
                }

                toGameUser = UserCacheGlobal.LoadOffline(toUserID);
                if (ContextUser.UseMagicID == 0 || toGameUser == null || toGameUser.UseMagicID == 0)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St4004_NoUseMagic;
                    return(false);
                }
                RankingHelper.SportSRewardGain(toUserID, toGameUser.RankID);   //被挑战者的竞技排名
                //todo 竞技场冷却时间清除
                //var userQueueCache = new GameDataCacheSet<UserQueue>();
                //var queueArray = userQueueCache.FindAll(Uid, m => m.QueueType == QueueType.JingJiTiaoZhan);
                //if (queueArray.Count > 0 && queueArray[0].DoRefresh() > 0)
                //{
                //    ErrorCode = LanguageManager.GetLang().ErrorCode;
                //    ErrorInfo = LanguageManager.GetLang().St5107_Colding;
                //    return false;
                //}
                //if (queueArray.Count > 0)
                //{
                //    var userQueue = queueArray[0];
                //    userQueue.ColdTime = codeTime;
                //    userQueue.TotalColdTime = codeTime;
                //    userQueue.Timing = DateTime.Now;
                //}
                //else
                //{
                //    UserQueue queue = new UserQueue()
                //    {
                //        QueueID = Guid.NewGuid().ToString(),
                //        QueueType = QueueType.JingJiTiaoZhan,
                //        QueueName = QueueType.JingJiTiaoZhan.ToString(),
                //        UserID = ContextUser.UserID,
                //        ColdTime = codeTime,
                //        IsSuspend = false,
                //        TotalColdTime = codeTime,
                //        Timing = DateTime.Now
                //    };
                //    userQueueCache.Add(queue);
                //    //queue.Append();
                //}
                //次数限制修改
                int sportNum = 0;
                UserDailyRestrain dailyRestrain = new GameDataCacheSet <UserDailyRestrain>().FindKey(ContextUser.UserID);
                if (dailyRestrain != null)
                {
                    sportNum = MathUtils.Addition(dailyRestrain.Funtion9, 1, int.MaxValue);
                    dailyRestrain.Funtion9 = sportNum;
                    //dailyRestrain.Update();
                }
                else
                {
                    sportNum = 1;
                }
                TriggerSportCombat(ContextUser, toGameUser, sportNum, ref sportsPrizeStr, userMail);

                var tempList = ContextUser.GetSportsCombat();
                if (tempList.Count > 0)
                {
                    _uSportsCombat     = tempList[tempList.Count - 1] ?? new SportsCombat();
                    _combatProcessList = _uSportsCombat.CombatProcess ?? new CombatProcessContainer();
                }
                //日常任务-竞技
                TaskHelper.TriggerDailyTask(Uid, 4006);
                _userTalPriority = CombatHelper.TotalPriorityNum(ContextUser.UserID, 0);
                _npcTalPriority  = CombatHelper.TotalPriorityNum(toUserID, 0);
            }
            else
            {
                ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }

            userMail.GameCoin = _uSportsCombat.RewardGoin;
            userMail.Obtion   = _uSportsCombat.RewardObtian;
            var tjxMailService = new TjxMailService(toGameUser);

            tjxMailService.Send(userMail);

            _selfAbilityEffectList    = UserAbilityHelper.GetSelfAbilityEffectList(ContextUser.UserID, 0);
            _defSelfAbilityEffectList = UserAbilityHelper.GetSelfAbilityEffectList(toUserID, 1);
            _selfAbilityEffectList.AddRange(_defSelfAbilityEffectList);
            return(true);
        }
Ejemplo n.º 16
0
 private static void ApprovedBylevel(volunteer_profile volunteer, VolunteerRepository repository, volunteer_profile oVolunteer, ContextUser cu)
 {
     if (cu.EnumRole == EnumUserRole.Approver1)
     {
         oVolunteer.IsApprovedAtLevel1       = true;
         oVolunteer.ApprovedAtLevel1Comments = volunteer.ApprovedAtLevel1Comments;
     }
     if (cu.EnumRole == EnumUserRole.Approver2)
     {
         oVolunteer.IsApprovedAtLevel2       = true;
         oVolunteer.ApprovedAtLevel2Comments = volunteer.ApprovedAtLevel2Comments;
     }
     if (cu.EnumRole == EnumUserRole.Approver3)
     {
         oVolunteer.IsApprovedAtLevel3       = true;
         oVolunteer.ApprovedAtLevel3Comments = volunteer.ApprovedAtLevel3Comments;
         string             password        = EncryptionKeys.Decrypt(oVolunteer.user.Password);
         string             url             = System.Web.HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Account/Login";
         var                bogusController = Util.CreateController <EmailTemplateController>();
         EmailTemplateModel emodel          =
             new EmailTemplateModel
         {
             Title         = "Volunteer Approved",
             RedirectUrl   = url,
             VolunteerName = oVolunteer.VolunteerName,
             UserName      = oVolunteer.user.Username,
             Password      = password
         };
         string body =
             Util.RenderViewToString(bogusController.ControllerContext, "VolunteerApproved", emodel);
         EmailSender.SendSupportEmail(body, oVolunteer.VolunteerEmail);
     }
     repository.Put(oVolunteer.Id, oVolunteer);
 }
Ejemplo n.º 17
0
        public override bool TakeAction()
        {
            ErrorCode = _ops;
            //1:镶嵌 2:卸下 3:出售
            if (_ops == 1)
            {
                if (string.IsNullOrEmpty(_userItemID))
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    return(false);
                }
                UserSparePart[] sparePartsArray = ContextUser.SparePartList.FindAll(m => m.UserItemID.Equals(_userItemID)).ToArray();
                if (sparePartsArray.Length > 0)
                {
                    //原因:装备上镶嵌超出开启位置数量的灵件
                    if (ContextUser.UserExtend != null)
                    {
                        if (_position > ContextUser.UserExtend.MaxLayerNum)
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St1213_GridNumNotEnough;
                            return(false);
                        }
                        if (sparePartsArray.Length >= ContextUser.UserExtend.MaxLayerNum)
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St1213_OpenNumNotEnough;
                            return(false);
                        }
                    }
                    foreach (UserSparePart part in sparePartsArray)
                    {
                        if (part.Position == _position)
                        {
                            ErrorCode = LanguageManager.GetLang().ErrorCode;
                            ErrorInfo = LanguageManager.GetLang().St1213_GridPotionFull;
                            return(false);
                        }
                    }
                }

                var sparePart = ContextUser.SparePartList.Find(m => m.UserSparepartID.Equals(_sparepartID));
                if (sparePart != null && string.IsNullOrEmpty(sparePart.UserItemID))
                {
                    sparePart.UpdateNotify(obj =>
                    {
                        sparePart.UserItemID = _userItemID;
                        sparePart.SetPosition(_position);
                        return(true);
                    });
                    UserLogHelper.AppendSparePartLog(ContextUser.UserID, sparePart, 3);
                    //ContextUser.UpdateSparePart();

                    var          package  = UserItemPackage.Get(Uid);
                    UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(sparePart.UserItemID));
                    if (userItem != null && userItem.ItemStatus.Equals(ItemStatus.YongBing))
                    {
                        var userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(Uid, userItem.GeneralID);
                        if (userGeneral != null)
                        {
                            userGeneral.RefreshMaxLife();
                        }
                    }
                }
            }
            else if (_ops == 2)
            {
                int currNum = ContextUser.SparePartList.FindAll(m => string.IsNullOrEmpty(m.UserItemID)).Count;
                if (currNum >= ContextUser.UserExtend.SparePartGridNum)
                {
                    ErrorCode = LanguageManager.GetLang().ErrorCode;
                    ErrorInfo = LanguageManager.GetLang().St1213_GridNumFull;
                    return(false);
                }
                var sparePart = ContextUser.SparePartList.Find(m => m.UserSparepartID.Equals(_sparepartID));
                if (sparePart != null && !string.IsNullOrEmpty(sparePart.UserItemID))
                {
                    var          package  = UserItemPackage.Get(Uid);
                    UserItemInfo userItem = package.ItemPackage.Find(m => !m.IsRemove && m.UserItemID.Equals(sparePart.UserItemID));

                    sparePart.UpdateNotify(obj =>
                    {
                        sparePart.SetPosition(0);
                        sparePart.UserItemID = string.Empty;
                        return(true);
                    });
                    UserLogHelper.AppendSparePartLog(ContextUser.UserID, sparePart, 3);
                    if (userItem != null && userItem.ItemStatus.Equals(ItemStatus.YongBing))
                    {
                        var userGeneral = new GameDataCacheSet <UserGeneral>().FindKey(Uid, userItem.GeneralID);
                        if (userGeneral != null)
                        {
                            userGeneral.RefreshMaxLife();
                        }
                    }
                }
            }
            else if (_ops == 3)
            {
                var sparePart = ContextUser.SparePartList.Find(m => m.UserSparepartID.Equals(_sparepartID));
                if (sparePart != null)
                {
                    var sparePartInfo = new ConfigCacheSet <SparePartInfo>().FindKey(sparePart.SparePartId) ?? new SparePartInfo();
                    ContextUser.GameCoin = MathUtils.Addition(ContextUser.GameCoin, sparePartInfo.CoinPrice);
                    ContextUser.UserExtend.UpdateNotify(obj =>
                    {
                        ContextUser.UserExtend.LingshiNum = MathUtils.Addition(ContextUser.UserExtend.LingshiNum, sparePartInfo.LingshiPrice);
                        return(true);
                    });
                    UserLogHelper.AppendSparePartLog(ContextUser.UserID, sparePart, 2);
                    ContextUser.RemoveSparePart(sparePart);
                    //ContextUser.Update();
                }
            }
            return(true);
        }
Ejemplo n.º 18
0
 public AccountController(ContextUser context)
 {
     db = context;
 }
Ejemplo n.º 19
0
 public WorkersController(ContextUser context)
 {
     _context = context;
 }
Ejemplo n.º 20
0
        public override bool TakeAction()
        {
            List <UserQueue> queueList = new PersonalCacheStruct <UserQueue>().FindAll(ContextUser.UserID, m => m.QueueType == QueueType.SaoDang);

            if (queueList.Count > 0)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St4007_Saodanging;
                return(false);
            }
            var itemList = UserItemHelper.GetItems(Uid).FindAll(m => m.ItemStatus == ItemStatus.BeiBao);

            if (itemList.Count >= ContextUser.GridNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St4007_BeiBaoTimeOut;
                return(false);
            }
            List <PlotNPCInfo> npcList = new ShareCacheStruct <PlotNPCInfo>().FindAll(m => m.PlotID == plotID);
            //战斗次数
            int plotNpcNum = npcList.Count;
            int energyNum  = 0;
            int battleNum;

            if (ops == 1)
            {
                //用尽精力,玩家可扫荡轮数
                energyNum = ContextUser.EnergyNum > 200 ? 200 : ContextUser.EnergyNum.ToInt();
                int userTurnsNum = (int)Math.Floor((double)energyNum / PlotInfo.BattleEnergyNum);
                battleNum = userTurnsNum * plotNpcNum;
                coldTime  = battleNum * PlotInfo.BattleSpeedNum;
            }
            else if (ops == 2)
            {
                //30分钟
                coldTime  = Time_30;
                battleNum = PlotHelper.GetBattleNum(Time_30);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }
            else if (ops == 3)
            {
                //60分钟
                coldTime  = Time_60;
                battleNum = PlotHelper.GetBattleNum(Time_60);
                energyNum = PlotHelper.GetTurnsNum(plotNpcNum, battleNum) * PlotInfo.BattleEnergyNum;
            }
            else
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                return(false);
            }
            if (ContextUser.EnergyNum == 0 || ContextUser.EnergyNum < energyNum)
            {
                this.ErrorCode = LanguageManager.GetLang().ErrorCode;
                this.ErrorInfo = LanguageManager.GetLang().St_EnergyNotEnough;
                return(false);
            }
            //清除扫荡池
            var sweepCacheSet = new PersonalCacheStruct <UserSweepPool>();
            List <UserSweepPool> sweepPoolList = sweepCacheSet.FindAll(ContextUser.UserID);

            foreach (UserSweepPool sweepPool in sweepPoolList)
            {
                if (sweepPool != null)
                {
                    sweepCacheSet.Delete(sweepPool);
                }
            }

            if (coldTime > 0)
            {
                //在开始战斗时扣一次玩家精力,无战斗离开返还
                ContextUser.ResetSweepPool(plotID);
                //开始扫荡暂不扣精力
                //ContextUser.RemoveEnergyNum(PlotInfo.BattleEnergyNum);
                ContextUser.UserStatus = UserStatus.SaoDang;
                //ContextUser.Update();

                //放入队列中
                UserQueue userQueue = new UserQueue()
                {
                    QueueID       = Guid.NewGuid().ToString(),
                    UserID        = ContextUser.UserID,
                    QueueType     = QueueType.SaoDang,
                    QueueName     = QueueType.SaoDang.ToString(),
                    TotalColdTime = coldTime,
                    Timing        = DateTime.Now,
                    ColdTime      = coldTime,
                    IsSuspend     = false
                };
                new PersonalCacheStruct <UserQueue>().Add(userQueue);
            }
            return(true);
        }
Ejemplo n.º 21
0
        public override bool TakeAction()
        {
            UserStatus status = ContextUser.UserStatus;

            if (status == UserStatus.FengJin)
            {
                return(false);
            }
            UserGeneral        general = UserGeneral.GetMainGeneral(ContextUser.UserID);
            Ranking <UserRank> ranking = RankingFactory.Get <UserRank>(CombatRanking.RankingKey);
            UserRank           rankInfo;

            if (ranking.TryGetRankNo(m => m.UserID == ContextUser.UserID, out rankID))
            {
                rankInfo = ranking.Find(s => s.UserID == ContextUser.UserID);
                //ContextUser.RankID = rankID;
            }
            else
            {
                rankInfo = new UserRank()
                {
                    UserID         = ContextUser.UserID,
                    HeadID         = general.HeadID,
                    GameCoin       = ContextUser.GameCoin,
                    NickName       = ContextUser.NickName,
                    ObtainNum      = ContextUser.ObtainNum,
                    UserLv         = ContextUser.UserLv,
                    RankId         = int.MaxValue,
                    RankDate       = DateTime.Now,
                    SportsIntegral = 0
                };
                ranking.TryAppend(rankInfo);
            }

            sportsName = UserHelper.SportTitleName(ContextUser.ObtainNum);

            sportNum       = GetChallGeNum(ContextUser.UserID);
            sportsIntegral = ContextUser.SportsIntegral.ToInt();
            sportsReward   = new ShareCacheStruct <SportsRewardInfo>().FindKey(rankInfo.RankId);
            receiveDate    = (int)(RankingHelper.GetNextReceiveDate() - DateTime.Now).TotalSeconds;

            CombatRanking combatrank = (CombatRanking)ranking;

            _userRankArray = combatrank.GetRanking(ContextUser);
            _userRankArray.Add(rankInfo);
            _userRankArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(x.RankId.CompareTo(y.RankId));
            });

            _userCombatArray = ContextUser.GetSportsCombat();
            _userCombatArray.QuickSort((x, y) =>
            {
                if (x == null && y == null)
                {
                    return(0);
                }
                if (x != null && y == null)
                {
                    return(1);
                }
                if (x == null)
                {
                    return(-1);
                }
                return(y.CombatDate.CompareTo(x.CombatDate));
            });

            if (rankInfo != null && rankID > 0)
            {
                victoryNum = rankInfo.VictoryNum;
            }

            //NoviceHelper.SportVictoryNum(ContextUser, 2001, victoryNum); //竞技场奖励
            if (victoryNum >= 7)
            {
                ActivitiesAward.HolidayFestival(ContextUser.UserID);
            }
            rankID = ContextUser.RankID;



            int count     = 10;
            int pagecount = 0;

            userRankArray = ranking.GetRange(1, count, out pagecount);
            return(true);
        }
 public HomeController(UserManager <User> userManager, SignInManager <User> signInManager, ContextUser _context)
 {
     _userManager   = userManager;
     _signInManager = signInManager;
     context        = _context;
 }