Ejemplo n.º 1
0
        public void perfectly_sequential()
        {
            var list = new List <long>()
            {
                3, 4, 5, 6, 7
            };

            EventPage.IsCompletelySequential(list)
            .ShouldBeTrue();
        }
Ejemplo n.º 2
0
        public async Task should_not_pause_the_fetcher_if_under_the_threshold()
        {
            var thePage = new EventPage(0, 100, new IEvent[0])
            {
                Count = 100
            };

            await theProjectionTrack.CachePage(thePage).ConfigureAwait(false);

            await theFetcher.DidNotReceive().Pause().ConfigureAwait(false);
        }
Ejemplo n.º 3
0
        public void Apply(IDocumentSession session, EventPage page)
        {
            MatchingStreams(page).Each(stream =>
            {
                var state = _finder.Find(stream, session);

                update(state, stream);

                session.Store(state);
            });
        }
Ejemplo n.º 4
0
 public string GetMapDisplayText(EventPage page)
 {
     if (MapNames.TryGetValue(page.MapId, out string MapName))
     {
         return($"{page.MapId:D3}:{MapName}");
     }
     else
     {
         return($"{page.MapId:D3}:");
     }
 }
        public EventCommandSetGuildBankSlots(SetGuildBankSlotsCommand refCommand, EventPage refPage, FrmEvent editor)
        {
            InitializeComponent();
            mMyCommand   = refCommand;
            mEventEditor = editor;
            mCurrentPage = refPage;
            InitLocalization();

            rdoGlobalVariable.Checked = mMyCommand.VariableType == VariableTypes.ServerVariable;
            SetupAmountInput();
        }
Ejemplo n.º 6
0
        public async Task should_restart_the_fetcher_if_it_was_paused_and_below_the_threshold()
        {
            theFetcher.State.Returns(FetcherState.Paused);

            var thePage = new EventPage(0, 100, EventMother.Random(100));
            await theProjectionTrack.CachePage(thePage).ConfigureAwait(false);

            await theProjectionTrack.StoreProgress(typeof(ActiveProject), thePage).ConfigureAwait(false);

            theFetcher.Received().Start(theProjectionTrack, theProjectionTrack.Lifecycle);
        }
Ejemplo n.º 7
0
        public void Apply(IDocumentSession session, EventPage page)
        {
            var events = page.Events.Select(e => e.Data).GroupBy(e => e.GetType());

            events.SelectMany(group =>
            {
                var handlerType = typeof(ISyncEventHandler <>).MakeGenericType(group.Key);
                var handlers    = this.handlerFactory(handlerType) ?? Enumerable.Empty <object>();
                return(handlers.SelectMany(h => group.Select(ev => handlerType.InvokeMember("Handle", BindingFlags.InvokeMethod, null, h, new[] { ev, session }))));
            }).ToArray();
        }
        public EventCommandChangeName(ChangeNameCommand refCommand, EventPage refPage, FrmEvent editor)
        {
            InitializeComponent();
            mMyCommand   = refCommand;
            mCurrentPage = refPage;
            mEventEditor = editor;

            cmbVariable.Items.Clear();
            cmbVariable.Items.AddRange(PlayerVariableBase.Names);

            InitLocalization();
        }
Ejemplo n.º 9
0
 public async Task ApplyAsync(IDocumentSession session, EventPage page, CancellationToken token)
 {
     foreach (var @event in page.Events)
     {
         var type = @event.Data?.GetType().Name;
         if (type != null)
         {
             Logger.Debug("Publishing event of type {EventType}", @event.Data.GetType());
             await _hubContext.Clients.All.SendAsync("event", new { Type = type, @event.Data }, cancellationToken : token);
         }
     }
 }
Ejemplo n.º 10
0
 public EventCommandChangeSpells(ChangeSpellsCommand refCommand, EventPage refPage, FrmEvent editor)
 {
     InitializeComponent();
     mMyCommand   = refCommand;
     mEventEditor = editor;
     mCurrentPage = refPage;
     InitLocalization();
     cmbSpell.Items.Clear();
     cmbSpell.Items.AddRange(SpellBase.Names);
     cmbAction.SelectedIndex = refCommand.Add ? 0 : 1;
     cmbSpell.SelectedIndex  = SpellBase.ListIndex(mMyCommand.SpellId);
 }
 public EventCommandStartQuest(StartQuestCommand refCommand, EventPage page, FrmEvent editor)
 {
     InitializeComponent();
     mMyCommand   = refCommand;
     mCurrentPage = page;
     mEventEditor = editor;
     InitLocalization();
     cmbQuests.Items.Clear();
     cmbQuests.Items.AddRange(QuestBase.Names);
     cmbQuests.SelectedIndex    = QuestBase.ListIndex(refCommand.QuestId);
     chkShowOfferWindow.Checked = refCommand.Offer;
 }
Ejemplo n.º 12
0
            public Task ApplyAsync(IDocumentSession session, EventPage page, CancellationToken token)
            {
                if (!_failed && _random.Next(0, 10) == 9)
                {
                    _failed = true;
                    throw new DivideByZeroException();
                }

                _failed = false;

                return(Task.CompletedTask);
            }
Ejemplo n.º 13
0
        public async Task stores_the_first_page()
        {
            var thePage = new EventPage(0, 100, new IEvent[0])
            {
                Count = 100
            };

            await theProjectionTrack.CachePage(thePage).ConfigureAwait(false);

            theProjectionTrack.Accumulator.AllPages().Single()
            .ShouldBe(thePage);
        }
Ejemplo n.º 14
0
        private async Task applyProjectionsAsync(CancellationToken token)
        {
            var streams = PendingChanges.Streams().ToArray();

            if (streams.Length > 0)
            {
                var eventPage = new EventPage(streams);
                foreach (var projection in DocumentStore.Events.InlineProjections)
                {
                    await projection.ApplyAsync(this, eventPage, token).ConfigureAwait(false);
                }
            }
        }
Ejemplo n.º 15
0
        void IProjection.Apply(IDocumentSession session, EventPage page)
        {
            var projections = getEventProjections(session, page);

            var viewIds = projections.Select(projection => projection.ViewId).Distinct().ToArray();

            if (viewIds.Length > 0)
            {
                var views = _sessionLoadMany(session, viewIds);

                applyProjections(session, projections, views);
            }
        }
Ejemplo n.º 16
0
        public Task ApplyAsync(IDocumentSession session, EventPage page, CancellationToken token)
        {
            var events = page.Events.Select(e => e.Data).GroupBy(e => e.GetType());

            return(Task.WhenAll(
                       events.SelectMany(group =>
            {
                var handlerType = typeof(IAsyncEventHandler <>).MakeGenericType(group.Key);
                var handlers = this.handlerFactory(handlerType) ?? Enumerable.Empty <object>();
                return handlers.SelectMany(h => group.Select(ev => (Task)handlerType.InvokeMember("Handle", BindingFlags.InvokeMethod,
                                                                                                  null, h, new[] { ev, session, token })));
            })));
        }
Ejemplo n.º 17
0
        async Task IProjection.ApplyAsync(IDocumentSession session, EventPage page, CancellationToken token)
        {
            var projections = getEventProjections(session, page);

            var viewIds = projections.Select(projection => projection.ViewId).Distinct().ToArray();

            if (viewIds.Length > 0)
            {
                var views = _sessionLoadMany(session, viewIds);

                await applyProjectionsAsync(session, projections, views);
            }
        }
Ejemplo n.º 18
0
            public Task ApplyAsync(IDocumentSession session, EventPage page, CancellationToken token)
            {
                _session = session;

                var projectEvents = page.Events.OrderBy(s => s.Sequence).Select(s => s.Data).OfType <ProjectStarted>();

                foreach (var e in projectEvents)
                {
                    Apply(e);
                }

                return(Task.CompletedTask);
            }
Ejemplo n.º 19
0
        private void applyProjections()
        {
            var streams = PendingChanges.Streams().ToArray();

            if (streams.Length > 0)
            {
                var eventPage = new EventPage(streams);
                foreach (var projection in DocumentStore.Events.InlineProjections)
                {
                    projection.Apply(this, eventPage);
                }
            }
        }
Ejemplo n.º 20
0
        public async Task store_progress_removes_obsolete_page()
        {
            var thePage  = new EventPage(0, 100, EventMother.Random(100));
            var thePage2 = new EventPage(101, 200, EventMother.Random(100));
            await theProjectionTrack.CachePage(thePage).ConfigureAwait(false);

            await theProjectionTrack.CachePage(thePage2).ConfigureAwait(false);

            await theProjectionTrack.StoreProgress(typeof(ActiveProject), thePage).ConfigureAwait(false);

            theProjectionTrack.Accumulator.AllPages().Single()
            .ShouldBe(thePage2);
        }
Ejemplo n.º 21
0
        public void NewPage()
        {
            TabContainer tc       = TabController.CreateTab("Untitled");
            EventPage    PageData = new EventPage();

            EventData.Pages.Add(PageData);
            EventPageContainer epc = new EventPageContainer(this, EventData, PageData, tc);

            epc.SetSize(750, 515);
            EventPageContainers.Add(epc);
            TabController.SelectTab(TabController.Tabs.Count - 1);
            TabController.Redraw();
            DeletePageButton.SetEnabled(true);
        }
Ejemplo n.º 22
0
        public ActionResult Create(EventPageModel model, bool continueEditing)
        {
            //if (!_permissionService.Authorize(StandardPermissionProvider.ManageProducts))
            //    return AccessDeniedView();

            if (ModelState.IsValid)
            {
                var entity = new EventPage()
                {
                    Name                  = model.Name,
                    LocationName          = model.LocationName,
                    LocationAddress1      = model.LocationAddress1,
                    LocationAddress2      = model.LocationAddress2,
                    LocationCity          = model.City,
                    LocationState         = model.LocationState,
                    LocationZipPostalCode = model.ZipPostalCode,
                    LocationPhone         = model.Phone,
                    LocationWebsite       = model.Website,
                    LocationEmail         = model.Email,
                    LocationCountry       = model.LocationCountry,
                    StartDate             = model.StartDate,
                    EndDate               = model.EndDate,
                    Description           = model.Description,
                    MetaKeywords          = model.MetaKeywords,
                    MetaDescription       = model.MetaDescription,
                    DateCreated           = DateTime.Now,
                    DateUpdated           = DateTime.Now,
                };

                //search engine name
                model.SeName = SeoExtensions.GetSeName(entity, _workContext.WorkingLanguage.Id);

                // todo: add event hosts
                _eventPageService.Insert(entity);

                //save hotels
                //SaveEventHotels(product, ParseProductTags(model.ProductTags));

                //activity log
                //_customerActivityService.InsertActivity("AddNewProduct", _localizationService.GetResource("ActivityLog.AddNewProduct"), product.Name);
                _customerActivityService.InsertActivity("AddNewEventPage", _localizationService.GetResource("ActivityLog.AddNewEventPage"), entity.Name);


                SuccessNotification(_localizationService.GetResource("Admin.MobSocial.EventPage.Added"));

                return(continueEditing ? RedirectToAction("Edit", new { id = entity.Id }) : RedirectToAction("List"));
            }

            return(View("~/Plugins/Widgets.mobSocial/Views/mobSocial/Admin/ManageEventPage/Create.cshtml", model));
        }
Ejemplo n.º 23
0
        public async Task ApplyAsync(IDocumentSession session, EventPage page, CancellationToken token)
        {
            var matchingStreams = MatchingStreams(page);

            await _finder.FetchAllAggregates(session, matchingStreams, token).ConfigureAwait(false);

            foreach (var stream in matchingStreams)
            {
                var state = await _finder.FindAsync(stream, session, token).ConfigureAwait(false) ?? New <T> .Instance();

                update(state, stream);

                session.Store(state);
            }
        }
Ejemplo n.º 24
0
        Task IProjection.ApplyAsync(IDocumentSession session, EventPage page, CancellationToken token)
        {
            var projections = getEventProjections(session, page);

            var viewIds = projections.Select(projection => projection.ViewId).Distinct().ToArray();

            if (viewIds.Length > 0)
            {
                var views = _sessionLoadMany(session, viewIds);

                return(applyProjectionsAsync((DocumentSessionBase)session, projections, views));
            }

            return(Task.CompletedTask);
        }
Ejemplo n.º 25
0
        public void DrawEvent(EventPage eventPage, Vector pos)
        {
            if (string.IsNullOrEmpty(eventPage.ImageKey))
            {
                return;
            }

            switch (eventPage.ImageType)
            {
            case ImageType.Icon:
                _iconManager.Draw(eventPage.ImageKey, eventPage.TilesetSource, new Rect(pos.X, pos.Y, eventPage.TilesetSource.Width, eventPage.TilesetSource.Height));
                break;
                //case ImageType.Tileset:
                //    _tilesetManager.Draw(eventPage.ImageKey, )
            }
        }
Ejemplo n.º 26
0
        public async void WhiteBoxTest_EventPage_EventPage()
        {
            EventPage eventPage = new EventPage();

            Events events = await EventConnection.GetEventData();

            await Task.Delay(10000);

            Assert.IsTrue(events.EventSet[0].EventDescription == eventPage.temp.EventSet[0].EventDescription);
            Assert.IsTrue(events.EventSet[0].EventDate == eventPage.temp.EventSet[0].EventDate);
            Assert.IsTrue(events.EventSet[0].EventId == eventPage.temp.EventSet[0].EventId);
            Assert.IsTrue(events.EventSet[0].EventTopic == eventPage.temp.EventSet[0].EventTopic);
            Assert.IsTrue(events.EventSet[0].EventImg == eventPage.temp.EventSet[0].EventImg);
            Assert.IsTrue(events.EventSet[0].EventLocation == eventPage.temp.EventSet[0].EventLocation);
            Assert.IsTrue(events.EventSet[0].EventSignUpUrl == eventPage.temp.EventSet[0].EventSignUpUrl);
        }
Ejemplo n.º 27
0
        public void should_pause_if_there_are_any_events()
        {
            var page = new EventPage(0, 100, new List <IEvent> {
                new Event <ProjectStarted>(new ProjectStarted())
            })
            {
                NextKnownSequence = 0,
                LastKnownSequence = 1000
            };

            page.Sequences.Add(97);
            page.Sequences.Add(98);
            page.Sequences.Add(99);

            page.ShouldPause().ShouldBeTrue();
        }
Ejemplo n.º 28
0
        public void last_encountered_with_non_zero_page()
        {
            var page = new EventPage(0, 100, new List <IEvent> {
                new Event <ProjectStarted>(new ProjectStarted())
            })
            {
                NextKnownSequence = 0,
                LastKnownSequence = 1000
            };

            page.Sequences.Add(97);
            page.Sequences.Add(98);
            page.Sequences.Add(99);

            page.LastEncountered().ShouldBe(1000);
        }
Ejemplo n.º 29
0
    /// <summary>
    /// 启动事件页
    /// </summary>
    /// <param name="page"></param>
    public void setupPage(int page)
    {
        Debug.Log(string.Format("setupPage {0}", page));
        this.page = page;
        if (this.page == -1)
        {
            this.list          = null;
            this.interpreter   = null;
            this.characterName = "";    // 清理图像
        }
        else
        {
            // 显示控制
            EventPage[] pages = this.getEventSprite().GetComponentsInChildren <EventPage>(true);

            // 只显示本页对应精灵
            EventPage currPage = pages[page];
            this.characterName = currPage.characterName;
            this.direction     = currPage.direction;
            Debug.Log(string.Format("curr char pattern {0}", this.pattern));
            this.pattern = currPage.pattern;
            Debug.Log(string.Format("curr char pattern {0}", this.pattern));
            this.priorityType  = currPage.priorityType;
            this.through       = currPage.through;
            this.moveSpeed     = currPage.moveSpeed;
            this.moveFrequency = currPage.moveFrequency;
            this.walkAnime     = currPage.walkAnime;
            this.stepAnime     = currPage.stepAnime;
            this.directionFix  = currPage.directionFix;
            this.list          = this.getCommands(page);
            this.trigger       = this.getPageInfo(page).trigger;
            this.isDirty       = true;
            // 注册光效
            GameTemp.gameScreen.registerLight(this.eventId, currPage.lightType);
            // 并行解释器
            if (this.trigger == GameInterpreter.TriggerTypes.Async)
            {
                // 并行处理:
                this.interpreter = new GameInterpreter(0, false);
            }
            else
            {
                this.interpreter = null;
            }
        }
    }
            public void Apply(IDocumentSession session, EventPage page)
            {
                var questEvents = page.Events.OrderBy(s => s.Sequence).Select(s => s.Data);

                foreach (var @event in questEvents)
                {
                    if (@event is Quest)
                    {
                        session.Store(new QuestPatchTestProjection {
                            Id = ((Quest)@event).Id
                        });
                    }
                    else if (@event is QuestStarted)
                    {
                        session.Patch <QuestPatchTestProjection>(((QuestStarted)@event).Id).Set(x => x.Name, "New Name");
                    }
                }
            }
Ejemplo n.º 31
0
        public static void CreateScheduledEmail(EventPage eventPage, AttendStatus status, EmailTemplateBlock emailTemplate, ContentReference emailTemplateContentReference, string name)
        {
            ScheduledEmailBlock emailBlock =
                API.AttendScheduledEmailEngine.GenerateScheduledEmailBlock(eventPage.ContentLink).CreateWritableClone() as ScheduledEmailBlock;
            emailBlock.EmailSendOptions = SendOptions.Action;
            emailBlock.SendOnStatus = status;
            emailBlock.EmailTemplate.BCC = emailTemplate.BCC;
            emailBlock.EmailTemplate.CC = emailTemplate.CC;
            emailBlock.EmailTemplate.From = emailTemplate.From;
            emailBlock.EmailTemplate.To = emailTemplate.To;
            emailBlock.EmailTemplate.Subject = emailTemplate.Subject;
            emailBlock.EmailTemplate.MainBody = emailTemplate.MainBody;
            emailBlock.EmailTemplate.MainTextBody = emailTemplate.MainTextBody;

            emailBlock.EmailTemplateContentReference = emailTemplateContentReference;

            (emailBlock as IContent).Name = name;

            DataFactory.Instance.Save(emailBlock as IContent, SaveAction.Publish);

        }
Ejemplo n.º 32
0
        public static int UpdateEvent(EventPage eventPage)
        {
            var scheduledEmails =
                Attend.Business.API.AttendScheduledEmailEngine.GetScheduledEmails(eventPage.ContentLink);
            int cnt = 0;
            if (!ContainsStatusMail(scheduledEmails, AttendStatus.Submitted))
            {
                cnt++;
                CreateScheduledEmail(eventPage, AttendStatus.Submitted, eventPage.SubmitMailTemplate, eventPage.SubmitMailTemplateBlock, "Submit mail template");
            }

            if (!ContainsStatusMail(scheduledEmails, AttendStatus.Confirmed))
            {
                cnt++;
                CreateScheduledEmail(eventPage, AttendStatus.Confirmed, eventPage.ConfirmMailTemplate, eventPage.ConfirmMailTemplateBlock, "Confirm mail template");
            }

            if (!ContainsStatusMail(scheduledEmails, AttendStatus.Cancelled))
            {
                cnt++;
                CreateScheduledEmail(eventPage, AttendStatus.Cancelled, eventPage.CancelMailTemplate, eventPage.CancelMailTemplateBlock, "Cancel mail template");
            }

            return cnt;

        }