Ejemplo n.º 1
0
        //TODO: Uncomment the Following Code To Enable AuditLog Repository

        public IList <AuditLogsExt> searchResult(string _SdateFrom, string _SdateTo, string _Action, string _UserID)
        {
            DateTime dateFrom = DateTime.Now;
            DateTime dateTo   = DateTime.Now;
            long?    UserID   = null;

            SecurityUtils.ConvertToDateTime(_SdateFrom, ref dateFrom);
            SecurityUtils.ConvertToDateTime(_SdateTo, ref dateTo);
            UserID = SecurityUtils.ConvertToLongOrNull(_UserID);

            var logs =
                (from product in db.AuditLogs

                 join u in db.Users on product.UserID equals u.UserID into subMembers
                 from uMembers in subMembers.DefaultIfEmpty()

                 where

                 ((_SdateFrom == "" && _SdateFrom != null) || product.LogDate >= dateFrom) &&
                 ((_SdateTo == "" && _SdateTo != null) || product.LogDate <= dateTo) &&
                 ((_Action == "" && _Action != null) || product.AuditLogShortDesc.Contains(_Action)) &&
                 (UserID == null || product.UserID == UserID)
                 orderby product.LogDate descending
                 select new AuditLogsExt
            {
                AuditLogID = product.AuditLogID,
                LogDate = product.LogDate,
                UserID = product.UserID,
                Username = (uMembers == null ? string.Empty : uMembers.FullName),
                AuditLogShortDesc = product.AuditLogShortDesc,
                AuditLogLongDesc = product.AuditLogLongDesc
            });

            return(logs.ToList <AuditLogsExt>());
        }