public DataPublisher()
        {
            publisher = new EventActivity(
                new ActivitySettings(ActivityDrilldown.Second));

            timer = new Timer(Update, null, 1000, 1000);
        }
 protected EventActivityTrackTests(ActivityTimeframe timeframe)
 {
     EventActivity = new EventActivity(
         new ActivitySettings(1, timeframe));
     EventActivity.Reset().Wait();
     EventActivity.Track(EventName, Timestamp).Wait();
 }
 protected EventActivityTrackTests(ActivityDrilldown drilldown)
 {
     EventActivity = new EventActivity(
         new ActivitySettings(1, drilldown));
     EventActivity.Reset().Wait();
     EventActivity.Track(EventName, Timestamp).Wait();
 }
        public LiveFeedsHub()
        {
            var eventActivity = new EventActivity(
                new ActivitySettings(ActivityDrilldown.Second));

            subscription = eventActivity.CreateSubscription(
                "order:placed",
                OnDataReceive);
        }
        public DataPublisher()
        {
            publisher = new EventActivity(
                new ActivitySettings(ActivityTimeframe.Second));

            timer = new Timer(
                Update,
                null,
                TimeSpan.FromSeconds(3),
                TimeSpan.FromSeconds(1));
        }
        public DonationInfo Donate(decimal donationAmount, EventActivity eventActivity)
        {
            var donation = _supplementConfiguration.CalculateSupplementedAmount(donationAmount, eventActivity.EventType);
            var giftAid = _calculator.CalculateGiftAidAmount(donation, _taxRateStore.RetrieveTaxRate());
            var giftAidRounded = decimal.Round(giftAid, 2);

            return new DonationInfo
            {
                OriginalDonation = donationAmount,
                SupplementedDonation = donation,
                GiftAid = giftAid,
                GiftAidRounded = giftAidRounded,
            };
        }
Exemple #7
0
        // Save the results to the data source
        public void Save()
        {
            // This is where you would replace the "guts" with anything you wanted for writing
            // Create the object to save the values to
            using (var context = new EventSampleEntities())
            {
                // Use Automapper to map the fields
                //Future: Change to static maps?
                var           config = new MapperConfiguration(cfg => cfg.CreateMap <LogWriterEF, EventActivity>());
                EventActivity ev     = config.CreateMapper().Map <EventActivity>(this);
                ev.EventDate = System.DateTime.UtcNow;
                context.EventActivities.Add(ev);
                context.SaveChanges();

                Reset();
            }
        }
        } // end of CollectingMethodsPerControlUnitType

        #endregion

        //--------------------------------------------------------------------------------------------------
        // Interface Methods
        //--------------------------------------------------------------------------------------------------

        #region CreateCurrentState

        /// <summary>
        /// Creates the current state, for each triggered event the appropriate method is called if any
        /// is stored in the dictionaries, for all control units it is checked if a data collection method
        /// was stored, if so it is called
        /// </summary>
        /// <param name="currentEvents">List of events that have been triggered at current time of simulation</param>
        /// <param name="time">Current time of simulation</param>
        public void CreateCurrentState(List <Event> currentEvents, DateTime time)
        {
            if (time < EndOfWarmUpPeriod)
            {
                return;
            }

            foreach (Event ev in currentEvents)
            {
                if (ev is EventActivity)
                {
                    EventActivity activityEvent = ev as EventActivity;
                    Type          activityType  = activityEvent.ParentActivity.GetType();

                    if (activityEvent.EventType == EventType.Start)
                    {
                        if (CollectingMethodsPerActivityStartEventType.ContainsKey(activityType))
                        {
                            CollectingMethodsPerActivityStartEventType[activityType](activityEvent.ParentActivity, time);
                        }
                    }
                    else if (((EventActivity)ev).EventType == EventType.End)
                    {
                        if (CollectingMethodsPerActivityEndEventType.ContainsKey(activityType))
                        {
                            CollectingMethodsPerActivityEndEventType[activityType](activityEvent.ParentActivity, time);
                        }
                    } // end if
                }
                else
                {
                    if (CollectingMethodsPerStandaloneEventType.ContainsKey(ev.GetType()))
                    {
                        CollectingMethodsPerStandaloneEventType[ev.GetType()](ev, time);
                    }
                } // end if
            }     // end foreach

            foreach (ControlUnit control in ParentSimulationModel.ControlUnits.Values)
            {
                if (CollectingMethodsPerControlUnitType.ContainsKey(control.GetType()))
                {
                    CollectingMethodsPerControlUnitType[control.GetType()](control, time);
                }
            } // end foreach
        }     // end of CreateCurrentState
Exemple #9
0
        public void Begin()
        {
            if (_trace.IsEnabled)
            {
                _traceActivity = _trace.WriteEventActivity(
                    TraceProvider.StoryBoard_Start,
                    EventOpcode.Start,
                    payload: new[] {
                    this.GetParent()?.GetType().Name,
                    this.GetParent()?.GetDependencyObjectId().ToString(),
                }
                    );
            }

            State = TimelineState.Active;
            _hasFillingChildren = false;
            _replayCount        = 1;
            _lastBeginTime      = DateTimeOffset.Now;

            Play();
        }
Exemple #10
0
        private UIAsyncOperation EnqueueOperation(CoreDispatcherPriority priority, DispatchedHandler handler)
        {
            EventActivity scheduleActivity = null;

            if (_trace.IsEnabled)
            {
                scheduleActivity = _trace.WriteEventActivity(
                    TraceProvider.CoreDispatcher_Schedule,
                    EventOpcode.Send,
                    new[] {
                    ((int)priority).ToString(),
                    handler.Method.DeclaringType.FullName + "." + handler.Method.DeclaringType.Name
                }
                    );
            }

            var operation = new UIAsyncOperation(handler, scheduleActivity);

            if (priority < CoreDispatcherPriority.Idle || priority > CoreDispatcherPriority.High)
            {
                throw new ArgumentException($"The priority {priority} is not supported");
            }

            var queue = GetQueue(priority);

            bool shouldEnqueue;

            lock (_gate)
            {
                queue.Enqueue(operation);
                shouldEnqueue = IncrementGlobalCount() == 1;
            }

            if (shouldEnqueue)
            {
                EnqueueNative();
            }

            return(operation);
        }
Exemple #11
0
 public EventActivityResetTests()
 {
     eventActivity = new EventActivity(
         new ActivitySettings(1, ActivityDrilldown.Year));
     eventActivity.Reset().Wait();
 }
        private IList <SaveEventViewModel> AdminBooking(BookingModel model)
        {
            var userInformationID = GetUserInformationID(model);
            var ids          = model.Events.Select(x => x.CalendarID).ToList();
            var rawcalendars = _context.Calendars.Where(x => ids.Contains(x.ID)).ToList();


            var adminUid = Guid.Parse("d6fa4a98-1927-4da9-8bb7-36ff5eecde41");
            //var adminUid = Guid.Parse("d2b65c8a-a79e-43e8-b3a1-5666397238c8");

            var calendars =
                rawcalendars.Where(
                    x =>
                    x.RouteEntity.Participants.Any(
                        z =>
                        z.AccessStatus == AccessStatus.Owner ||
                        z.AccessStatus == AccessStatus.Administrator && z.UserInformation.ID == adminUid))
                .ToList();

            var strs = new List <string>();

            Order order = new Order
            {
                ID                = Guid.NewGuid(),
                OrderDate         = DateTime.Now,
                UserInformationID = userInformationID,
                Status            = _context.Statuses.Find(StatusID.NewOrder) ?? new Status()
                {
                    ID = StatusID.NewOrder, Title = "Новый Заказ", Description = "Толькло что созданный заказ"
                }
            };



            foreach (var @event in model.Events)
            {
                var calendar = calendars.FirstOrDefault(x => x.ID == @event.CalendarID);
                if (calendar == null)
                {
                    continue;
                }

                var newevent = new Event
                {
                    ID                = Guid.NewGuid(),
                    Calendar          = calendar,
                    Title             = "Занято",
                    Start             = @event.Start,
                    End               = @event.End,
                    AllDay            = @event.AllDay,
                    GoogleID          = @event.GoogleID,
                    UserInformationID = userInformationID,
                    Description       = @event.Description,
                    Price             = @event.Price ?? calendar.GetCost(@event.Start, @event.End),
                    Tags              = "Импортировано",
                    CreatedByID       = adminUid
                };

                order.Add(newevent);

                var str =
                    $" {calendar.GetName()} в {calendar.GetRouteName()} на {@event.Start.Day:00}.{@event.Start.Month:00} c {@event.Start.Hour:00}:{@event.Start.Minute:00} по {@event.End.Hour:00}:{@event.End.Minute:00}";
                strs.Add(str);


                var activity = new EventActivity()
                {
                    ID           = Guid.NewGuid(),
                    Event        = newevent,
                    UserID       = adminUid,
                    Title        = "Импортировано",
                    Description  = str,
                    ActivityTime = DateTime.Now,
                    Route        = calendar.RouteEntity,
                    State        = EventActivityState.Created
                };
                _context.Activities.Add(activity);
            }


            _context.Orders.Add(order);
            _context.SaveChanges();
            return(model.Events);
        }
Exemple #13
0
 /// <summary>
 /// Creates a <see cref="UIAsyncOperation"/> using the provided handler.
 /// </summary>
 /// <param name="action">A handler</param>
 /// <param name="scheduleActivity">An ID that defines the activity being scheduled, used for tracing.</param>
 internal UIAsyncOperation(DispatchedHandler action, EventActivity scheduleActivity)
 {
     Action = action;
     ScheduleEventActivity = scheduleActivity;
 }
 public EventActivityPubSubTests()
 {
     activity = new EventActivity(
         new ActivitySettings(1, ActivityTimeframe.Year));
     activity.Reset().Wait();
 }
 public EventActivityPubSubTests()
 {
     activity = new EventActivity(
         new ActivitySettings(1, ActivityTimeframe.Year));
     activity.Reset().Wait();
 }
 public EventActivityPubSubTests()
 {
     publisher = new EventActivity(
         new ActivitySettings(1, ActivityDrilldown.Year));
     publisher.Reset().Wait();
 }
 public EventActivityPubSubTests()
 {
     publisher = new EventActivity(
         new ActivitySettings(1, ActivityDrilldown.Year));
     publisher.Reset().Wait();
 }
Exemple #18
0
 /// <inheritdoc />
 public async Task <ResultOrError <ResultObject> > AddOrUpdateActivityAsync(EventActivity activity)
 {
     return(await CallAsync <ResultObject>(
                "crm", "addOrUpdateActivity", activity
                ));
 }
Exemple #19
0
 public MemberAdapter(Activity activity, ObservableCollection <MemberViewModel> items)
 {
     Activity      = (EventActivity)activity;
     Items         = items;
     FilteredItems = items;
 }
 public void Bind(EventActivity <TInstance> activity)
 {
     _activityCache[activity.Event].Add(activity);
 }
Exemple #21
0
 public EventActivityResetTests()
 {
     eventActivity = new EventActivity(
         new ActivitySettings(1, ActivityTimeframe.Year));
     eventActivity.Reset().Wait();
 }
 public EventActivityCountsTests()
 {
     eventActivity = new EventActivity(new ActivitySettings(1));
     eventActivity.Reset().Wait();
 }
 public EventActivityCountsTests()
 {
     eventActivity = new EventActivity(new ActivitySettings(1));
     eventActivity.Reset().Wait();
 }
 /// <summary>
 /// Creates an immutable trackable event that occurred at the given time.
 /// </summary>
 /// <param name="type">Type of event that occured.</param>
 /// <param name="time">Time of occurrence.</param>
 public TrackableEvent(EventType type, DateTime time)
 {
     _type = type;
       _time = time;
       _activity = GetActivity(type);
 }