Exemplo n.º 1
0
        public ActionResult Query(FcpaSearchDTO dto)
        {
            UserLoginDTO lng = Session["UserLoginInfo"] as UserLoginDTO;

            dto.UserInfo = lng.UserInfo();
            var result = FcpaProvider.Query(dto);

            return(new JsonResult(result));
        }
Exemplo n.º 2
0
        public ActionResult Export(FcpaSearchDTO dto)
        {
            dto.rows = int.MaxValue;
            dto.page = 1;
            UserLoginDTO lng = Session["UserLoginInfo"] as UserLoginDTO;

            dto.UserInfo = lng.UserInfo();
            var result = FcpaProvider.Query(dto);

            var headers = new List <ExcelHeaderModel>()
            {
                new ExcelHeaderModel {
                    Header = "经销商", PropertyName = "DistributorName", Width = 40
                },
                new ExcelHeaderModel {
                    Header = "姓名", PropertyName = "Name", Width = 15
                },
                new ExcelHeaderModel {
                    Header = "部门", PropertyName = "Department", Width = 15
                },
                new ExcelHeaderModel {
                    Header = "职位", PropertyName = "Title", Width = 15
                },
                new ExcelHeaderModel {
                    Header = "培训状态", PropertyName = "StatusDesc", Width = 10
                },
                new ExcelHeaderModel {
                    Header = "培训完成日期", PropertyName = "CompletedDate", Width = 22
                },
                new ExcelHeaderModel {
                    Header = "在职状态", PropertyName = "OffWorkDesc", Width = 22
                },
                new ExcelHeaderModel {
                    Header = "所属领域", PropertyName = "DomainDesc", Width = 22
                },
                new ExcelHeaderModel {
                    Header = "更新日期", PropertyName = "UpdateDate", Width = 22
                },
                new ExcelHeaderModel {
                    Header = "过期日期", PropertyName = "ExpireDate", Width = 10
                },
                new ExcelHeaderModel {
                    Header = "备注", PropertyName = "Remark", Width = 10
                }
            };
            var buffer = result.rows.ToExcel(headers);

            return(File(buffer, "application/vnd.ms-excel", string.Format("FCPA Training Record List({0}).xlsx", DateTime.Now.ToString("yyyyMMddHHmmss"))));
        }
Exemplo n.º 3
0
 public static PageableDTO <CredentialResultDTO> Query(FcpaSearchDTO dto)
 {
     return(PostAPI <PageableDTO <CredentialResultDTO> >(WebConfiger.FcpaServicesUrl + "Credentials/Query", dto));
 }
Exemplo n.º 4
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
            });
        }
Exemplo n.º 5
0
 public PageableDTO <CredentialResultDTO> Query(FcpaSearchDTO q)
 {
     return(_FcpaService.Query(q));
 }