Exemplo n.º 1
0
        //Do we need/use both this and the immediately preceding event? 
        public void ReportBookingRequestOwnershipChanged(int bookingRequestId, string bookerId)
        {
            using (var uow = ObjectFactory.GetInstance<IUnitOfWork>())
            {
                var bookingRequestDO = uow.BookingRequestRepository.GetByKey(bookingRequestId);
                if (bookingRequestDO == null)
                    throw new EntityNotFoundException<BookingRequestDO>(bookingRequestId);
                var bookerDO = uow.UserRepository.GetByKey(bookerId);
                if (bookerDO == null)
                    throw new EntityNotFoundException<UserDO>(bookerId);
                string status = bookingRequestDO.BookingRequestStateTemplate.Name;
                FactDO curAction = new FactDO
                    {
                        PrimaryCategory = "BookingRequest",
                        SecondaryCategory = "Ownership",
                        Activity = "Change",
                        CustomerId = bookingRequestDO.Customer.Id,
                        ObjectId = bookingRequestDO.Id.ToString(CultureInfo.InvariantCulture),
                        BookerId = bookerId,
                        Status = status,
                        Data = string.Format(
                            "BookingRequest ID :{0}, Booker EmailAddress: {1}",
                            bookingRequestDO.Id,
                            bookerDO.EmailAddress.Address)
                    };

                //AddFact(uow, curAction);
                uow.SaveChanges();
            }
        }
Exemplo n.º 2
0
 private void SaveFact(FactDO curAction)
 {
     using (IUnitOfWork uow = ObjectFactory.GetInstance<IUnitOfWork>())
     {
         uow.FactRepository.Add(curAction);
         uow.SaveChanges();
     }
 }
Exemplo n.º 3
0
        public void ReportUserRegistered(UserDO curUser)
        {
            using (var uow = ObjectFactory.GetInstance<IUnitOfWork>())
            {
                FactDO curFactDO = new FactDO
                    {
                        PrimaryCategory = "User",
                        SecondaryCategory = "",
                        Activity = "Registered",
                        CustomerId = curUser.Id,
                        ObjectId = null,
                        Data = string.Format("User registrated with :{0},", curUser.EmailAddress.Address)
                        //Data = "User registrated with " + curUser.EmailAddress.Address
                    };
                Logger.GetLogger().Info(curFactDO.Data);
                uow.FactRepository.Add(curFactDO);
                uow.SaveChanges();
            }

        }
Exemplo n.º 4
0
        public void ReportBookingRequestCreated(int bookingRequestId)
        {
            using (var uow = ObjectFactory.GetInstance<IUnitOfWork>())
            {
                var bookingRequestDO = uow.BookingRequestRepository.GetByKey(bookingRequestId);


                ObjectFactory.GetInstance<ITracker>().Track(bookingRequestDO.Customer, "BookingRequest", "Submit", new Dictionary<string, object> { { "BookingRequestId", bookingRequestDO.Id } });

                FactDO curAction = new FactDO
                    {
                        PrimaryCategory = "BookingRequest",
                        SecondaryCategory = "",
                        Activity = "Created",
                        CustomerId = bookingRequestDO.CustomerID,
                        ObjectId = bookingRequestId.ToString(CultureInfo.InvariantCulture)
                    };
              
                curAction.Data = string.Format("{0} ID :{1},", curAction.PrimaryCategory, curAction.ObjectId);
                SaveFact(curAction);
            }
        }
Exemplo n.º 5
0
 public void ReportEmailSent(int emailId, string customerId)
 {
     FactDO curAction = new FactDO
         {
             PrimaryCategory = "Email",
             SecondaryCategory = "",
             Activity = "Sent",
             CustomerId = customerId,
             ObjectId = emailId.ToString(CultureInfo.InvariantCulture)
         };
     SaveFact(curAction);
 }
Exemplo n.º 6
0
        public void ReportEmailReceived(int emailId, string customerId)
        {
            using (var uow = ObjectFactory.GetInstance<IUnitOfWork>())
            {
                string emailSubject = uow.EmailRepository.GetByKey(emailId).Subject;
                emailSubject = emailSubject.Length <= 10 ? emailSubject : (emailSubject.Substring(0, 10) + "...");

                FactDO curAction = new FactDO
                    {
                        PrimaryCategory = "Email",
                        SecondaryCategory = "",
                        Activity = "Received",
                        CustomerId = customerId,
                        ObjectId = emailId.ToString(CultureInfo.InvariantCulture)
                    };
              
                curAction.Data = string.Format("{0} ID :{1}, {2} {3}: ObjectId: {4} EmailAddress: {5} Subject: {6}", curAction.PrimaryCategory, emailId, curAction.SecondaryCategory, curAction.Activity, emailId, (uow.UserRepository.GetByKey(curAction.CustomerId).EmailAddress.Address), emailSubject);

                SaveFact(curAction);
            }
        }
Exemplo n.º 7
0
        private void ReportCustomerCreated(string curUserId)
        {
            using (var uow = ObjectFactory.GetInstance<IUnitOfWork>())
            {
                FactDO curAction = new FactDO
                    {
                        PrimaryCategory = "User",
                        SecondaryCategory = "",
                        Activity = "Created",
                        CustomerId = curUserId,
                        ObjectId = null,
                        Data = string.Format("User with email :{0}, created from: {1}", uow.UserRepository.GetByKey(curUserId).EmailAddress.Address, new StackTrace())
                    };

                SaveFact(curAction);
            }
        }
Exemplo n.º 8
0
 private static void EntityStateChanged(string entityName, object id, string stateName, string stateValue)
 {
     using (var uow = ObjectFactory.GetInstance<IUnitOfWork>())
     {
         var newFactDO = new FactDO
         {
             PrimaryCategory = entityName,
             SecondaryCategory = stateName,
             Activity = "StateChanged",
             ObjectId = id != null ? id.ToString() : null,
             CreatedByID = ObjectFactory.GetInstance<ISecurityServices>().GetCurrentUser(),
             Status = stateValue,
         };
         uow.FactRepository.Add(newFactDO);
         uow.SaveChanges();
     }
 }