Ejemplo n.º 1
0
 // [HttpPost]
  public ActionResult ExportTraineeList([DataSourceRequest] DataSourceRequest request, Tra_TraineeSearchModel1 model)
  {
      return ExportAllAndReturn<Tra_TraineeEntity, Tra_TraineeModel, Tra_TraineeSearchModel1>(request, model, ConstantSql.hrm_tra_sp_get_Trainee);
  }
Ejemplo n.º 2
0
        public ActionResult ExportTraineeListByTemplate([DataSourceRequest] DataSourceRequest request, Tra_TraineeSearchModel1 model)
        {

            string status = string.Empty;
            var isDataTable = false;
            object obj = new Tra_TraineeModel();
            request.Page = 1;
            request.PageSize = int.MaxValue - 1;
            var result = GetListData<Tra_TraineeModel, Tra_TraineeEntity, Tra_TraineeSearchModel1>(request, model, ConstantSql.hrm_tra_sp_get_Trainee, ref status);
            //Guid[] classID = null;
            //if (!string.IsNullOrEmpty(model.ClassID.Value))
            //{
            //    classID = model.ClassID.Split(',').Select(s => Guid.Parse(s)).ToArray();
            //    if (classID != null)
            //    {
            //        result = result.Where(s => classID.Contains(s.ClassID)).ToList();
            //    }
            //}
            //Guid[] courseID = null;
            //if (!string.IsNullOrEmpty(model.CourseID.Value))
            //{
            //    courseID = model.CourseID.Split(',').Select(s => Guid.Parse(s)).ToArray();
            //    if (courseID != null)
            //    {
            //        result = result.Where(s => courseID.Contains(s.CourseID)).ToList();
            //    }
            //}
            //Guid[] RequirementTrainIDs = null;
            //if (!string.IsNullOrEmpty(model.RequirementTrainID))
            //{
            //    RequirementTrainIDs = model.RequirementTrainID.Split(',').Select(s => Guid.Parse(s)).ToArray();
            //    result = result.Where(s => s.RequirementTrainID != null && RequirementTrainIDs.Contains((Guid)s.RequirementTrainID)).ToList();
            //}
            var listModel = new List<Tra_TraineeModel>();
            var hreServiceProfile = new Hre_ProfileServices();
            var lstProfile = hreServiceProfile.GetProfileNameAll();
            foreach (var item in result)
            {
                if (item.TrainerOtherList != null)
                {
                    string _strTrainerOtherList = item.TrainerOtherList.Replace(" ", "");
                    string[] lstitem = _strTrainerOtherList.Split(',').ToArray();
                    if (lstProfile != null && lstitem != null)
                    {
                        List<Hre_ProfileEntity> lstitemprofile = lstProfile.Where(s => lstitem.Contains(s.CodeEmp)).ToList();
                        string Stringresult = string.Empty;
                        foreach (var itemstring in lstitemprofile)
                        {
                            Stringresult += itemstring.ProfileName + ", ";
                        }
                        if (!string.IsNullOrEmpty(Stringresult))
                        {
                            Stringresult = Stringresult.Substring(0, Stringresult.Length - 2);
                        }
                        item.TeacherName = Stringresult;
                    }
                }
                var newModle = (Tra_TraineeModel)typeof(Tra_TraineeModel).CreateInstance();
                foreach (var property in item.GetType().GetProperties())
                {
                    newModle.SetPropertyValue(property.Name, item.GetPropertyValue(property.Name));
                }
                
                listModel.Add(newModle);
            }
            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();
                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = new Tra_TraineeModel(),
                    FileName = "Tra_Trainee",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

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

            return Json(listModel.ToDataSourceResult(request));
        }
Ejemplo n.º 3
0
         public ActionResult GetTraineeList([DataSourceRequest] DataSourceRequest request, Tra_TraineeSearchModel1 model)
         {
             var services = new ActionService(UserLogin);
             var traineeServices = new Tra_TraineeServices();
             string status = string.Empty;
             var objTrainee = new List<object>();
             objTrainee.AddRange(new object[15]);
             objTrainee[0] = model.ClassID;
             objTrainee[1] = model.CodeEmp;
             objTrainee[2] = model.CourseID;
             objTrainee[3] = model.DateFrom;
             objTrainee[4] = model.DateTo;
             objTrainee[8] = model.OrgStructureID;
             objTrainee[9] = model.ProfileName;
             objTrainee[10] = model.Status;
             objTrainee[11] = model.RequirementTrainName;
             objTrainee[12] = null;
             objTrainee[13] = 1;
             objTrainee[14] = int.MaxValue - 1;
             var result = services.GetData<Tra_TraineeEntity>(objTrainee, ConstantSql.hrm_tra_sp_get_Trainee, ref status);
             
             if (model.RequirementTrainID != null)
             {
                List<Guid> _RequirementTrainIDs = model.RequirementTrainID.Split(',').Select(s => Guid.Parse(s)).ToList();
                result = traineeServices.GetListTrainees(result, _RequirementTrainIDs);
             }

             return Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
         }