Beispiel #1
0
        private void reRaiseEventAsProcessed(ProjectChangeEvent projectChangeEvent)
        {
            var newEvent = new ProjectChangeEvent(projectChangeEvent);

            newEvent.Processed = true;
            OnRaiseProjectChangeEvent(newEvent);
        }
Beispiel #2
0
        public void handleProjectChangeEvent(object sender, ProjectChangeEvent projectChangeEvent)
        {
            //RTODO locking?
            //Console.WriteLine("Received this message: {0}", projectChangeEvent.ToString());

            if (!projectChangeEvent.Processed)
            {
                //As far as I can tell processed means that the event was exhaustively handled but still a bit unclear how this event pipleline really works...
                Boolean processed = false;

                foreach (var processor in projectChangeProcessors) //RTODO, may we should either refire or return an object to have something more like a chain-semantic?!
                {
                    if (sender != processor)
                    {
                        processed |= processor.process(projectChangeEvent);
                    }
                }
                if (!processed)
                {
                    reRaiseEventAsProcessed(projectChangeEvent);
                }
            }
            else
            {
                //Invoke all storages
                foreach (var storage in worktimeRecordStorages)
                {
                    try
                    {
                        storage.handleProjectChangeEvent(projectChangeEvent);
                    }
                    catch (Exception ex)
                    {
                        RaiseStorageExceptionEvent(this, ex);
                    }
                }

                //Update fields
                currentProject        = projectChangeEvent.NewProject;
                currentProjectComment = projectChangeEvent.NewComment;
                if (projectChangeEvent.WorktimeRecord != null && projectChangeEvent.WorktimeRecords.Last().End >= currentProjectSince)
                {
                    currentProjectSince = projectChangeEvent.WorktimeRecords.Last().End;
                }
            }
        }