Exemplo n.º 1
0
        public ActionResult GetReportTraineeJoinCoursePass([DataSourceRequest] DataSourceRequest request, Tra_ReportTraineeJoinCourseModel model)
        {

            string status = string.Empty;

            Tra_ReportServices service = new Tra_ReportServices();
            Cat_PayrollGroupServices payrollGroupServices = new Cat_PayrollGroupServices();
            ActionService service1 = new ActionService(UserLogin);
            var hrService = new Hre_ProfileServices();
            Guid[] _RankIDs = null;
            if (model.RankID != null)
                _RankIDs = model.RankID.Split(',').Select(s => Guid.Parse(s)).ToArray();
            Guid[] _CourseIDs = null;
            if (model.CourseID != null)
                _CourseIDs = model.CourseID.Split(',').Select(s => Guid.Parse(s)).ToArray();
            Guid[] _RequirementTrainIDs = null;
            if (model.RequirementTrainID != null)
            {
                _RequirementTrainIDs = model.RequirementTrainID.Split(',').Select(s => Guid.Parse(s)).ToArray();
            }

            //List<object> strOrgIDs = new List<object>();
            //strOrgIDs.AddRange(new object[3]);
            //strOrgIDs[0] = (object)model.OrgStructureID;

            //List<Guid> lstProfileIDs = hrService.GetData<Hre_ProfileIdEntity>(strOrgIDs, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status).Select(s => s.ID).ToList();

            DataTable result = service.GetReportTraineeJoinCoursePass(_CourseIDs, model.OrgStructureID, model.IsCreateTemplate, _RequirementTrainIDs, UserLogin);
            //HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = model.DateFrom };
            //HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = model.DateTo };
            //List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };

            #region Xử lý cách export mới
            var isDataTable = false;
            DataTable obj = null;
            if (model.IsCreateTemplateForDynamicGrid)
            {

                obj = result;
                isDataTable = true;
            }

            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = obj,
                    FileName = "Tra_ReportTraineeJoinCourseEntity",
                    OutPutPath = path,
                    // HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            #endregion
            if (model.ExportId != Guid.Empty)
            {
                var col = result.Columns.Count;
                result.Columns.RemoveAt(col - 1);

                var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);

                return Json(fullPath);
            }
            return Json(result.ToDataSourceResult(request));

        }
Exemplo n.º 2
0
        public ActionResult GetReportTraineeJoinCourse([DataSourceRequest] DataSourceRequest request, Tra_ReportTraineeJoinCourseModel model)
        {

            string status = string.Empty;

            Tra_ReportServices service = new Tra_ReportServices();
            Cat_PayrollGroupServices payrollGroupServices = new Cat_PayrollGroupServices();
            ActionService service1 = new ActionService(UserLogin);
            var hrService = new Hre_ProfileServices();
            Guid[] _RankIDs = null;
            if (model.RankID != null)
                _RankIDs = model.RankID.Split(',').Select(s => Guid.Parse(s)).ToArray();
            string[] _CourseIDs = null;
            if (model.CourseID != null)
                _CourseIDs = model.CourseID.Split(',').ToArray();


            List<object> strOrgIDs = new List<object>();
            strOrgIDs.AddRange(new object[3]);
            strOrgIDs[0] = (object)model.OrgStructureID;

           // List<Guid> lstProfileIDs = hrService.GetData<Hre_ProfileIdEntity>(strOrgIDs, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrg, ref status).Select(s => s.ID).ToList();

            DataTable result = service.GetReportTraineeJoinCourse(_RankIDs, _CourseIDs, model.OrgStructureID, model.IsCreateTemplate, model.DateSeniory, UserLogin);

            #region Xử lý cách export mới
            var isDataTable = false;
            DataTable obj = null;
            if (model.IsCreateTemplateForDynamicGrid)
            {

                obj = result;
                isDataTable = true;
            }

            if (model != null && model.IsCreateTemplate)
            {
                var path = Common.GetPath("Templates");
                ExportService exportService = new ExportService();

                ConfigExport cfgExport = new ConfigExport()
                {
                    Object = obj,
                    FileName = "Tra_ReportTraineeJoinCourseEntity",
                    OutPutPath = path,
                    //     HeaderInfo = listHeaderInfo,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            #endregion
            if (model.ExportId != Guid.Empty)
            {
                var col = result.Columns.Count;
                result.Columns.RemoveAt(col - 1);

                var fullPath = ExportService.Export(model.ExportId, result, null, model.ExportType);

                return Json(fullPath);
            }
            if (model.IsAllPage)
            {
                string strCodeEmp = "";
                foreach (DataRow item in result.Rows)
                {
                    strCodeEmp += item[Tra_ReportTraineeJoinCourseEntity.FieldNames.CodeEmp] + ",";
                }
                return Json(strCodeEmp, JsonRequestBehavior.AllowGet);
                //ViewBag.checkAll = strCodeEmp;
            }
            return new JsonResult() { Data = result.ToDataSourceResult(request), MaxJsonLength = Int32.MaxValue, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
            //    return Json(result.ToDataSourceResult(request));

        }