Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rsSource">Report Server Source object //ReportingService2005</param>
        /// <param name="filePath">Report Source Path (local)</param>
        /// <param name="reportDestinationPath">Report Destination Path</param>
        /// <param name="dataSource">Report Destination DataSource</param>
        /// <param name="dataSourceLocation">Report DataSource Path</param>
        /// <returns>True or False</returns>
        public bool DeployReport(ReportingService2005 rsSource,
                                 string filePath,
                                 string reportDestinationPath,
                                 string dataSource,
                                 string dataSourceLocation)
        {
            bool resVal = false;

            try
            {
                reportDestinationPath = reportDestinationPath.Substring(reportDestinationPath.Length - 1, 1) == @"\"
                           ? reportDestinationPath.Substring(0, reportDestinationPath.Length - 1).Replace(@"\", @"/")
                           : reportDestinationPath.Replace(@"\", @"/");

                if (rsSource == null)
                {
                    return(false);
                }

                var fileInfo = new FileInfo(filePath);

                string fileName = fileInfo.Name.Replace(fileInfo.Extension, string.Empty);

                DeleteItem(ItemTypeEnum.Report,
                           reportDestinationPath.Replace(fileName, string.Empty).Replace(@"\", "/"),
                           fileName);

                ReportsServerInstance.CreateReport(fileName,
                                                   reportDestinationPath.Replace(fileName, string.Empty).Replace(@"\", "/"),
                                                   true,
                                                   File.ReadAllBytes(filePath),
                                                   null);
                try
                {
                    AttachDataSourceToReport(dataSource,
                                             dataSourceLocation.Replace(dataSource, string.Empty).Replace(@"\", "/"),
                                             fileName,
                                             reportDestinationPath.Replace(fileName, string.Empty).Replace(@"\", "/"));
                }
                catch (Exception)
                {
                    MessageBox.Show(string.Format("The Report {0} was created but the report's Datasource cannot be updated! Please do it manually... (if you want)", fileName));
                }
                resVal = true;
            }
            catch (Exception)
            {
                resVal = false;
            }

            return(resVal);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="rsSource">Report Server Source object //ReportingService2005</param>
        /// <param name="reportNameSource">Report Source Name</param>
        /// <param name="reportSourcePath">Report Source path</param>
        /// <param name="reportDestinationPath">Report Destination Path</param>
        /// <param name="dataSource">Report Destination DataSource</param>
        /// <param name="dataSourceLocation">Report DataSource Path</param>
        /// <returns>True or False</returns>
        public bool DeployReport(ReportingService2005 rsSource,
                                 string reportNameSource,
                                 string reportSourcePath,
                                 string reportDestinationPath,
                                 string dataSource,
                                 string dataSourceLocation)
        {
            bool resVal = false;

            try
            {
                if (rsSource == null)
                {
                    return(false);
                }

                byte[] reportDefinition = rsSource.GetReportDefinition(reportSourcePath.Replace(@"\", "/"));

                DeleteItem(ItemTypeEnum.Report,
                           reportDestinationPath.Replace(reportNameSource, string.Empty).Replace(@"\", "/"),
                           reportNameSource);

                ReportsServerInstance.CreateReport(reportNameSource,
                                                   reportDestinationPath.Replace(reportNameSource, string.Empty).Replace(@"\", "/"),
                                                   true,
                                                   reportDefinition,
                                                   null);
                try
                {
                    AttachDataSourceToReport(rsSource, dataSource,
                                             dataSourceLocation.Replace(dataSource, string.Empty).Replace(@"\", "/"),
                                             reportNameSource,
                                             reportDestinationPath.Replace(reportNameSource, string.Empty).Replace(@"\", "/"));
                }
                catch (Exception)
                {
                    MessageBox.Show(string.Format("The Report {0} was created but the report's Datasource cannot be updated! Please do it manually... (if you want)", reportNameSource));
                }

                resVal = true;
            }
            catch (Exception)
            {
                resVal = false;
            }


            return(resVal);
        }
Esempio n. 3
0
 public DataSourceDefinition GetDataSourceDefinition(string sharedDataSourcePath)
 {
     return(ReportsServerInstance.GetDataSourceContents(sharedDataSourcePath));
 }
Esempio n. 4
0
        public DataSource GetDataSource(string sharedDataSourcePath, string dataSourceName)
        {
            var dataSources = ReportsServerInstance.GetItemDataSources(sharedDataSourcePath);

            return(dataSources.Where(dataSource => dataSource.Name == dataSourceName).FirstOrDefault());
        }