public ActionResult Translate_App() { try { if (SessionData.CurrentUser == null) { return(Redirect("/")); } SessionData.CurrentUser.chashFile.Clear(); string pAppCode = ""; if (RouteData.Values.ContainsKey("id")) { pAppCode = RouteData.Values["id"].ToString().ToUpper(); } ViewBag.AppCode = pAppCode; App_Translate_BL _App_Translate_BL = new App_Translate_BL(); List <Sys_App_Translate_Info> _lst = _App_Translate_BL.Sys_App_Translate_GetBy_Casecode(pAppCode); foreach (var item in _lst) { item.TxtId = "txt" + item.Object_Name; } ViewBag.LstTranslate = _lst; decimal pAppHeaderId = 0; if (RouteData.Values.ContainsKey("id1")) { pAppHeaderId = Convert.ToDecimal(RouteData.Values["id1"].ToString()); } // lấy thông tin đã dịch ViewBag.App_Header_Id = pAppHeaderId; List <App_Translate_Info> _lst_translate = _App_Translate_BL.App_Translate_GetBy_AppId(pAppHeaderId); ViewBag.Lst_Translate_App = _lst_translate; // thông tin đơn DataSet _ds_detail = _App_Translate_BL.AppDetail_GetBy_Id(pAppCode, pAppHeaderId); ViewBag.Ds_detail = _ds_detail; if (_ds_detail != null && _ds_detail.Tables.Count > 0) { ApplicationHeaderInfo applicationHeaderInfo = CBO <ApplicationHeaderInfo> .FillObjectFromDataTable(_ds_detail.Tables[0]); ViewBag.objAppHeaderInfo = applicationHeaderInfo; } // thông tin class if (_ds_detail != null && _ds_detail.Tables.Count > 2) { List <App_Class_Info> app_Class_Infos = CBO <App_Class_Info> .FillCollectionFromDataTable(_ds_detail.Tables[2]); ViewBag.Lst_Class = app_Class_Infos; } // thông tin tài liệu khác if (_ds_detail != null && _ds_detail.Tables.Count > 3) { List <AppDocumentOthersInfo> app_Document_Others = CBO <AppDocumentOthersInfo> .FillCollectionFromDataTable(_ds_detail.Tables[3]); ViewBag.Document_Others = app_Document_Others; } return(PartialView("~/Areas/Manager/Views/Translate/Translate_App.cshtml")); } catch (Exception ex) { Logger.LogException(ex); return(View()); } }
public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate) { try { string language = AppsCommon.GetCurrentLang(); App_Detail_C01_BL objBL = new App_Detail_C01_BL(); ApplicationHeaderInfo applicationHeaderInfo = new ApplicationHeaderInfo(); App_Detail_C01_Info app_Detail = new App_Detail_C01_Info(); List <AppFeeFixInfo> appFeeFixInfos = new List <AppFeeFixInfo>(); List <AppDocumentInfo> appDocumentInfos = new List <AppDocumentInfo>(); List <AppDocumentOthersInfo> _LstDocumentOthersInfo = new List <AppDocumentOthersInfo>(); List <AppDocumentOthersInfo> pLstImagePublic = new List <AppDocumentOthersInfo>(); app_Detail = objBL.GetByID(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref appFeeFixInfos, ref _LstDocumentOthersInfo, ref pLstImagePublic); AppsCommon.Prepare_Data_Export_C01(ref app_Detail, applicationHeaderInfo, appDocumentInfos, pLstImagePublic); if (_LstDocumentOthersInfo != null) { foreach (var item in _LstDocumentOthersInfo) { app_Detail.Note += item.Documentname + " ; "; } if (_LstDocumentOthersInfo.Count > 0) { app_Detail.Note = app_Detail.Note.Substring(0, app_Detail.Note.Length - 2); } } List <App_Detail_C01_Info> _lst = new List <App_Detail_C01_Info>(); _lst.Add(app_Detail); DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_C01_Info>(_lst, false); CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm"); string _tempfile = "C01.rpt"; string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"); if (p_View_Translate == 1) { // nếu là tiếng việt thì xem bản tiếng anh và ngược lại if (applicationHeaderInfo.Languague_Code == Language.LangVI) { _tempfile = "C01_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"; } else { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"; } } else { if (applicationHeaderInfo.Languague_Code == Language.LangVI) { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_VN_" + _datetimenow + ".pdf"; } else { _tempfile = "C01_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C01_EN_" + _datetimenow + ".pdf"; } } oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile)); if (_ds_all != null) { _ds_all.Tables[0].TableName = "Table"; //_ds_all.WriteXml(@"C:\inetpub\C01.xml", XmlWriteMode.WriteSchema); // đè các bản dịch lên if (p_View_Translate == 1) { // nếu là bản xem của thằng dịch App_Translate_BL _App_Translate_BL = new App_Translate_BL(); List <App_Translate_Info> _lst_translate = _App_Translate_BL.App_Translate_GetBy_AppId(pAppHeaderId); AppsCommon.Overwrite_DataSouce_Export(ref _ds_all, _lst_translate); } oRpt.SetDataSource(_ds_all); } oRpt.Refresh(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); System.IO.Stream oStream = oRpt.ExportToStream(ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq return(Json(new { success = 0 })); } catch (Exception ex) { Logger.LogException(ex); return(Json(new { success = 0 })); } }
public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate) { try { string language = AppsCommon.GetCurrentLang(); ApplicationHeaderInfo applicationHeaderInfo = new ApplicationHeaderInfo(); App_Detail_PLC05_KN_Info app_Detail = new App_Detail_PLC05_KN_Info(); List <AppFeeFixInfo> appFeeFixInfos = new List <AppFeeFixInfo>(); List <AppDocumentInfo> appDocumentInfos = new List <AppDocumentInfo>(); App_Detail_PLC05_KN_BL objBL = new App_Detail_PLC05_KN_BL(); app_Detail = objBL.GetByID(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref appFeeFixInfos); string _fileTemp = System.Web.HttpContext.Current.Server.MapPath("/Content/AppForms/C05_VI.docx"); DocumentModel document = DocumentModel.Load(_fileTemp); // Fill export_header AppsCommon.Prepare_Data_Export_C05(ref app_Detail, applicationHeaderInfo, appDocumentInfos, appFeeFixInfos); List <App_Detail_PLC05_KN_Info> _lst = new List <App_Detail_PLC05_KN_Info>(); _lst.Add(app_Detail); DataSet _ds_all = ConvertData.ConvertToDataSet <App_Detail_PLC05_KN_Info>(_lst, false); CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument(); string _tempfile = "TM_PLC05_KN.rpt"; string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm"); string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C05_VN_" + _datetimenow + ".pdf"); if (p_View_Translate == 1) { // nếu là tiếng việt thì xem bản tiếng anh và ngược lại if (applicationHeaderInfo.Languague_Code == Language.LangVI) { _tempfile = "TM_PLC05_KN_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C05_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C05_EN_" + _datetimenow + ".pdf"; } else { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C05_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C05_VN_" + _datetimenow + ".pdf"; } } else { if (applicationHeaderInfo.Languague_Code == Language.LangVI) { fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C05_VN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C05_VN_" + _datetimenow + ".pdf"; } else { _tempfile = "TM_PLC05_KN_EN.rpt"; // tiếng anh fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "C05_EN_" + _datetimenow + ".pdf"); SessionData.CurrentUser.FilePreview = "/Content/Export/" + "C05_EN_" + _datetimenow + ".pdf"; } } oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile)); if (_ds_all != null) { _ds_all.Tables[0].TableName = "Table"; // đè các bản dịch lên if (p_View_Translate == 1) { // nếu là bản xem của thằng dịch App_Translate_BL _App_Translate_BL = new App_Translate_BL(); List <App_Translate_Info> _lst_translate = _App_Translate_BL.App_Translate_GetBy_AppId(pAppHeaderId); AppsCommon.Overwrite_DataSouce_Export(ref _ds_all, _lst_translate); } oRpt.Database.Tables["Table"].SetDataSource(_ds_all.Tables[0]); //oRpt.SetDataSource(_ds_all); } oRpt.Refresh(); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); System.IO.Stream oStream = oRpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); byte[] byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); System.IO.File.WriteAllBytes(fileName_pdf, byteArray.ToArray()); // Requires System.Linq return(Json(new { success = 0 })); } catch (Exception ex) { Logger.LogException(ex); return(Json(new { success = 0 })); } }