Exemple #1
0
 /// <summary>
 /// The reporting services message.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="eventArgs">
 /// The event args.
 /// </param>
 private void deploymentMangerMessages(object sender, DeploymentMangerMessageEventArgs eventArgs)
 {
     RSBuildHelper.SendDeploymentMangerMessage(eventArgs, this.BuildEngine, this.ToString());
 }
Exemple #2
0
        /// <summary>
        /// When overridden in a derived class, executes the task.
        /// </summary>
        /// <returns>
        /// true if the task successfully executed; otherwise, false.
        /// </returns>
        public override bool Execute()
        {
            R2DeploymentManger r2DeploymentManger = new R2DeploymentManger(this.ReportServerURL);

            r2DeploymentManger.DeploymentMangerMessages += this.deploymentMangerMessages;
            ReportSubscription[] reportSubscriptions = new ReportSubscription[this.Subscriptions.Length];

            try
            {
                for (int i = 0; i < this.Subscriptions.Length; i++)
                {
                    if (!string.IsNullOrEmpty(this.Subscriptions[i].GetMetadata("QueryText")))
                    {
                        ReportDataSubscription reportDataSubscription = new ReportDataSubscription();
                        reportDataSubscription.Description = this.Subscriptions[i].GetMetadata(
                            "SubscriptionDescription");
                        reportDataSubscription.ScheduleName          = this.Subscriptions[i].GetMetadata("ReportScheduleName");
                        reportDataSubscription.DeliveryMethodOptions =
                            RSBuildHelper.DeliveryMethodOption(this.Subscriptions[i].GetMetadata("DeliveryMethod"));
                        RSBuildHelper.GetParameters(
                            reportDataSubscription.ReportParameters,
                            this.Subscriptions[i].GetMetadata("SubscriptionReportParamters"),
                            reportDataSubscription.DeliveryMethodOptions);
                        RSBuildHelper.GetParameters(
                            reportDataSubscription.ExtensionSettings,
                            this.Subscriptions[i].GetMetadata("SubscriptionSettings"),
                            reportDataSubscription.DeliveryMethodOptions);
                        reportDataSubscription.Reports.AddRange(
                            this.Subscriptions[i].GetMetadata("SubscriptionReports").Split(new[] { ';' }));
                        reportDataSubscription.SubscriptionQuery.QueryText =
                            this.Subscriptions[i].GetMetadata("QueryText");
                        reportDataSubscription.SubscriptionQuery.Fields.AddRange(
                            this.Subscriptions[i].GetMetadata("QueryFields").Split(new[] { ';' }));
                        reportDataSubscription.SubscriptionQuery.ShareConnection =
                            this.Subscriptions[i].GetMetadata("SubscriptionShareConnection");
                        RSBuildHelper.GetParameters(
                            reportDataSubscription.ExtensionSettingsFieldReferences,
                            this.Subscriptions[i].GetMetadata("SubscriptioSettingsFieldReferences"),
                            reportDataSubscription.DeliveryMethodOptions);
                        RSBuildHelper.GetParameters(
                            reportDataSubscription.ReportFieldReferences,
                            this.Subscriptions[i].GetMetadata("SubscriptionReportsFieldReferences"),
                            reportDataSubscription.DeliveryMethodOptions);
                        reportSubscriptions[i] = reportDataSubscription;
                    }
                    else
                    {
                        reportSubscriptions[i]             = new ReportSubscription();
                        reportSubscriptions[i].Description = this.Subscriptions[i].GetMetadata(
                            "SubscriptionDescription");
                        reportSubscriptions[i].ScheduleName          = this.Subscriptions[i].GetMetadata("ReportScheduleName");
                        reportSubscriptions[i].DeliveryMethodOptions =
                            RSBuildHelper.DeliveryMethodOption(this.Subscriptions[i].GetMetadata("DeliveryMethod"));
                        RSBuildHelper.GetParameters(
                            reportSubscriptions[i].ReportParameters,
                            this.Subscriptions[i].GetMetadata("SubscriptionReportParamters"),
                            reportSubscriptions[i].DeliveryMethodOptions);
                        RSBuildHelper.GetParameters(
                            reportSubscriptions[i].ExtensionSettings,
                            this.Subscriptions[i].GetMetadata("SubscriptionSettings"),
                            reportSubscriptions[i].DeliveryMethodOptions);
                        reportSubscriptions[i].Reports.AddRange(
                            this.Subscriptions[i].GetMetadata("SubscriptionReports").Split(new[] { ';' }));
                    }
                }

                return(r2DeploymentManger.CreateSubscrptions(
                           reportSubscriptions,
                           this.ReportingSite,
                           this.DeleteExistingSubscriptions,
                           this.DeployIfExistingSubscriptions));
            }
            catch (Exception ex)
            {
                this.BuildEngine.LogErrorEvent(
                    new BuildErrorEventArgs(
                        "Reporting",
                        "CreateSubscriptions",
                        this.BuildEngine.ProjectFileOfTaskNode,
                        this.BuildEngine.LineNumberOfTaskNode,
                        this.BuildEngine.ColumnNumberOfTaskNode,
                        0,
                        0,
                        ex.Message,
                        string.Empty,
                        this.ToString()));
                return(false);
            }
        }