Exemple #1
0
        public B03_Info_Export GetByID_Exp(decimal p_app_header_id, string p_language_code,
                                           ref ApplicationHeaderInfo applicationHeaderInfo,
                                           ref List <AppDocumentInfo> appDocumentInfos, ref List <AppFeeFixInfo> appFeeFixInfos)
        {
            try
            {
                B03_DA          _obj_da   = new B03_DA();
                DataSet         dataSet   = _obj_da.GetByID(p_app_header_id, p_language_code);
                B03_Info_Export _b03_Info = CBO <B03_Info_Export> .FillObjectFromDataSet(dataSet);

                if (dataSet != null && dataSet.Tables.Count == 4)
                {
                    applicationHeaderInfo = CBO <ApplicationHeaderInfo> .FillObjectFromDataTable(dataSet.Tables[1]);

                    appDocumentInfos = CBO <AppDocumentInfo> .FillCollectionFromDataTable(dataSet.Tables[2]);

                    appFeeFixInfos = CBO <AppFeeFixInfo> .FillCollectionFromDataTable(dataSet.Tables[3]);
                }

                return(_b03_Info);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex);
                return(new B03_Info_Export());
            }
        }
Exemple #2
0
        public ActionResult ExportData_View_IU(ApplicationHeaderInfo pInfo, B03_Info pDetail,
                                               List <AppDocumentInfo> pAppDocumentInfo, List <AppFeeFixInfo> pFeeFixInfo)
        {
            try
            {
                string _datetimenow         = DateTime.Now.ToString("ddMMyyyyHHmm");
                string language             = AppsCommon.GetCurrentLang();
                var    objBL                = new B03_BL();
                List <B03_Info_Export> _lst = new List <B03_Info_Export>();

                string p_appCode    = "B03_Preview";
                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B03_VN_" + _datetimenow + ".pdf");
                if (language == Language.LangVI)
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B03_VN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "B03_VN_" + _datetimenow + ".pdf";
                }
                else
                {
                    fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B03_EN_" + _datetimenow + ".pdf");
                    SessionData.CurrentUser.FilePreview = "/Content/Export/" + "B03_EN_" + _datetimenow + ".pdf";
                }

                B03_Info_Export _A01_Info_Export = new B03_Info_Export();
                B03_Info_Export.CopyB03_Info(ref _A01_Info_Export, pDetail);


                // Phí cố định
                List <AppFeeFixInfo> _lstFeeFix = Call_Fee.CallFee_B03(pDetail, pAppDocumentInfo);
                AppsCommon.Prepare_Data_Export_B03(ref _A01_Info_Export, pInfo, pAppDocumentInfo, _lstFeeFix);

                _lst.Add(_A01_Info_Export);
                DataSet _ds_all = ConvertData.ConvertToDataSet <B03_Info_Export>(_lst, false);
                //_ds_all.WriteXml(@"C:\inetpub\A01.xml", XmlWriteMode.WriteSchema);
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();

                string _tempfile = "B03.rpt";
                if (language == Language.LangEN)
                {
                    _tempfile = "B03_EN.rpt";
                }
                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table1";
                    oRpt.SetDataSource(_ds_all);
                }
                oRpt.Refresh();

                Response.Buffer = false;
                Response.ClearContent();
                Response.ClearHeaders();

                //oRpt.ExportToDisk(ExportFormatType.PortableDocFormat, fileName_pdf);

                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 }));
            }
        }
Exemple #3
0
        public ActionResult ExportData_View(decimal pAppHeaderId, string p_appCode, decimal p_View_Translate)
        {
            try
            {
                string _datetimenow = DateTime.Now.ToString("ddMMyyyyHHmm");
                string language     = AppsCommon.GetCurrentLang();

                var objBL = new B03_BL();
                List <B03_Info_Export> _lst = new List <B03_Info_Export>();

                List <AppDocumentInfo> appDocumentInfos      = new List <AppDocumentInfo>();
                List <AppFeeFixInfo>   _lst_appFeeFixInfos   = new List <AppFeeFixInfo>();
                ApplicationHeaderInfo  applicationHeaderInfo = new ApplicationHeaderInfo();

                B03_Info_Export app_Detail = objBL.GetByID_Exp(pAppHeaderId, language, ref applicationHeaderInfo, ref appDocumentInfos, ref _lst_appFeeFixInfos);

                string fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B03" + _datetimenow + ".pdf");

                // tiếng việt, bị lộn nên ko muốn đổi
                string _tempfile = "B03.rpt";
                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.LangEN)
                    {
                        _tempfile    = "B03.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B03" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "B03" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        _tempfile    = "B03_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B03_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "B03_EN_" + _datetimenow + ".pdf";
                    }
                }
                else
                {
                    if (applicationHeaderInfo.Languague_Code == Language.LangVI)
                    {
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B03" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "B03" + _datetimenow + ".pdf";
                    }
                    else
                    {
                        _tempfile    = "B03_EN.rpt"; // tiếng anh
                        fileName_pdf = System.Web.HttpContext.Current.Server.MapPath("/Content/Export/" + "B03_EN_" + _datetimenow + ".pdf");
                        SessionData.CurrentUser.FilePreview = "/Content/Export/" + "B03_EN_" + _datetimenow + ".pdf";
                    }
                }

                AppsCommon.Prepare_Data_Export_B03(ref app_Detail, applicationHeaderInfo, appDocumentInfos, _lst_appFeeFixInfos);

                _lst.Add(app_Detail);
                DataSet _ds_all = ConvertData.ConvertToDataSet <B03_Info_Export>(_lst, false);
                CrystalDecisions.CrystalReports.Engine.ReportDocument oRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();


                oRpt.Load(Path.Combine(Server.MapPath("~/Report/"), _tempfile));

                if (_ds_all != null)
                {
                    _ds_all.Tables[0].TableName = "Table1";
                    // đè 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();
                //_ds_all.WriteXml(@"D:\MyData.xml");
                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 }));
            }
        }