コード例 #1
0
        internal static IReportEngine Get(Utility.Ctx p_ctx, ProcessEngine.ProcessInfo _pi, out int totalRecords, bool IsArabicReportFromOutside)
        {
            IReportEngine re = null;

            Type type = null;

            try
            {
                Assembly asm = Assembly.Load("VARCOMSvc");
                type = asm.GetType("ViennaAdvantage.Classes.ReportFromatWrapper");
                ConstructorInfo cinfo = type.GetConstructor(new Type[] { typeof(Ctx), typeof(string), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int), typeof(int) });
                re = (IReportEngine)cinfo.Invoke(new object[] { p_ctx, _pi.GetTitle(), _pi.GetAD_Process_ID(), _pi.GetTable_ID(), _pi.GetRecord_ID(), 0, 0, _pi.GetAD_PInstance_ID() });



                MethodInfo mInfo = type.GetMethod("Init");
                totalRecords = Convert.ToInt32(mInfo.Invoke(re, new object[] { IsArabicReportFromOutside }));
            }
            catch
            {
                totalRecords = 0;
            }

            return(re);
        }
コード例 #2
0
        public static IReportEngine GetReportEngine(Ctx ctx, ProcessInfo pi, VAdvantage.DataBase.Trx trx, String assemblyName, String fqClassname)
        {
            IReportEngine re = null;

            //1 load assembly
            Type type = VAdvantage.Utility.ClassTypeContainer.GetClassType(fqClassname, assemblyName);

            if (type != null && type.IsClass)
            {
                re = (IReportEngine)Activator.CreateInstance(type);
            }
            else
            {
                pi.SetSummary("Could not find class " + fqClassname);
            }
            if (re != null)
            {
                //oClass.StartProcess(_ctx, _pi, _trx);
                if (!re.StartReport(ctx, pi, trx))
                {
                    re = null;
                }
            }
            return(re);
        }
コード例 #3
0
        /// <summary>
        /// Based on Report ID, Generate report and then save it in physcal location
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="_trx"></param>
        /// <param name="AD_TableID"></param>
        /// <param name="recordID"></param>
        /// <param name="AD_UserID"></param>
        /// <param name="AD_ClientID"></param>
        /// <param name="nodeName"></param>
        /// <param name="windowID"></param>
        /// <param name="WFActivity"></param>
        /// <returns>file info.</returns>
        public FileInfo GetPdfReportForMail(Ctx ctx, Trx _trx, int AD_TableID, int recordID, int AD_UserID, int AD_ClientID, string nodeName, int windowID, int WFActivity)
        {
            try
            {
                int reportID = GetDoctypeBasedReport(ctx, AD_TableID, recordID, windowID, WFActivity);

                if (reportID == 0)
                {
                    VLogger.Get().Warning("No Report found on DocType and Window Tab. For Table=" + AD_TableID);
                    return(null);
                }
                FileInfo temp    = null;
                MProcess process = MProcess.Get(ctx, reportID);

                ProcessInfo pi = new ProcessInfo(nodeName, reportID,
                                                 AD_TableID, recordID);
                pi.SetAD_User_ID(AD_UserID);
                pi.SetAD_Client_ID(AD_ClientID);
                MPInstance pInstance = new MPInstance(process, recordID);
                //FillParameter(pInstance, trx);
                pi.SetAD_PInstance_ID(pInstance.GetAD_PInstance_ID());

                if (process.GetIsCrystalReport() == "Y")
                {
                    pi.SetIsCrystal(true);
                }
                else
                {
                    pi.SetIsCrystal(false);
                }

                pi.SetAD_ReportFormat_ID(process.GetAD_ReportFormat_ID());
                pi.SetAD_ReportMaster_ID(process.GetAD_ReportMaster_ID());
                process.ProcessIt(pi, _trx);

                IReportEngine repo    = ReportRun(pi, ctx, _trx);
                byte[]        bytes   = repo.GetReportBytes();
                string        repPath = repo.GetReportFilePath(true, out bytes);

                repPath = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath + repPath;
                ctx.SetContext("FetchingDocReport", "N");
                if (!string.IsNullOrEmpty(repPath))
                {
                    temp = new FileInfo(repPath);
                    if (temp.Exists)
                    {
                        return(temp);
                    }
                    return(null);
                }
                return(null);
            }
            catch
            {
                ctx.SetContext("FetchingDocReport", "N");
                return(null);
            }
        }
コード例 #4
0
        private Stream GenerateReport(string guid, Type exporterType)
        {
            IReportTemplate template = null;

            using (IDataRepository repository = new DataRepository())
            {
                ReportData report = repository.Get(guid);
                if (report != null)
                {
                    template = _templateFactory.Create(new MemoryStream(Encoding.UTF8.GetBytes(report.Definition)));
                }
            }

            /* Attach our custom data source.
             */
            StaticDataProvider ours = new StaticDataProvider();

            ours.AddTable(new System.Data.DataTable());
            ours.Tables.First().Columns.Add(new System.Data.DataColumn("Id", typeof(int))
            {
                AutoIncrement = true, AutoIncrementSeed = 1, AutoIncrementStep = 1, AllowDBNull = false
            });
            ours.Tables.First().Columns.Add(new System.Data.DataColumn("Text", typeof(string)));

            foreach (string value in new[] { "Hello", "World!", "This", "is", "a", "test!", "This", "report", "generator", "rocks!" })
            {
                ours.AddRow(0, null, value);
            }

            template.DataSources.Set(new DataSource("ours", ours));

            // Uncomment the following statement to replace the above data source with one that generates random data each time.
            //template.DataSources.Set(new DataSource("ours", new ezNReporting.Web.Utilities.ezNReporting.RandomDataProvider()));

            /* Generate the report.
             */
            IReportEngine engine = _engineFactory.Create();

            return(engine.Generate(template, exporterType));
        }
コード例 #5
0
        /// <summary>
        /// Generate Report based on whatever type of report is selected.
        /// </summary>
        /// <param name="_pi"></param>
        public IReportEngine ReportRun(ProcessInfo _pi, Ctx p_ctx, Trx _trx)
        {
            //  start report code
            ///	Start Report	-----------------------------------------------
            ///
            IReportEngine rpe                = null;
            bool          isDocxFile         = false;
            int           AD_ReportFormat_ID = _pi.GetAD_ReportFormat_ID();

            //if("Y".Equals(DB.ExecuteScalar("SELECT IsCrystalReport FROM AD_Process WHERE AD_Process_ID = "+_pi.GetAD_Process_ID())))

            //Dynamic Report
            if (_pi.GetAD_ReportMaster_ID() > 0)
            {
                String  fqClassName = "", asmName = "";
                DataSet ds = DB.ExecuteDataset("SELECT ClassName,AssemblyName FROM AD_ReportMaster WHERE IsActive='Y' AND AD_ReportMaster_ID = " + _pi.GetAD_ReportMaster_ID());
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                    fqClassName = ds.Tables[0].Rows[0]["ClassName"].ToString();
                    asmName     = ds.Tables[0].Rows[0]["AssemblyName"].ToString();
                    rpe         = VAdvanatge.Report.ReportEngine.GetReportEngine(p_ctx, _pi, _trx, asmName, fqClassName);
                }
                else
                {
                    VLogger.Get().Warning("Report Engine data not found Error -> InActive record");
                    rpe = null;
                }
            }

            else if (AD_ReportFormat_ID > 0)
            {
                try
                {
                    string lang = p_ctx.GetAD_Language().Replace("_", "-");

                    if ((AD_ReportFormat_ID > 0) && (lang == "ar-IQ"))
                    {
                        isDocxFile = true;
                        rpe        = VAdvantage.ReportFormat.ReportFormatEngine.Get(p_ctx, _pi, true);
                    }
                    else
                    {
                        rpe = VAdvantage.ReportFormat.ReportFormatEngine.Get(p_ctx, _pi, false);
                    }
                }
                catch
                {
                    rpe = null;
                }
            }

            else if (_pi.GetIsCrystal())
            {
                //_pi.SetIsCrystal(true);
                try
                {
                    rpe = new VAdvantage.CrystalReport.CrystalReportEngine(p_ctx, _pi);
                }
                catch
                {
                    rpe = null;
                }
            }
            else
            {
                //If user Choose BI Report...................
                if ("B".Equals(DB.ExecuteScalar("SELECT IsCrystalReport FROM AD_Process WHERE AD_Process_ID = " + _pi.GetAD_Process_ID())))
                {
                    rpe = VAdvanatge.Report.ReportEngine.GetReportEngine(p_ctx, _pi, _trx, "VA039", "VA039.Classes.BIReportEngine");
                }
                else if ("J".Equals(DB.ExecuteScalar("SELECT IsCrystalReport FROM AD_Process WHERE AD_Process_ID = " + _pi.GetAD_Process_ID())))
                {
                    //isJasperReport = true;
                    rpe = VAdvanatge.Report.ReportEngine.GetReportEngine(p_ctx, _pi, _trx, "VA039", "VA039.Classes.JasperReportEngine");
                }
                else
                {
                    rpe = ReportCtl.Start(p_ctx, _pi, true);
                }
            }

            _pi.SetSummary("Report", rpe != null);

            //ReportCtl.Report = re;
            return(rpe);
        }
コード例 #6
0
 public void GenerateReport(IReportEngine reportEngine)
 {
     reportEngine.GenerateReport(viewModel, null);
 }
コード例 #7
0
ファイル: ProcessCtl.cs プロジェクト: vuongthai91/ERP-CMR-DMS
        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());
        }
コード例 #8
0
ファイル: ProcessCtl.cs プロジェクト: vuongthai91/ERP-CMR-DMS
        public void Run()
        {
            log.Fine("AD_PInstance_ID=" + _pi.GetAD_PInstance_ID() + ", Record_ID=" + _pi.GetRecord_ID());
            Lock();

            //	Get Process Information: Name, Procedure Name, ClassName, IsReport, IsDirectPrint
            String procedureName    = "";
            int    AD_ReportView_ID = 0;
            int    AD_Workflow_ID   = 0;
            bool   IsReport         = false;
            bool   IsDirectPrint    = 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,"
                         + " p.IsServerProcess "
                         + "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";

            if (!Utility.Env.IsBaseLanguage(_ctx, "AD_Process"))                            //   GlobalVariable.IsBaseLanguage())
            {
                sql = "SELECT t.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 CASE,"
                      + " p.IsServerProcess "
                      + "FROM AD_Process p"
                      + " INNER JOIN AD_PInstance i ON (p.AD_Process_ID=i.AD_Process_ID) "
                      + " INNER JOIN AD_Process_Trl t ON (p.AD_Process_ID=t.AD_Process_ID"
                      + " AND t.AD_Language='" + Utility.Env.GetAD_Language(_ctx) + "') "
                      + "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;
                        if ("Y".Equals(dr[5].ToString()) && !Ini.IsPropertyBool(Ini.P_PRINTPREVIEW))
                        {
                            IsDirectPrint = true;
                        }
                    }
                    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 (SqlException ex)
            {
                if (dr != null)
                {
                    dr.Close();
                }
                _pi.SetSummary(Msg.GetMsg(_ctx, "ProcessNoProcedure") + " " + ex.Message, true);
                Unlock();
                log.Log(Level.SEVERE, "run", ex);
                return;
            }
            finally
            {
                if (dr != null)
                {
                    dr.Close();
                }
            }

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

            if (AD_Workflow_ID > 0)
            {
                StartWorkflow(AD_Workflow_ID);
                re = ReportCtl.Report;

                Unlock();
                return;
            }

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

                if (!IsReport && procedureName.Length == 0)
                {
                    Unlock();
                    return;
                }

                if (IsReport && AD_ReportView_ID == 0)
                {
                    Unlock();
                    return;
                }
            }

            //  If not a report, we need a prodedure name
            if (!IsReport && procedureName.Length == 0)
            {
                _pi.SetSummary(Msg.GetMsg(_ctx, "ProcessNoProcedure", true));
                Unlock();
                return;
            }

            if (IsReport)
            {
                if (procedureName.Length > 0)
                {
                    if (!StartDBProcess(procedureName))
                    {
                        Unlock();
                        return;
                    }
                }

                //start report code
                //	Start Report	-----------------------------------------------
                re = ReportCtl.Start(_ctx, _pi, IsDirectPrint);

                _pi.SetSummary("Report", re != null);
                Unlock();
                if (re != null && IsDirectPrint)
                {
                    re = null;
                    //ve =  new Viewer(re);
                    //new ReportDialog(re);
                }
            }
            else
            {
                if (!StartDBProcess(procedureName))
                {
                    Unlock();
                    return;
                }

                ProcessInfoUtil.SetSummaryFromDB(_pi);
                Unlock();
            }
        }
コード例 #9
0
 public ReportContainer ( IReportEngine reportEngine, IStorageEngine storage, IDeliveryEngine delivery...)
コード例 #10
0
 public void GenerateReport(IReportEngine reportEngine)
 {
     throw new NotImplementedException();
 }
コード例 #11
0
 public ReportProcessorService(IAppSettings appSettings, IConcurrencyCoordinator concurrencyCoordinator, IReportEngine reportEngine)
 {
     _appSettings            = appSettings;
     _concurrencyCoordinator = concurrencyCoordinator;
     _reportEngine           = reportEngine;
 }
コード例 #12
0
 public TestController(IReportEngine reportEngine)
 {
     _reportEngine = reportEngine;
 }