Exemplo n.º 1
0
        public QueuedReport QueueReport(
            string guid,
            int WTS_RESOURCEID,
            int REPORT_TYPEID,
            DateTime scheduledDate,
            Dictionary <string, string> reportParameters,
            string reportName     = null,
            string reportAssembly = null,
            string reportClass    = null,
            string reportMethod   = null
            )
        {
            QueuedReport rpt = new QueuedReport();

            rpt.Guid             = guid ?? Guid.NewGuid().ToString();
            rpt.WTS_RESOURCEID   = WTS_RESOURCEID;
            rpt.REPORT_TYPEID    = REPORT_TYPEID;
            rpt.REPORT_STATUSID  = (int)ReportStatusEnum.Queued;
            rpt.ReportName       = string.IsNullOrWhiteSpace(reportName) ? ((ReportTypeEnum)REPORT_TYPEID).ToString() : reportName;
            rpt.ReportAssembly   = reportAssembly;
            rpt.ReportClass      = reportClass;
            rpt.ReportMethod     = reportMethod;
            rpt.ScheduledDate    = scheduledDate != DateTime.MinValue ? scheduledDate : DateTime.Now;
            rpt.ReportParameters = reportParameters;
            rpt.CreatedDate      = DateTime.Now;
            rpt.CreatedBy        = HttpContext.Current.User.Identity.Name;

            return(SaveReport(rpt));
        }
Exemplo n.º 2
0
        public QueuedReport SaveReport(QueuedReport rpt)
        {
            string procName = "ReportQueue_Save";

            try
            {
                using (SqlConnection cn = new SqlConnection(WTSCommon.WTS_ConnectionString))
                {
                    cn.Open();
                    using (SqlCommand cmd = new SqlCommand(procName, cn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.Add("@ReportQueueID", SqlDbType.BigInt).Value = rpt.ReportQueueID;
                        cmd.Parameters["@ReportQueueID"].Direction                          = ParameterDirection.InputOutput;
                        cmd.Parameters.Add("@Guid", SqlDbType.VarChar).Value                = rpt.Guid;
                        cmd.Parameters.Add("@WTS_RESOURCEID", SqlDbType.Int).Value          = rpt.WTS_RESOURCEID;
                        cmd.Parameters.Add("@REPORT_TYPEID", SqlDbType.Int).Value           = rpt.REPORT_TYPEID;
                        cmd.Parameters.Add("@REPORT_STATUSID", SqlDbType.Int).Value         = rpt.REPORT_STATUSID;
                        cmd.Parameters.Add("@ReportName", SqlDbType.VarChar).Value          = rpt.ReportName ?? (object)DBNull.Value;
                        cmd.Parameters.Add("@ReportAssembly", SqlDbType.VarChar).Value      = rpt.ReportAssembly ?? (object)DBNull.Value;
                        cmd.Parameters.Add("@ReportClass", SqlDbType.VarChar).Value         = rpt.ReportClass ?? (object)DBNull.Value;
                        cmd.Parameters.Add("@ReportMethod", SqlDbType.VarChar).Value        = rpt.ReportMethod ?? (object)DBNull.Value;
                        cmd.Parameters.Add("@ScheduledDate", SqlDbType.DateTime).Value      = rpt.ScheduledDate != DateTime.MinValue ? rpt.ScheduledDate : (object)DBNull.Value;
                        cmd.Parameters.Add("@ExecutionStartDate", SqlDbType.DateTime).Value = rpt.ExecutionStartDate != DateTime.MinValue ? rpt.ExecutionStartDate : (object)DBNull.Value;
                        cmd.Parameters.Add("@CompletedDate", SqlDbType.DateTime).Value      = rpt.CompletedDate != DateTime.MinValue ? rpt.CompletedDate : (object)DBNull.Value;

                        string json = rpt.ReportParameters != null && rpt.ReportParameters.Count > 0 ? JsonConvert.SerializeObject(rpt.ReportParameters, Newtonsoft.Json.Formatting.None) : null;
                        cmd.Parameters.Add("@ReportParameters", SqlDbType.NVarChar).Value = json ?? (object)DBNull.Value;

                        cmd.Parameters.Add("@CreatedBy", SqlDbType.NVarChar).Value   = rpt.CreatedBy ?? "SYSTEM";
                        cmd.Parameters.Add("@CreatedDate", SqlDbType.DateTime).Value = rpt.CreatedDate;
                        cmd.Parameters.Add("@Result", SqlDbType.VarChar).Value       = rpt.Result ?? (object)DBNull.Value;
                        cmd.Parameters.Add("@Error", SqlDbType.VarChar).Value        = rpt.Error ?? (object)DBNull.Value;
                        cmd.Parameters.Add("@OutFileName", SqlDbType.VarChar).Value  = rpt.OutFileName ?? (object)DBNull.Value;
                        cmd.Parameters.Add("@OutFile", SqlDbType.VarBinary).Value    = rpt.OutFile ?? (object)DBNull.Value;
                        cmd.Parameters.Add("@Archive", SqlDbType.Bit).Value          = rpt.Archive;
                        cmd.Parameters.Add("@OutFileSize", SqlDbType.BigInt).Value   = rpt.OutFileSize > 0 ? rpt.OutFileSize : (object)DBNull.Value;

                        cmd.ExecuteNonQuery();

                        SqlParameter reportQueueID = cmd.Parameters["@ReportQueueID"];

                        rpt.ReportQueueID = (long)reportQueueID.Value;
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtility.LogException(ex);
            }

            return(rpt);
        }
Exemplo n.º 3
0
        public QueuedReport GetReport(long reportQueueID, string guid, bool includeReportData, bool includeArchived = true)
        {
            QueuedReport rpt = null;

            List <QueuedReport> rpts = GetReports(reportQueueID, guid, 0, null, null, DateTime.MinValue, includeReportData, includeArchived, false);

            if (rpts != null && rpts.Count > 0)
            {
                rpt = rpts[0];
            }

            return(rpt);
        }
Exemplo n.º 4
0
        public List <QueuedReport> GetReports(long reportQueueID, string guid, int WTS_RESOURCEID, List <int> reportTypes, List <int> reportStatuses, DateTime scheduledDateMax, bool includeReportData, bool includeArchived, bool includeAverages)
        {
            List <QueuedReport> reports = new List <QueuedReport>();

            DataTable dt = GetReportsDataTable(reportQueueID, guid, WTS_RESOURCEID, reportTypes, reportStatuses, scheduledDateMax, includeReportData, includeArchived, includeAverages);

            if (dt != null)
            {
                foreach (DataRow row in dt.Rows)
                {
                    QueuedReport rpt = new QueuedReport();

                    rpt.Load(row);

                    reports.Add(rpt);
                }
            }

            return(reports);
        }