public static void AppsOnDerive(this CommunicationEvent @this, ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if ([email protected])
            {
                var owner = @this.Strategy.Session.GetUser() as Person;
                if (owner == null)
                {
                    owner = @this.Strategy.Session.GetSingleton().Guest as Person;
                }

                @this.Owner = owner;
            }

            if (@this.ExistScheduledStart && @this.ExistScheduledEnd && @this.ScheduledEnd < @this.ScheduledStart)
            {
                derivation.Validation.AddError(@this, M.CommunicationEvent.ScheduledEnd, ErrorMessages.EndDateBeforeStartDate);
            }

            if (@this.ExistActualStart && @this.ExistActualEnd && @this.ActualEnd < @this.ActualStart)
            {
                derivation.Validation.AddError(@this, M.CommunicationEvent.ActualEnd, ErrorMessages.EndDateBeforeStartDate);
            }

            if ([email protected])
            {
                if ([email protected] || (@this.ExistActualStart && @this.ActualStart > DateTime.UtcNow))
                {
                    @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Scheduled;
                }

                if (@this.ExistActualStart && @this.ActualStart <= DateTime.UtcNow &&
                    (@this.ExistActualEnd && @this.ActualEnd > DateTime.UtcNow || [email protected]))
                {
                    @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).InProgress;
                }

                if (@this.ExistActualEnd && @this.ActualEnd <= DateTime.UtcNow)
                {
                    @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Completed;
                }
            }

            if ([email protected] && @this.ExistScheduledStart)
            {
                @this.InitialScheduledStart = @this.ScheduledStart;
            }

            if ([email protected] && @this.ExistScheduledEnd)
            {
                @this.InitialScheduledEnd = @this.ScheduledEnd;
            }

            @this.DeriveInvolvedParties();
            @this.DeriveOwnerSecurity();
        }
예제 #2
0
        public static void BaseOnDerive(this CommunicationEvent @this, ObjectOnDerive method)
        {
            var derivation = method.Derivation;

            if ([email protected] && @this.Strategy.Session.GetUser() is Person owner)
            {
                @this.Owner = owner;
            }

            if (@this.ExistScheduledStart && @this.ExistScheduledEnd && @this.ScheduledEnd < @this.ScheduledStart)
            {
                derivation.Validation.AddError(@this, M.CommunicationEvent.ScheduledEnd, ErrorMessages.EndDateBeforeStartDate);
            }

            if (@this.ExistActualStart && @this.ExistActualEnd && @this.ActualEnd < @this.ActualStart)
            {
                derivation.Validation.AddError(@this, M.CommunicationEvent.ActualEnd, ErrorMessages.EndDateBeforeStartDate);
            }

            if ([email protected])
            {
                if ([email protected] || (@this.ExistActualStart && @this.ActualStart > @this.Strategy.Session.Now()))
                {
                    @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Scheduled;
                }

                if (@this.ExistActualStart && @this.ActualStart <= @this.Strategy.Session.Now() &&
                    ((@this.ExistActualEnd && @this.ActualEnd > @this.Strategy.Session.Now()) || [email protected]))
                {
                    @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).InProgress;
                }

                if (@this.ExistActualEnd && @this.ActualEnd <= @this.Strategy.Session.Now())
                {
                    @this.CommunicationEventState = new CommunicationEventStates(@this.Strategy.Session).Completed;
                }
            }

            if ([email protected] && @this.ExistScheduledStart)
            {
                @this.InitialScheduledStart = @this.ScheduledStart;
            }

            if ([email protected] && @this.ExistScheduledEnd)
            {
                @this.InitialScheduledEnd = @this.ScheduledEnd;
            }

            var openCommunicationTasks = @this.TasksWhereWorkItem
                                         .OfType <CommunicationTask>()
                                         .Where(v => !v.ExistDateClosed)
                                         .ToArray();

            if (@this.ExistActualEnd)
            {
                if (openCommunicationTasks.Length > 0)
                {
                    openCommunicationTasks.First().DateClosed = @this.Strategy.Session.Now();
                }
            }
            else
            {
                if (openCommunicationTasks.Length == 0)
                {
                    new CommunicationTaskBuilder(@this.Strategy.Session).WithCommunicationEvent(@this).Build();
                }
            }

            @this.DeriveInvolvedParties();
        }