public static IEnumerable <Category> ListCategories(int userId, ReportingApplication application)
        {
#if MOCKUP
            XDocument doc              = XDocument.Load(Path.Combine(System.Configuration.ConfigurationManager.AppSettings["AppDataPathForMockup"], "Reports.xml"));
            XElement  root             = doc.Element("Reports");
            var       reportCategories =
                from e in root.Elements("Report")
                orderby !string.IsNullOrEmpty(e.Attribute("Category_UISortOrder").Value) ? (int)e.Attribute("Category_UISortOrder") : int.MaxValue
                group e by(string) e.Attribute("Category") into categoryGroup
                select new Category
            {
                Name = !string.IsNullOrEmpty(categoryGroup.Key) ? categoryGroup.Key : "Miscellaneous Reports"
            };

            return(reportCategories);
#else
            using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
            {
                var reportCategories =
                    from r in sql.ListReports(userId)
                    orderby r.CategorySortOrder
                    group r by r.CategoryName into categoryGroup
                    select new Category
                {
                    Name = !string.IsNullOrEmpty(categoryGroup.Key) ? categoryGroup.Key : "Miscellaneous Reports"
                };

                return(reportCategories.ToList());
            }
#endif
        }
Exemple #2
0
 public static void AddExecution(Subscription subscription, ReportingApplication application)
 {
     using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
     {
         sql.AddSubscriptionExecution(int.Parse(subscription.Id), int.Parse(subscription.ReportId), int.Parse(subscription.FormatId), subscription.GetParameterValuesXml());
     }
 }
Exemple #3
0
        public static IEnumerable <Category> ListReportsByCategory(int userId, ReportingApplication application)
        {
            using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
            {
                var reportCategories =
                    from r in sql.ListReports(userId)
                    orderby r.CategorySortOrder
                    group r by r.CategoryName into categoryGroup
                    select new Category
                {
                    Name    = !string.IsNullOrEmpty(categoryGroup.Key) ? categoryGroup.Key : "Miscellaneous Reports",
                    Reports =
                        from r in categoryGroup
                        orderby
                        r.SortOrder.HasValue ? r.SortOrder.Value : int.MaxValue,
                    r.Name
                    select new Report
                    {
                        Id                       = r.ReportID.ToString(),
                        Name                     = r.Name,
                        Description              = r.Description,
                        ReportingServicesPath    = r.ReportPath,
                        Category                 = categoryGroup.Key,
                        ReportParametersUrl      = r.ReportParametersURL,
                        ReportingEnvironmentId   = (ReportingEnvironmentEnum)r.EnvironmentID,
                        ReportingEnvironmentName = r.EnvironmentName
                    }
                };

                return(reportCategories.ToList());
            }
        }
        public async Task SendMetric(string applicationName, string property, string metric)
        {
            ReportingApplication application = GetApplication(applicationName);

            application.Metrics.Add(new ReportingMetric()
            {
                Property = property, Value = metric
            });
            await Clients.All.SendAsync("ReceiveMetric", applicationName, property, metric);
        }
Exemple #5
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));
 }
        public async Task SendError(string applicationName, string errorMessage)
        {
            ReportingApplication application = GetApplication(applicationName);

            application.Errors.Add(new ReportingError()
            {
                Message = errorMessage
            });
            await Clients.All.SendAsync("ReceiveError", applicationName, errorMessage);
        }
        /// <summary>
        /// A metric was received from an application
        /// </summary>
        /// <param name="applicationName">The name of the application</param>
        /// <param name="path">The path for the metric seperated with pipes</param>
        /// <param name="metric">The value of the metric</param>
        /// <returns></returns>
        public async Task SendMetric(string applicationName, string path, Double metric)
        {
            ReportingApplication application = coordinator.GetApplication(applicationName);

            // Ask the application to add the metric and handle any locking internally
            application.AddMetric(path, metric);

            // Tell all the clients a new metric was received
            await Clients.All.SendAsync("ReceiveMetric", applicationName, path, metric);
        }
        public async Task SendHeartbeat(string applicationName, DateTime nextRunTime)
        {
            ReportingApplication application = GetApplication(applicationName);

            application.NextRunTime = nextRunTime;
            application.Heartbeats.Add(new ReportingHeartbeat()
            {
                NextRunTime = nextRunTime
            });
            await Clients.All.SendAsync("ReceiveHeartbeat", applicationName, nextRunTime);
        }
        /// <summary>
        /// An error was recieved from an application via SignalR
        /// </summary>
        /// <param name="applicationName">The name of the application</param>
        /// <param name="errorMessage">The error message as generated by the application</param>
        /// <returns></returns>
        public async Task SendError(string applicationName, string errorMessage)
        {
            // Get the application from the coordinator
            ReportingApplication application = coordinator.GetApplication(applicationName);

            // Add the error to the memory error list for this application
            application.Errors.Add(new ReportingError()
            {
                Message = errorMessage
            });
            application.AddMetric("Errors", 1); // Add an error to the default error metric

            // Tell all the clients a new error was received
            await Clients.All.SendAsync("ReceiveError", applicationName, errorMessage);
        }
Exemple #10
0
        public static Execution LoadExecution(string id, int userId, ReportingApplication application)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException("id");
            }

            int executionId = int.Parse(id);

            if (executionId < 1)
            {
                throw new ArgumentOutOfRangeException("id");
            }

            using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
            {
                var result =
                    (from e in sql.GetExecution(userId, executionId)
                     select new Execution
                {
                    Application = application,
                    OwnerId = userId.ToString(),
                    Id = e.ReportExecutionID.ToString(),
                    Description = e.Name,
                    SubscriptionId = e.ReportSubscriptionID.ToString(),
                    ReportingEnvironmentId = (ReportingEnvironmentEnum)e.EnvironmentID,
                    ReportingEnvironmentName = e.EnvironmentName,
                    ReportId = e.ReportID.ToString(),
                    StatusId = (ExecutionStatusEnum)e.ReportExecutionStatusID,
                    FormatId = e.ReportFormatID.ToString(),
                    Parameters = ReportParametersHelper.GetParameterValuesFromXml(e.Parameters),
                    ActualCompletionTime = e.EndDate,
                    ActualStartTime = e.StartDate,
                    ExpirationDate = e.ExpirationDate,
                    ScheduledRunTime = e.ScheduledStartDate,
                    ModifiedDate = e.ModifiedDate,
                    ModifiedUser = e.ModifiedUser,
                    ErrorName = e.ErrorName,
                    ErrorDescription = e.ErrorDescription
                })
                    .FirstOrDefault();
                if (result == null)
                {
                    throw new KeyNotFoundException(string.Format("The report execution could not be found for user {0}: {1}", userId, executionId));
                }
                return(result);
            }
        }
Exemple #11
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);
            }
        }
Exemple #12
0
 public static IEnumerable <Report> ListReports(int userId, ReportingApplication application)
 {
     using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
     {
         var reports =
             from r in sql.ListReports(userId)
             orderby r.CategorySortOrder, r.SortOrder
             select new Report
         {
             Id                       = r.ReportID.ToString(),
             Name                     = r.Name,
             Description              = r.Description,
             ReportingServicesPath    = r.ReportPath,
             Category                 = r.CategoryName,
             ReportParametersUrl      = r.ReportParametersURL,
             ReportingEnvironmentId   = (ReportingEnvironmentEnum)r.EnvironmentID,
             ReportingEnvironmentName = r.EnvironmentName
         };
         return(reports.ToList());
     }
 }
        /// <summary>
        /// Check to see if the application has been received before, if not create it
        /// and return the value that was either found or created
        /// </summary>
        /// <param name="applicationName"></param>
        /// <returns></returns>
        private ReportingApplication GetApplication(String applicationName)
        {
            // Format the application name so it's consistent
            String searchString = (applicationName ?? String.Empty).ToLower().Trim();

            // See if the application has already been received
            if (!applications.ContainsKey(searchString))
            {
                // Lock the applications object whilst we are inserting
                // as it could be getting another request at the same time
                // and we don't want to overwrite it
                lock (lockingObject)
                {
                    // Now the application is locked, check again just incase someone
                    // else wrote whilst we were waiting to lock
                    if (applications.ContainsKey(searchString))
                    {
                        return(applications[searchString]);
                    }

                    // After the second check the application still wasn't there
                    // Create the new application for reporting and adding to the cache
                    ReportingApplication newApplication = new ReportingApplication()
                    {
                        Name = applicationName.Trim()
                    };

                    // Cache it for someone else
                    applications[searchString] = newApplication;

                    // Return the application
                    return(newApplication);
                } // Unlock so others can create applications
            }
            else
            {
                return(applications[searchString]); // Send the existing one back
            }
        }
 public static ClientLabels LoadClientLabels(int clientId, ReportingApplication application)
 {
     using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
     {
         return((from l in sql.GetClientLabels(clientId)
                 select new ClientLabels
         {
             LabelPatientID = l.LabelPatientID,
             LabelPatientName = l.LabelPatientName,
             LabelGender = l.LabelGender,
             LabelBirthdate = l.LabelBirthdate,
             LabelAppointmentDate = l.LabelAppointmentDate,
             LabelOrderNumber = l.LabelOrderNumber,
             LabelPatientLetter = l.LabelPatientLetter,
             LabelUserField1 = l.LabelUserField1,
             LabelUserField2 = l.LabelUserField2,
             LabelUserField3 = l.LabelUserField3,
             LabelUserField4 = l.LabelUserField4,
             LabelUserField5 = l.LabelUserField5,
             LabelBillingUnit = l.LabelBillingUnit,
             LabelDictator = l.LabelDictator
         }).FirstOrDefault());
     }
 }
Exemple #15
0
 public ReportingDataContext(ReportingApplication application, string connectionStringName)
 {
     this.Application      = application;
     this.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings[connectionStringName].ConnectionString;
     this.traceSource      = new TraceSource("Emdat.InVision.Sql");
 }
Exemple #16
0
        public static Subscription LoadSubscription(string id, int userId, ReportingApplication application)
        {
            #region validation

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

            int subscriptionId = int.Parse(id);

            if (subscriptionId < 1)
            {
                throw new ArgumentOutOfRangeException("id");
            }

            #endregion

            using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
            {
                var subscription =
                    (from s in sql.GetSubscription(subscriptionId)
                     let next = sql.GetSubscriptionNextExecution(s.ReportSubscriptionID).FirstOrDefault()
                                let prev = sql.GetSubscriptionPreviousExecution(s.ReportSubscriptionID).FirstOrDefault()
                                           let notifications = sql.GetSubscriptionNotifications(s.ReportSubscriptionID)
                                                               let notificationEmail =
                         (notifications.Any(n => n.ReportNotificationTypeID == 2) && !String.IsNullOrEmpty(notifications.FirstOrDefault(n => n.ReportNotificationTypeID == 2).ReportNotificationOptions)) ?
                         XDocument.Parse(notifications.FirstOrDefault(n => n.ReportNotificationTypeID == 2).ReportNotificationOptions).Element("NotificationOptions").Element("EmailAddress").Value : string.Empty
                         let schedule = new Schedule(
                             s.ScheduleFrequencyID,
                             s.FrequencyInterval,
                             s.FrequencyRecurrenceFactor,
                             s.FrequencyRelativeInterval,
                             next != null ? next.ScheduledStartDate : prev != null ? prev.ScheduledStartDate : null,
                             s.StartTime,
                             s.EndTime)
                                        select new Subscription
                {
                    Application = application,
                    OwnerId = userId.ToString(),
                    Description = s.Name,
                    FormatId = s.ReportFormatID.ToString(),
                    Id = s.ReportSubscriptionID.ToString(),
                    IsActive = s.IsActive,
                    ErrorDescription = prev != null ? prev.ReportExecutionErrorDescription : null,
                    LastRunEndTime = prev != null ? prev.EndDate : null,
                    LastRunScheduledTime = prev != null ? prev.ScheduledStartDate : null,
                    LastRunStartTime = prev != null ? prev.StartDate : null,
                    ModifiedDate = s.ModifiedDate,
                    ModifiedUser = s.ModifiedUser,
                    NextRunTime = next != null ? next.ScheduledStartDate : null,
                    Parameters = ReportParametersHelper.GetParameterValuesFromXml(s.Parameters),
                    ReportingEnvironmentId = (ReportingEnvironmentEnum)s.EnvironmentID,
                    ReportingEnvironmentName = s.EnvironmentName,
                    ReportId = s.ReportID.ToString(),
                    NotifyOnScreen = notifications.Any(n => n.ReportNotificationTypeID == 1),
                    NotifyEmail = notifications.Any(n => n.ReportNotificationTypeID == 2),
                    NotificationEmail = notificationEmail,
                    ScheduleOptionId = next != null && next.ScheduledStartDate.HasValue ? ScheduleOptionEnum.Schedule :
                                       schedule.RecurrenceOption == ScheduleRecurrence.Once ? ScheduleOptionEnum.QueueNow :
                                       false == s.IsActive ? ScheduleOptionEnum.Schedule :
                                       ScheduleOptionEnum.QueueNow,
                    Schedule = schedule,
                    StatusId = s.IsActive ? GetSubscriptionStatus(prev, next) : ExecutionStatusEnum.Inactive,
                    Options = s.Options
                }).FirstOrDefault();
                if (subscription == null)
                {
                    throw new KeyNotFoundException(string.Format("The report subscription could not be found: {0}", id));
                }
                return(subscription);
            }
        }
Exemple #17
0
 public static IEnumerable <ReportParameterViewItem> GetReportParameters(string reportId, int userId, int?clientId, ReportingApplication application, ReportingEnvironmentEnum environment)
 {
     return(GetReportParameters(reportId, null, userId, clientId, application, environment));
 }
Exemple #18
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);
            }
        }
Exemple #19
0
 public ReportingDataContext(ReportingApplication application)
     : this(application, "Emdat.InVision.ReportInfo")
 {
 }
Exemple #20
0
 public static IEnumerable <Execution> ListExecutions(int userId, int?companyId, ReportingApplication application)
 {
     return(ListExecutions(userId, companyId, application, null, true));
 }
Exemple #21
0
        public static IEnumerable <Execution> ListExecutions(int userId, int?companyId, ReportingApplication application, ICacheProvider cache, bool forceRefresh)
        {
            IEnumerable <Execution> executions = null;

            #region caching

            string cacheKey = string.Format("Emdat.InVision.Execution.ListExecutions({0},{1},{2})", userId, companyId, application);
            if (!forceRefresh && cache != null)
            {
                executions = cache[cacheKey] as IEnumerable <Execution>;
            }

            #endregion

            if (executions == null)
            {
                using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
                {
                    var executionsQuery =
                        from e in sql.ListExecutions(userId, companyId)
                        let prms = ReportParametersHelper.GetParameterValuesFromXml(e.Parameters)
                                   //let startDatePrm = (from p in prms where p.Name == "Start_Date" select p.Value).FirstOrDefault()
                                   //let endDatePrm = (from p in prms where p.Name == "End_Date" select p.Value).FirstOrDefault()
                                   where e.ReportExecutionStatusID != (int)ExecutionStatusEnum.Running
                                   select new Execution
                    {
                        Application              = application,
                        OwnerId                  = e.OwnerID.ToString(),
                        OwnerName                = string.Format("{0}, {1}", e.OwnerNameLast, e.OwnerNameFirst),
                        OwnerUsername            = e.OwnerUsername,
                        Id                       = e.ReportExecutionID.ToString(),
                        ActualCompletionTime     = e.EndDate,
                        ActualStartTime          = e.StartDate,
                        Description              = e.Name, //string.Format("{0} ({1} - {2})", e.Name, startDatePrm, endDatePrm),
                        ExpirationDate           = e.ExpirationDate,
                        FormatId                 = e.ReportFormatID.ToString(),
                        Parameters               = prms,
                        ReportingEnvironmentId   = (ReportingEnvironmentEnum)e.EnvironmentID,
                        ReportingEnvironmentName = e.EnvironmentName,
                        ReportId                 = e.ReportID.ToString(),
                        ScheduledRunTime         = e.ScheduledStartDate,
                        SubscriptionId           = e.ReportSubscriptionID.ToString(),
                        StatusId                 = (ExecutionStatusEnum)e.ReportExecutionStatusID,
                        ErrorName                = e.ErrorName,
                        ErrorDescription         = e.ErrorDescription
                    };
                    executions = executionsQuery.ToList();

                    #region caching

                    //add to cache
                    if (cache != null)
                    {
                        cache.Add(cacheKey, executions, CacheDuration);
                    }

                    #endregion
                }
            }
            return(executions);
        }
Exemple #22
0
        public static IEnumerable <Subscription> ListSubscriptions(int userId, int?companyId, ReportingApplication application, ICacheProvider cache, bool forceRefresh)
        {
            IEnumerable <Subscription> subscriptions = null;

            #region caching

            string cacheKey = string.Format("Emdat.InVision.Subscription.ListSubscriptions({0},{1},{2})", userId, companyId, application);
            if (!forceRefresh && cache != null)
            {
                subscriptions = cache[cacheKey] as IEnumerable <Subscription>;
            }

            #endregion

            if (subscriptions == null)
            {
                using (var sql = new Emdat.InVision.Sql.ReportingDataContext(application))
                {
                    var subscriptionsQuery =
                        from s in sql.ListSubscriptions(userId, companyId)
                        let next                       = sql.GetSubscriptionNextExecution(s.ReportSubscriptionID).FirstOrDefault()
                                              let prev = sql.GetSubscriptionPreviousExecution(s.ReportSubscriptionID).FirstOrDefault()
                                                         select new Subscription
                    {
                        Application              = application,
                        OwnerId                  = s.OwnerID.ToString(),
                        OwnerName                = string.Format("{0}, {1}", s.OwnerNameLast, s.OwnerNameFirst),
                        OwnerUsername            = s.OwnerUsername,
                        Description              = s.Name,
                        FormatId                 = s.ReportFormatID.ToString(),
                        Id                       = s.ReportSubscriptionID.ToString(),
                        IsActive                 = s.IsActive,
                        ErrorDescription         = prev != null ? prev.ReportExecutionErrorDescription : null,
                        LastRunEndTime           = prev != null ? prev.EndDate : null,
                        LastRunScheduledTime     = prev != null ? prev.ScheduledStartDate : null,
                        LastRunStartTime         = prev != null ? prev.StartDate : null,
                        ModifiedDate             = s.ModifiedDate,
                        ModifiedUser             = s.ModifiedUser,
                        NextRunTime              = next != null ? next.ScheduledStartDate : null,
                        Parameters               = ReportParametersHelper.GetParameterValuesFromXml(s.Parameters),
                        ReportingEnvironmentId   = (ReportingEnvironmentEnum)s.EnvironmentID.GetValueOrDefault(1),
                        ReportingEnvironmentName = s.EnvironmentName,
                        ReportId                 = s.ReportID.ToString(),
                        //								ScheduleOption = ???,
                        Schedule = new Schedule(
                            s.ScheduleFrequencyID,
                            s.FrequencyInterval,
                            s.FrequencyRecurrenceFactor,
                            s.FrequencyRelativeInterval,
                            next != null ? next.ScheduledStartDate : null,
                            s.StartTime,
                            s.EndTime),
                        StatusId = s.IsActive ? GetSubscriptionStatus(prev, next) : ExecutionStatusEnum.Inactive,
                        Options  = s.Options
                    };
                    subscriptions = subscriptionsQuery.ToList();

                    #region caching

                    //add to cache
                    if (cache != null)
                    {
                        cache.Add(cacheKey, subscriptions, CacheDuration);
                    }

                    #endregion
                }
            }
            return(subscriptions);
        }