Beispiel #1
0
        public async Task <PS_PaySubGroup> GetPaySubGroupRawAsync(int id, string asOf = null)
        {
            try {
                PS_PaySubGroup result = ObjectMapper.Map <PS_PaySubGroup, PS_PaySubGroup>(await Task.Run(() => Repository
                                                                                                         .Include(x => x.PayGroup)
                                                                                                         .Include(x => x.LegalEntity)
                                                                                                         .Include(x => x.Frequency)
                                                                                                         .Include(x => x.PayrollPeriod)
                                                                                                         .ThenInclude(x => x.PayPeriods)
                                                                                                         .Include(x => x.AllowedBanks)
                                                                                                         .First(x => x.Id == id)));

                if (asOf != null)
                {
                    DateTime            asOfDateTime = DateTime.Parse(asOf);
                    List <EntityChange> logs         = AuditLogsRepo.WithDetails().Where(x => x.EntityChanges != null && x.EntityChanges.Any(x => x.EntityId == id.ToString() && x.EntityTenantId == CurrentTenant.Id && x.ChangeTime >= asOfDateTime))
                                                       .SelectMany(x => x.EntityChanges.Where(y => y.EntityId == id.ToString() && y.EntityTenantId == CurrentTenant.Id)).ToList();

                    logs.Reverse();
                    for (int i = 0; i < logs.Count; i++)
                    {
                        EntityChange log = logs[i];
                        //log.ChangeType
                        for (int y = 0; y < log.PropertyChanges.Count; y++)
                        {
                            EntityPropertyChange propertyChange = log.PropertyChanges.ElementAt(y);
                            PropertyInfo         prop           = typeof(PS_PaySubGroup).GetProperty(propertyChange.PropertyName);
                            if (prop != null)
                            {
                                try
                                {
                                    prop.SetValue(result, propertyChange.OriginalValue);
                                }
                                catch (Exception ex)
                                {
                                }
                            }
                        }
                    }
                }
                return(result);
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #2
0
        public async Task <JsonResult> OnGetDataAuditTrail()
        {
            dynamic        result         = new ExpandoObject();
            List <dynamic> DS             = new List <dynamic>();
            List <dynamic> secondaryDS    = new List <dynamic>();
            List <dynamic> tertiaryDS     = new List <dynamic>();
            var            departmentLogs = AuditLogsRepo.WithDetails().Where(x => x.Url == HttpContext.Request.Path.Value && x.EntityChanges != null && x.EntityChanges.Count > 0).ToList();

            List <OS_DivisionTemplate_Dto> Entities = await OS_DivisionTemplateAppService.GetAllDivisionTemplatesAsync();

            TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

            for (int i = 0; i < departmentLogs.Count; i++)
            {
                AuditLog auditLog = departmentLogs[i];
                if (auditLog.EntityChanges == null || auditLog.EntityChanges.Count == 0)
                {
                    continue;
                }
                var entityChanges = auditLog.EntityChanges.ToList();
                for (int j = 0; j < entityChanges.Count; j++)
                {
                    EntityChange entityChange = entityChanges[j];

                    dynamic changeRow = new ExpandoObject();
                    changeRow.AuditLogId     = entityChange.Id;
                    changeRow.EntityChangeId = entityChange.Id;

                    OS_DivisionTemplate_Dto department = Entities.First(x => x.Id.ToString() == entityChange.EntityId);
                    changeRow.Id     = department.Id;
                    changeRow.Name   = department.Name;
                    changeRow.Date   = entityChange.ChangeTime.ToShortDateString();
                    changeRow.Time   = entityChange.ChangeTime.ToShortTimeString();
                    changeRow.User   = auditLog.UserName;
                    changeRow.Status = entityChange.ChangeType.GetDisplayName();

                    DS.Add(changeRow);

                    dynamic generalTypeRow = new ExpandoObject();
                    generalTypeRow.EntityChangeId = entityChange.Id;
                    generalTypeRow.TypeId         = 1;
                    generalTypeRow.Type           = "General";
                    generalTypeRow.Name           = "";
                    generalTypeRow.Status         = "Updated";

                    changeRow.Type = "General";
                    //changeRow.Name = "";
                    changeRow.ChangeStatus = "Updated";

                    secondaryDS.Add(generalTypeRow);

                    var generalPropertyChanges = entityChange.PropertyChanges.ToList();

                    for (int k = 0; k < generalPropertyChanges.Count; k++)
                    {
                        EntityPropertyChange propertyChange = generalPropertyChanges[k];
                        dynamic propertyChangeRow           = new ExpandoObject();
                        propertyChangeRow.TypeId         = 1;
                        propertyChangeRow.EntityChangeId = propertyChange.EntityChangeId;
                        propertyChangeRow.Field          = textInfo.ToTitleCase(propertyChange.PropertyName.ToSentenceCase());
                        propertyChangeRow.NewValue       = propertyChange.NewValue != "null" && propertyChange.NewValue != "\"\"" ? propertyChange.NewValue.TrimStart('"').TrimEnd('"') : "—";
                        propertyChangeRow.OriginalValue  = propertyChange.OriginalValue != "null" && propertyChange.OriginalValue != "\"\"" ? propertyChange.OriginalValue.TrimStart('"').TrimEnd('"') : "—";;

                        changeRow.Field         = textInfo.ToTitleCase(propertyChange.PropertyName.ToSentenceCase());
                        changeRow.NewValue      = propertyChange.NewValue != "null" && propertyChange.NewValue != "\"\"" ? propertyChange.NewValue.TrimStart('"').TrimEnd('"') : "—";
                        changeRow.OriginalValue = propertyChange.OriginalValue != "null" && propertyChange.OriginalValue != "\"\"" ? propertyChange.OriginalValue.TrimStart('"').TrimEnd('"') : "—";;

                        tertiaryDS.Add(propertyChangeRow);
                    }

                    //List<EmployeeExtraPropertyHistory> extraPropertyHistories = entityChange.GetProperty<List<EmployeeExtraPropertyHistory>>("extraPropertiesHistory");
                    //if (extraPropertyHistories != null && extraPropertyHistories.Count > 0)
                    //{
                    //    foreach (EmployeeExtraPropertyHistory extraPropertyHistory in extraPropertyHistories)
                    //    {
                    //        dynamic typeRow = new ExpandoObject();
                    //        typeRow.EntityChangeId = entityChange.Id;
                    //        typeRow.TypeId = extraPropertyHistory.TypeId;
                    //        typeRow.Type = extraPropertyHistory.Type;
                    //        typeRow.Name = extraPropertyHistory.Name;
                    //        typeRow.Status = extraPropertyHistory.Status;

                    //        secondaryDS.Add(typeRow);

                    //        var propertyChanges = extraPropertyHistory.PropertyChanges.ToList();

                    //        for (int k = 0; k < propertyChanges.Count; k++)
                    //        {
                    //            EmployeeTypePropertyChange propertyChange = propertyChanges[k];
                    //            dynamic propertyChangeRow = new ExpandoObject();
                    //            propertyChangeRow.TypeId = extraPropertyHistory.TypeId;
                    //            propertyChangeRow.EntityChangeId = typeRow.EntityChangeId;
                    //            propertyChangeRow.Field = textInfo.ToTitleCase(propertyChange.PropertyName.ToSentenceCase());
                    //            propertyChangeRow.NewValue = propertyChange.NewValue != "null" && propertyChange.NewValue != "\"\"" ? propertyChange.NewValue.TrimStart('"').TrimEnd('"') : "—";
                    //            propertyChangeRow.OriginalValue = propertyChange.OriginalValue != "null" && propertyChange.OriginalValue != "\"\"" ? propertyChange.OriginalValue.TrimStart('"').TrimEnd('"') : "—"; ;

                    //            tertiaryDS.Add(propertyChangeRow);
                    //        }
                    //    }
                    //}
                }
            }
            result.ds          = DS;
            result.secondaryDS = secondaryDS;
            result.tertiaryDS  = tertiaryDS;

            var secondaryGrid = new JsonResult(result);

            return(secondaryGrid);
        }
Beispiel #3
0
        public async Task <JsonResult> OnGetDataAuditTrail()
        {
            dynamic        result       = new ExpandoObject();
            List <dynamic> DS           = new List <dynamic>();
            List <dynamic> secondaryDS  = new List <dynamic>();
            List <dynamic> tertiaryDS   = new List <dynamic>();
            var            employeeLogs = AuditLogsRepo.WithDetails().Where(x => x.Url == "/HR/Employee" && x.EntityChanges != null && x.EntityChanges.Count > 0).ToList();

            //List<Employee_Dto> Employees = employeeAppService.GetAllEmployees();
            //TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;

            //for (int i = 0; i < employeeLogs.Count; i++)
            //{
            //    AuditLog auditLog = employeeLogs[i];
            //    if (auditLog.EntityChanges == null || auditLog.EntityChanges.Count == 0) continue;
            //    var entityChanges = auditLog.EntityChanges.ToList();
            //    for (int j = 0; j < entityChanges.Count; j++)
            //    {
            //        EntityChange entityChange = entityChanges[j];

            //        dynamic changeRow = new ExpandoObject();
            //        changeRow.AuditLogId = entityChange.Id;
            //        changeRow.EntityChangeId = entityChange.Id;

            //        Employee_Dto emp = Employees.First(x => x.Id.ToString() == entityChange.EntityId);
            //        changeRow.Id = emp.GetReferenceId;
            //        changeRow.EmpName = emp.Name;
            //        changeRow.Date = entityChange.ChangeTime.ToShortDateString();
            //        changeRow.Time = entityChange.ChangeTime.ToShortTimeString();
            //        changeRow.User = auditLog.UserName;
            //        changeRow.Status = entityChange.ChangeType.GetDisplayName();

            //        DS.Add(changeRow);

            //        dynamic generalTypeRow = new ExpandoObject();
            //        generalTypeRow.EntityChangeId = entityChange.Id;
            //        generalTypeRow.TypeId = 1;
            //        generalTypeRow.Type = "General";
            //        generalTypeRow.Name = "";
            //        generalTypeRow.Status = "Updated";

            //        secondaryDS.Add(generalTypeRow);

            //        var generalPropertyChanges = entityChange.PropertyChanges.ToList();

            //        for (int k = 0; k < generalPropertyChanges.Count; k++)
            //        {
            //            EntityPropertyChange propertyChange = generalPropertyChanges[k];
            //            dynamic propertyChangeRow = new ExpandoObject();
            //            propertyChangeRow.TypeId = 1;
            //            propertyChangeRow.EntityChangeId = propertyChange.EntityChangeId;
            //            propertyChangeRow.Field = textInfo.ToTitleCase(propertyChange.PropertyName.ToSentenceCase());
            //            propertyChangeRow.NewValue = propertyChange.NewValue != "null" && propertyChange.NewValue != "\"\""? propertyChange.NewValue.TrimStart('"').TrimEnd('"') : "—";
            //            propertyChangeRow.OriginalValue = propertyChange.OriginalValue != "null" && propertyChange.OriginalValue != "\"\"" ? propertyChange.OriginalValue.TrimStart('"').TrimEnd('"') : "—"; ;

            //            tertiaryDS.Add(propertyChangeRow);
            //        }

            //        List<EmployeeExtraPropertyHistory> extraPropertyHistories = entityChange.GetProperty<List<EmployeeExtraPropertyHistory>>("extraPropertiesHistory");
            //        if (extraPropertyHistories != null && extraPropertyHistories.Count > 0)
            //        {
            //            foreach (EmployeeExtraPropertyHistory extraPropertyHistory in extraPropertyHistories)
            //            {
            //                dynamic typeRow = new ExpandoObject();
            //                typeRow.EntityChangeId = entityChange.Id;
            //                typeRow.TypeId = extraPropertyHistory.TypeId;
            //                typeRow.Type = extraPropertyHistory.Type;
            //                typeRow.Name = extraPropertyHistory.Name;
            //                typeRow.Status = extraPropertyHistory.Status;

            //                secondaryDS.Add(typeRow);

            //                var propertyChanges = extraPropertyHistory.PropertyChanges.ToList();

            //                for (int k = 0; k < propertyChanges.Count; k++)
            //                {
            //                    EmployeeTypePropertyChange propertyChange = propertyChanges[k];
            //                    dynamic propertyChangeRow = new ExpandoObject();
            //                    propertyChangeRow.TypeId = extraPropertyHistory.TypeId;
            //                    propertyChangeRow.EntityChangeId = typeRow.EntityChangeId;
            //                    propertyChangeRow.Field = textInfo.ToTitleCase(propertyChange.PropertyName.ToSentenceCase());
            //                    propertyChangeRow.NewValue = propertyChange.NewValue != "null" && propertyChange.NewValue != "\"\"" ? propertyChange.NewValue.TrimStart('"').TrimEnd('"') : "—";
            //                    propertyChangeRow.OriginalValue = propertyChange.OriginalValue != "null" && propertyChange.OriginalValue != "\"\"" ? propertyChange.OriginalValue.TrimStart('"').TrimEnd('"') : "—"; ;

            //                    tertiaryDS.Add(propertyChangeRow);
            //                }
            //            }
            //        }
            //    }
            //}
            //result.ds = DS;
            //result.secondaryDS = secondaryDS;
            //result.tertiaryDS = tertiaryDS;

            //var secondaryGrid = new JsonResult(result);
            var secondaryGrid = new JsonResult(new { });

            return(secondaryGrid);
        }