public ActionResult SignUpCvk(string key)
        {
            if (key == null)
            {
                throw new BusinessLogicException("Вы не можете зарегистрироваться, так как вы не указали код приглашения");
            }

            key = key.Replace("`", "");
            var inviteEntity = InviteService.GetInvite(key);

            if (inviteEntity == null)
            {
                throw new BusinessLogicException("Вы не можете зарегистрироваться, так как вы указали неправильный код приглашения");
            }

            if (inviteEntity.State == (byte)InviteState.Requested)
            {
                throw new BusinessLogicException("Вы не можете зарегистрироваться, так как ваш запрос еще не рассмотрели");
            }

            if (inviteEntity.State == (byte)InviteState.Used)
            {
                throw new BusinessLogicException("Вы не можете  зарегистрироваться, так как данный ключ уже был использован");
            }

            return(View("signupcvk", new SignUpCvkViewModel
            {
                Email = inviteEntity.Email,
                InviteKey = key,
                PhoneNumber = inviteEntity.Phone,
            }));
        }
Exemple #2
0
        /// 发布资讯
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRelease_Click(object sender, EventArgs e)
        {
            if (Session["loginUser"] == null)
            {
                Jscript.AlertAndRedirect("请登录", "/admin/login.aspx");
                return;
            }
            string peopleCount = txtPeopleCount.Text.Trim();

            if (peopleCount.Length == 0)
            {
                lblError.Text = "请输入招聘人数";
                return;
            }
            Invite item = new Invite();

            item.inviteType = 0;
            try
            {
                item.inviteType = Convert.ToInt32(txtPeopleCount.Text.Trim());
            }
            catch (Exception je)
            {
                lblError.Text = "招聘人数输入错误";
                return;
            }
            item.inviteName = txtTitle.Text.Trim();
            item.inviteInfo = this.content1.Value;
            item.inviteDesc = txtZhaiYao.Value.Trim();
            txtHidInfo.Text = item.inviteInfo;
            item.inforemark = txtHidInfo.Text.Trim();
            txtHidInfo.Text = item.inviteDesc;
            item.descremark = txtHidInfo.Text;
            item.addTime    = DateTime.Now;
            item.status     = 0;
            if (id != 0)
            {
                item.id = id;
                if (InviteService.Update(item))
                {
                    Jscript.AlertAndRedirect("修改成功", "inviteInfo.aspx");
                }
                else
                {
                    Jscript.AlertAndRedirect("修改失败", "inviteInfo.aspx");
                }
            }
            else
            {
                int num = InviteService.Add(item);
                if (num > 0)
                {
                    Jscript.AlertAndRedirect("添加成功", "inviteInfo.aspx");
                }
                else
                {
                    Jscript.AlertAndRedirect("添加失败", "inviteInfo.aspx");
                }
            }
        }
        public ActionResult Answer(int id, bool answer)
        {
            InviteService repoInvite = new InviteService();

            repoInvite.Answer(UserSession.CurrentUser.Id, id, answer);
            return(RedirectToAction("Index"));
        }
        public static void Main(string[] args)
        {
            // See https://support.microsoft.com/en-gb/help/821268/contention-poor-performance-and-deadlocks-when-you-make-calls-to-web-s
            // Experimentation shows we need the ThreadPool to always spin up threads for good performance under load
            ThreadPool.GetMaxThreads(out var workerThreads, out var ioThreads);
            ThreadPool.SetMinThreads(workerThreads, ioThreads);

            Parser.Default.ParseArguments <PartyServerCommandLineArgs>(args)
            .WithParsed(parsedArgs =>
            {
                parsedArgs.Validate();

                var spatialRefreshToken = Secrets.GetEnvSecret(SpatialRefreshTokenEnvironmentVariable);

                PartyDataModel.Defaults.MinMembers = (uint)parsedArgs.DefaultMinMembers;
                PartyDataModel.Defaults.MaxMembers = (uint)parsedArgs.DefaultMaxMembers;

                Log.Logger = new LoggerConfiguration()
                             .WriteTo.Console(new RenderedCompactJsonFormatter())
                             .Enrich.FromLogContext()
                             .CreateLogger();

                using (var server = GrpcBaseServer.Build(parsedArgs))
                    using (var memoryStoreManager = new RedisClientManager(parsedArgs.RedisConnectionString))
                    {
                        Log.Information($"Successfully connected to Redis at {parsedArgs.RedisConnectionString}");
                        server.AddInterceptor(new PlayerIdentityTokenValidatingInterceptor(
                                                  PlayerAuthServiceClient.Create(credentials: new PlatformRefreshTokenCredential(spatialRefreshToken)),
                                                  memoryStoreManager.GetRawClient(Database.CACHE)
                                                  ))
                        .AddInterceptor(new ExceptionMappingInterceptor(new Dictionary <Type, StatusCode>
                        {
                            { typeof(EntryNotFoundException), StatusCode.NotFound },
                            { typeof(EntryAlreadyExistsException), StatusCode.AlreadyExists },
                            { typeof(TransactionAbortedException), StatusCode.Unavailable }
                        }));
                        server.AddService(
                            PartyService.BindService(new PartyServiceImpl(memoryStoreManager)));
                        server.AddService(
                            InviteService.BindService(new InviteServiceImpl(memoryStoreManager)));
                        var serverTask = Task.Run(() => server.Start());
                        var signalTask = Task.Run(() => UnixSignal.WaitAny(new[] { new UnixSignal(Signum.SIGINT), new UnixSignal(Signum.SIGTERM) }));
                        Task.WaitAny(serverTask, signalTask);

                        if (signalTask.IsCompleted)
                        {
                            Log.Information($"Received UNIX signal {signalTask.Result}");
                            Log.Information("Server shutting down...");
                            server.Shutdown();
                            serverTask.Wait();
                            Log.Information("Server stopped cleanly");
                        }
                        else
                        {
                            /* The server task has completed; we can just exit. */
                            Log.Information("The Party server has stopped itself or encountered an unhandled exception.");
                        }
                    }
            });
        }
Exemple #5
0
 public BigSelecteController(BigSelecteService bigselecteservice, InviteService inviteservice, DateService dateservice, ValidationService validationservice)
 {
     _bigselecteService = bigselecteservice;
     _inviteService     = inviteservice;
     _dateService       = dateservice;
     _validationService = validationservice;
 }
        //InviteToTeam <teamName> <username>
        public string Execute(string[] inputArgs)
        {
            Check.CheckLength(2, inputArgs);
            AuthenticationManager.Authorize();

            string teamName = inputArgs[0];
            string username = inputArgs[1];

            if (!(CommandHelper.IsTeamExisting(teamName) && CommandHelper.IsUserExisting(username)))
            {
                throw new ArgumentException(Constants.ErrorMessages.TeamOrUserNotExist);
            }

            if (InviteService.IsInvitePending(teamName, username))
            {
                throw new InvalidOperationException(Constants.ErrorMessages.InviteIsAlreadySent);
            }

            if (!TeamService.IsCreatorOrPartOfTeam(teamName))
            {
                throw new InvalidOperationException(Constants.ErrorMessages.NotAllowed);
            }

            InviteService.SendInvite(teamName, username);

            return($"Team {teamName} invited {username}!");
        }
Exemple #7
0
        /// <summary>
        /// Display latest <see cref="Post"/> objects in current space.
        /// </summary>
        /// <param name="app">The app</param>
        /// <param name="query">An object with query parameters for search, paging etc.</param>
        public override ActionResult Get(Posts app, Query query)
        {
            var model = new PostsViewModel();

            if (!IsEmbedded)
            {
                model.Members = SpaceService.GetMembers(WeavyContext.Current.Space.Id, new MemberQuery {
                    Top = 6, OrderBy = "Random", Count = true
                });
                model.ExternalMemberCount = SpaceService.GetMembers(WeavyContext.Current.Space.Id, new MemberQuery {
                    External = true, CountOnly = true
                }).TotalCount ?? 0;
                model.InviteCount = InviteService.Search(new InviteQuery()
                {
                    Top = 6, OrderBy = "Random", SpaceId = app.SpaceId, CountOnly = true
                }).TotalCount ?? 0;
            }

            query.Top   = PageSizes[0] / 5; // NOTE: reduced number of items/page for better perf.
            model.Posts = PostService.GetPosts(app.Id, opts: query);
            if (Request.IsAjaxRequest())
            {
                // infinite scroll, return partial view
                return(PartialView("_Posts", model.Posts));
            }

            // REVIEW: can we do this automagically?
            return(View(IsEmbedded ? "Get.Embedded": null, model));
        }
Exemple #8
0
        public void Setup()
        {
            var ctx = Substitute.For <IDbContext>();

            this.inviteRepository = Substitute.For <IRepository <Invite> >();

            this._inviteService = new InviteService(inviteRepository);
        }
Exemple #9
0
        public MyGroupController()
        {
            msgService    = new MessageService();
            groupService  = new GroupService();
            mgrService    = new MemberGroupService();
            inviteService = new InviteService();

            gpostService = new GroupPostService();
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view = base.OnCreateView(inflater, container, savedInstanceState);
            var contactList = view.FindViewById <MvxListView>(Resource.Id.contacts_list);

            contactsAdapter     = new ContactsListAdapter(Activity, (IMvxAndroidBindingContext)BindingContext);
            contactList.Adapter = contactsAdapter;
            UndateControls();
            inviteService = new InviteService(this);
            return(view);
        }
Exemple #11
0
        /// <summary>
        /// 加载信息进行修改
        /// </summary>
        private void LoadInfo()
        {
            Invite item = InviteService.GetModel(id);

            if (item != null)
            {
                txtTitle.Text       = item.inviteName;
                txtPeopleCount.Text = item.inviteType.ToString();
                txtZhaiYao.Value    = item.inviteDesc;
                content1.Value      = item.inviteInfo;
            }
        }
Exemple #12
0
        // GET: Event/Details/5
        public ActionResult Details(int id)
        {
            EventService    repo       = new EventService();
            EmployeeService emprepo    = new EmployeeService();
            InviteService   repoInvite = new InviteService();
            DocumentService repoDoc    = new DocumentService();
            Event           events     = repo.Get(id);
            IEnumerable <EventEmployeeListItem> employees = repoInvite.GetByEventId(id).Select(i => new EventEmployeeListItem(emprepo.Get(i.EmployeeId), repoInvite.Get(i.EmployeeId, id)));
            IEnumerable <DocumentList>          docs      = repoDoc.GetByEvent(id).Select(d => new DocumentList(d));
            EventDetail ev = new EventDetail(events, emprepo.Get(events.EmployeeId), employees, docs);

            return(View(ev));
        }
Exemple #13
0
 /// <summary>
 /// 控件行命令事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("del"))
     {
         int id = Convert.ToInt32(e.CommandArgument);
         InviteService.Delete(id);
         LoadData();
     }
     if (e.CommandName.Equals("mod"))
     {
         Response.Redirect("addInvite.aspx?id=" + e.CommandArgument);
     }
 }
        protected override void Setup()
        {
            var mockUsers = new List <User>
            {
                new User {
                    Email = "*****@*****.**"
                },
            };

            Context.Users.AddRange(mockUsers);
            Context.SaveChanges();
            _mockInviteEmailService = new Mock <IInviteEmailService>();
            _inviteService          = new InviteService(_mockInviteEmailService.Object, Context, MockClock.Object);
        }
Exemple #15
0
        public RegisterController()
        {
            userService    = new UserService();
            confirmService = new UserConfirmService();
            confirmEmail   = new ConfirmEmail();
            loginService   = new LoginService();

            appService  = new UserAppService();
            menuService = new UserMenuService();

            inviteService = new InviteService();

            HidePermission(typeof(SecurityController));
        }
Exemple #16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                KeyWordBind();

                DataSet ds = InviteService.GetList("");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    repInfo.DataSource = ds;
                    repInfo.DataBind();
                }
            }
        }
Exemple #17
0
        /// <summary>
        /// 加载数据
        /// </summary>
        private void LoadData()
        {
            DataSet ds = InviteService.GetList("");

            if (ds.Tables[0].Rows.Count > 0)
            {
                this.repInfo.DataSource = ds;
                repInfo.DataBind();
            }
            else
            {
                this.repInfo.DataSource = null;
                repInfo.DataBind();
            }
        }
Exemple #18
0
        public void Test_Create_Invite_NotFound()
        {
            var userRepo = new UserRepository(database);
            var usr      = userRepo.CreateNew(new User {
                DateCreated = DateTime.Now, Email = "*****@*****.**", Name = "Jaytee"
            });
            var invRepo = new InviteRepository(database, userRepo);
            var project = invRepo.CreateNew(new Project {
                CreatedByUserId = usr.Id, DateCreated = DateTime.Now, Description = "A demo api", Name = "DEMO API"
            });
            var service = new InviteService(invRepo);

            Assert.ThrowsAsync <DocIT.Core.Services.Exceptions.InviteException>(async() => await service.CreateInvite(new Core.Data.Payloads.InvitePayload {
                Email = "*****@*****.**", ProjectId = Guid.NewGuid()
            }, Guid.NewGuid()));
        }
Exemple #19
0
        public void Test_Create_Invite()
        {
            var userRepo = new UserRepository(database);
            var usr      = userRepo.CreateNew(new User {
                DateCreated = DateTime.Now, Email = "*****@*****.**", Name = "Jaytee"
            });
            var invRepo = new InviteRepository(database, userRepo);
            var project = invRepo.CreateNew(new Project {
                CreatedByUserId = usr.Id, DateCreated = DateTime.Now, Description = "A demo api", Name = "DEMO API"
            });
            var service = new InviteService(invRepo);

            var res = service.CreateInvite(new Core.Data.Payloads.InvitePayload {
                Email = "*****@*****.**", ProjectId = project.Id
            }, Guid.NewGuid()).Result;

            Assert.NotNull(res);
        }
Exemple #20
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view = base.OnCreateView(inflater, container, savedInstanceState);
            parallaxScrollView = view.FindViewById <ScrollView>(Resource.Id.parallax_scroll_view);
            parallaxImage      = view.FindViewById <ImageView>(Resource.Id.parallax_image);
            parallaxScrollView.SetOnScrollChangeListener(this);
            UndateControls();
            view.FindViewById <ImageButton>(Resource.Id.submit_button).Click += (s, e) =>
            {
                ViewModel.ChallengeSubmit();
            };
            imageButton   = view.FindViewById <ImageButton>(Resource.Id.submit_button);
            inviteService = new InviteService(this);



            return(view);
        }
Exemple #21
0
        // GET: Event
        public ActionResult Index()
        {
            EventService    repo       = new EventService();
            EmployeeService emprepo    = new EmployeeService();
            InviteService   repoInvite = new InviteService();
            //-------------------------LIST DES EVENTS QUE L'USER A CREER------------------------------------//
            List <EventListItem> finallist = repo.GetByEmployeeId(UserSession.CurrentUser.Id).Select(e => new EventListItem(e, emprepo.Get(e.EmployeeId))).ToList();
            //-------------------------LIST DES EVENTS AUQUEL L'USER EST INVITER------------------------------------//
            IEnumerable <Invite>       invites    = repoInvite.GetByEmployeeId(UserSession.CurrentUser.Id);
            List <EventInviteListItem> listInvite = new List <EventInviteListItem>();

            foreach (Invite i in invites)
            {
                Event e = repo.Get(i.EventId);
                EventInviteListItem invite = new EventInviteListItem(e, emprepo.Get(e.EmployeeId), i);
                listInvite.Add(invite);
            }
            return(View(new EventIndex(finallist, listInvite)));
        }
        public async Task Add_AfterAdded_Success()
        {
            InviteService inviteService = new InviteService(
                IBaseDAOMock <AppUserEntity> .Create().Exists_Failure().Object,
                IBaseDAOMock <RoleEntity> .Create().Object,
                IBaseDAOMock <InviteEntity> .Create().Add_Success().Exists_Failure().Object,
                IGroupStoreMock.Create().Object,
                IGroupUserStoreMock.Create().Object,
                IEmailServiceMock.Create().SendInvite_Success().Object,
                IAddInviteFilterMock.Create().BeforeAdd_Success().AfterAdded_Success().Object,
                IValidatorMock <InviteToGroupRequest> .Create().Object,
                IValidatorMock <InviteRequest> .Create().Object,
                NullLogger <InviteService> .Instance,
                IOptionsMock <IdentityUIOptions> .Create().DefaultValue().Object,
                IOptionsMock <IdentityUIEndpoints> .Create().DefaultValue().Object);

            Result result = await inviteService.AddInvite("email");

            result.Success.Should().BeTrue();
        }
Exemple #23
0
        //•	DeclineInvite <teamName>
        public string Execute(string[] inputArgs)
        {
            Check.CheckLength(1, inputArgs);
            AuthenticationManager.Authorize();

            string teamName = inputArgs[0];

            if (!CommandHelper.IsTeamExisting(teamName))
            {
                throw new ArgumentException(string.Format(Constants.ErrorMessages.TeamNotFound, teamName));
            }

            if (!CommandHelper.IsInviteExisting(teamName,
                                                AuthenticationManager.GetCurrentUser()))
            {
                throw new ArgumentException(string.Format(Constants.ErrorMessages.InviteNotFound, teamName));
            }

            InviteService.DeclineInvite(teamName);

            return($"User {AuthenticationManager.GetCurrentUser().Username} declined {teamName}'s invitation!");
        }
Exemple #24
0
        // 根据邀请码注册,需要加为好友
        public static void ProcessFriend(User newRegUser, MvcContext ctx)
        {
            IInviteService inviteService = new InviteService();
            IFriendService friendService = new FriendService();

            int friendId = ctx.PostInt("friendId");

            if (friendId <= 0)
            {
                return;
            }

            String friendCode = ctx.Post("friendCode");

            Result result = inviteService.Validate(friendId, friendCode);

            if (result.HasErrors)
            {
                return;
            }

            friendService.AddInviteFriend(newRegUser, friendId);
        }
        public ActionResult InviteRequest(InviteRequestViewModel model)
        {
            if (ModelState.IsValid)
            {
                var inviteData = new InviteDataStruct()
                {
                    Name          = model.Name,
                    Surname       = model.Surname,
                    Patronymic    = model.Patronymic,
                    Email         = model.Email,
                    FacebookId    = model.FacebookUrl,
                    LiveJournalId = model.LiveJournalUrl,
                    State         = InviteState.Requested,
                    UserInfo      = model.UserInfo
                };

                InviteService.CreateInvite(inviteData);

                //todo - сделать вьюху для сообщения "вы успешно послали реквест"
                return(RedirectToAction("index", "home", null));
            }

            return(View(model));
        }
        public ActionResult SignUpWithKey(InviteSignUpWithKeyViewModel model, bool?isdialog)
        {
            if (ModelState.IsValid)
            {
                string key = string.IsNullOrWhiteSpace(model.InviteKey) ? null : model.InviteKey.Trim().ToLower();

                if (key != string.Empty)
                {
                    string email = string.IsNullOrWhiteSpace(model.Email) ? null : model.Email.Trim().ToLower();

                    key = key.Replace("`", "");
                    var inviteEntity = InviteService.GetInvite(key);

                    if (inviteEntity == null)
                    {
                        throw new BusinessLogicException("Вы не можете зарегистрироваться, так как вы указали неправильный код приглашения");
                    }

                    if (inviteEntity.State == (byte)InviteState.Requested)
                    {
                        throw new BusinessLogicException("Вы не можете зарегистрироваться, так как ваш запрос еще не рассмотрели");
                    }

                    if (inviteEntity.State == (byte)InviteState.Used)
                    {
                        throw new BusinessLogicException("Вы не можете  зарегистрироваться, так как данный ключ уже был использован");
                    }

                    if (inviteEntity.State != (byte)InviteState.Used || inviteEntity.State != (byte)InviteState.Requested)
                    {
                        var phone = UserService.NormalizePhoneNumber(model.PhoneNumber);

                        var encryptedPhoneNumber = CryptographyService.DecryptPhone(phone);
                        var existedUsersCount    = DataService.PerThread.BaseUserSet.OfType <User>().Count(u => u.EncryptedPhoneNumber == encryptedPhoneNumber);
                        if (existedUsersCount != 0)
                        {
                            throw new ValidationException("Пользователь с таким номером телефона уже зарегистрирован");
                        }

                        var user = (User)AccountService.SignUp(email, email, model.Password);
                        user.FirstName    = inviteEntity.Name;
                        user.SurName      = inviteEntity.Surname;
                        user.Patronymic   = inviteEntity.Patronymic;
                        user.InviteTicket = inviteEntity;
                        user.PhoneNumber  = phone;
                        user.Info         = inviteEntity.UserInfo;
                        user.UTCOffset    = (short)TimeSpan.Parse(model.UTCOffset).TotalMinutes;

                        UserService.NormalizePhoneNumber(user);

                        inviteEntity.State = (byte)InviteState.Used;

                        DataService.PerThread.SaveChanges();
                        AccountService.TrySignIn(email, model.Password, true, HttpContext.Request.UserHostAddress);

                        MonitoringService.AsynchLogUserRegistration(user.Id, HttpContext.Request.UserHostAddress);

                        return(RedirectToAction("index", "user", null));
                    }
                }
            }

            if (isdialog.HasValue)
            {
                if (isdialog.Value)
                {
                    return(View("SignUpWithKey", "_LightLayout", model));
                }
            }

            return(View(model));
        }
Exemple #27
0
        public Session()
        {
            AccountService        = new Riot.Services.AccountService(this);
            ChampionTradeService  = new Riot.Services.ChampionTradeService(this);
            ClientFacadeService   = new Riot.Services.ClientFacadeService(this);
            GameInvitationService = new Riot.Services.GameInvitationService(this);
            GameService           = new Riot.Services.GameService(this);
            InventoryService      = new Riot.Services.InventoryService(this);
            LcdsProxyService      = new Riot.Services.LcdsProxyService(this);
            LeaguesService        = new Riot.Services.LeaguesService(this);
            LoginService          = new Riot.Services.LoginService(this);
            MasteryBookService    = new Riot.Services.MasteryBookService(this);
            MatchmakingService    = new Riot.Services.MatchmakingService(this);
            PlayerStatsService    = new Riot.Services.PlayerStatsService(this);
            RerollService         = new Riot.Services.RerollService(this);
            SpellBookService      = new Riot.Services.SpellBookService(this);
            SummonerIconService   = new Riot.Services.SummonerIconService(this);
            SummonerRuneService   = new Riot.Services.SummonerRuneService(this);
            SummonerService       = new Riot.Services.SummonerService(this);
            SummonerTeamService   = new Riot.Services.SummonerTeamService(this);

            LootService             = new LootService(this, LcdsProxyService);
            ChampionMasteryService  = new ChampionMasteryService(this, LcdsProxyService);
            TeambuilderDraftService = new TeambuilderDraftService(this, LcdsProxyService);

            PlayerPreferencesService = new PlayerPreferencesService(this);
            MatchHistoryService      = new MatchHistoryService(this);

            var patcher = new PatcherService(this);

            this.chat = new ChatService(this);

            this.Maestro = new Maestro(chat, patcher);

            var settings = new SettingsService(this);

            var hextech   = new HextechService(this);
            var champions = new ChampionsService(this);
            var masteries = new MasteriesService(this);
            var runes     = new RunesService(this);

            var matches = new Server.Profile.MatchHistoryService(this);

            this.summoner = new SummonerService(this);
            this.Assets   = new AssetsService(patcher);

            var rooms = new ChatRoomService(this, chat);
            var login = new AuthService(this);

            var game   = new PlayLoopService(this, rooms);
            var invite = new InviteService(this, game);

            var meta  = new MetaService(this);
            var debug = new DebugService(this);

            var replay = new ReplayService(this);

            patcher.FinishWAD();

            var info = new InfoService(this, patcher);
        }
Exemple #28
0
 public InviteController(InviteService inviteService, PersonService personService, ConfigService configService)
 {
     this.inviteService = inviteService ?? throw new ArgumentNullException(nameof(inviteService));
     this.personService = personService ?? throw new ArgumentNullException(nameof(personService));
     this.configService = configService ?? throw new ArgumentNullException(nameof(configService));
 }