Пример #1
0
        private ActivityLog SaveActivityLogDomain(ActivityLogEditModel activityLogEditModel)
        {
            var activityLogDomain = _mongoFactory.CreateDomain(activityLogEditModel);

            _repositoryActivityLog.Save(activityLogDomain);
            return(activityLogDomain);
        }
Пример #2
0
        public async void AsyncLogModel(ModelType modelType, ActivityLogEditModel logModel, dynamic model, bool fromAPI = false)
        {
            if (modelType == ModelType.List)
            {
                await _activityLogService.LogListModel(logModel, model, fromAPI);
            }
            else if (modelType == ModelType.View)
            {
                await _activityLogService.LogViewModel(logModel, model, fromAPI);
            }
            else if (modelType == ModelType.Edit)
            {
                var modelId = GetEditModelIdValue(logModel);

                if (modelId > 0)
                {
                    await _activityLogService.LogEditModel(logModel, model, fromAPI);
                }
                else
                {
                    await _activityLogService.LogViewModel(logModel, model, fromAPI);
                }
            }
            else
            {
                await _activityLogService.LogEditModel(logModel, model, fromAPI);
            }
        }
Пример #3
0
        // Use it from the Aspx to log multiple list against single action
        public Task LogRelatedModel(ActivityLogEditModel activityLogEditModel, dynamic model, bool fromAPI = false)
        {
            return(Task.Run(() =>
            {
                var activityLogDomain = SaveActivityLogDomain(activityLogEditModel);

                PropertyInfo[] members = model.GetType().GetProperties();

                foreach (var property in members)
                {
                    var propertyValue = property.GetValue(model);
                    if (property.Name.EndsWith("List"))
                    {
                        SaveListLoggedModel(propertyValue, fromAPI, activityLogDomain);
                    }
                    else
                    {
                        SaveLoggedModel(propertyValue, fromAPI, activityLogDomain);
                    }
                    //try
                    //{

                    //}
                    //catch (NullReferenceException)
                    //{
                    //}
                }
            }));
        }
Пример #4
0
        public Task LogListModel(ActivityLogEditModel activityLogEditModel, dynamic model, bool fromAPI = false)
        {
            return(Task.Run(() =>
            {
                var activityLogDomain = SaveActivityLogDomain(activityLogEditModel);

                SaveListLoggedModel(model, fromAPI, activityLogDomain);
            }));
        }
Пример #5
0
 public ActivityLog CreateDomain(ActivityLogEditModel model)
 {
     return new ActivityLog
     {
         Action = model.Action,
         UrlAccessed = model.UrlAccessed,
         ModelFullName = model.ModelFullName,
         ModelName = model.ModelName,
         RequestType = model.RequestType,
         UserLogId = model.UserLogId,
         Timestamp = model.Timestamp,
         AccessById = model.AccessById,
         CustomerId = model.CustomerId
     };
 }
Пример #6
0
        public ActivityLogEditModel GetActivityLogEditModel(string filePath, string requestType, dynamic model, string activityType)
        {
            var logModel = new ActivityLogEditModel
            {
                Action        = activityType,
                UrlAccessed   = filePath,
                ModelFullName = model.GetType().FullName,
                ModelName     = model.GetType().Name,
                RequestType   = requestType,
                Timestamp     = DateTime.Now,
                UserLogId     = _sessionContext.UserSession.UserLoginLogId,
                AccessById    = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId
            };

            return(logModel);
        }
Пример #7
0
        public Task LogEditModel(ActivityLogEditModel activityLogEditModel, dynamic model, bool fromAPI = false)
        {
            return(Task.Run(() =>
            {
                if (activityLogEditModel.CustomerId <= 0)
                {
                    var customerId = CheckModifiedCustomerId(model);
                    if (!fromAPI && customerId > 0)
                    {
                        activityLogEditModel.CustomerId = customerId;
                    }
                }

                var activityLogDomain = SaveActivityLogDomain(activityLogEditModel);
                SaveLoggedModel(model, fromAPI, activityLogDomain);
            }));
        }
Пример #8
0
        private void LogUserEditModel(dynamic model, ActivityLogEditModel logModel)
        {
            var userEditModel = (UserEditModel)model;

            if (userEditModel.UsersRoles != null && userEditModel.UsersRoles.Count() > 0)
            {
                if (!userEditModel.UsersRoles.Any(ur => ur.GetSystemRoleId == (long)Roles.MedicalVendorUser))
                {
                    userEditModel.PhysicianProfile = null;
                }
            }
            var userValidator = IoC.Resolve <UserEditModelValidator>();
            var result        = userValidator.Validate(model);

            if (result.IsValid)
            {
                _activityLogService.LogEditModel(logModel, userEditModel);
            }
        }
Пример #9
0
        private void LogMassRegistrationModel(dynamic model, ActivityLogEditModel logModel)
        {
            var registrationValidator = IoC.Resolve <MassRegistrationEditModelValidator>();

            foreach (var registrationEditModel in ((MassRegistrationListModel)model).Registrations)
            {
                if (registrationEditModel.HomeNumber != null &&
                    !string.IsNullOrEmpty(registrationEditModel.HomeNumber.ToString()))
                {
                    registrationEditModel.HomeNumber =
                        PhoneNumber.Create(registrationEditModel.HomeNumber.ToNumber().ToString(),
                                           PhoneNumberType.Home);
                }
                var result = registrationValidator.Validate(registrationEditModel);
                if (result.IsValid)
                {
                    logModel.Action = Type.Created.ToString();
                    _activityLogService.LogEditModel(logModel, registrationEditModel);
                }
            }
        }
Пример #10
0
        private bool ExceptionClassLogging(string modelName, object model, ActivityLogEditModel logModel)
        {
            if (modelName.ToLower().Equals("healthassessmenteditmodel"))
            {
                _activityLogService.LogListModel(logModel, model);
                return(true);
            }

            if (modelName.ToLower().Equals("massregistrationlistmodel"))
            {
                LogMassRegistrationModel(model, logModel);
                return(true);
            }

            if (modelName.ToLower().Equals("usereditmodel"))
            {
                LogUserEditModel(model, logModel);
                return(true);
            }
            return(false);
        }
Пример #11
0
        public ActivityLogEditModel GetActivityLogEditModel(dynamic request, dynamic model, string activityType)
        {
            if (_sessionContext == null || _sessionContext.UserSession == null)
            {
                return(null);
            }

            var logModel = new ActivityLogEditModel
            {
                Action        = activityType,
                UrlAccessed   = request.FilePath ?? string.Empty,
                ModelFullName = model.GetType().FullName,
                ModelName     = model.GetType().Name,
                RequestType   = request.RequestType,
                Timestamp     = DateTime.Now,
                UserLogId     = _sessionContext.UserSession.UserLoginLogId,
                AccessById    = _sessionContext.UserSession.CurrentOrganizationRole.OrganizationRoleUserId
            };

            return(logModel);
        }
Пример #12
0
        public Task LogDeleteActivity(ActivityLogEditModel activityLogEditModel, dynamic model, bool fromAPI = false)
        {
            return(Task.Run(() =>
            {
                var activityLogDomain = SaveActivityLogDomain(activityLogEditModel);

                if (model == null)
                {
                    return;
                }

                var type = (Type)model.GetType();
                if ((type.IsGenericType &&
                     (type.GetGenericTypeDefinition() == typeof(IEnumerable <>) ||
                      type.GetGenericTypeDefinition() == typeof(Dictionary <,>) ||
                      type.GetGenericTypeDefinition() == typeof(List <>))) || type.IsArray)
                {
                    var collection = (List <BsonDocument>)_reflectionFactory.ListProperty(model);
                    if (!collection.Any())
                    {
                        return;
                    }
                    var collectionToBeSaved = collection.Select(x => new LoggedCollectionModel
                    {
                        LogId = activityLogDomain.Id,
                        Model = x
                    }).ToList();

                    _repositoryLoggedCollectionModel.Save(collectionToBeSaved);
                }
                else
                {
                    SaveLoggedModel(model, fromAPI, activityLogDomain);
                }
            }));
        }