示例#1
0
文件: DAL.cs 项目: mr0bot/VMAReports
        public static void SetReportParameters(CRPT rpt)
        {
            DataTable dt = new DataTable();

            try
            {
                using (OracleConnection oc = new OracleConnection(GetConnectionString()))
                {
                    using (OracleCommand cmd = new OracleCommand("NCLSEA.NCL_VMA_RPT_PKG.GET_RPT_PARM_VALUES", oc))
                    {
                        oc.Open();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("OUT_CUR", OracleDbType.RefCursor).Direction    = ParameterDirection.Output;
                        cmd.Parameters.Add("IN_RPT_NAME", OracleDbType.Varchar2).Direction = ParameterDirection.Input;
                        cmd.Parameters["IN_RPT_NAME"].Value = rpt.ReportName;
                        cmd.Parameters.Add("IN_GROUP_LEVEL", OracleDbType.Int32).Direction = ParameterDirection.Input;
                        cmd.Parameters["IN_GROUP_LEVEL"].Value = rpt.GroupLevel;
                        OracleDataAdapter adapter = new OracleDataAdapter(cmd);
                        adapter.Fill(dt);
                    }

                    foreach (DataRow row in dt.Rows)
                    {
                        rpt.Parameters.Add(row["PARAM_NAME"].ToString(), row["PARAM_VALUE"].ToString());
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
示例#2
0
 private string GetGroupLevelFileName(CRPT report)
 {
     if (report.GroupLevel <= 1)
     {
         return(report.Filename);
     }
     string[] fname = report.Filename.Split('.');
     return(fname.First() + "_00" + report.GroupLevel.ToString() + "." + fname.Last());
 }
示例#3
0
        /// <summary>
        /// Method IsEmptyReport checks to see if report pulls data or not. This would tell us weather we needed send an email or not.
        /// Users requested to send email with attached empty report regardless of the existence of data.
        /// </summary>
        /// <param name="report"></param>
        /// <param name="p_ReportDocument"></param>
        /// <returns></returns>
        private bool ExportReport(CRPT report, ReportDocument p_ReportDocument)
        {
            try
            {
                string outputDir = ConfigurationManager.AppSettings["OutputPath"].ToString() + report.OutputPath + "\\" + DateTime.Now.ToString("yyyy_MM_dd");
                string fname     = GetGroupLevelFileName(report);
                string strReportExportNamePath = outputDir + "\\" + fname;

                bool IsRFPT = SetParameterValues(report, p_ReportDocument);

                if (IsRFPT)
                {
                    // if (IsEmptyReport(p_ReportDocument)) return false;
                    try
                    {
                        if (!Directory.Exists(outputDir))
                        {
                            Directory.CreateDirectory(outputDir);
                        }

                        if (report.IsPdf())
                        {
                            p_ReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, strReportExportNamePath);
                        }
                        else
                        {
                            p_ReportDocument.ExportToDisk(ExportFormatType.Excel, strReportExportNamePath);
                        }

                        SendMail(strReportExportNamePath, report.Recipients, "Generated Report Attached.", "FreestyleConnect Report");
                    }
                    catch (Exception e)
                    {
                        VMALogger.Log(LogLevel.Error, Environment.NewLine + "Report Name: " + report.ReportName + "Export error message: " + e.Message);
                        return(false);
                    }
                }
                else
                {
                    VMALogger.Log(LogLevel.Error, Environment.NewLine + "Report Name: " + report.ReportName + "Export Parameters not found");
                    return(false);
                }
            }
            catch (Exception ex)
            {
                VMALogger.Log(LogLevel.Error, Environment.NewLine + "Set Parameter Error: " + report.ReportName + " Error Message: " + ex.Message);
                return(false);
            }

            return(true);
        }
示例#4
0
        private bool SetParameterValues(CRPT report, ReportDocument p_ReportDocument)
        {
            report.SetParameterValues();

            if (report.MainParmDic.Count + report.SubParmDic.Count == 0)
            {
                return(false);
            }

            SetReportDataValues(p_ReportDocument, report.MainParmDic);

            foreach (ReportDocument sub in p_ReportDocument.Subreports)
            {
                SetReportDataValues(sub, report.SubParmDic);
            }

            return(true);
        }
示例#5
0
文件: DAL.cs 项目: mr0bot/VMAReports
        public static List <CRPT> GetReportData()
        {
            DataTable   dt      = new DataTable();
            List <CRPT> rptlist = new List <CRPT>();

            //string sql = SqlString();

            try
            {
                using (OracleConnection oc = new OracleConnection(GetConnectionString()))
                {
                    using (OracleCommand cmd = new OracleCommand("NCLSEA.NCL_VMA_RPT_PKG.GET_RPT_ROUTING_INFO", oc))
                    {
                        oc.Open();
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("OUT_CUR", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
                        OracleDataAdapter adapter = new OracleDataAdapter(cmd);
                        adapter.Fill(dt);
                    }

                    foreach (DataRow row in dt.Rows)
                    {
                        CRPT report = new CRPT()
                        {
                            ReportName   = row["RPTNAME"].ToString(),
                            GroupLevel   = Convert.ToInt32(row["GROUP_LEVEL"]),
                            OutputPath   = row["OUTPATH"].ToString(),
                            ReportSource = row["RPT_SOURCE"].ToString(),
                            Filename     = row["FILENAME"].ToString(),
                            Recipients   = row["RECIPIENTS"].ToString().Replace(";", ",")
                        };
                        rptlist.Add(report);
                    }
                }
                return(rptlist);
            }
            catch (Exception)
            {
                throw;
            }
        }