コード例 #1
0
        public virtual void AddDataLogs(TDto dto, string actionType)
        {
            try
            {
                if (this.GenericService.GetOnDataLogs())
                {
                    SmartLogDTO.OnDataLogs = true;
                }
                else
                {
                    return;                                                                         // DO NOTHING
                }
                if (dto.EditedDate == null || ((DateTime)dto.EditedDate).Year == 1)
                {
                    dto.EditedDate = DateTime.Now;
                }

                List <string>       entityPropertyNames = typeof(TEntity).GetProperties().Select(s => s.Name).ToList();
                List <PropertyInfo> propertyInfos       = typeof(TDto).GetProperties().OrderBy(o => o.Name).ToList();
                foreach (PropertyInfo propertyInfo in propertyInfos)
                {
                    if (SmartLogDTO.CheckProperty(propertyInfo.PropertyType.Name, propertyInfo.Name))
                    {
                        if (!SmartLogDTO.OptionalNames.Contains(propertyInfo.Name) || entityPropertyNames.Contains(propertyInfo.Name))
                        {
                            this.GenericService.AddDataLogs(dto.GetID(), null, dto.EditedDate, dto.NMVNTaskID.ToString(), actionType, typeof(TDto).Name.Replace("DTO", ""), propertyInfo.Name, (propertyInfo.GetValue(dto) != null ? propertyInfo.GetValue(dto).ToString() : null));
                        }
                    }
                }
            }
            catch (Exception ex) { }
        }
コード例 #2
0
        public override void AddViewDetailDataLogs(TDto dto, string actionType)
        {
            try
            {
                base.AddViewDetailDataLogs(dto, actionType);
                if (!SmartLogDTO.OnDataLogs)
                {
                    return;                         // DO NOTHING: IMPORTANT: SmartLogDTO.OnDataLogs WILL BE CHECKED AND SET EVERY TIME CALL AddDataLogs. TO: SHOULD CALL AddDataLogs BEFORE CALL AddViewDetailDataLogs
                }
                List <string>       entityPropertyNames = typeof(TEntityDetail).GetProperties().Select(s => s.Name).ToList();
                List <PropertyInfo> propertyInfos       = typeof(TDtoDetail).GetProperties().OrderBy(o => o.Name).ToList();

                List <string> entityViewDetailPropertyNames = typeof(TEntityViewDetail).GetProperties().Select(s => s.Name).ToList(); //JUST ADD PROPERTIES RETURNED BY TEntityViewDetail

                if (dto.GetDetails() != null && dto.GetDetails().Count > 0)
                {
                    dto.GetDetails().Each(detailDTO =>
                    {
                        foreach (PropertyInfo propertyInfo in propertyInfos)
                        {
                            if (SmartLogDTO.CheckProperty(propertyInfo.PropertyType.Name, propertyInfo.Name))
                            {
                                if ((!SmartLogDTO.OptionalNames.Contains(propertyInfo.Name) || entityPropertyNames.Contains(propertyInfo.Name)) && entityViewDetailPropertyNames.Contains(propertyInfo.Name))
                                {
                                    this.genericWithViewDetailService.AddDataLogs(dto.GetID(), detailDTO.GetID(), dto.EditedDate, dto.NMVNTaskID.ToString(), actionType, typeof(TDtoDetail).Name.Replace("DTO", ""), propertyInfo.Name, (propertyInfo.GetValue(detailDTO) != null ? propertyInfo.GetValue(detailDTO).ToString() : null));
                                }
                            }
                        }
                    });
                }
            }
            catch (Exception ex) { throw ex; }
        }