Exemple #1
0
        private string DeployModel(string localPath, string serverPath, string dataSourcePath, string dataSourceName)
        {
            byte[]    definition = null;
            Warning[] warnings   = null;
            string    retRes     = String.Empty;

            try
            {
                // Read the file and put it into a byte array to pass to SRS
                FileStream stream = File.OpenRead(localPath);
                definition = new byte[stream.Length];
                stream.Read(definition, 0, (int)(stream.Length));
                stream.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // We are going to use the name of the rdl file as the name of our report
            string reportName = Path.GetFileNameWithoutExtension(localPath);


            // Now lets use this information to publish the report
            try
            {
                warnings = rs.CreateModel(reportName, serverPath, definition, null);

                if (warnings != null)
                {
                    retRes = String.Format("Report {0} failed with warnings :\n", reportName);
                    foreach (Warning warning in warnings)
                    {
                        retRes += warning.Message + "\n";
                    }
                }
                else
                {
                    retRes = String.Format("Report {0} created successfully with no warnings\n", reportName);
                }

                //set the datasource
                DataSourceReference dsr = new DataSourceReference();
                dsr.Reference = dataSourcePath + "/" + dataSourceName;


                DataSource[] dsarray = rs.GetItemDataSources(serverPath + "/" + reportName);
                DataSource   ds      = new DataSource();

                ds      = dsarray[0];
                ds.Item = (DataSourceReference)dsr;

                rs.SetItemDataSources(serverPath + "/" + reportName, dsarray);
            }
            catch (SoapException ex)
            {
                return(String.Format("Report {0} failed with exception {1}\n", reportName, ex.Detail.InnerXml.ToString()));
            }

            return(retRes);
        }
Exemple #2
0
 public ReportWarning[] CreateModel(string visibleName, string parentFolder, Byte[] definition, string properties)
 {
     return(Array.ConvertAll(webserviceProxy.CreateModel(visibleName, parentFolder, definition, null), ConvertSPWarningToReportWarning));
 }