Exemple #1
0
        public ActionResult ExportCourseListByTemplate([DataSourceRequest] DataSourceRequest request, Tra_CourseSearchModel model)
        {
            string status = string.Empty;
            var isDataTable = false;
            object obj = new Tra_CourseModel();
            var result = GetListData<Tra_CourseModel, Tra_CourseEntity, Tra_CourseSearchModel>(request, model, ConstantSql.hrm_tra_sp_get_Course, ref status);



            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Tra_CourseModel(),
                    FileName = "Tra_Course",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            var courseServices = new ActionService(UserLogin);
            var objCourse = new List<object>();
            objCourse.AddRange(new object[11]);
            objCourse[9] = 1;
            objCourse[10] = int.MaxValue - 1;
            var lstCourse = courseServices.GetData<Tra_CourseEntity>(objCourse, ConstantSql.hrm_tra_sp_get_Course, ref status).ToList();
            var orgServices = new ActionService(UserLogin);
            var objOrg = new List<object>();
            objOrg.AddRange(new object[5]);
            objOrg[3] = 1;
            objOrg[4] = int.MaxValue - 1;
            var lstOrg = orgServices.GetData<Cat_OrgStructureEntity>(objOrg, ConstantSql.hrm_cat_sp_get_OrgStructure, ref status).ToList();

            var jobTitleServices = new ActionService(UserLogin);
            var objJobtitle = new List<object>();
            objJobtitle.AddRange(new object[5]);
            objJobtitle[3] = 1;
            objJobtitle[4] = int.MaxValue - 1;
            var lstJobTitle = jobTitleServices.GetData<Cat_JobTitleEntity>(objJobtitle, ConstantSql.hrm_cat_sp_get_JobTitle, ref status).ToList();



            var lstResult = new List<Tra_CourseModel>();
            foreach (var item in result)
            {
                int[] orgForTrainee = new int[1];
                int[] orgForTrainer = new int[1];
                string[] jobTitleForTrainee = new string[1];
                string[] jobTitleForTrainer = new string[1];
                string[] courseForTrainee = new string[1];
                string[] courseForTrainer = new string[1];

                if (!string.IsNullOrEmpty(item.OrgListCode1))
                {
                    if (item.OrgListCode1.IndexOf(',') != -1)
                    {
                        orgForTrainee = item.OrgListCode1.Split(',').Select(s => int.Parse(s)).ToArray();
                    }
                    else
                    {
                        orgForTrainee[0] = int.Parse(item.OrgListCode1);
                    }

                }

                var lstOrgForTrainee = lstOrg.Where(s => orgForTrainee.Contains(s.OrderNumber)).ToList();
                item.OrgStructureNameForTrainee = string.Join(",", lstOrgForTrainee.Select(s => s.OrgStructureName));
                item.OrgStructureCodeForTrainee = string.Join(",", lstOrgForTrainee.Select(s => s.Code));

                if (!string.IsNullOrEmpty(item.JobTitleListCode1))
                {
                    if (item.JobTitleListCode1.IndexOf(',') != -1)
                    {
                        jobTitleForTrainee = item.JobTitleListCode1.Split(',').ToArray();
                    }
                    else
                    {
                        jobTitleForTrainee[0] = item.JobTitleListCode1;
                    }
                }

                var lstJobTitleForTrainee = lstJobTitle.Where(s => jobTitleForTrainee.Contains(s.Code)).ToList();
                item.JobTileNameForTrainee = string.Join(",", lstJobTitleForTrainee.Select(s => s.JobTitleName));

                if (!string.IsNullOrEmpty(item.CourseListID))
                {
                    if (item.CourseListID.IndexOf(',') != -1)
                    {
                        courseForTrainee = item.CourseListID.Split(',').ToArray();
                    }
                    else
                    {
                        courseForTrainee[0] = item.CourseListID;
                    }
                }
                var lstCourseForTrainee = lstCourse.Where(s => courseForTrainee.Contains(s.Code)).ToList();
                item.CourseNameForTrainee = string.Join(",", lstCourseForTrainee.Select(s => s.CourseName));

                if (!string.IsNullOrEmpty(item.OrgListTrainerCode))
                {
                    if (item.OrgListTrainerCode.IndexOf(',') != -1)
                    {
                        orgForTrainer = item.OrgListTrainerCode.Split(',').Select(s => int.Parse(s)).ToArray();
                    }
                    else
                    {
                        orgForTrainer[0] = int.Parse(item.OrgListTrainerCode);
                    }
                }
                var lstOrgForTrainer = lstOrg.Where(s => orgForTrainer.Contains(s.OrderNumber)).ToList();
                item.OrgStructureNameForTrainer = string.Join(",", lstOrgForTrainer.Select(s => s.OrgStructureName));
                item.OrgStructureCodeForTrainer = string.Join(",", lstOrgForTrainer.Select(s => s.Code));

                if (!string.IsNullOrEmpty(item.JobTitleListTrainerCode))
                {
                    if (item.JobTitleListTrainerCode.IndexOf(',') != -1)
                    {
                        jobTitleForTrainer = item.JobTitleListTrainerCode.Split(',').ToArray();
                    }
                    else
                    {
                        jobTitleForTrainer[0] = item.JobTitleListTrainerCode;
                    }
                }
                var lstJobTitleForTrainer = lstJobTitle.Where(s => jobTitleForTrainer.Contains(s.Code)).ToList();
                item.JobTileNameForTrainer = string.Join(",", lstJobTitleForTrainer.Select(s => s.JobTitleName));

                if (!string.IsNullOrEmpty(item.CourseListTrainerID))
                {
                    if (item.CourseListTrainerID.IndexOf(',') != -1)
                    {
                        courseForTrainer = item.CourseListTrainerID.Split(',').ToArray();
                    }
                    else
                    {
                        courseForTrainer[0] = item.CourseListTrainerID;
                    }
                }
                var lstCourseForTrainer = lstCourse.Where(s => courseForTrainer.Contains(s.Code)).ToList();
                item.CourseNameForTrainer = string.Join(",", lstCourseForTrainer.Select(s => s.CourseName));

                lstResult.Add(item);

            }



            if (model.ExportId != Guid.Empty)
            {
                var fullPath = ExportService.Export(model.ExportId, lstResult, null, model.ExportType);
                return Json(fullPath);
            }

            return Json(result.ToDataSourceResult(request));



        }
Exemple #2
0
        public ActionResult GetCourseList([DataSourceRequest] DataSourceRequest request, Tra_CourseSearchModel model)
        {
            return GetListDataAndReturn<Tra_CourseModel, Tra_CourseEntity, Tra_CourseSearchModel>(request, model, ConstantSql.hrm_tra_sp_get_Course);

        }