Example #1
0
        public CredentialResultDTO Get(string id)
        {
            var p = fcpa.fcpa_CredentialInfo.Find(new Guid(id));

            Mapper.Initialize(m => m.CreateMap <fcpa_DistributorInfo, DistributorResultDTO>());
            return(new CredentialResultDTO
            {
                ID = p.ID,
                Distributor = Mapper.Map <fcpa_DistributorInfo, DistributorResultDTO>(p.fcpa_DistributorInfo),
                DistributorName = p.fcpa_DistributorInfo.DistributorName,
                Certificate = p.Certificate,
                Status = p.Status,
                Name = p.Name,
                Department = p.Department,
                Title = p.Title,
                CompletedDate = p.CompletedDate,
                OffWork = p.OffWork,
                OffWorkDate = p.OffWorkDate,
                Domain1 = p.Domain1,
                Domain2 = p.Domain2,
                Domain = p.Domain1 + "," + p.Domain2,
                UpdateDate = p.UpdateDate,
                ExpireDate = p.ExpireDate,
                Remark = p.Remark,
                StatusDesc = Const.Status(p.Status),
                OffWorkDesc = Const.Offwork(p.OffWork, p.OffWorkDate),
                DomainDesc = Const.Domain(p.Domain1, p.Domain2)
            });
        }
Example #2
0
        public PageableDTO <AlermResultDTO> Query(AlermSearchDTO q)
        {
            q.InitQuery("AlarmTime", false);
            var roles = q.Role.ToIntArray();
            var res   = fcpa.fcpa_AlarmInfo.Where(p =>
                                                  (string.IsNullOrEmpty(q.UserCode) ? true : p.fcpa_UserInfo.UserCode.Contains(q.UserCode)) &&
                                                  (string.IsNullOrEmpty(q.FullName) ? true : p.fcpa_UserInfo.FullName.Contains(q.FullName)) &&
                                                  (string.IsNullOrEmpty(q.PhoneNumber) ? true : p.fcpa_UserInfo.PhoneNumber.Contains(q.PhoneNumber)) &&
                                                  (string.IsNullOrEmpty(q.Email) ? true : p.fcpa_UserInfo.Email.Contains(q.Email)) &&
                                                  (q.Domain1.HasValue ? p.fcpa_UserInfo.Domain1 == q.Domain1 : true) &&
                                                  (q.Domain2.HasValue ? p.fcpa_UserInfo.Domain2 == q.Domain2 : true) &&
                                                  (string.IsNullOrEmpty(q.Role) ? true : roles.Any(a => p.fcpa_UserInfo.Role == a)) &&
                                                  (string.IsNullOrEmpty(q.RelDistributor) ? true : p.fcpa_UserInfo.RelDistributor.Contains(q.RelDistributor)) &&
                                                  (q.AlarmTimeFrom.HasValue ? p.AlarmTime >= q.AlarmTimeFrom : true) &&
                                                  (q.AlarmTimeTo.HasValue ? p.AlarmTime <= q.AlarmTimeTo : true)
                                                  ).Select(p => new AlermResultDTO
            {
                ID             = p.ID,
                UserCode       = p.fcpa_UserInfo.UserCode,
                FullName       = p.fcpa_UserInfo.FullName,
                PhoneNumber    = p.fcpa_UserInfo.PhoneNumber,
                Email          = p.fcpa_UserInfo.Email,
                Domain1        = p.fcpa_UserInfo.Domain1,
                Domain2        = p.fcpa_UserInfo.Domain2,
                Role           = p.fcpa_UserInfo.Role,
                RelDistributor = p.fcpa_UserInfo.RelDistributor,
                AlarmTime      = p.AlarmTime
            })
                        .ToPageable(q);

            res.rows.ForEach(p =>
            {
                p.RoleDesc           = Const.Role(p.Role);
                p.RelDistributorDesc = Const.RelDistributor(p.RelDistributor, fcpa);
                p.DomainDesc         = Const.Domain(p.Domain1, p.Domain2);
            });

            return(res);
        }
Example #3
0
        public PageableDTO <CredentialResultDTO> Query(FcpaSearchDTO q)
        {
            var token = q.UserInfo;

            q.InitQuery("ID");
            var status   = q.Status.ToIntArray();
            var offworks = q.OffWork.ToBoolArray();
            var areas    = q.Area.ToStringArray();

            q.UserDistributorIDs = string.Join(",", token.DistributorIDs);
            var queryable = fcpa.fcpa_CredentialInfo.Where(p =>
                                                           (string.IsNullOrEmpty(q.Status) ? true : status.Any(a => p.Status == a)) &&
                                                           (q.Year.HasValue ? p.UpdateDate.HasValue && p.UpdateDate.Value.Year == q.Year : true) &&
                                                           (q.Year.HasValue ? p.UpdateDate.HasValue && p.UpdateDate.Value.Year == q.Year : true) &&
                                                           (string.IsNullOrEmpty(q.Area) ? true : areas.Any(a => p.fcpa_DistributorInfo.AreaName == a)) &&
                                                           (string.IsNullOrEmpty(q.Region) ? true : p.fcpa_DistributorInfo.RegionName.Contains(q.Region)) &&
                                                           (string.IsNullOrEmpty(q.DistributorName) ? true : p.fcpa_DistributorInfo.DistributorName.Contains(q.DistributorName)) &&
                                                           (string.IsNullOrEmpty(q.Name) ? true : p.Name.Contains(q.Name)) &&
                                                           (string.IsNullOrEmpty(q.Department) ? true : p.Department.Contains(q.Department)) &&
                                                           (string.IsNullOrEmpty(q.Title) ? true : p.Title.Contains(q.Title)) &&
                                                           (q.CompletedDateFrom.HasValue ? p.CompletedDate >= q.CompletedDateFrom : true) &&
                                                           (q.CompletedDateTo.HasValue ? p.CompletedDate <= q.CompletedDateTo : true) &&
                                                           (q.UpdateDateFrom.HasValue ? p.UpdateDate >= q.UpdateDateFrom : true) &&
                                                           (q.UpdateDateTo.HasValue ? p.UpdateDate <= q.UpdateDateTo : true) &&
                                                           (string.IsNullOrEmpty(q.OffWork) ? true : offworks.Any(a => p.OffWork.HasValue && p.OffWork.Value == a)) &&
                                                           (q.Domain1.HasValue ? p.Domain1 == q.Domain1 : true) &&
                                                           (q.Domain2.HasValue ? p.Domain2 == q.Domain2 : true) &&
                                                           (string.IsNullOrEmpty(q.Remark) ? true : p.Remark.Contains(q.Remark))
                                                           )
                            .Where(p => token.Role == 0 ? true : q.UserDistributorIDs.Contains(p.fcpa_DistributorInfo.DistributorID))
                            .Where(p => string.IsNullOrEmpty(q.DistributorID) ? true : q.DistributorID.Contains(p.fcpa_DistributorInfo.DistributorID));
            var res = queryable.ToPageable(q);

            Mapper.Initialize(m => m.CreateMap <fcpa_DistributorInfo, DistributorResultDTO>());
            var resultList = res.rows.Select(p => new CredentialResultDTO
            {
                ID              = p.ID,
                Distributor     = Mapper.Map <fcpa_DistributorInfo, DistributorResultDTO>(p.fcpa_DistributorInfo),
                DistributorName = p.fcpa_DistributorInfo.DistributorName,
                Certificate     = p.Certificate,
                Status          = p.Status,
                Name            = p.Name,
                Department      = p.Department,
                Title           = p.Title,
                CompletedDate   = p.CompletedDate,
                OffWork         = p.OffWork,
                OffWorkDate     = p.OffWorkDate,
                Domain1         = p.Domain1,
                Domain2         = p.Domain2,
                Domain          = p.Domain1 + "," + p.Domain2,
                UpdateDate      = p.UpdateDate,
                ExpireDate      = p.ExpireDate,
                Remark          = p.Remark,
                StatusDesc      = Const.Status(p.Status),
                OffWorkDesc     = Const.Offwork(p.OffWork, p.OffWorkDate),
                DomainDesc      = Const.Domain(p.Domain1, p.Domain2)
            }).ToList();

            return(new PageableDTO <CredentialResultDTO>
            {
                rows = resultList,
                total = res.total
            });
        }