예제 #1
0
        }       //	StartDocumentPrint

        static public ReportEngine_N StartFinReport(Ctx ctx, ProcessInfo pi)
        {
            int AD_Client_ID = ctx.GetAD_Client_ID();

            //  Create Query from Parameters
            String TableName = pi.GetAD_Process_ID() == 202 ? "T_Report" : "T_ReportStatement";
            Query  query     = Query.Get(ctx, pi.GetAD_PInstance_ID(), TableName);

            //	Get PrintFormat
            MPrintFormat format = (MPrintFormat)pi.GetTransientObject();

            if (format == null)
            {
                format = (MPrintFormat)pi.GetSerializableObject();
            }
            if (format == null)
            {
                s_log.Log(Level.SEVERE, "startFinReport - No PrintFormat");
                return(null);
            }
            PrintInfo info = new PrintInfo(pi);

            ReportEngine_N re = new ReportEngine_N(ctx, format, query, info);

            return(re);
        }       //	startFinReport
예제 #2
0
 public void InitPrint(ReportEngine_N s_reportEngine)
 {
     try
     {
         //this.printDoc.DefaultPageSettings.Margins.Top = 1;
         //this.printDoc.DefaultPageSettings.Margins.Left = 1;
         //this.printDoc.DefaultPageSettings.Margins.Right = 1;
         //this.printDoc.DefaultPageSettings.Margins.Bottom = 1;
         m_reportEngine = s_reportEngine;
         m_reportEngine.CreatePDF(Application.StartupPath + "\\temp.pdf", true);
         //this.printDoc.Print();      //print the page
     }
     catch
     {
     }
 }
예제 #3
0
        }       //	create

        /// <summary>
        /// Start Standard Report.
        /// - Get Table Info & submit
        /// </summary>
        /// <param name="ctx">Context</param>
        /// <param name="pi">Process Info</param>
        /// <param name="IsDirectPrint">if true, prints directly - otherwise View</param>
        /// <returns>true if OK</returns>
        static public ReportEngine_N StartStandardReport(Ctx ctx, ProcessInfo pi, bool IsDirectPrint)
        {
            ReportEngine_N re = ReportEngine_N.Get(ctx, pi);

            if (re == null)
            {
                pi.SetSummary("");//No ReportEngine_N");
                s_log.Log(Level.SEVERE, "No ReportEngine_N");
                return(null);
            }
            if (IsDirectPrint)
            {
                re.Print();
            }
            return(re);
        }       //	startStandardReport
예제 #4
0
        }       //	startFinReport

        /// <summary>
        /// Start Document Print for Type. Called also directly from ProcessDialog, VInOutGen, VInvoiceGen, VPayPrint
        /// </summary>
        /// <param name="ctx">document type in ReportEngine</param>
        /// <param name="type"></param>
        /// <param name="Record_ID"></param>
        /// <param name="IsDirectPrint">if true, prints directly - otherwise View</param>
        /// <param name="IsShowError"></param>
        /// <returns>true if success</returns>
        public static ReportEngine_N StartDocumentPrint(Ctx ctx, int type, int Record_ID, bool IsDirectPrint, bool IsShowError)
        {
            ReportEngine_N re = ReportEngine_N.Get(ctx, type, Record_ID);

            if (re == null)
            {
                //if (IsShowError)
                //    ShowMessage.Error("NoDocPrintFormat", true);
                return(null);
            }
            if (IsDirectPrint)
            {
                re.Print();
                ReportEngine_N.PrintConfirm(type, Record_ID);
            }
            return(re);
        }       //	StartDocumentPrint
예제 #5
0
        }       //	launchReport

        /// <summary>
        /// Launch Report
        /// </summary>
        /// <param name="pf">PrintFormat Object</param>
        private void LaunchReport(MPrintFormat pf)
        {
            //Code to preload the format (not include as user can change setting at the last moment )
            int Record_ID = 0;

            if (_query.GetRestrictionCount() == 1 && (_query.GetCode(0)).GetType() == typeof(int))
            {
                Record_ID = ((int)_query.GetCode(0));
            }
            PrintInfo info = new PrintInfo(pf.GetName(), pf.GetAD_Table_ID(), Record_ID);

            info.SetDescription(_query.GetInfo());

            ReportEngine_N re = new ReportEngine_N(Env.GetContext(), pf, _query, info);
            //new Viewer(re);
            //new ReportDialog(pf,  _query);
        }       //	launchReport
예제 #6
0
        ///**
        // *    Create PDF
        // *	@return File or null
        // */
        //public File createPDF ()
        //{
        //    try
        //    {
        //        File temp = File.createTempFile(get_TableName()+get_ID()+"_", ".pdf");
        //        return createPDF (temp);
        //    }
        //    catch (Exception e)
        //    {
        //        //log.severe("Could not create PDF - " + e.getMessage());
        //    }
        //    return null;
        //}	//	getPDF

        ///**
        // *    Create PDF file
        // *	@param file output file
        // *	@return file if success
        // */
        //public File createPDF (File file)
        //{
        ////	ReportEngine re = ReportEngine.Get (GetCtx(), ReportEngine.INVOICE, getC_Invoice_ID());
        ////	if (re == null)
        //        return null;
        ////	return re.getPDF(file);
        //}

        /// <summary>
        /// Create PDF
        /// </summary>
        /// <returns>File or null</returns>
        public FileInfo CreatePDF()
        {
            //try
            //{
            //    string fileName = Get_TableName() + Get_ID() + "_" + CommonFunctions.GenerateRandomNo()
            //                        + ".txt"; //.pdf
            //    string filePath = Path.GetTempPath() + fileName;

            //    //File temp = File.createTempFile(Get_TableName() + Get_ID() + "_", ".pdf");
            //    //FileStream fOutStream = new FileStream(filePath, FileMode.Create, FileAccess.Write);

            //    FileInfo temp = new FileInfo(filePath);
            //    if (!temp.Exists)
            //    {
            //        return CreatePDF(temp);
            //    }
            //}
            //catch (Exception e)
            //{
            //    log.Severe("Could not create PDF - " + e.Message);
            //}
            //return null;



            try
            {
                //string fileName = Get_TableName() + Get_ID() + "_" + CommonFunctions.GenerateRandomNo()
                String fileName = Get_TableName() + Get_ID() + "_" + CommonFunctions.GenerateRandomNo() + ".pdf";
                string filePath = Path.Combine(System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath, "TempDownload", fileName);

                int        processID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT AD_Process_Id FROM AD_Process WHERE VALUE='CashJournalReport'", null, null));
                MPInstance instance  = new MPInstance(GetCtx(), processID, GetC_Cash_ID());
                instance.Save();
                ProcessInfo pi = new ProcessInfo("", processID, Get_Table_ID(), GetC_Cash_ID());
                pi.SetAD_PInstance_ID(instance.GetAD_PInstance_ID());

                ProcessCtl ctl = new ProcessCtl();
                ctl.IsArabicReportFromOutside = false;
                byte[]         report         = null;
                ReportEngine_N re             = null;
                Dictionary <string, object> d = ctl.Process(pi, GetCtx(), out report, out re);

                File.WriteAllBytes(filePath, report);
                return(new FileInfo(filePath));
                //re.GetView();
                //bool b = re.CreatePDF(filePath);

                //File temp = File.createTempFile(Get_TableName() + Get_ID() + "_", ".pdf");
                //FileStream fOutStream = new FileStream(filePath, FileMode.Create, FileAccess.Write);

                //FileInfo temp = new FileInfo(filePath);

                //if (!temp.Exists)
                //{
                //    b = re.CreatePDF(filePath);
                //    if (b)
                //    {
                //        return new FileInfo(filePath);
                //    }
                //    return null;
                //}
                //else
                //    return temp;
            }
            catch (Exception e)
            {
                log.Severe("Could not create PDF - " + e.Message);
            }
            return(null);
        }
예제 #7
0
        public Dictionary <string, object> Process(ProcessInfo pi, Ctx ctx, out byte[] report, out string reportFilePath)
        {
            reportFilePath = null;

            _ctx   = ctx;
            _pi    = pi;
            report = null;

            MPInstance instance = null;

            if (_pi.GetAD_PInstance_ID() < 1)
            {
                try
                {
                    instance = new MPInstance(ctx, _pi.GetAD_Process_ID(), _pi.GetRecord_ID());
                }
                catch (Exception e)
                {
                    _pi.SetSummary(e.Message);
                    _pi.SetError(true);
                    return(_pi.ToList());
                }

                if (!instance.Save())
                {
                    _pi.SetSummary(Msg.GetMsg(ctx, "ProcessNoInstance", true));
                    _pi.SetError(true);
                    return(_pi.ToList());
                }

                _pi.SetAD_PInstance_ID(instance.Get_ID());
            }



            String procedureName      = "";
            int    AD_ReportView_ID   = 0;
            int    AD_ReportFormat_ID = 0;
            int    AD_Workflow_ID     = 0;
            bool   IsReport           = false;

            bool IsDirectPrint = false;

            bool IsCrystalReport = false;

            String sql = "SELECT p.Name, p.procedureName,p.Classname, p.AD_Process_ID,"                                        //	1..4
                         + " p.IsReport,p.IsDirectPrint,p.AD_ReportView_ID,p.AD_Workflow_ID,"                                  //	5..8
                         + " CASE WHEN COALESCE(p.Statistic_Count,0)=0 THEN 0 ELSE p.Statistic_Seconds/p.Statistic_Count END," //9
                         + " p.IsServerProcess, "                                                                              //10
                         + " p.IsCrystalReport, "                                                                              // crystal  11...12
                         + " p.AD_ReportFormat_ID "                                                                            //12
                         + " FROM AD_Process p"
                         + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) "
                         + " WHERE p.IsActive='Y'"
                         + " AND i.AD_PInstance_ID=@pinstanceid";

            IDataReader dr = null;

            try
            {
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@pinstanceid", _pi.GetAD_PInstance_ID());
                dr       = SqlExec.ExecuteQuery.ExecuteReader(sql, param);
                while (dr.Read())
                {
                    _pi.SetTitle(dr[0].ToString());
                    //if (m_waiting != null)
                    //    m_waiting.setTitle(_pi.getTitle());
                    procedureName = dr[1].ToString();

                    _pi.SetClassName(dr[2].ToString());

                    _pi.SetAD_Process_ID(Utility.Util.GetValueOfInt(dr[3].ToString()));
                    //	Report
                    if ("Y".Equals(dr[4].ToString()))
                    {
                        IsReport           = true;
                        IsCrystalReport    = "Y".Equals(dr[10].ToString());
                        AD_ReportFormat_ID = dr[11].ToString() == "" ? 0 : Utility.Util.GetValueOfInt(dr[11].ToString());
                        //later
                    }
                    AD_ReportView_ID = dr[6].ToString() == "" ? 0 : Utility.Util.GetValueOfInt(dr[6].ToString());
                    AD_Workflow_ID   = dr[7].ToString() == "" ? 0 : Utility.Util.GetValueOfInt(dr[7].ToString());
                    //
                    //_IsServerProcess = "Y".Equals(dr[9].ToString());
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                _pi.SetSummary(Msg.GetMsg(ctx, "ProcessNoProcedure") + " " + ex.Message, true);
                Unlock();
            }

            if (procedureName == null)
            {
                procedureName = "";
            }

            if (AD_Workflow_ID > 0)
            {
                StartWorkflow(AD_Workflow_ID);

                //Updated by raghu to open reports from work flow

                byte[] repByt = null;
                re = ReportCtl.Report;
                if (re != null)
                {
                    int reportTable_ID = 0;
                    if (re is IReportView)
                    {
                        IReportView irv = re as IReportView;
                        reportTable_ID = irv.GetPrintFormat().GetAD_Table_ID();
                        irv.GetView();
                        _pi.Set_AD_PrintFormat_Table_ID(irv.GetPrintFormat().GetAD_Table_ID());
                    }
                    _pi.SetSummary("Report", re != null);
                    Unlock();
                    if (re != null)
                    {
                        reportFilePath = re.GetReportFilePath(true, out repByt);
                    }
                }
                else
                {
                    repByt = null;
                }
                report = repByt;
                return(_pi.ToList());
            }

            if (_pi.GetClassName() != null)
            {
                if (!StartProcess())
                {
                    report = null;
                    return(_pi.ToList());
                }

                if (!IsReport && procedureName.Length == 0)
                {
                    report = null;
                    return(_pi.ToList());
                }
            }
            report = null;
            if (IsReport)
            {
                if (procedureName.Length > 0)
                {
                    if (!StartDBProcess(procedureName))
                    {
                    }
                }


                if (AD_ReportFormat_ID > 0)             // For Report Formats
                {
                    _pi.SetIsReportFormat(true);
                    int totalRecords = 0;
                    re = VAdvantage.ReportFormat.ReportFormatEngine.Get(_ctx, _pi, out totalRecords, IsArabicReportFromOutside);
                    Unlock();
                    _pi.SetSummary("Report", re != null);
                    _pi.SetTotalRecords(totalRecords);
                    if (re != null)
                    {
                        //isRCReport = true;
                        if (GetIsPrintCsv())
                        {
                            string s = "";
                            reportFilePath = re.GetCsvReportFilePath(s);
                        }
                        else
                        {
                            report         = re.GetReportBytes();
                            reportFilePath = re.GetReportFilePath(true, out report);
                        }
                        ReportString = re.GetReportString();
                    }
                }


                else if (!IsCrystalReport)
                {
                    //start report code
                    //	Start Report	-----------------------------------------------
                    re = ReportCtl.Start(_ctx, _pi, IsDirectPrint);
                    ReportEngine_N _rep = (ReportEngine_N)re;
                    //null check Implemented by raghu 22-May-2015
                    if (_rep != null)
                    {
                        reportTable_ID = _rep.GetPrintFormat().GetAD_Table_ID();
                        _rep.GetView();

                        _pi.Set_AD_PrintFormat_Table_ID(_rep.GetPrintFormat().GetAD_Table_ID());
                        _pi.Set_AD_PrintFormat_ID(_rep.GetPrintFormat().GetAD_PrintFormat_ID());
                        _pi.SetSummary("Report", re != null);
                        Unlock();
                        if (GetIsPrintFormat() && re != null && !GetIsPrintCsv())
                        {
                            reportFilePath = re.GetReportFilePath(true, out report);
                        }
                        else if (GetIsPrintCsv() && re != null)
                        {
                            report = _rep.CreateCSV(_ctx);
                            string filePath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + "TempDownload";

                            if (!Directory.Exists(filePath))
                            {
                                Directory.CreateDirectory(filePath);
                            }

                            filePath = filePath + "\\temp_" + CommonFunctions.CurrentTimeMillis() + ".csv";
                            File.WriteAllBytes(filePath, report);
                            reportFilePath = filePath.Substring(filePath.IndexOf("TempDownload"));
                        }
                        else
                        {
                            rptHtml = _rep.GetRptHtml().ToString();
                        }
                        report = _rep.CreatePDF();
                    }
                }
                else
                {
                    _pi.SetIsCrystal(true);
                    string errorMsg        = null;
                    CrystalReportEngine en = null;
                    try
                    {
                        en = new CrystalReportEngine(_ctx, _pi);

                        reportFilePath = en.GetReportFilePath(true, out report);// .GenerateCrystalReport();
                    }
                    catch (Exception err)
                    {
                        errorMsg = err.Message;
                    }

                    _pi.SetSummary(errorMsg ?? "Done", errorMsg != null);
                }
            }
            else
            {
                if (!StartDBProcess(procedureName))
                {
                    _pi.SetSummary("procedure ERROR");
                    return(_pi.ToList());
                }
                ProcessInfoUtil.SetSummaryFromDB(_pi);
            }

            return(_pi.ToList());
        }
        public GridReportInfo GenerateReport(Ctx _ctx, int id, List <string> queryInfo, Object code, bool isCreateNew, Dictionary <string, string> nProcessInfo, int pageNo, int AD_PInstance_ID, string fileType, int?nodeID, int?treeID, bool showSummary)
        {
            GridReportInfo res = new GridReportInfo();

            VIS.Models.PageSetting ps = new Models.PageSetting();
            parentIDs.Clear();
            ProcessReportInfo rep    = null;
            ReportEngine_N    re     = null;
            Query             _query = null;
            int    Record_ID         = 0;
            object AD_tab_ID         = 0;

            // _ctx.SetContext("#TimeZoneName", "India Standard Time");
            if (queryInfo.Count > 0 || AD_PInstance_ID > 0)
            {
                string tableName = queryInfo[0];
                if (AD_PInstance_ID > 0)
                {
                    if ((code).GetType() == typeof(int))        //	Form = one record
                    {
                        _query = Query.GetEqualQuery(tableName, ((int)code));
                    }
                    else
                    {
                        _query = Query.Get(_ctx, AD_PInstance_ID, tableName);
                    }
                }
                else
                {
                    string wherClause = queryInfo[1];
                    _query = new Query(tableName);

                    if (!string.IsNullOrEmpty(wherClause))
                    {
                        _query.AddRestriction(wherClause);
                    }
                }

                if (_query.GetRestrictionCount() == 1 && (code).GetType() == typeof(int))
                {
                    Record_ID = ((int)code);
                }

                if (nodeID > 0)
                {
                    GetChildNodesID(_ctx, Convert.ToInt32(nodeID), Convert.ToInt32(treeID));
                    MTree  tree          = new MTree(_ctx, Convert.ToInt32(treeID), null);
                    string nodeTableName = tree.GetNodeTableName();
                    _query.AddRestriction(" " + tableName + "." + tableName + "_ID  IN (SELECT NODE_ID FROM " + nodeTableName + "  WHERE Parent_ID IN (" + parentIDs.ToString() + ") OR NODE_ID IN (" + parentIDs + ")) ");

                    if (!showSummary)
                    {
                        _query.AddRestriction(" " + tableName + "." + "IsSummary= 'N'");
                    }
                }
            }
            else
            {
                if (nodeID > 0)
                {
                    MTree  tree      = new MTree(_ctx, Convert.ToInt32(treeID), null);
                    string tableName = MTable.GetTableName(_ctx, tree.GetAD_Table_ID());

                    _query = new Query(tableName);

                    GetChildNodesID(_ctx, Convert.ToInt32(nodeID), Convert.ToInt32(treeID));
                    string nodeTableName = tree.GetNodeTableName();
                    _query.AddRestriction(" " + tableName + "." + tableName + "_ID  IN (SELECT NODE_ID FROM " + nodeTableName + "  WHERE Parent_ID IN (" + parentIDs.ToString() + ")) ");


                    if (!showSummary)
                    {
                        _query.AddRestriction(" " + tableName + "." + "IsSummary= 'N'");
                    }
                }
            }

            if (_query == null)
            {
                _query = new Query();
                _query.AddRestriction(" 1 = 1");
            }



            if (queryInfo.Count > 2)
            {
                if (queryInfo[2] != null && queryInfo[2] != "" && Convert.ToInt32(queryInfo[2]) > 0)
                {
                    AD_tab_ID = Convert.ToInt32(queryInfo[2]);
                }
            }
            //Context _ctx = new Context(ctxDic);
            //Env.SetContext(_ctx);
            string lang = _ctx.GetAD_Language().Replace("_", "-");


            System.Globalization.CultureInfo original = System.Threading.Thread.CurrentThread.CurrentCulture;

            System.Threading.Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo(lang);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang);



            byte[] b = null;
            try
            {
                MPrintFormat pf = null;

                if (!isCreateNew)
                {
                    bool isPFExist = Util.GetValueOfInt(DB.ExecuteScalar("SELECT Count(*) FROM AD_PrintFormat WHERE AD_PrintFormat_ID=" + id)) > 0;
                    if (isPFExist)
                    {
                        pf = MPrintFormat.Get(_ctx, id, true);
                    }
                    else
                    {
                        rep           = new ProcessReportInfo();
                        rep.ErrorText = "NoDocPrintFormat";
                        res.repInfo   = rep;
                        return(res);
                    }
                }
                else
                {
                    //   pf = MPrintFormat.CreateFromTable(_ctx, id);
                    if (Convert.ToInt32(AD_tab_ID) > 0)
                    {
                        pf = MPrintFormat.CreateFromTable(_ctx, id, AD_tab_ID, true);
                    }
                    else
                    {
                        pf = MPrintFormat.CreateFromTable(_ctx, id, true);
                    }
                }

                pf.IsGridReport = true;
                pf.PageNo       = pageNo;



                rep = new ProcessReportInfo();
                pf.SetName(Env.TrimModulePrefix(pf.GetName()));
                if (nProcessInfo == null || pageNo > 0 || (Util.GetValueOfInt(nProcessInfo["Record_ID"]) == 0 && Util.GetValueOfInt(nProcessInfo["Process_ID"]) == 0 &&
                                                           Util.GetValueOfInt(nProcessInfo["AD_PInstance_ID"]) == 0))
                {
                    PrintInfo info = new PrintInfo(pf.GetName(), pf.GetAD_Table_ID(), Record_ID);
                    info.SetDescription(_query == null ? "" : _query.GetInfo());
                    re = new ReportEngine_N(_ctx, pf, _query, info);
                }
                else
                {
                    ProcessInfo pi = new ProcessInfo().FromList(nProcessInfo);
                    pi.Set_AD_PrintFormat_ID(id);
                    ProcessCtl ctl = new ProcessCtl();
                    ctl.Process(pi, _ctx, out b, out re);
                    re.SetPrintFormat(pf);
                }
                lock (_lock)
                {
                    re.GetView();
                    if (fileType == ProcessCtl.ReportType_PDF)
                    {
                        rep.ReportFilePath = re.GetReportFilePath(true, out b);
                    }
                    else if (fileType == ProcessCtl.ReportType_CSV)
                    {
                        rep.ReportFilePath = re.GetCSVPath(_ctx);
                    }
                    else
                    {
                        rep.ReportFilePath    = re.GetReportFilePath(true, out b);
                        rep.HTML              = re.GetRptHtml().ToString();
                        rep.AD_PrintFormat_ID = re.GetPrintFormat().GetAD_PrintFormat_ID();
                        rep.ReportProcessInfo = null;
                        rep.Report            = re.CreatePDF();
                    }
                }

                ps.TotalPage   = pf.TotalPage;
                ps.CurrentPage = pageNo;
                // b = re.CreatePDF();
                //rep.Report = b;
                //rep.HTML = re.GetRptHtml().ToString();
                //rep.AD_PrintFormat_ID = re.GetPrintFormat().GetAD_PrintFormat_ID();
                //rep.ReportProcessInfo = null;
            }
            catch (Exception ex)
            {
                rep.IsError   = true;
                rep.ErrorText = ex.Message;
                log.Severe("ReportEngine_N_CreatePDF_" + ex.ToString());
            }
            //      VAdvantage.Classes.CleanUp.Get().Start();
            res.repInfo  = rep;
            res.pSetting = ps;
            return(res);
        }
예제 #9
0
        public static ProcessReportInfo GenerateReport(Ctx _ctx, int id, List <string> queryInfo, Object code, bool isCreateNew, Dictionary <string, object> nProcessInfo, bool pdf, bool csv)
        {
            ProcessReportInfo rep    = null;
            ReportEngine_N    re     = null;
            Query             _query = null;
            int    Record_ID         = 0;
            object AD_tab_ID         = 0;

            // _ctx.SetContext("#TimeZoneName", "India Standard Time");
            if (queryInfo.Count > 0)
            {
                string tableName  = queryInfo[0];
                string wherClause = queryInfo[1];
                _query = new Query(tableName);

                if (!string.IsNullOrEmpty(wherClause))
                {
                    _query.AddRestriction(wherClause);
                }


                if (_query.GetRestrictionCount() == 1 && (code).GetType() == typeof(int))
                {
                    Record_ID = ((int)code);
                }
            }
            if (queryInfo.Count > 2)
            {
                if (queryInfo[2] != null && queryInfo[2] != "" && Convert.ToInt32(queryInfo[2]) > 0)
                {
                    AD_tab_ID = Convert.ToInt32(queryInfo[2]);
                }
            }
            //Context _ctx = new Context(ctxDic);
            //Env.SetContext(_ctx);
            string lang = _ctx.GetAD_Language().Replace("_", "-");


            System.Globalization.CultureInfo original = System.Threading.Thread.CurrentThread.CurrentCulture;

            System.Threading.Thread.CurrentThread.CurrentCulture   = new System.Globalization.CultureInfo(lang);
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(lang);



            byte[] b = null;
            try
            {
                MPrintFormat pf = null;

                if (!isCreateNew)
                {
                    pf = MPrintFormat.Get(_ctx, id, true);
                }
                else
                {
                    //   pf = MPrintFormat.CreateFromTable(_ctx, id);
                    if (Convert.ToInt32(AD_tab_ID) > 0)
                    {
                        pf = MPrintFormat.CreateFromTable(_ctx, id, AD_tab_ID);
                    }
                    else
                    {
                        pf = MPrintFormat.CreateFromTable(_ctx, id);
                    }
                }

                rep = new ProcessReportInfo();
                pf.SetName(Env.TrimModulePrefix(pf.GetName()));
                if (nProcessInfo == null)
                {
                    PrintInfo info = new PrintInfo(pf.GetName(), pf.GetAD_Table_ID(), Record_ID);
                    info.SetDescription(_query == null ? "" : _query.GetInfo());
                    re = new ReportEngine_N(_ctx, pf, _query, info);
                }
                else
                {
                    ProcessInfo pi = new ProcessInfo().FromList(nProcessInfo);
                    pi.Set_AD_PrintFormat_ID(id);
                    ProcessCtl ctl = new ProcessCtl();
                    ctl.Process(pi, _ctx, out b, out re);
                    re.SetPrintFormat(pf);
                }

                re.GetView();
                if (pdf)
                {
                    rep.ReportFilePath = re.GetReportFilePath(true, out b);
                }
                else if (csv)
                {
                    rep.ReportFilePath = re.GetCSVPath(_ctx);
                }
                else
                {
                    rep.HTML = re.GetRptHtml().ToString();
                    rep.AD_PrintFormat_ID = re.GetPrintFormat().GetAD_PrintFormat_ID();
                    rep.ReportProcessInfo = null;
                    rep.Report            = re.CreatePDF();
                }
                // b = re.CreatePDF();
                //rep.Report = b;
                //rep.HTML = re.GetRptHtml().ToString();
                //rep.AD_PrintFormat_ID = re.GetPrintFormat().GetAD_PrintFormat_ID();
                //rep.ReportProcessInfo = null;
            }
            catch (Exception ex)
            {
                rep.IsError   = true;
                rep.ErrorText = ex.Message;
            }
            return(rep);
        }