Exemple #1
0
        /// <summary>
        /// Traverse all the Child Entities of a Report or Summary and queue queue the appropriate messages for
        /// any cascade deletes.
        /// </summary>
        private void ProcessCascadeDeletes(IPublicSafetyAggregate aggregate, DataEntryAggregateType aggregateType, IUnitOfWork unitOfWork)
        {
            // Event
            if (aggregate.Event != null)
            {
                unitOfWork.PendingMessages.Add(
                    EventMessageFactory.Deleted(IdentityId, aggregate.Event, aggregate.ModuleType, aggregateType));
            }

            // Attachments
            foreach (var entity in aggregate.Attachments)
            {
                unitOfWork.PendingMessages.Add(
                    AttachmentMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }

            // Drugs
            foreach (var entity in aggregate.Drugs)
            {
                unitOfWork.PendingMessages.Add(
                    DrugMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }

            // Guns
            foreach (var entity in aggregate.Guns)
            {
                unitOfWork.PendingMessages.Add(
                    GunMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }

            // Narratives
            foreach (var entity in aggregate.Narratives)
            {
                unitOfWork.PendingMessages.Add(
                    NarrativeMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }

            // Offenses
            foreach (var entity in aggregate.Offenses)
            {
                unitOfWork.PendingMessages.Add(
                    OffenseMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }

            // Officers
            foreach (var entity in aggregate.Officers)
            {
                unitOfWork.PendingMessages.Add(
                    OfficerMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }

            // Organizations
            foreach (var entity in aggregate.Organizations)
            {
                unitOfWork.PendingMessages.Add(
                    OrganizationMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }

            // People
            foreach (var entity in aggregate.People)
            {
                unitOfWork.PendingMessages.Add(
                    PersonMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }

            // Property
            foreach (var entity in aggregate.Property)
            {
                unitOfWork.PendingMessages.Add(
                    PropertyMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }

            // Vehicles
            foreach (var entity in aggregate.Vehicles)
            {
                unitOfWork.PendingMessages.Add(
                    VehicleMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }


            // FeesPayments
            foreach (var entity in aggregate.FeesPayments)
            {
                unitOfWork.PendingMessages.Add(
                    FeePaymentMessageFactory.Deleted(IdentityId, entity, aggregate.ModuleType, aggregateType));
            }


            // TODO: Module Specific Entities (i.e. OfficerInvolvedShooting and AlcoholDrugTest)
        }
        /// <summary>
        /// Create the appropriate entity Created message.
        /// </summary>
        /// <param name="entity">The entity being Created.</param>
        /// <param name="moduleType">Module Type of </param>
        /// <param name="aggregateType"></param>
        public static EntityModifiedMessage EntityCreated <TEntity>(TEntity entity, ModuleType moduleType, DataEntryAggregateType aggregateType)
            where TEntity : PublicSafetyEntity
        {
            if (entity == null)
            {
                Log.Error("EntityCreated called with null entity.");
            }

            else if (entity is PublicSafetyAttachment)
            {
                return(AttachmentMessageFactory.Created(entity as PublicSafetyAttachment, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyDrug)
            {
                return(DrugMessageFactory.Created(entity as PublicSafetyDrug, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyEvent)
            {
                return(EventMessageFactory.Created(entity as PublicSafetyEvent, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyGun)
            {
                return(GunMessageFactory.Created(entity as PublicSafetyGun, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyNarrative)
            {
                return(NarrativeMessageFactory.Created(entity as PublicSafetyNarrative, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyOffense)
            {
                return(OffenseMessageFactory.Created(entity as PublicSafetyOffense, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyOfficer)
            {
                return(OfficerMessageFactory.Created(entity as PublicSafetyOfficer, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyOrganization)
            {
                return(OrganizationMessageFactory.Created(entity as PublicSafetyOrganization, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyPerson)
            {
                return(PersonMessageFactory.Created(entity as PublicSafetyPerson, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyProperty)
            {
                return(PropertyMessageFactory.Created(entity as PublicSafetyProperty, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyVehicle)
            {
                return(VehicleMessageFactory.Created(entity as PublicSafetyVehicle, moduleType, aggregateType));
            }

            else if (entity is PublicSafetyFeesPayments)
            {
                return(FeePaymentMessageFactory.Created(entity as PublicSafetyFeesPayments, moduleType, aggregateType));
            }

            //else if (entity is CallForServiceCaseReceived)
            //    return CFSCaseReceivedMessageFactory.Created(entity as CallForServiceCaseReceived, moduleType, aggregateType);

            else if (entity is CallForServiceE911)
            {
                return(CFSE911MessageFactory.Created(entity as CallForServiceE911, moduleType, aggregateType));
            }

            else if (entity is CallForServiceResponse)
            {
                return(CFSResponseMessageFactory.Created(entity as CallForServiceResponse, moduleType, aggregateType));
            }

            else if (entity is CallForServiceVehicle)
            {
                return(CFSVehicleMessageFactory.Created(entity as CallForServiceVehicle, moduleType, aggregateType));
            }

            else if (entity is IncidentOfficerInvolvedShooting)
            {
                return(OfficerInvolvedShootingMessageFactory.Created(entity as IncidentOfficerInvolvedShooting, moduleType, aggregateType));
            }

            else
            {
                Log.Info("No EntityCreated message is defined for entity type " + entity.GetType().Name);
            }

            return(null);
        }