Пример #1
0
 // /facts/query
 public IHttpActionResult ProcessQuery(FactDO query)
 {
     using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
     {
         var facts = _fact.GetByObjectId(uow, query.ObjectId);
         return(Ok(facts.Select(Mapper.Map <FactDTO>)));
     };
 }
Пример #2
0
        private void SaveFact(FactDO curFact)
        {
            using (IUnitOfWork uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                uow.FactRepository.Add(curFact);
                uow.MultiTenantObjectRepository.Add(curFact.ToFactCM(), _security.GetCurrentUser());

                uow.SaveChanges();
            }
        }
Пример #3
0
        // /facts/query
        public IHttpActionResult ProcessQuery(FactDO query)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                //TODO: verify objectId owned by current user? i.e. requested container

                var facts = _fact.GetByObjectId(uow, query.ObjectId);
                return(Ok(facts.Select(Mapper.Map <FactDTO>)));
            };
        }
Пример #4
0
        public void EventBooked(int eventId, string Fr8UserId)
        {
            FactDO curAction = new FactDO
            {
                PrimaryCategory   = "Event",
                SecondaryCategory = "",
                Activity          = "Booked",
                Fr8UserId         = Fr8UserId,
                ObjectId          = eventId.ToString(CultureInfo.InvariantCulture)
            };

            SaveAndLogFact(curAction);
        }
Пример #5
0
        public void EmailSent(int emailId, string Fr8UserId)
        {
            FactDO curAction = new FactDO
            {
                PrimaryCategory   = "Email",
                SecondaryCategory = "",
                Activity          = "Sent",
                Fr8UserId         = Fr8UserId,
                ObjectId          = emailId.ToString(CultureInfo.InvariantCulture)
            };

            SaveAndLogFact(curAction);
        }
Пример #6
0
        private void TrackablePropertyUpdated(string entityName, string propertyName, object id, object value)
        {
            var newFactDO = new FactDO
            {
                PrimaryCategory                              = entityName,
                SecondaryCategory                            = propertyName,
                Activity                                     = "PropertyUpdated",
                ObjectId                                     = id != null?id.ToString() : null,
                                                 CreatedByID = _security.GetCurrentUser(),
                                                 Status      = value != null?value.ToString() : null,
            };

            SaveAndLogFact(newFactDO);
        }
Пример #7
0
        /// <summary>
        /// The method logs the fact of Process Template creation.
        /// </summary>
        /// <param name="userId">UserId received from DocuSign.</param>
        /// <param name="planId">EnvelopeId received from DocuSign.</param>
        public void RouteCreated(string userId, string planName)
        {
            FactDO fact = new FactDO
            {
                PrimaryCategory   = "PlanService",
                SecondaryCategory = null,
                Activity          = "Created",
                Fr8UserId         = userId,
                ObjectId          = "0",
                Data = string.Format("Plan Name: {0}.", planName)
            };

            SaveAndLogFact(fact);
        }
Пример #8
0
        private FactDO CreatedPlanFact(Guid planId, string state)
        {
            var factDO = new FactDO()
            {
                PrimaryCategory   = "Plan",
                SecondaryCategory = "PlanState",
                Activity          = "StateChanged",
                ObjectId          = planId.ToString(),
                Fr8UserId         = _security.GetCurrentUser(),
                CreatedByID       = _security.GetCurrentUser(),
                Data = string.Join(Environment.NewLine, "Plan State: " + state)
            };

            return(factDO);
        }
Пример #9
0
        private void ContainerExecutionCompleted(ContainerDO containerDO)
        {
            var factDO = new FactDO()
            {
                PrimaryCategory   = "Container Execution",
                SecondaryCategory = "Container",
                Activity          = "Launched",
                ObjectId          = containerDO.Id.ToString(),
                Fr8UserId         = _security.GetCurrentUser(),
                CreatedByID       = _security.GetCurrentUser(),
                Data = string.Join(Environment.NewLine, "Container Id: " + containerDO.Id, "Plan Id: " + containerDO.PlanId)
            };

            SaveAndLogFact(factDO);
        }
Пример #10
0
        private void LogTerminalEvent(LoggingDataCM eventDataCm)
        {
            var fact = new FactDO
            {
                ObjectId          = eventDataCm.ObjectId,
                Fr8UserId         = eventDataCm.Fr8UserId,
                Data              = eventDataCm.Data,
                PrimaryCategory   = eventDataCm.PrimaryCategory,
                SecondaryCategory = eventDataCm.SecondaryCategory,
                Component         = "Terminal",
                Activity          = eventDataCm.Activity
            };

            SaveAndLogFact(fact);
        }
Пример #11
0
        private void AddFactOnToken(string userId, string activity)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                FactDO factDO = new FactDO
                {
                    PrimaryCategory   = "DocuSign",
                    SecondaryCategory = "Token",
                    Activity          = activity,
                    Fr8UserId         = userId,
                };

                SaveAndLogFact(factDO);
            }
        }
Пример #12
0
        private void EntityStateChanged(string entityName, object id, string stateName, string stateValue)
        {
            var newFactDO = new FactDO
            {
                PrimaryCategory                              = entityName,
                SecondaryCategory                            = stateName,
                Fr8UserId                                    = _security.GetCurrentUser(),
                Activity                                     = "StateChanged",
                ObjectId                                     = id != null?id.ToString() : null,
                                                 CreatedByID = _security.GetCurrentUser(),
                                                 Status      = stateValue,
            };

            SaveAndLogFact(newFactDO);
        }
Пример #13
0
        public void UserRegistered(Fr8AccountDO curUser)
        {
            FactDO curFactDO = new FactDO
            {
                PrimaryCategory   = "User",
                SecondaryCategory = "",
                Activity          = "Registered",
                Fr8UserId         = curUser.Id,
                ObjectId          = null,
                Data = string.Format("User registrated with :{0},", curUser.EmailAddress.Address)
                       //Data = "User registrated with " + curUser.EmailAddress.Address
            };

            SaveAndLogFact(curFactDO);
        }
Пример #14
0
        public static FactDO TestFactDO()
        {
            var curFactDO = new FactDO
            {
                ObjectId          = "Terminal Incident",
                Fr8UserId         = "not_applicable",
                Data              = "service_start_up",
                PrimaryCategory   = "Operations",
                SecondaryCategory = "System Startup",
                Activity          = "system startup",
                CreateDate        = DateTimeOffset.UtcNow.AddDays(-1)
            };

            return(curFactDO);
        }
Пример #15
0
        /// <summary>
        /// The method logs the fact of processing of a notification from DocuSign
        /// by an individual Process.
        /// </summary>
        /// <param name="userId">UserId received from DocuSign.</param>
        /// <param name="envelopeId">EnvelopeId received from DocuSign.</param>
        public void AlertProcessProcessing(string userId, string envelopeId, int containerId)
        {
            FactDO fact = new FactDO
            {
                PrimaryCategory   = "Notification",
                SecondaryCategory = null,
                Activity          = "Processed",
                Fr8UserId         = userId,
                ObjectId          = null,
                Data = string.Format("A notification from DocuSign is processed. UserId: {0}, EnvelopeId: {1}, ContainerDO id: {2}.", userId,
                                     envelopeId, containerId)
            };

            SaveAndLogFact(fact);
        }
Пример #16
0
        private void ProcessingTerminatedPerActivityResponse(ContainerDO containerDO, ActivityResponse resposneType)
        {
            var factDO = new FactDO()
            {
                PrimaryCategory   = "Container Execution",
                SecondaryCategory = "Container",
                Activity          = "Terminated",
                Status            = resposneType.ToString(),
                ObjectId          = containerDO.Id.ToString(),
                CreatedByID       = _security.GetCurrentUser(),
                Fr8UserId         = _security.GetCurrentUser(),
                Data = string.Join(Environment.NewLine, "Container Id: " + containerDO.Name)
            };

            SaveAndLogFact(factDO);
        }
Пример #17
0
        public void ActivityTemplatesSuccessfullyRegistered(int count)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                FactDO curFactDO = new FactDO
                {
                    PrimaryCategory   = "StartUp",
                    SecondaryCategory = "Activity Templates",
                    Activity          = "Registered",
                    ObjectId          = null,
                    Data = string.Format("{0} activity templates were registrated", count)
                           //Data = "User registrated with " + curUser.EmailAddress.Address
                };

                SaveAndLogFact(curFactDO);
            }
        }
Пример #18
0
        private void CustomerCreated(string curUserId)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                FactDO curAction = new FactDO
                {
                    PrimaryCategory   = "User",
                    SecondaryCategory = "",
                    Activity          = "Created",
                    Fr8UserId         = curUserId,
                    ObjectId          = null,
                    Data = string.Format("User with email :{0}, created from: {1}", uow.UserRepository.GetByKey(curUserId).EmailAddress.Address, new StackTrace())
                };

                SaveAndLogFact(curAction);
            }
        }
Пример #19
0
        private void ActivityResponseReceived(ActivityDO activityDo, ActivityResponse responseType)
        {
            var template = _activityTemplate.GetByKey(activityDo.ActivityTemplateId);

            var factDO = new FactDO()
            {
                PrimaryCategory   = "Container",
                SecondaryCategory = "Activity",
                Activity          = "Process Execution",
                Status            = responseType.ToString(),
                ObjectId          = activityDo.Id.ToString(),
                Fr8UserId         = _security.GetCurrentUser(),
                CreatedByID       = _security.GetCurrentUser(),
                Data = string.Join(Environment.NewLine, "Activity Name: " + template?.Name)
            };

            SaveAndLogFact(factDO);
        }
Пример #20
0
        private void LogEventProcessLaunched(ContainerDO launchedContainer)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var plan = uow.PlanRepository.GetById <PlanDO>(launchedContainer.PlanId);

                var fact = new FactDO
                {
                    Fr8UserId         = plan.Fr8AccountId,
                    Data              = launchedContainer.Id.ToStr(),
                    ObjectId          = launchedContainer.Id.ToStr(),
                    PrimaryCategory   = "Container Execution",
                    SecondaryCategory = "Container",
                    Activity          = "Launched"
                };

                SaveAndLogFact(fact);
            }
        }
Пример #21
0
        private void AuthTokenCreated(AuthorizationTokenDO authToken)
        {
            var factDO = new FactDO();

            factDO.PrimaryCategory   = "AuthToken";
            factDO.SecondaryCategory = "Created";
            factDO.Activity          = "AuthToken Created";
            factDO.ObjectId          = null;
            factDO.CreatedByID       = _security.GetCurrentUser();
            factDO.Data = string.Join(
                Environment.NewLine,
                "AuthToken method: Created",
                "User Id: " + authToken.UserID.ToString(),
                "Terminal name: " + FormatTerminalName(authToken),
                "External AccountId: " + authToken.ExternalAccountId
                );

            SaveAndLogFact(factDO);
        }
Пример #22
0
        private void EventManagerOnEventProcessRequestReceived(ContainerDO containerDO)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var plan = uow.PlanRepository.GetById <PlanDO>(containerDO.PlanId);

                var fact = new FactDO
                {
                    Fr8UserId         = plan.Fr8AccountId,
                    Data              = containerDO.Id.ToStr(),
                    ObjectId          = containerDO.Id.ToStr(),
                    PrimaryCategory   = "Process Access",
                    SecondaryCategory = "Process",
                    Activity          = "Requested"
                };

                SaveAndLogFact(fact);
            }
        }
Пример #23
0
        private void AuthTokenRemoved(AuthorizationTokenDO authToken)
        {
            var newFactDO = new FactDO
            {
                PrimaryCategory   = "AuthToken",
                SecondaryCategory = "Removed",
                Activity          = "AuthToken Removed",
                ObjectId          = null,
                CreatedByID       = _security.GetCurrentUser(),
                Data = string.Join(
                    Environment.NewLine,
                    "AuthToken method: Removed",
                    "User Id: " + authToken.UserID.ToString(),
                    "Terminal name: " + FormatTerminalName(authToken),
                    "External AccountId: " + authToken.ExternalAccountId
                    )
            };

            SaveAndLogFact(newFactDO);
        }
Пример #24
0
        public void EmailReceived(int emailId, string Fr8UserId)
        {
            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",
                    Fr8UserId         = Fr8UserId,
                    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.Fr8UserId).EmailAddress.Address), emailSubject);

                SaveAndLogFact(curAction);
            }
        }
Пример #25
0
        private void LogEventActivityStarted(ActivityDO curActivity, ContainerDO containerInExecution)
        {
            FactDO fact;

            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var plan = containerInExecution != null?uow.PlanRepository.GetById <PlanDO>(containerInExecution.PlanId) : null;

                fact = new FactDO
                {
                    Fr8UserId         = (containerInExecution != null) ? plan.Fr8AccountId : "unknown",
                    Data              = (containerInExecution != null) ? containerInExecution.Id.ToStr() : "unknown",
                    ObjectId          = curActivity.Id.ToStr(),
                    PrimaryCategory   = "Process Execution",
                    SecondaryCategory = "Action",
                    Activity          = "Started"
                };
            }

            SaveAndLogFact(fact);
        }
Пример #26
0
        private void ActivityRunRequested(ActivityDO activityDo, ContainerDO containerDO)
        {
            try
            {
                using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
                {
                    var template = _activityTemplate.GetByKey(activityDo.ActivityTemplateId);

                    var factDO = new FactDO()
                    {
                        PrimaryCategory   = "Container",
                        SecondaryCategory = "Activity",
                        Activity          = "Process Execution",
                        Status            = "Activity Execution Initiating",
                        ObjectId          = activityDo.Id.ToString(),
                        Fr8UserId         = _security.GetCurrentUser(),
                        CreatedByID       = _security.GetCurrentUser(),
                        Data = string.Join(Environment.NewLine, "Activity Name: " + template?.Name)
                    };
                    SaveAndLogFact(factDO);

                    // Create user notifications about activity execution
                    var _pusherNotifier = ObjectFactory.GetInstance <IPusherNotifier>();
                    _pusherNotifier.NotifyUser(new NotificationMessageDTO()
                    {
                        NotificationType = NotificationType.GenericInfo,
                        Subject          = "Executing Activity",
                        Message          = "For Plan: " + containerDO.Name + "\nContainer: " + containerDO.Id.ToString(),
                        ActivityName     = template.Label,
                        Collapsed        = true,
                    }, activityDo.Fr8Account.Id);
                }
            }
            catch (Exception exception)
            {
                EventManager.UnexpectedError(exception);
            }
        }
Пример #27
0
        private void LogEventCriteriaEvaluationFinished(Guid curContainerId)
        {
            ContainerDO containerInExecution;
            FactDO      fact;

            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                containerInExecution = uow.ContainerRepository.GetByKey(curContainerId);
                var plan = containerInExecution != null?uow.PlanRepository.GetById <PlanDO>(containerInExecution.PlanId) : null;

                fact = new FactDO
                {
                    Fr8UserId                                            = containerInExecution != null ? plan.Fr8AccountId : "unknown",
                    Data                                                 = containerInExecution != null?containerInExecution.Id.ToStr() : "unknown",
                                                       ObjectId          = null,
                                                       PrimaryCategory   = "Process Execution",
                                                       SecondaryCategory = "Criteria Evaluation",
                                                       Activity          = "Finished"
                };
            }

            SaveAndLogFact(fact);
        }
Пример #28
0
        private void CreateContainerFact(ContainerDO containerDO, string activity, ActivityDO activityDO = null)
        {
            using (var uow = ObjectFactory.GetInstance <IUnitOfWork>())
            {
                var plan = uow.PlanRepository.GetById <PlanDO>(containerDO.PlanId);

                var curFact = new FactDO
                {
                    Fr8UserId         = plan.Fr8AccountId,
                    ObjectId          = containerDO.Id.ToStr(),
                    PrimaryCategory   = "Containers",
                    SecondaryCategory = "Operations",
                    Activity          = activity
                };

                if (activityDO != null)
                {
                    var activityTemplate = _activityTemplate.GetByKey(activityDO.ActivityTemplateId);
                    curFact.Data = string.Format("Terminal: {0} - Action: {1}.", activityTemplate.Terminal.Name, activityTemplate.Name);
                }

                SaveAndLogFact(curFact);
            }
        }
Пример #29
0
 private void SaveAndLogFact(FactDO fact)
 {
     SaveFact(fact);
     LogHistoryItem(fact);
 }