Пример #1
0
 public EventController(ApplicationDbContext context, Geocoding geocoding,
                        PublicEvents publicEvents, MailKitService mailKitService)
 {
     _context        = context;
     _geocoding      = geocoding;
     _publicEvents   = publicEvents;
     _mailKitService = mailKitService;
 }
Пример #2
0
 public MainViewModel()
 {
     CreateRule = new RelayCommand <Project>(param =>
     {
         Questions.Clear();
         PublicEventConnection.Dispose();
         Rules.Add(new Rule()
         {
             What       = param.Work.What,
             Enabled    = true,
             Comparison = RuleType.Equals,
             From       = new TimeSpan(0, 0, 0),
             To         = new TimeSpan(23, 59, 59),
             Do         = Rule.Ignore
         });
         PublicEventConnection = PublicEvents.Connect();
     });
 }
Пример #3
0
        internal void Load()
        {
            Questions = new ObservableDictionary <Work, Project>();
            var awtWatch     = AutoHotKeyObservable.WatchAwt(TimeSpan.FromMilliseconds(2000));
            var windows      = awtWatch.OfType <ProcessInfo>().Select(p => p.ToString()).DistinctUntilChanged();
            var personActive = awtWatch.MouseMoving().PersonActive();

            PublicEvents = windows.CombineLatest(personActive,
                                                 (w, a) => a == PersonInfo.ActiveStatus.Active ? w : a.ToString()).
                           CombineLatest(SessionObservable.SessionSwitched(),
                                         (w, s) => s == SessionSwitchReason.SessionUnlock ? w : s.ToString()).
                           TimeInterval().HowLongHas("Active").Timestamp().Select(i =>
            {
                return(new Timestamped <TimeInterval <string> >(i.Value, i.Timestamp.RoundDown()));
            }).Publish();


            WhatWereYouDoing = PublicEvents.Where(evt =>
            {
                return(!Rules.
                       Where(r => r.Enabled).
                       Where(r => evt.Timestamp.TimeOfDay >= r.From).
                       Where(r => evt.Timestamp.TimeOfDay <= r.To).
                       Where(r => r.Comparison == RuleType.Equals).
                       Where(r => r.What == evt.Value.Value).Any());
            }).ObserveOnDispatcher().Subscribe((i) =>
            {
                Work w = new Work()
                {
                    What = i.Value.Value, When = i.Timestamp.ToLocalTime()
                };
                if (Questions.ContainsKey(w))
                {
                    Questions[w].Interval += i.Value.Interval;
                }
                else
                {
                    Questions.Add(w, new Project(i.Value.Interval, w));
                }
            });
            PublicEventConnection = PublicEvents.Connect();
        }
Пример #4
0
        public override string ToString()
        {
            StringBuilder commitInfoBuilder = new StringBuilder();

            commitInfoBuilder.AppendLine("AggregateCommit details:");

            commitInfoBuilder.Append("RootId:");
            commitInfoBuilder.AppendLine(Encoding.UTF8.GetString(AggregateRootId));

            commitInfoBuilder.Append("Revision:");
            commitInfoBuilder.AppendLine(Revision.ToString());

            commitInfoBuilder.Append("Events:");
            commitInfoBuilder.AppendLine(string.Join(Environment.NewLine, Events.Select(e => "\t" + e.ToString())));

            commitInfoBuilder.Append("PublicEvents:");
            commitInfoBuilder.AppendLine(string.Join(Environment.NewLine, PublicEvents.Select(e => "\t" + e.ToString())));

            return(commitInfoBuilder.ToString());
        }
Пример #5
0
 protected IContextDefinition RegisterPublicEvents(params Type[] types)
 {
     Events.Load(types);
     PublicEvents.Load(types);
     return(this);
 }
Пример #6
0
 protected IContextDefinition RegisterPublicEvent <TEvent>() where TEvent : IAggregateEvent
 {
     Events.Load(typeof(TEvent));
     PublicEvents.Load(typeof(TEvent));
     return(this);
 }