Exemplo n.º 1
0
 public ReportUploader(string sourceFolder, string targetFolder, string dataSourcesFolder, ReportingService2005 rs)
 {
     this.sourceFolder      = sourceFolder;
     this.targetFolder      = targetFolder;
     this.dataSourcesFolder = dataSourcesFolder;
     this.rs = rs;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Get Reporting Service and setup the service
        /// </summary>
        /// <returns></returns>
        public static ReportingService2005 GetReportingService(string sessionID)
        {
            ReportingService2005 rs       = new ReportingService2005();
            ReportSettings       settings = Util.GetSettings();

            //1. Setup reporting service
            //rs.Url = this.ServerUrl + "/ReportService2005.asmx";
            rs.Url = settings.ReportServer + "/ReportService2005.asmx";
            //Set authentication
            if (settings.CredentialUserName == "")
            {
                rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            }
            else
            {
                rs.Credentials = new System.Net.NetworkCredential(settings.CredentialUserName, settings.CredentialPassword, settings.CredentialDomain);
            }


            //Set session header
//TODO			rs.SessionHeaderValue = new SessionHeader();

            {
//TODO				rs.SessionHeaderValue.SessionId = sessionID;
            }

            return(rs);
        }
Exemplo n.º 3
0
        public static void CreateReport(string reportingServiceUrl, string name, string parent, string[] dataSourcePaths, string definitionFile)
        {
            // Open the definition.

            byte[] definition;
            using (var stream = File.OpenRead(definitionFile))
            {
                definition = new byte[stream.Length];
                stream.Read(definition, 0, (int)stream.Length);
                stream.Close();
            }

            var service = new ReportingService2005
            {
                Url         = reportingServiceUrl,
                Credentials = System.Net.CredentialCache.DefaultCredentials
            };

            var warnings = service.CreateReport(name, parent, true, definition, null);

            // If there are data sources then associate them with the report.

            if (dataSourcePaths != null && dataSourcePaths.Length > 0)
            {
                var dataSources = (from dsp in dataSourcePaths
                                   select new DataSource
                {
                    Item = new DataSourceReference {
                        Reference = dsp
                    },
                    Name = GetName(dsp),
                }).ToArray();
                service.SetItemDataSources(GetPath(name, parent), dataSources);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the items.
        /// </summary>
        /// <param name="service2005">The service2005.</param>
        /// <param name="item">The item.</param>
        /// <param name="menuItem">The menu item.</param>
        /// 11/02/2011 by gpilar
        private void GetItems(ref ReportingService2005 service2005, CatalogItem item,
                              ref ToolStripMenuItem menuItem)
        {
            List <CatalogItem> listDependentItems = service2005.ListChildren(item.Path, false).ToList();

            listDependentItems.RemoveAll(
                i => i.Hidden == ShowHidenItems || (i.Type != ItemTypeEnum.Report && i.Type != ItemTypeEnum.Folder));
            //
            foreach (CatalogItem catalogItem in listDependentItems)
            {
                if (catalogItem.Type == ItemTypeEnum.Report)
                {
                    string rName = catalogItem.Name.Replace("/", " ").Replace("_", " ").ToProperCase().Trim();
                    string rTag  = catalogItem.Path;
                    var    rItem = new ToolStripMenuItem(rName)
                    {
                        Image = ReportImage, Tag = rTag
                    };
                    rItem.Click += ((sender, e) => OnShow(sender, new ShowReportsEventArgs(((ToolStripMenuItem)sender).Tag.ToString())));
                    menuItem.DropDownItems.Add(rItem);
                    continue;
                }
                if (catalogItem.Type == ItemTypeEnum.Folder)
                {
                    string rName = catalogItem.Name.Replace("/", " ").Replace("_", " ").ToProperCase().Trim();
                    var    fItem = new ToolStripMenuItem(rName)
                    {
                        Image = FolderImage
                    };
                    menuItem.DropDownItems.Add(fItem);
                    //
                    GetItems(ref service2005, catalogItem, ref fItem);
                }
            }
        }
        private static int disableSubscription(ReportingService2005 rs, string subID)
        {
            /* Set up schedule info for any time in the past */
            string scheduleXML =
                    @"<ScheduleDefinition>" +
                     "   <StartDateTime>2010-12-31T08:00:00-08:00" +
                     "   </StartDateTime>" +
                     "</ScheduleDefinition>";

            ExtensionSettings es;
            string owner;
            string description;
            ActiveState activeState;
            string status;
            string eventType;
            string matchData = scheduleXML; //Based on if schedule is shared schedule, make it stop now
            string oldMatchData;
            ParameterValue[] parameters = null;

            try
            {
                owner = rs.GetSubscriptionProperties(subID, out es, out description, out activeState, out status, out eventType, out oldMatchData, out parameters);
                rs.SetSubscriptionProperties(subID, es, description, eventType, matchData, parameters);
            }
            catch (SoapException ex)
            {
                Console.WriteLine(ex.ToString());
            }

            return 0;
        }
Exemplo n.º 6
0
 private void loadTreeNode(string path, TreeNodeCollection nodes, ReportingService2005 rs, Dictionary <string, string> dataSources)
 {
     CatalogItem[] items = rs.ListChildren(path, false);
     foreach (var item in items)
     {
         TreeNode t = new TreeNode();
         t.Text = item.Name;
         t.Name = item.Name;
         if (item.Type == ItemTypeEnum.DataSource)
         {
             if (!dataSources.ContainsKey(item.Name))
             {
                 dataSources.Add(item.Name, item.Path);
             }
         }
         if (item.Type != ItemTypeEnum.Model && item.Type != ItemTypeEnum.DataSource)
         {
             nodes.Add(t);
         }
         if (item.Type == ItemTypeEnum.Folder)
         {
             loadTreeNode(item.Path, t.Nodes, rs, dataSources);
         }
         else
         {
         }
     }
 }
Exemplo n.º 7
0
        private bool LoadReportItems(ReportingService2005 service, ReportItem parent)
        {
            var dataSources = DataSources;
            var newItems    = GetReportItems(service, parent.Path);

            foreach (var item in newItems)
            {
                switch (item.Type)
                {
                case ItemTypeEnum.DataSource:
                    if (!dataSources.ContainsKey(item.Name))
                    {
                        dataSources.Add(item.Name, item.Path);
                    }
                    break;

                case ItemTypeEnum.Folder:
                    var newParent = AddReportItem(parent, item, true);
                    LoadReportItems(service, newParent);
                    break;

                case ItemTypeEnum.Model:
                    break;

                default:
                    AddReportItem(parent, item, false);
                    break;
                }
            }

            return(true);
        }
Exemplo n.º 8
0
        private static void CreateFolder(string reportingServiceUrl, string folder, string parent)
        {
            try
            {
                var service = new ReportingService2005
                {
                    Url         = reportingServiceUrl,
                    Credentials = System.Net.CredentialCache.DefaultCredentials
                };

                service.CreateFolder(folder, parent, null);
            }
            catch (SoapException ex)
            {
                // Check whether the folder already exists.

                var errorCodeNode = ex.Detail["ErrorCode"];
                if (errorCodeNode == null)
                {
                    throw;
                }
                var errorCode = errorCodeNode.InnerText;
                if (errorCode != "rsItemAlreadyExists")
                {
                    throw;
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Gets the reporting service object.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="credentials">The credentials.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentException">url</exception>
        private static ReportingService2005 GetReportingService(string url, ICredentials credentials)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentException("url");
            }

            if (credentials == null)
            {
                credentials = CredentialCache.DefaultNetworkCredentials;
            }

            if (!url.EndsWith("reportservice2005.asmx"))
            {
                if (url.EndsWith("/"))
                {
                    url = url.Substring(0, url.Length - 1);
                }

                url = string.Format("{0}/reportservice2005.asmx", url);
            }

            ReportingService2005 service = new ReportingService2005();

            service.Url = url;

            service.Credentials           = credentials;
            service.PreAuthenticate       = true;
            service.UseDefaultCredentials = true;

            return(service);
        }
Exemplo n.º 10
0
 private void InitSSRS()
 {
     //init ssrs stuff
     rs             = new ReportingService2005();
     rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
     rs.Url         = GetRSURL();
 }
        private void PickSchedule_Load(object sender, EventArgs e)
        {
            rs             = new ReportingService2005();
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            Schedule[] schedules = null;

            try
            {
                schedules = rs.ListSchedules();
                if (schedules != null)
                {
                    //Build list items
                    ArrayList aList = new ArrayList();
                    // Now add the Do not schedule item
                    aList.Add(new ComboItem("Do not schedule", "NS"));
                    // And the Snapshot schedule
                    aList.Add(new ComboItem("Schedule with Snapshot", "SS"));
                    foreach (Schedule s in schedules)
                    {
                        aList.Add(new ComboItem(s.Description, s.ScheduleID));
                        Debug.WriteLine(String.Format("Desc: {0} - ID: {1}", s.Description,
                                                      s.ScheduleID));
                    }
                    //Bind list items to combo box
                    sharedSchedules.DataSource    = aList;
                    sharedSchedules.DisplayMember = "Display";
                    sharedSchedules.ValueMember   = "Value";
                }
            }
            catch (SoapException ex)
            {
                MessageBox.Show(ex.Detail.InnerXml.ToString());
            }
        }
Exemplo n.º 12
0
        protected override IReportServerRepository CreateInstance(IContext context)
        {
            string url  = Properties.Settings.Default.ReportServer2008WebServiceUrl;
            string path = Properties.Settings.Default.DestinationPath;

            if (!url.EndsWith("reportservice2005.asmx"))
            {
                if (url.EndsWith("/"))
                {
                    url = url.Substring(0, url.Length - 1);
                }

                url = string.Format("{0}/reportservice2005.asmx", url);
            }

            ReportingService2005 service = new ReportingService2005();

            service.Url = url;

            service.Credentials           = CredentialCache.DefaultNetworkCredentials;
            service.PreAuthenticate       = true;
            service.UseDefaultCredentials = true;

            return(new ReportServer2005Repository(path, service, new ReportingService2005DataMapper()));
        }
Exemplo n.º 13
0
        /// <summary>
        /// Teardowns the environment.
        /// </summary>
        /// <param name="url">The URL.</param>
        /// <param name="credentials">The credentials.</param>
        /// <param name="path">The path to delete.</param>/param>
        /// <exception cref="System.ArgumentException">
        /// url
        /// or
        /// path
        /// </exception>
        public static void TeardownEnvironment(string url,
                                               ICredentials credentials,
                                               string path)
        {
            if (string.IsNullOrEmpty(url))
            {
                throw new ArgumentException("url");
            }

            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException("path");
            }

            ReportingService2005 service = ReportingService2005TestEnvironment.GetReportingService(url, credentials);

            // If the path exists, delete it to clean up after the tests
            if (ReportingService2005TestEnvironment.ItemExists(service, path, ItemTypeEnum.Folder))
            {
                service.DeleteItem(path);
            }

            if (ReportingService2005TestEnvironment.ItemExists(service, path, ItemTypeEnum.Folder))
            {
                service.DeleteItem(path);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// Gets the reports.
        /// </summary>
        /// <param name="menuItem">The menu item.</param>
        /// 11/02/2011 by gpilar
        public void GetReports(ToolStripDropDownItem menuItem)
        {
            ReportingService2005 service2005 = ReportingService2005;
            //
            List <CatalogItem> list = service2005.ListChildren(Reportpath, false).ToList();

            list.RemoveAll(i => i.Hidden == !ShowHidenItems || (i.Type != ItemTypeEnum.Report && i.Type != ItemTypeEnum.Folder));

            foreach (CatalogItem item in list)
            {
                if (item.Type == ItemTypeEnum.Report)
                {
                    string rName = item.Name.Replace("/", "").Replace("_", " ").ToProperCase().Trim();
                    string rTag  = item.Path;
                    var    rItem = new ToolStripMenuItem(rName)
                    {
                        Image = FolderImage, Tag = rTag
                    };
                    rItem.Click += ((sender, e) => OnShow(sender, new ShowReportsEventArgs(((ToolStripMenuItem)sender).Tag.ToString())));
                    menuItem.DropDownItems.Add(rItem);
                }
                if (item.Type == ItemTypeEnum.Folder)
                {
                    string rName = item.Name.Replace("/", " ").Replace("_", " ").ToProperCase().Trim();
                    var    fItem = new ToolStripMenuItem(rName)
                    {
                        Image = FolderImage
                    };
                    menuItem.DropDownItems.Add(fItem);
                    GetItems(ref service2005, item, ref fItem);
                }
            }
        }
Exemplo n.º 15
0
        public ReportingServicesMgmt(string url, string username, string password, bool integratedAuth)
        {
            var reportServerUrl = url.TrimEnd('/') + ServicesUrl;

            DataSources = new Dictionary <string, string>();

            ReportingService = new ReportingService2005 {
                Url = reportServerUrl
            };
            if (!integratedAuth)
            {
                var nameParts = username.Split('\\', '/');
                if (nameParts.Length > 2)
                {
                    throw new Exception(Resources.Incorrect_destination_user_name);
                }
                ReportingService.Credentials = nameParts.Length == 2
                    ? new System.Net.NetworkCredential(nameParts[1], password, nameParts[0])
                    : new System.Net.NetworkCredential(username, password);
            }
            else
            {
                ReportingService.Credentials = System.Net.CredentialCache.DefaultCredentials;
            }
        }
Exemplo n.º 16
0
        private void GetReportParameters()
        {
            try
            {
                ReportParameter[] parameters;
                using (ReportingService2005 reportsServerInstance = ((ReportServerProperties)(SourceNode.TreeView.Tag)).ReportsServerInstance)
                {
                    reportsServerInstance.Credentials = System.Net.CredentialCache.DefaultCredentials;

                    string                  historyID    = null;
                    bool                    forRendering = true;
                    ParameterValue[]        values       = null;
                    DataSourceCredentials[] credentials  = null;

                    parameters = reportsServerInstance.GetReportParameters
                                 (
                        SourceNode.FullPath.Replace(SourceNode.TreeView.Nodes[0].Text, string.Empty).Replace(@"\", @"/"),
                        historyID,
                        forRendering,
                        values,
                        credentials
                                 );
                }

                int ControlCounter = 0;

                foreach (var parameter in parameters)
                {
                    Control control = new Label
                    {
                        Name    = string.Format("txParamLabel{0}", ControlCounter),
                        Text    = string.Format("[{0} - {1}]", parameter.Name, parameter.Type),
                        Visible = true,
                        Height  = 120
                    };

                    flowLayoutPanel1.Controls.Add(control);


                    control = (parameter.Type != ParameterTypeEnum.Boolean)
                                  ? new TextBox()
                                  : new CheckBox() as Control;

                    control.Name    = string.Format("txDynamicControl{0}", ControlCounter);
                    control.Visible = true;
                    control.Tag     = parameter;
                    control.Height  = 120;

                    flowLayoutPanel1.Controls.Add(control);


                    ControlCounter++;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }
Exemplo n.º 17
0
 public ReportDeployHelper(string domain, string userName, string password, string reportService)
 {
     this._rs = new ReportingService2005
     {
         Url         = reportService,
         Credentials = new NetworkCredential(userName, password, domain)
     };
 }
Exemplo n.º 18
0
        private static void CreateFolders(ReportingService2005 reportingService, string path)
        {
            foreach (FolderItem folder in SetupFolderItems)
            {
                string fullPath = string.Format(folder.Path, path);

                ReportingService2005TestEnvironment.CreateFolderFromPath(reportingService, fullPath);
            }
        }
Exemplo n.º 19
0
 public void InicializeEngine()
 {
     this.WebServiceUrl        = this.WebServiceUrl;
     this.ReportingService2005 = new ReportingService2005
     {
         Url = WebServiceUrl,
         UseDefaultCredentials = UseDefaultCredentials
     };
 }
Exemplo n.º 20
0
 public void FillTreeview(ReportingService2005 reportService2005)
 {
     Cursor.Current = Cursors.WaitCursor;
     treeView1.BeginUpdate();
     treeView1.Nodes.Clear();
     treeView1.Nodes.Add(TreeViewHandling.GetFolderAsNodes(reportService2005, true));
     treeView1.EndUpdate();
     treeView1.ExpandAll();
     Cursor.Current = Cursors.Arrow;
 }
Exemplo n.º 21
0
        internal static TreeNode GetFolderAsNodes(ReportingService2005 reportingService2005, bool showDataSource)
        {
            TreeNode xRoot = new TreeNode(reportingService2005.Url)
            {
                Tag        = reportingService2005.Url,
                ImageIndex = 3
            };

            return(FillTreeView("/", xRoot, reportingService2005, showDataSource));
        }
Exemplo n.º 22
0
        private void DisposeOfService()
        {
            var service = _Service;

            if (service != null)
            {
                service.Dispose();
                _Service = null;
            }
        }
        private void getFolders_Click(object sender, EventArgs e)
        {
            ssrsFolders.Nodes.Clear();
            rs             = new ReportingService2005();
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
            CatalogItem[] items = null;
            rs.Url = GetRSURL();

            TreeNode root = new TreeNode();

            root.Text = "Root";
            ssrsFolders.Nodes.Add(root);
            ssrsFolders.SelectedNode = ssrsFolders.TopNode;

            // Retrieve a list items from the server
            try
            {
                items = rs.ListChildren("/", true);

                int j = 1;

                // Iterate through the list of items and find all of the folders and display them to the user
                foreach (CatalogItem ci in items)
                {
                    if (ci.Type == ItemTypeEnum.Folder)
                    {
                        Regex rx       = new Regex("/");
                        int   matchCnt = rx.Matches(ci.Path).Count;
                        if (matchCnt > j)
                        {
                            ssrsFolders.SelectedNode = ssrsFolders.SelectedNode.LastNode;
                            j = matchCnt;
                        }
                        else if (matchCnt < j)
                        {
                            ssrsFolders.SelectedNode = ssrsFolders.SelectedNode.Parent;
                            j = matchCnt;
                        }
                        AddNode(ci.Name);
                    }
                }
            }

            catch (SoapException ex)
            {
                MessageBox.Show(ex.Detail.InnerXml.ToString());
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            // Make sure the user can see that the root folder is selected by default
            ssrsFolders.HideSelection = false;
        }
Exemplo n.º 24
0
        public static SSRSVersion GetSqlServerVersion(ReportingService2005 reportServerConnection)
        {
            if (reportServerConnection == null)
            {
                throw new ArgumentNullException("reportServerConnection");
            }

            reportServerConnection.ListSecureMethods();

            return(GetSqlServerVersion(reportServerConnection.ServerInfoHeaderValue.ReportServerVersion));
        }
Exemplo n.º 25
0
        private void EnsureDescendantNodesAreLoaded(TreeNode parentNode, ReportingService2005 reportingService, bool source)
        {
            if (!EnsureChildNodesAreLoaded(parentNode, reportingService, source))
            {
                return;
            }

            foreach (TreeNode childNode in parentNode.Nodes)
            {
                EnsureDescendantNodesAreLoaded(childNode, reportingService, source);
            }
        }
Exemplo n.º 26
0
 private CatalogItem[] GetReportItems(ReportingService2005 service, string path)
 {
     try
     {
         return(service.ListChildren(path, false));
     }
     catch (Exception exception)
     {
         // Todo: Display error message
         return(new CatalogItem[0]);
     }
 }
        /// <summary>
        /// Deploys the report.
        /// </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;

            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);

                ReportsServerInstance2005.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);
        }
Exemplo n.º 28
0
        private void btnLoad_Click(object sender, EventArgs e)
        {
            try
            {
                sourceRS = new ReportService.ReportingService2005();
                string reportServerURI = "http://localhost:8080/ReportServer";
                if (!String.IsNullOrEmpty(txtSourceUrl.Text))
                {
                    reportServerURI = txtSourceUrl.Text;
                }

                sourceRS.Url = reportServerURI + "/ReportService2005.asmx";

                if (!String.IsNullOrEmpty(txtSourceUser.Text))
                {
                    var userName  = txtSourceUser.Text;
                    var nameParts = userName.Split('\\', '/');
                    if (nameParts.Length > 2)
                    {
                        MessageBox.Show("Incorrect source user name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else if (nameParts.Length == 2)
                    {
                        userName             = nameParts[1];
                        sourceRS.Credentials = new System.Net.NetworkCredential(userName, txtSourcePassword.Text, nameParts[0]);
                    }
                    else
                    {
                        sourceRS.Credentials = new System.Net.NetworkCredential(userName, txtSourcePassword.Text);
                    }
                }
                else
                {
                    sourceRS.Credentials = System.Net.CredentialCache.DefaultCredentials;
                }

                rptSourceTree.Nodes.Clear();
                sourceDS = new Dictionary <string, string>();
                loadTreeNode(ROOT_FOLDER, rptSourceTree.Nodes, sourceRS, sourceDS);
                if (radConn.Checked)
                {
                    btnLoadDSNames.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Loading failed." + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 29
0
        private static void CreateDataSources(ReportingService2005 reportingService, string path)
        {
            if (reportingService == null)
            {
                throw new ArgumentNullException("reportingService");
            }

            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentException("path");
            }

            foreach (DataSourceItem dataSource in SetupDataSourceItems)
            {
                DataSourceDefinition def = new DataSourceDefinition();
                def.ConnectString = dataSource.ConnectString;

                switch (dataSource.CredentialsRetrieval)
                {
                case "Integrated":
                    def.CredentialRetrieval = CredentialRetrievalEnum.Integrated; break;

                case "None":
                    def.CredentialRetrieval = CredentialRetrievalEnum.None; break;

                case "Prompt":
                    def.CredentialRetrieval = CredentialRetrievalEnum.Prompt; break;

                case "Store":
                    def.CredentialRetrieval = CredentialRetrievalEnum.Store; break;
                }

                def.Enabled                              = dataSource.Enabled;
                def.EnabledSpecified                     = dataSource.EnabledSpecified;
                def.Extension                            = dataSource.Extension;
                def.ImpersonateUser                      = dataSource.ImpersonateUser;
                def.ImpersonateUserSpecified             = dataSource.ImpersonateUserSpecified;
                def.OriginalConnectStringExpressionBased = dataSource.OriginalConnectStringExpressionBased;
                def.Password                             = dataSource.Password;
                def.Prompt = dataSource.Prompt;
                def.UseOriginalConnectString = dataSource.UseOriginalConnectString;
                def.UserName           = dataSource.UserName;
                def.WindowsCredentials = dataSource.WindowsCredentials;

                string fullPath = string.Format(dataSource.Path, path);
                string parent   = TesterUtility.GetParentPath(fullPath);

                reportingService.CreateDataSource(dataSource.Name, parent, true, def, null);
            }
        }
Exemplo n.º 30
0
        private bool EnsureChildNodesAreLoaded(TreeNode parentNode, ReportingService2005 reportingService, bool source)
        {
            LoadingTreeNode loadingTreeNode;

            if (LoadingTreeNode.TryGetLoadingNode(parentNode, out loadingTreeNode))
            {
                parentNode.Nodes.Clear();
                LoadTreeNode(loadingTreeNode.SsrsPath, parentNode.Nodes, reportingService, source);

                return(true);
            }

            return(false);
        }
Exemplo n.º 31
0
 public RSCommunicator(string url, string userName = null, string password = null)
 {
     _reportService                 = new ReportingService2005();
     _reportService.Url             = url;
     _reportService.PreAuthenticate = true;
     if (String.IsNullOrWhiteSpace(userName) || String.IsNullOrWhiteSpace(password))
     {
         _reportService.UseDefaultCredentials = true;
     }
     else
     {
         _reportService.Credentials = new NetworkCredential(userName, password);
     }
 }
 static void Main(string[] args)
 {
     if (args.Length < 2)
     {
         printUsage();
         Console.ReadLine();
     }
     else
     {
         var rs = new ReportingService2005();
         rs.Credentials = CredentialCache.DefaultCredentials;
         rs.Url = args[0];
         string subID = args[1];
         disableSubscription(rs, subID);
         Console.WriteLine("\nFinished... Press any key");
         Console.ReadLine();
     }
 }
 static void Main(string[] args)
 {
     if (args.Length < 3)
     {
         printUsage();
         Console.ReadLine();
     }
     else
     {
         var rs = new ReportingService2005();
         rs.Credentials = CredentialCache.DefaultCredentials;
         rs.Url = args[0];
         CatalogItem item = new CatalogItem();
         item.Path = args[1];
         List<CatalogItem> items = new List<CatalogItem>();
         items.Add(item);
         string emailAddressMapFile = args[2];
         Dictionary<string, string> emailAddressMap = populateEmailAddressMap(emailAddressMapFile);
         modSubscriptionEmail(rs, items, emailAddressMap);
         Console.WriteLine("\nFinished... Press any key");
         Console.ReadLine();
     }
 }
        private static int modSubscriptionEmail(ReportingService2005 rs, List<CatalogItem> items, Dictionary<string, string> emailAddressMap)
        {
            if (items.Count == 0)
            {
                return 0;
            }
            else
            {
                CatalogItem item = items[items.Count - 1];
                items.RemoveAt(items.Count - 1);
                //Console.WriteLine("Hitting: " + item.Path);

                if (rs.GetItemType(item.Path) == ItemTypeEnum.Report)
                {
                    Console.WriteLine("Modifying email address for: " + item.Path);
                    foreach (var sub in rs.ListSubscriptions(item.Path, null))
                    {
                        if (sub.EventType == "TimedSubscription" && sub.IsDataDriven == false)
                        {
                            string subID = sub.SubscriptionID;
                            string owner = sub.Owner;
                            string description = sub.Description;
                            ActiveState activeState = sub.Active;
                            string status = sub.Status;
                            string eventType = sub.EventType;
                            string matchData;
                            ParameterValue[] parameters = null;
                            ExtensionSettings es = sub.DeliverySettings;

                            if (sub.DeliverySettings.Extension == "Report Server FileShare")
                            {
                                es.ParameterValues = setPassword(es.ParameterValues);
                            }

                            try
                            {
                                rs.GetSubscriptionProperties(subID, out es, out description, out activeState, out status, out eventType, out matchData, out parameters);
                                es = swapEmailAddresses(es, emailAddressMap, ref description);
                                rs.SetSubscriptionProperties(sub.SubscriptionID, es, description, eventType, matchData, parameters);
                            }
                            catch (SoapException ex)
                            {
                                Console.WriteLine(ex.ToString());
                            }
                        }
                    }
                }
                else if (rs.GetItemType(item.Path) == ItemTypeEnum.Folder)
                {
                    Console.WriteLine("Descending into folder: " + item.Path);
                    items.InsertRange(0, rs.ListChildren(item.Path, false));
                    //disableSubscriptions(rs, new List<CatalogItem>(rs.ListChildren(item.Path, true)));

                    //foreach (var catalogItem in rs.ListChildren(path, true))
                    //{
                    //    disableSubscriptions(rs, catalogItem.Path);
                    //}
                }
                modSubscriptionEmail(rs, items, emailAddressMap);
                return 0;
            }
        }
Exemplo n.º 35
0
        private ReportParameter[] GetReportParameters(ParameterValue[] values)
        {
            string serverUrl;
            string modelsFolder;
            string company;
            string languageCulture;

            ReportParameter[] parameters = null;
            string errMsg = null;
            try
            {
                ReportUtility.GetSessionInfo(out serverUrl, out modelsFolder, out company, out languageCulture);
                if (string.IsNullOrEmpty(serverUrl))
                {
                    throw new InvalidOperationException(Resources.GetString(Report.NoServerUrl));
                }

                ReportSettings settings = new ReportSettings();
                settings.ReportManagerUrl = serverUrl;
                settings.RootFolder = modelsFolder;
                settings.ReportPath = this.ReportPath;

                string fullPath = settings.ResolveFullPath();

                // Ask reporting services for a list of all reports and all the parameters for the currently selected report.
                using (ReportingService2005 rs = new ReportingService2005())
                {
                    // Provoke potential exceptions by validating the full path
                    settings.ValidateFullPath(fullPath);

                    rs.Url = settings.ResolvedServiceUrl;
                    rs.Credentials = System.Net.CredentialCache.DefaultCredentials;
                    parameters = rs.GetReportParameters(fullPath, null, values != null, values, null);
                }
            }
            catch (System.Net.WebException)
            {
                errMsg = Resources.GetString(Report.cant_read_from_server);
            }
            catch (InvalidOperationException reportException)
            {
                errMsg = Microsoft.SharePoint.Utilities.SPHttpUtility.HtmlEncode(reportException.Message);
            }
            catch (ReportException reportException)
            {
                errMsg = AxRSReportWebPart.FormatMissingReportExceptionMessage(
                    reportException,
                    this.WebPartToEdit.CultureInfo,
                    this.WebPartToEdit.Title,
                    this.ReportPath);
            }
            catch (Exception exception)
            {
                errMsg = Microsoft.SharePoint.Utilities.SPHttpUtility.HtmlEncode(exception.Message);
            }

            if (!string.IsNullOrEmpty(errMsg))
            {
                this.AddErrorMessage(errMsg);
            }

            return parameters;
        }
Exemplo n.º 36
0
 private void DisposeOfService()
 {
     var service = _Service;
     if (service != null)
     {
         service.Dispose();
         _Service = null;
     }
 }
        private static int disableSubscriptions(ReportingService2005 rs, List<CatalogItem> items)
        {
            /* Set up schedule info for any time in the past */
            string scheduleXML =
                    @"<ScheduleDefinition>" +
                     "   <StartDateTime>2010-12-31T08:00:00-08:00" +
                     "   </StartDateTime>" +
                     "</ScheduleDefinition>";

            if (items.Count == 0)
            {
                return 0;
            }
            else
            {
                CatalogItem item = items[items.Count -1];
                items.RemoveAt(items.Count - 1);
                //Console.WriteLine("Hitting: " + item.Path);

                if (rs.GetItemType(item.Path) == ItemTypeEnum.Report)
                {
                    Console.WriteLine("Disabling subscriptions for: " + item.Path);
                    foreach (var sub in rs.ListSubscriptions(item.Path, null))
                    {
                        if (sub.EventType == "TimedSubscription" && sub.IsDataDriven == false)
                        {
                            ExtensionSettings es = sub.DeliverySettings;

                            if (sub.DeliverySettings.Extension == "Report Server FileShare")
                            {
                                es.ParameterValues = setPassword(es.ParameterValues);
                            }

                            string description = sub.Description;
                            string eventType = sub.EventType;
                            string matchData = scheduleXML;//Based on if schedule is shared schedule, make it stop now
                            ParameterValue[] parameters = null;

                            try
                            {
                                rs.SetSubscriptionProperties(sub.SubscriptionID, es, description, eventType, matchData, parameters);
                            }
                            catch (SoapException ex)
                            {
                                Console.WriteLine(ex.ToString());
                            }
                        }
                    }
                }
                else if (rs.GetItemType(item.Path) == ItemTypeEnum.Folder)
                {
                    Console.WriteLine("Descending into folder: " + item.Path);
                    items.InsertRange(0, rs.ListChildren(item.Path, false));
                    //disableSubscriptions(rs, new List<CatalogItem>(rs.ListChildren(item.Path, true)));

                    //foreach (var catalogItem in rs.ListChildren(path, true))
                    //{
                    //    disableSubscriptions(rs, catalogItem.Path);
                    //}
                }
                disableSubscriptions(rs, items);
                return 0;
            }
        }
 static void Main(string[] args)
 {
     if (args.Length < 2)
     {
         printUsage();
         Console.ReadLine();
     }
     else
     {
         var rs = new ReportingService2005();
         rs.Credentials = CredentialCache.DefaultCredentials;
         rs.Url = args[0];
         CatalogItem item = new CatalogItem();
         item.Path = args[1];
         List<CatalogItem> items = new List<CatalogItem>();
         items.Add(item);
         disableSubscriptions(rs, items);
         Console.WriteLine("\nFinished... Press any key");
         Console.ReadLine();
     }
 }
Exemplo n.º 39
0
 private CatalogItem[] GetReportItems(ReportingService2005 service, string path)
 {
     try
     {
         return service.ListChildren(path, false);
     }
     catch (Exception exception)
     {
         // Todo: Display error message
         return new CatalogItem[0];
     }
 }
Exemplo n.º 40
0
        private bool LoadReportItems(ReportingService2005 service, ReportItem parent)
        {
            var dataSources = DataSources;
            var newItems = GetReportItems(service, parent.Path);
            foreach (var item in newItems)
            {
                switch (item.Type)
                {
                    case ItemTypeEnum.DataSource:
                        if (!dataSources.ContainsKey(item.Name))
                        {
                            dataSources.Add(item.Name, item.Path);
                        }
                        break;
                    case ItemTypeEnum.Folder:
                        var newParent = AddReportItem(parent, item, true);
                        LoadReportItems(service, newParent);
                        break;
                    case ItemTypeEnum.Model:
                        break;
                    default:
                        AddReportItem(parent, item, false);
                        break;
                }
            }

            return true;
        }