public string SaveEvalutionData(int year, Guid? TimesGetDataID, string orgStructureID, DateTime? _dateStart, DateTime? _dateEnd,string userLogin)
 {
     using (var context = new VnrHrmDataContext())
     {
         var evaServices = new Eva_ReportServices();
         List<Eva_EvalutionDataEntity> lstEvalutionDataEntity = new List<Eva_EvalutionDataEntity>();
         lstEvalutionDataEntity = evaServices.SummaryEvalutionData(year, TimesGetDataID, orgStructureID, _dateStart, _dateEnd,userLogin);
         var unitOfWork = (IUnitOfWork)new UnitOfWork(context);
         var repoEva_EvalutionData = new CustomBaseRepository<Eva_EvalutionData>(unitOfWork);
         List<Eva_EvalutionData> lstEvalutionData = new List<Eva_EvalutionData>();
         lstEvalutionData = lstEvalutionDataEntity.Translate<Eva_EvalutionData>();
         if (lstEvalutionData != null)
         {
             int _total = lstEvalutionData.Count;
             int _totalPage = _total / 200 + 1;
             int _pageSize = 200;
             for (int _page = 1; _page <= _totalPage; _page++)
             {
                 int _skip = _pageSize * (_page - 1);
                 var _listCurrenPage = lstEvalutionData.Skip(_skip).Take(_pageSize).ToList();
                 foreach (var item in _listCurrenPage)
                 {
                     repoEva_EvalutionData.Add(item);
                 }
                 unitOfWork.SaveChanges();
             }
         }
         return "SaveSuccess";
         //    #endregion
     }
 }  
Exemple #2
0
        public ActionResult GetReportHCSales([DataSourceRequest] DataSourceRequest request, Hre_ReportHCSalesModel model)
        {
            var service = new Hre_ReportServices();
            var eva_Service = new Eva_ReportServices();
            var hrService = new Hre_ProfileServices();

            //List<object> listObj = new List<object>();
            //listObj.Add(model.OrgStructureID);
            //listObj.Add(string.Empty);
            //listObj.Add(string.Empty);

            //string status = string.Empty;

            //var listEntity = hrService.GetData<Hre_ProfileIdEntity>(listObj, ConstantSql.hrm_hr_sp_get_ProfileIdsByOrgStructure, ref status).Select(s => s.ID).ToList();

            var result = eva_Service.GetReportHCSales(model.dateSearch, model.OrgStructureID, model.IsCreateTemplate, UserLogin);
            //var rs = result.Translate<Hre_ReportMonthlyHCModel>();

            HeaderInfo headerInfo1 = new HeaderInfo() { Name = "DateFrom", Value = DateTime.Now };
            HeaderInfo headerInfo2 = new HeaderInfo() { Name = "DateTo", Value = DateTime.Now };
            List<HeaderInfo> listHeaderInfo = new List<HeaderInfo>() { headerInfo1, headerInfo2 };
            object obj = new Hre_ReportHCSalesModel();
            var isDataTable = false;
            if (model.IsCreateTemplateForDynamicGrid)
            {
                var col = result.Columns.Count;
                result.Columns.RemoveAt(col - 1);
                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 = "Hre_ReportHCSalesModel",
                    OutPutPath = path,
                    DownloadPath = Hrm_Main_Web + "Templates",
                    IsDataTable = isDataTable
                };
                var str = exportService.CreateTemplate(cfgExport);
                return Json(str);
            }

            if (model.ExportID != Guid.Empty)
            {
                //var row = result.Rows.Count;
                // result.Rows[row - 1].Delete();
                var col = result.Columns.Count;
                result.Columns.RemoveAt(col - 1);

                var fullPath = ExportService.Export(model.ExportID, result, listHeaderInfo, model.ExportType);

                return Json(fullPath);
            }
            //0string dataReturn = result.ConvertDataTabletoString();
            return Json(result.ToDataSourceResult(request));
        }