コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Subscription"/> class.
 /// </summary>
 /// <param name="reportId">The report id.</param>
 /// <param name="ownerId">The owner id.</param>
 public Subscription(string reportId, ReportingEnvironmentEnum environment, int?ownerId, int?clientId, ReportingApplication?application)
 {
     this.Application            = application;
     this.OwnerId                = ownerId.ToString();
     this.ClientId               = clientId;
     this.ReportingEnvironmentId = environment;
     this.ReportId               = reportId;
     this.Description            = this.ReportName; //default to report name
     this.ErrorDescription       = null;
     this.FormatId               = "7";             //default to PDF
     this.Id                   = null;
     this.IsActive             = true;
     this.NotifyOnScreen       = true;         // default to on screen notification
     this.NotifyEmail          = false;
     this.NotificationEmail    = string.Empty; // todo: default to user/mt/asp email
     this.LastRunEndTime       = null;
     this.LastRunScheduledTime = null;
     this.LastRunStartTime     = null;
     this.ModifiedDate         = null;
     this.ModifiedUser         = string.Empty;
     this.NextRunTime          = null;
     this.Parameters           = null;
     this.Schedule             = new Schedule();
     this.ScheduleOptionId     = ScheduleOptionEnum.QueueNow;
     this.StatusId             = ExecutionStatusEnum.New;
     this.Options              = null;
 }
コード例 #2
0
 /// <summary>
 /// Gets the report parameters.
 /// </summary>
 /// <param name="reportId">The report id.</param>
 /// <param name="parameterValues">The parameter values.</param>
 /// <returns></returns>
 public static IEnumerable <ReportParameterViewItem> GetReportParameters(
     string reportId,
     IEnumerable <ParameterValue> parameterValues,
     int userId,
     int?clientId,
     ReportingApplication application,
     ReportingEnvironmentEnum environment)
 {
     return(GetReportParameters(reportId, parameterValues, GetReportParameterOptions.IncludeAllParameters, userId, clientId, application, environment));
 }
コード例 #3
0
 public static IEnumerable <ReportParameterViewItem> GetReportParameters(string reportId, int userId, int?clientId, ReportingApplication application, ReportingEnvironmentEnum environment)
 {
     return(GetReportParameters(reportId, null, userId, clientId, application, environment));
 }
コード例 #4
0
        public static IEnumerable <ReportParameterViewItem> GetReportParameters(
            string reportId,
            IEnumerable <ParameterValue> parameterValues,
            GetReportParameterOptions options,
            int userId,
            int?clientId,
            ReportingApplication application,
            ReportingEnvironmentEnum environment)
        {
            //load report info to get the SSRS path
            Report report = LoadReport(reportId, userId, clientId, application, environment);

            if (report == null)
            {
                throw new KeyNotFoundException(string.Format("The report was not found: {0}", reportId));
            }

            string path = report.GetSpecificReportPath(parameterValues);

            using (var ssrs = new ReportingService2005())
            {
                //HACK: To get around issues between DEV-DB02 and the DC, use a local user
                if (0 == string.Compare(System.Configuration.ConfigurationManager.AppSettings["ReportServerUseDefaultCredentials"], "FALSE", StringComparison.OrdinalIgnoreCase))
                {
                    ssrs.UseDefaultCredentials = false;
                    ssrs.Credentials           = new NetworkCredential(
                        System.Configuration.ConfigurationManager.AppSettings["ReportServerUserName"],
                        System.Configuration.ConfigurationManager.AppSettings["ReportServerPassword"]);
                }
                else
                {
                    ssrs.UseDefaultCredentials = true;
                }

                //first, get default report parameters
                var prms = ssrs.GetReportParameters(
                    path,
                    null,
                    true,
                    null,
                    null);

                //build a list of dependent parameters
                var dependentPrms =
                    from p in prms
                    where p.Dependencies != null
                    from d in p.Dependencies
                    where (from q in prms
                           where q.Name == d
                           where q.PromptUser
                           select q).Any() //Do not include internal parameters as dependencies as the UI does not need to refresh.
                    select new
                {
                    ParameterName = d,
                    Dependent     = p.Name
                };

                //if parameter values were specified, calculate "actual" values and validate again
                if (parameterValues != null)
                {
                    var actualParameterValues =
                        from p in prms
                        join v in parameterValues on p.Name equals v.Name
                        select new ParameterValue
                    {
                        Name  = p.Name,
                        Value = _GetActualParameterValue(p, v)
                    };

                    prms = ssrs.GetReportParameters(
                        path,
                        null,
                        true,
                        actualParameterValues.ToArray(),
                        null);
                }

                //build view item list
                var prmViewItems =
                    from p in prms
                    where p.PromptUser //don't return internal (read-only) parameters
                    join v in parameterValues ?? new List <ParameterValue>() on p.Name equals v.Name into pvGroup
                    from pv in pvGroup.DefaultIfEmpty(GetDefaultParameterValue(p))
                    let dependents = from d in dependentPrms where d.ParameterName == p.Name select d.Dependent
                                     select new ReportParameterViewItem(p, pv, dependents.ToArray());

                //return view items depending on the options specified
                return
                    (from p in prmViewItems
                     where (GetReportParameterOptions.IncludeAllParameters == (options & GetReportParameterOptions.IncludeAllParameters)) ||
                     p.IsVisible == (options == GetReportParameterOptions.IncludeVisibleParameters)
                     select p);
            }
        }
コード例 #5
0
        public static Report LoadReport(string reportId, int userId, int?clientId, ReportingApplication application, ReportingEnvironmentEnum environment)
        {
            #region input validation

            if (string.IsNullOrEmpty(reportId))
            {
                throw new ArgumentNullException("reportId");
            }

            int reportIdValue = int.Parse(reportId);

            #endregion

            using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
            {
                Report report =
                    (from r in sql.GetReport(reportIdValue, (int)environment)
                     select new Report
                {
                    Id = r.ReportID.ToString(),
                    Name = r.Name,
                    Description = r.Description,
                    ReportingServicesPath = r.ReportPath,
                    Category = r.CategoryName,
                    ReportParametersUrl = r.ReportParametersURL,
                    Options = r.Options
                })
                    .FirstOrDefault();
                if (report == null)
                {
                    throw new KeyNotFoundException(string.Format("The report could not be found: {0}", reportId));
                }
                else
                {
                    if (ReportingApplication.InQuiry == application && clientId.HasValue)
                    {
                        var clientLabels = ClientLabels.LoadClientLabels(clientId.Value, application);
                        clientLabels.ApplyToReport(report);
                    }
                }
                return(report);
            }
        }