public void CreateSdkEventWithoutEventTypeThrowTest()
        {
            var options = SecureNativeConfigurationBuilder.DefaultConfigBuilder().Build();
            var e       = new EventOptions("");

            var _ = new SdkEvent(e, options);
        }
Пример #2
0
 public void Clean()
 {
     //cleanVertexTracer(true);
     //cleanVertexTracer(false);
     if (Source != null)
     {
         Source.PositionChanged -= source_PositionChanged;
     }
     if (Target != null)
     {
         Target.PositionChanged -= source_PositionChanged;
     }
     _oldSource = _oldTarget = null;
     Source     = null;
     Target     = null;
     Edge       = null;
     RootArea   = null;
     HighlightBehaviour.SetIsHighlightEnabled(this, false);
     DragBehaviour.SetIsDragEnabled(this, false);
     _linegeometry    = null;
     _arrowgeometry   = null;
     _linePathObject  = null;
     _arrowPathObject = null;
     if (EventOptions != null)
     {
         EventOptions.Clean();
     }
 }
        public void CreateSdkEventWithoutUserIdThrowTest()
        {
            var options = SecureNativeConfigurationBuilder.DefaultConfigBuilder().Build();
            var e       = new EventOptions(EventTypes.LOG_IN.ToString());

            var _ = new SdkEvent(e, options);
        }
Пример #4
0
        public void Track(EventOptions eventOptions)
        {
            Logger.Info("Track event call");
            var e = new SdkEvent(eventOptions, _options);

            _eventManager.SendAsync(e, ApiRoute.TRACK, true);
        }
Пример #5
0
        public override void Clean()
        {
            Source   = null;
            Target   = null;
            Edge     = null;
            RootArea = null;
            HighlightBehaviour.SetIsHighlightEnabled(this, false);
            DragBehaviour.SetIsDragEnabled(this, false);
            Linegeometry      = null;
            LinePathObject    = null;
            SelfLoopIndicator = null;
            EdgeLabelControls.ForEach(l => l.Dispose());
            EdgeLabelControls.Clear();

            if (EdgePointerForSource != null)
            {
                EdgePointerForSource.Dispose();
                EdgePointerForSource = null;
            }
            if (EdgePointerForTarget != null)
            {
                EdgePointerForTarget.Dispose();
                EdgePointerForTarget = null;
            }
            EventOptions?.Clean();
        }
Пример #6
0
        public bool ShuffleGifts()
        {
            bool algorithmChooses = false;


            var allEvents = _context.Events.
                            Include(x => x.EventOptionEvents).
                            ThenInclude(x => x.EventOption).
                            Include(x => x.UserEvents).
                            ThenInclude(x => x.User).
                            Include(x => x.UserEvents).
                            ThenInclude(x => x.Shuffle).
                            //Where(x => x.GiftsAddBy.Date == DateTime.Today).
                            ToList();

            foreach (var eventt in allEvents)
            {
                foreach (var eventOptionEvent in eventt.EventOptionEvents)
                {
                    if (eventOptionEvent.EventOption.Name == EventOptions.AlgorithmChooses().Name)
                    {
                        algorithmChooses = true;
                    }
                    ;
                }

                var allUserEvents = eventt.UserEvents.Where(x => x.IsActive == true &&
                                                            x.IsConfirmed == true &&
                                                            x.Participats == true).
                                    ToList();


                if (algorithmChooses)
                {
                    foreach (var userEvent in allUserEvents)
                    {
                        var userEventGiftFor = _context.UserEvent.Include(x => x.Gift).FirstOrDefault(x => x.UserId == userEvent.Shuffle.UserGiftFor.Id &&
                                                                                                      x.EventId == eventt.Id);

                        var allGifts = userEventGiftFor.Gift.Where(x => x.IsActive == true).ToList();

                        if (algorithmChooses)
                        {
                            var shuffledGifts = ShuffleGiftsHelper.ShuffleGiftsAlgorithm(allGifts, eventt.MaxPrice);
                            userEvent.Shuffle.Gifts = shuffledGifts.Gifts;
                        }
                        else
                        {
                            userEvent.Shuffle.Gifts = allGifts;
                        }
                    }
                }

                eventt.GiftsShuffled = true;
                _context.SaveChanges();
            }

            return(true);
        }
Пример #7
0
 /// <summary>
 ///     是否包含该事件
 /// </summary>
 /// <param name="eventList">事件集合</param>
 /// <param name="eventObject">事件对象</param>
 /// <returns>包含返回True,否则返回False</returns>
 public static bool Contains(this EventOptions eventList, EventOptions eventObject)
 {
     if ((eventList | eventObject) == eventList)
     {
         return(true);
     }
     return(false);
 }
Пример #8
0
        protected TomatoLogClient(EventOptions options)
        {
            Check.NotNull(options, nameof(options));
            Check.NotNull(options.ProjectName, nameof(options.ProjectName));

            this.Options = options;
            Instance     = this;
        }
Пример #9
0
 public EventsLogic(IIdentityFactory identityFactory, IUserQueueRepository userQueueRepository,
                    IRabbitMqClient rabbitMqClient, IOptions <EventOptions> eventOptions, IEventsPublisher eventsPublisher)
 {
     _identityFactory     = identityFactory;
     _userQueueRepository = userQueueRepository;
     _rabbitMqClient      = rabbitMqClient;
     _eventOptions        = eventOptions?.Value;
     _eventsPublisher     = eventsPublisher;
 }
Пример #10
0
            public static EventCreater New(IServiceProvider serviceProvider, EventOptions eventOptions)
            {
                if (eventOptions.MessageCreater is null)
                {
                    eventOptions.MessageCreater = builder => builder.WithRetainFlag();
                }

                return(new EventCreater(serviceProvider, eventOptions));
            }
Пример #11
0
    public void RandomEventSpawner()
    {
        if (counter == 0)
        {
            counter++;
            return;
        }
        var controller = dataController.GetComponent <DataController> ();

        long followers = controller.followers;
        long tribute   = controller.tribute;

        int addValueFollowers = Mathf.RoundToInt(followers * 0.01f);
        int addValueTribute   = Mathf.RoundToInt(tribute * 0.02f);

        print(addValueFollowers);
        print(followers);
        // Carrega JSON com eventos

        EventOptions[] events = LoadJSON(eventsFileName);

        int eventsLenght = events.GetLength(0);

        int randomEvent = Random.Range(0, eventsLenght);

        // Seleciona evento randomicamente

        EventOptions selectedEvent = events[randomEvent];

        if (selectedEvent.Operator == "Sub")
        {
            addValueFollowers = addValueFollowers * -1;
            addValueTribute   = addValueFollowers * -1;
        }

        if (selectedEvent.Type == "Tribute")
        {
            controller.addTributeSpaw(addValueTribute);

            print(addValueTribute);
        }
        else if (selectedEvent.Type == "Followers")
        {
            controller.addFollowers(addValueFollowers);

            print(addValueFollowers);
        }

        string popUpMessage = System.String.Format(
            "{0}. {1}: {2}.",
            selectedEvent.Text,
            selectedEvent.Type,
            selectedEvent.Operator
            );

        btn.GetComponent <DrawPopUp>().Show(popUpMessage);
    }
Пример #12
0
 /// <summary>
 /// Cleans all potential memory-holding code
 /// </summary>
 public override void Clean()
 {
     Vertex   = null;
     RootArea = null;
     HighlightBehaviour.SetIsHighlightEnabled(this, false);
     DragBehaviour.SetIsDragEnabled(this, false);
     VertexLabelControl = null;
     if (EventOptions != null)
     {
         EventOptions.Clean();
     }
 }
Пример #13
0
        private void searchButton_Click(object sender, EventArgs e)
        {
            EventOptions options = GetEventOptionsFromFilters();

            string[] keywords = searchTextBox.Text.Split(' ', StringSplitOptions.RemoveEmptyEntries);
            foreach (var keyword in keywords)
            {
                options.AddKeyword(keyword);
            }

            LoadMainEvents(options);
        }
Пример #14
0
 /// <summary>
 /// Cleans all potential memory-holding code
 /// </summary>
 public void Clean()
 {
     Vertex   = null;
     RootArea = null;
     HighlightBehaviour.SetIsHighlightEnabled(this, false);
     DragBehaviour.SetIsDragEnabled(this, false);
     if (EventOptions != null)
     {
         EventOptions.PositionChangeNotification = false;
         EventOptions.Clean();
     }
 }
Пример #15
0
        public void SeedEventOptions()
        {
            if (!_context.EventOptions.Any())
            {
                _context.EventOptions.Add(EventOptions.UnkonwGiftGiver());
                _context.EventOptions.Add(EventOptions.KnownGiftGiver());
                _context.EventOptions.Add(EventOptions.OneOfManyGifts());
                _context.EventOptions.Add(EventOptions.OneGift());
                _context.EventOptions.Add(EventOptions.AlgorithmChooses());
                _context.EventOptions.Add(EventOptions.ParticipantChooses());

                _context.SaveChanges();
            }
        }
Пример #16
0
        private void ClearLists()
        {
            if (fileName != null)
            {
                fileName = "";
            }

            newNames.Clear();
            newDialogue.Clear();
            numberOfLines = 1;
            newNames.Add("");
            newDialogue.Add("");
            eventChoice = EventOptions.None;
        }
Пример #17
0
        public override void Clean()
        {
            //TODO rename to _sourceWatcher _targetWatcher
            if (_sourceWatcher != null)
            {
                _sourceWatcher.Dispose();
            }
            if (_targetWatcher != null)
            {
                _targetWatcher.Dispose();
            }
            if (Source != null)
            {
                Source.PositionChanged -= source_PositionChanged;
            }
            if (Target != null)
            {
                Target.PositionChanged -= source_PositionChanged;
            }
            _oldSource = _oldTarget = null;
            Source     = null;
            Target     = null;
            Edge       = null;
            RootArea   = null;
            HighlightBehaviour.SetIsHighlightEnabled(this, false);
            DragBehaviour.SetIsDragEnabled(this, false);
            _linegeometry     = null;
            LinePathObject    = null;
            SelfLoopIndicator = null;
            if (EdgeLabelControl != null)
            {
                EdgeLabelControl.Dispose();
                EdgeLabelControl = null;
            }

            if (EdgePointerForSource != null)
            {
                EdgePointerForSource.Dispose();
                EdgePointerForSource = null;
            }
            if (EdgePointerForTarget != null)
            {
                EdgePointerForTarget.Dispose();
                EdgePointerForTarget = null;
            }
            if (EventOptions != null)
            {
                EventOptions.Clean();
            }
        }
Пример #18
0
        public async Task PrepareEventWithRemoteAddressTest()
        {
            var options = new EventOptions
            {
                RaiseErrorEvents       = true,
                RaiseFailureEvents     = true,
                RaiseInformationEvents = true,
                RaiseSuccessEvents     = true
            };

            var remoteIp  = "127.0.0.1";
            var traceId   = Guid.NewGuid().ToString();
            var procId    = Process.GetCurrentProcess().Id;
            var subjectId = "123456789";
            var fooEvent  = new FooEvent("FooEvents", "FooEvent", EventTypes.Information, 1337, "Some foo message")
            {
                Foo = "bar"
            };

            var mockHttpContextAccessor = new Mock <IHttpContextAccessor>();
            var mockHttpContext         = new Mock <HttpContext>();
            var mockConnectionInfo      = new Mock <ConnectionInfo>();

            mockHttpContext.SetupGet(c => c.TraceIdentifier).Returns(traceId);
            mockConnectionInfo.SetupGet(c => c.RemoteIpAddress).Returns(System.Net.IPAddress.Parse(remoteIp));
            mockHttpContextAccessor.SetupGet(c => c.HttpContext).Returns(mockHttpContext.Object);
            mockHttpContext.SetupGet(c => c.Connection).Returns(mockConnectionInfo.Object);

            mockHttpContext.SetupGet(c => c.User).Returns(new ClaimsPrincipal(new ClaimsIdentity(new Claim[]
            {
                new Claim("sub", subjectId)
            })));

            var mockEventSink = new Mock <IEventSink>();

            var eventService = new DefaultEventService(
                options,
                mockHttpContextAccessor.Object,
                new DateTimeAccessor(),
                mockEventSink.Object);

            await eventService.RaiseAsync(fooEvent);


            /*eventOut.Should().Equals(eventIn);
             * eventOut.Context.Should().NotBeNull();
             * eventOut.Context.ProcessId.Should().Be(procId);
             * eventOut.Context.RemoteIpAddress.Should().Be(remoteIp);
             * eventOut.Context.SubjectId.Should().Be(subjectId);*/
        }
Пример #19
0
 public EventPublisher(
     ILogger <EventPublisher> logger,
     IGuidProvider guidProvider,
     IDateTimeProvider dateTimeProvider,
     IOptions <EventOptions> eventOptionsAccessor,
     IEventGridClientFacade eventGridClientFacade)
 {
     _logger                      = logger;
     _guidProvider                = guidProvider;
     _dateTimeProvider            = dateTimeProvider;
     _eventGridClientFacade       = eventGridClientFacade;
     _eventOptions                = eventOptionsAccessor.Value;
     _lazyTopicNameInformationMap = new Lazy <IDictionary <string, EventInformation> >(GetTopicsMap);
 }
    private void ClearLists()
    {
        if (FileName != null)
        {
            FileName = "";
        }

        NewNames.Clear();
        NewDialogue.Clear();
        NumberOfLines = 1;
        NewNames.Add("");
        NewDialogue.Add("");
        EventChoice = EventOptions.None;
    }
Пример #21
0
        static void RunEventOptions(EventOptions opts)
        {
            Person pers = PersonFactory.Create(opts.Name);

            pers.FillEventList();
            DateTime     start          = ParseDate(opts.StartDate);
            DateTime     finish         = ParseDate(opts.EndDate);
            List <Event> eventToDisplay = pers.GetEventsByDate(start, finish);

            foreach (Event evento in eventToDisplay)
            {
                Console.WriteLine("{0} - {1}. *Held on {2} - {3}", evento.Name, evento.Description, evento.StartTime, evento.EndTime);
            }
        }
Пример #22
0
        public static void Execute(Action action, EventOptions withEvents = EventOptions.GraphEvents)
        {
            Transaction  trans    = RunningTransaction;
            EventOptions oldValue = trans.FireEvents;

            trans.FireEvents = withEvents;

            try
            {
                action.Invoke();
            }
            finally
            {
                trans.FireEvents = oldValue;
            }
        }
Пример #23
0
        /// <summary>
        /// Cleans all potential memory-holding code
        /// </summary>
        public override void Clean()
        {
            Vertex   = null;
            RootArea = null;
            HighlightBehaviour.SetIsHighlightEnabled(this, false);
            DragBehaviour.SetIsDragEnabled(this, false);
            VertexLabelControl = null;

            if (EventOptions != null)
            {
#if WPF
                EventOptions.PositionChangeNotification = false;
#endif
                EventOptions.Clean();
            }
        }
Пример #24
0
        public void TestEmptyQueryString()
        {
            EventOptions options = new EventOptions
            {
            };
            var query = Utils.BuildQueryString(new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>(nameof(options.PerPage).ToCamelCase(), options.PerPage),
                new KeyValuePair <string, object>(nameof(options.AssetId).ToCamelCase(), options.AssetId),
                new KeyValuePair <string, object>(nameof(options.Data).ToCamelCase(), options.Data),
                new KeyValuePair <string, object>(nameof(options.FromTimestamp).ToCamelCase(), options.FromTimestamp),
                new KeyValuePair <string, object>(nameof(options.ToTimestamp).ToCamelCase(), options.ToTimestamp)
            });

            Assert.IsTrue(query == "");
        }
            private EmbedBuilder GetEmbed(Event.Type type, EventOptions opts, long currentPot)
            {
                switch (type)
                {
                case Event.Type.Reaction:
                    return(new EmbedBuilder()
                           .WithOkColor()
                           .WithTitle(GetText("reaction_title"))
                           .WithDescription(GetDescription(opts.Amount, currentPot))
                           .WithFooter(GetText("new_reaction_footer", opts.Hours)));

                default:
                    break;
                }
                throw new ArgumentOutOfRangeException(nameof(type));
            }
Пример #26
0
        public EventList GetEvents(EventOptions options)
        {
            var query = Utils.BuildQueryString(new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>(nameof(options.PerPage).ToCamelCase(), options.PerPage),
                new KeyValuePair <string, object>(nameof(options.AssetId).ToCamelCase(), options.AssetId),
                new KeyValuePair <string, object>(nameof(options.Data).ToCamelCase(), options.Data),
                new KeyValuePair <string, object>(nameof(options.FromTimestamp).ToCamelCase(), options.FromTimestamp),
                new KeyValuePair <string, object>(nameof(options.ToTimestamp).ToCamelCase(), options.ToTimestamp),
                new KeyValuePair <string, object>(nameof(options.CreatedBy).ToCamelCase(), options.CreatedBy),
                new KeyValuePair <string, object>(nameof(options.Page).ToCamelCase(), options.Page),
            });

            var events = _request.GetRequest <EventList>($"events{query}");

            return(events);
        }
Пример #27
0
        //public event Func<ulong, Task> OnEnded;

        public NotRaidEvent(DiscordSocketClient client, ICurrencyService cs, IBotConfigProvider bc,
                            SocketGuild g, SocketTextChannel ch, EventOptions opts,
                            Func <Event.Type, EventOptions, long, EmbedBuilder> embed)
        {
            _client       = client;
            _cs           = cs;
            _bc           = bc;
            this.g        = g;
            this.ch       = ch;
            this.opts     = opts;
            this.embed    = embed;
            _amount       = opts.Amount;
            PotSize       = opts.PotSize;
            _isPotLimited = PotSize > 0;
            _log          = LogManager.GetCurrentClassLogger();

            _t = new Timer(OnTimerTick, null, Timeout.InfiniteTimeSpan, TimeSpan.FromSeconds(2));
        }
Пример #28
0
        public VerifyResult Verify(EventOptions eventOptions)
        {
            Logger.Info("Verify event call");
            var e = new SdkEvent(eventOptions, _options);

            try
            {
                var res = _eventManager.SendSync(e, ApiRoute.VERIFY);
                return(JsonConvert.DeserializeObject <VerifyResult>(res.GetBody()));
            }
            catch (Exception ex)
            {
                Logger.Error($"Failed to call verify; {ex.Message}");
                return(FailOverStrategy.FAIL_OPEN.Equals(_options.GetFailOverStrategy()) ?
                       new VerifyResult(RiskLevel.LOW, 0, new string[0])
                        : new VerifyResult(RiskLevel.HIGH, 1, new string[0]));
            }
        }
Пример #29
0
        public void TestValidQueryString()
        {
            EventOptions options = new EventOptions
            {
                PerPage = 5,
                AssetId = "0x55"
            };
            var query = Utils.BuildQueryString(new List <KeyValuePair <string, object> >
            {
                new KeyValuePair <string, object>(nameof(options.PerPage).ToCamelCase(), options.PerPage),
                new KeyValuePair <string, object>(nameof(options.AssetId).ToCamelCase(), options.AssetId),
                new KeyValuePair <string, object>(nameof(options.Data).ToCamelCase(), options.Data),
                new KeyValuePair <string, object>(nameof(options.FromTimestamp).ToCamelCase(), options.FromTimestamp),
                new KeyValuePair <string, object>(nameof(options.ToTimestamp).ToCamelCase(), options.ToTimestamp)
            });

            Assert.IsTrue(query == $"?perPage={options.PerPage.Value}&assetId={options.AssetId}");
        }
Пример #30
0
        public async Task <bool> TryCreateEventAsync(ulong guildId, ulong channelId, CurrencyEvent.Type type,
                                                     EventOptions opts, Func <CurrencyEvent.Type, EventOptions, long, EmbedBuilder> embed)
        {
            SocketGuild       g  = _client.GetGuild(guildId);
            SocketTextChannel ch = g?.GetChannel(channelId) as SocketTextChannel;

            if (ch == null)
            {
                return(false);
            }

            ICurrencyEvent ce;

            if (type == CurrencyEvent.Type.Reaction)
            {
                ce = new ReactionEvent(_client, _cs, _bc, g, ch, opts, embed);
            }
            //else if (type == Event.Type.NotRaid)
            //{
            //    ce = new NotRaidEvent(_client, _cs, _bc, g, ch, opts, embed);
            //}
            else
            {
                return(false);
            }

            var added = _events.TryAdd(guildId, ce);

            if (added)
            {
                try
                {
                    ce.OnEnded += OnEventEnded;
                    await ce.StartEvent().ConfigureAwait(false);
                }
                catch (Exception ex)
                {
                    _log.Warn(ex);
                    _events.TryRemove(guildId, out ce);
                    return(false);
                }
            }
            return(added);
        }
Пример #31
0
 /// <summary>
 /// Determines whether the specified <see cref="Cronofy.EventOptions"/>
 /// is equal to the current <see cref="Cronofy.EventOptions"/>.
 /// </summary>
 /// <param name="other">
 /// The <see cref="Cronofy.EventOptions"/> to compare with the current
 /// <see cref="Cronofy.EventOptions"/>.
 /// </param>
 /// <returns>
 /// <c>true</c> if the specified <see cref="Cronofy.EventOptions"/> is
 /// equal to the current <see cref="Cronofy.EventOptions"/>; otherwise,
 /// <c>false</c>.
 /// </returns>
 private bool Equals(EventOptions other)
 {
     return this.Delete == other.Delete && this.Update == other.Update;
 }