示例#1
0
        private void DeployLinkedReports(List <ReportInfo> reports, string parentReportsLocation,
                                         string linkedReportsLocation, int dateTypeValue)
        {
            string targetLocation = CreateTargetLocation(linkedReportsLocation);

            foreach (ReportInfo report in reports)
            {
                string newReport = linkedReportsLocation + "/" + report.Name;

                if (_bgWorker.CancellationPending)
                {
                    return;
                }

                //// Skip this report when deploying linked - it does not have dates
                //if (report.FileName.Equals("SQLcmReportAlertRules.rdl"))
                //    continue;

                // See if we should over
                if (ItemExists(newReport, ItemTypeEnum.LinkedReport))
                {
                    if (_drd.OverwriteExisting)
                    {
                        _rs.DeleteItem(newReport);
                    }
                    else
                    {
                        _bgWorker.ReportProgress(1, String.Format("Skipping linked report: {0}...", linkedReportsLocation + "/" + report.Name));
                        continue;
                    }
                }
                // Create the report
                _bgWorker.ReportProgress(1, String.Format("Deploying linked report: {0}...", linkedReportsLocation + "/" + report.Name));
                _rs.CreateLinkedReport(report.Name, targetLocation,
                                       parentReportsLocation + "/" + report.Name, null);

                // Fix the parameters
                ReportParameter[] parameters = _rs.GetReportParameters(newReport, null, false, null, null);

                foreach (ReportParameter parameter in parameters)
                {
                    if (parameter.Name == "dateType")
                    {
                        parameter.DefaultValues[0] = dateTypeValue.ToString();
                    }
                    else if (parameter.Name == "startDate")
                    {
                        parameter.PromptUser          = false;
                        parameter.PromptUserSpecified = true;
                    }
                    else if (parameter.Name == "endDate")
                    {
                        parameter.PromptUser          = false;
                        parameter.PromptUserSpecified = true;
                    }
                }
                _rs.SetReportParameters(newReport, parameters);
            }
        }