예제 #1
0
        static void UploadReports()
        {
            ReportService2010.ReportingService2010 rs = new ReportService2010.ReportingService2010();
            string serviceUrl = Properties.Settings.Default.SSRSUrl;
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            rs.Url = serviceUrl;
            string strItemType = "Report";
            string strName;
            Byte[] definition = null;
            ReportService2010.Warning[] warnings = null;

            String[] reportFiles = Directory.GetFiles(Properties.Settings.Default.ReportsSourceFolder, "*.rdl", SearchOption.TopDirectoryOnly);

            foreach (String reportFile in reportFiles)
            {
                try
                {
                    System.Console.WriteLine("Reading the report file" + reportFile);

                    FileStream stream = File.OpenRead(reportFile);
                    definition = new Byte[stream.Length];
                    stream.Read(definition, 0, (int)stream.Length);
                    stream.Close();

                    System.Console.WriteLine("Finished Reading the report file");
                }
                catch (IOException e)
                {
                    System.Console.WriteLine(e.Message);
                }

                try
                {
                    string parent = Properties.Settings.Default.SSRSFolder;
                    strName = Path.GetFileNameWithoutExtension(reportFile);
                    System.Console.WriteLine("Uploading the report " + strName);
                    ReportService2010.CatalogItem report = rs.CreateCatalogItem(strItemType, strName, parent, true, definition, null, out warnings);

                    if (warnings != null)
                    {
                        foreach (ReportService2010.Warning warning in warnings)
                        {
                            System.Console.WriteLine(warning.Message);
                        }
                    }

                    else
                        System.Console.WriteLine("Report: {0} created successfully " +
                                          " with no warnings", strName);
                }
                catch (SoapException e)
                {
                    System.Console.WriteLine(e.Detail.InnerXml.ToString());
                }

            }
        }
예제 #2
0
 static void UploadDataSource(String dataSourceName,DataSourceDefinition definition)
 {
     ReportingService2010 rs = new ReportingService2010();
     rs.Url = Properties.Settings.Default.SSRSUrl;
     rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
     rs.CreateDataSource(dataSourceName, Properties.Settings.Default.SSRSFolder, true, definition, null);
 }