Exemplo n.º 1
0
 /// <summary>
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Tra_TraineeModel GetById(Guid id)
 {
     string status = string.Empty;
     var model = new Tra_TraineeModel();
     ActionService service = new ActionService(UserLogin);
     var entity = service.GetByIdUseStore<Tra_TraineeEntity>(id,ConstantSql.hrm_tra_sp_get_TraineeById ,ref status);
     if (entity!=null)
     {
         model = entity.CopyData<Tra_TraineeModel>();
     }
     model.ActionStatus = status;
     return model;
 }
Exemplo n.º 2
0
        public ActionResult ExportTraineePassListByTemplate([DataSourceRequest] DataSourceRequest request, Tra_TraineeSearchModel model)
        {

            string status = string.Empty;
            var isDataTable = false;
            object obj = new Tra_TraineeModel();
            var result = GetListData<Tra_TraineeModel, Tra_TraineeEntity, Tra_TraineeSearchModel>(request, model, ConstantSql.hrm_tra_sp_get_TraineePass, ref status);
            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, result, null, model.ExportType);
                return Json(fullPath);
            }

            return Json(result.ToDataSourceResult(request));
        }
Exemplo n.º 3
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));
        }