예제 #1
0
 public DataTable GetReportClass(List<Tra_ClassEntity> lstClass, Guid? _classID, bool isCreateTemplate)
 {
     using (var context = new VnrHrmDataContext())
     {
         string status = string.Empty;
         var unitOfWork = (UnitOfWork)(new UnitOfWork(context));
         DataTable table = CreateReportClassScheme();
         if (isCreateTemplate)
             return table;
         if (lstClass == null)
             return table;
         if (_classID != null)
             lstClass = lstClass.Where(s => s.ID == _classID).ToList();
         if (lstClass.Count == 0)
             return table;
         List<object> paraProfile = new List<object>();
         paraProfile.AddRange(new object[17]);
         paraProfile[15] = 1;
         paraProfile[16] = int.MaxValue - 1;
         var hreServiceProfile = new Hre_ProfileServices();
         //var lstProfile = hreServiceProfile.GetData<Hre_ProfileEntity>(paraProfile, ConstantSql.hrm_hr_sp_get_ProfileAll, ref status);
         var lstProfile = hreServiceProfile.GetProfileNameAll();
         foreach (var item in lstClass)
         {
             string _teacher = string.Empty;
             if (item.TrainerOtherList != null)
             {
                 string[] arrCodeEmps = item.TrainerOtherList.ToString().Split(',');
                 for (int i = 0; i < arrCodeEmps.Length; i++)
                 {
                     var objprofile = lstProfile.Where(s => s.CodeEmp == arrCodeEmps[i]).FirstOrDefault();
                     if (objprofile != null && objprofile.ProfileName != null)
                         _teacher += objprofile.ProfileName + ", ";
                 }
                 _teacher = _teacher.Substring(0, _teacher.Length - 2);
             }
             DataRow row = table.NewRow();
             if (item.Code != null)
                 row[Tra_ReportClassEntity.FieldNames.Code] = item.Code;
             if (item.ClassName != null)
                 row[Tra_ReportClassEntity.FieldNames.ClassName] = item.ClassName;
             if (item.StartDate != null)
                 row[Tra_ReportClassEntity.FieldNames.StartDate] = item.StartDate;
             if (item.EndDate != null)
                 row[Tra_ReportClassEntity.FieldNames.EndDate] = item.EndDate;
             if (item.ScheduleTimeStart != null)
                 row[Tra_ReportClassEntity.FieldNames.ScheduleTimeStart] = item.ScheduleTimeStart;
             if (item.ScheduleTimeEnd != null)
                 row[Tra_ReportClassEntity.FieldNames.ScheduleTimeEnd] = item.ScheduleTimeEnd;
             if (item.TrainingPlace != null)
                 row[Tra_ReportClassEntity.FieldNames.TrainingPlace] = item.TrainingPlace;
             if (item.TrainerOtherList != null)
                 row[Tra_ReportClassEntity.FieldNames.Teacher] = _teacher;
             table.Rows.Add(row);
         }
         return table.ConfigTable(true);
     }
 }
예제 #2
0
        public ActionResult GetClassList([DataSourceRequest] DataSourceRequest request, Tra_ClassSearchModel model)
        {
            var services = new ActionService(UserLogin);
            var traineeServices = new Tra_TraineeServices();
            var objTrainee = new List<object>();
            string status = string.Empty;
            var service = new ActionService(UserLogin);
            Guid[] _RequirementTrainIDs=null;
            if (!string.IsNullOrEmpty(model.RequirementTrainID))
            {
                _RequirementTrainIDs = model.RequirementTrainID.Split(',').Select(s => Guid.Parse(s)).ToArray();
            }
            ListQueryModel lstModel = new ListQueryModel
            {
                PageIndex = request.Page,
                PageSize = request.PageSize,
                Filters = ExtractFilterAttributes(request),
                Sorts = ExtractSortAttributes(request),
                AdvanceFilters = ExtractAdvanceFilterAttributes(model)
            };
            //List<object> paraprofile = new List<object>();
            //paraprofile.AddRange(new object[17]);
            //paraprofile[15] = 1;
            //paraprofile[16] = int.MaxValue - 1;
            //var lstProfile = service.GetData<Hre_ProfileEntity>(paraprofile, ConstantSql.hrm_hr_sp_get_ProfileAll, ref status);

            var hreServiceProfile = new Hre_ProfileServices();
            var lstProfile = hreServiceProfile.GetProfileNameAll();

            var listEntity = service.GetData<Tra_ClassEntity>(lstModel, ConstantSql.hrm_tra_sp_get_Class, ref status);
            
            
            if (_RequirementTrainIDs != null)
            {
                List<object> paraprofile = new List<object>();
                paraprofile.AddRange(new object[7]);
                paraprofile[5] = 1;
                paraprofile[6] = int.MaxValue - 1;
                var ListRequirementTrain = service.GetData<Tra_RequirementTrainEntity>(paraprofile, ConstantSql.hrm_tra_sp_get_RequirementTrain, ref status);
               // var _lstRequirementTrainByPlanID = new List<Guid>();
              //  _lstRequirementTrainByPlanID = ListRequirementTrain.Where(s => s.ID != null && _RequirementTrainIDs.Contains(s.ID)).Select(s => (Guid)s.PlanID).ToList();
                var result = services.GetData<Tra_TraineeEntity>(objTrainee, ConstantSql.hrm_tra_sp_get_Trainee, ref status);
                List<Guid> _RequirementTrainIDs1 = model.RequirementTrainID.Split(',').Select(s => Guid.Parse(s)).ToList();
                result = traineeServices.GetListTrainees(result, _RequirementTrainIDs1);
                //if (listEntity != null)
                //{
                //    listEntity = listEntity.Where(s => s.PlanID != null && _lstRequirementTrainByPlanID.Contains((Guid)s.PlanID)).ToList();
                //}
                return Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
               
            }
            var listModel = new List<Tra_ClassModel>();
            if (listEntity != null)
            {
                request.Page = 1;
                foreach (var item in listEntity)
                {
                    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_ClassModel)typeof(Tra_ClassModel).CreateInstance();
                    foreach (var property in item.GetType().GetProperties())
                    {
                        newModle.SetPropertyValue(property.Name, item.GetPropertyValue(property.Name));
                    }
                    listModel.Add(newModle);
                }
                var dataSourceResult = listModel.ToDataSourceResult(request);
                if (listModel.FirstOrDefault().GetPropertyValue("TotalRow") != null)
                {
                    dataSourceResult.Total = listModel.Count() <= 0 ? 0 : (int)listModel.FirstOrDefault().GetPropertyValue("TotalRow");
                }
                return Json(dataSourceResult, JsonRequestBehavior.AllowGet);
            }
            var listModelNull = new List<Tra_ClassModel>();
            ModelState.AddModelError("Id", status);
            return Json(listModelNull.ToDataSourceResult(request, ModelState));

            //return GetListDataAndReturn<Tra_ClassModel, Tra_ClassEntity, Tra_ClassSearchModel>(request, model, ConstantSql.hrm_tra_sp_get_Class);
        }
예제 #3
0
 public ActionResult ExportClassSelected(string selectedIds, string valueFields)
 {
     //return ExportSelectedAndReturn<Tra_ClassEntity, Tra_ClassModel>(selectedIds, valueFields, ConstantSql.hrm_tra_sp_get_ClassByIds);
     selectedIds = Common.DotNetToOracle(selectedIds);
     var service = new ActionService(UserLogin);
     var status = string.Empty;
     var listModel = new List<Tra_ClassModel>();
     var listEntity = service.GetData<Tra_ClassEntity>(selectedIds, ConstantSql.hrm_tra_sp_get_ClassByIds, ref status);
     if (listEntity != null && status == NotificationType.Success.ToString())
     {
         var hreServiceProfile = new Hre_ProfileServices();
         var lstProfile = hreServiceProfile.GetProfileNameAll();
         foreach (var item in listEntity)
         {
             if (item.TrainerOtherList != null)
             {
                 string[] lstitem = item.TrainerOtherList.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 + ',';
                     }
                     Stringresult = Stringresult.Substring(0, Stringresult.Length - 1);
                     item.TeacherName = Stringresult;
                 }
             }
             var newModle = (Tra_ClassModel)typeof(Tra_ClassModel).CreateInstance();
             foreach (var property in item.GetType().GetProperties())
             {
                 newModle.SetPropertyValue(property.Name, item.GetPropertyValue(property.Name));
             }
             listModel.Add(newModle);
         }
     //    listModel = listEntity.Translate<Tra_ClassModel>();
         Guid _templateID = Guid.Empty;
         status = ExportService.Export(_templateID, listModel, valueFields.Split(','), null);
     }
     return Json(status);
 }
예제 #4
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));
        }