Esempio n. 1
0
        public CatalogItem[] GetExistingReports(string folder)
        {
            string reportPath = "/" + folder;
            var    results    = _reportService.ListChildren(reportPath, true);

            return(results);
        }
Esempio n. 2
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);
                }
            }
        }
Esempio n. 3
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
         {
         }
     }
 }
Esempio n. 4
0
 private object GetFoldersOnServer(ReportingService2005 reportingService2005, BackgroundWorker worker, DoWorkEventArgs e)
 {
     try
     {
         return(rs.ListChildren("/", true));
         //this returns : CatalogItem[]
     }
     catch (SoapException ex)
     {
         throw new Exception("SOAP Exception occured : " + ex.Detail.InnerXml.ToString(), ex);
     }
     catch (Exception ex)
     {
         throw new Exception("Unexpected exception occured while retrieving Folders on reporting server", ex);
     }
 }
Esempio n. 5
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);
                }
            }
        }
        /// <summary>
        /// Gets the basic info.
        /// </summary>
        private void GetBasicInfo()
        {
            CatalogItem[] catalogItems = _reportServerProperties2005.ListChildren(SourceNode.Parent.FullPath.Replace(SourceNode.TreeView.Nodes[0].Text, string.Empty).Replace(@"\", "/"), false);
            foreach (CatalogItem catalogItem in catalogItems.Where(catalogItem => catalogItem.Name == SourceNode.Text))
            {
                _catalogItem = catalogItem;
                break;
            }

            if (_catalogItem == null)
            {
                return;
            }

            Text = string.Format(Text, IsNull(_catalogItem.Name));
            txtCreatedBy.Text   = IsNull(_catalogItem.CreatedBy);
            txtCreatedOn.Text   = IsNull(_catalogItem.CreationDate);
            txtDescription.Text = IsNull(_catalogItem.Description);
            txtID.Text          = "{" + IsNull(_catalogItem.ID) + "}";
            txtModifiedBy.Text  = IsNull(_catalogItem.ModifiedBy);
            txtModifyOn.Text    = IsNull(_catalogItem.ModifiedDate);

            txtSize.Text = (_catalogItem.Size != null)
                               ? string.Format("{0:F2}  KB", _catalogItem.Size / 1024)
                               : "n/a";
        }
        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;
        }
Esempio n. 8
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]);
     }
 }
Esempio n. 9
0
        private static Dictionary <string, DataSourceDefinitionOrReference> GetDataSources(ReportingService2005 rs, string folder)
        {
            var children = rs.ListChildren(folder, false);

            return(children
                   .Where(i => i.Type == ItemTypeEnum.DataSource)
                   .ToDictionary(
                       i => i.Name,
                       i => (DataSourceDefinitionOrReference) new DataSourceReference {
                Reference = i.Path
            }));
        }
Esempio n. 10
0
        private IEnumerable <string> GetServerReports()
        {
            // http://ssrstutorials.blogspot.com/2012/10/lesson-12-using-ssrs-web-services.html
            var rs = new ReportingService2005 {
                Credentials = System.Net.CredentialCache.DefaultCredentials
            };

            // Retrieve a list of all items from the report server database.
            try {
                return(rs.ListChildren("/", true).Where(i => i.Type == ItemTypeEnum.Report)
                       .Select(i => i.Path));
            }

            catch (SoapException ex) {
                Console.WriteLine(ex.Detail.OuterXml);
                return(null);
            }
        }
        public IEnumerable <CatalogItem> GetAllReport(string searchString, bool IsReportName = false)
        {
            var items = new HashSet <CatalogItem>();
            var log   = new StringBuilder();

            log.AppendLine("Report Log:");
            try
            {
                var rs = new ReportingService2005();
                rs.Url = CommonFunction.Instance.ReportPath() + @"/ReportService2005.asmx";
                log.AppendLine(String.Format("\tTarget: {0}", rs.Url));
                rs.Credentials = new System.Net.NetworkCredential(
                    CommonFunction.Instance.ReportUser(),
                    CommonFunction.Instance.ReportPass()
                    );
                log.AppendLine("Credentials set.");
                var root = CommonFunction.Instance.ReportFolder();
                log.AppendLine(String.Format("Listing children under: {0}", CommonFunction.Instance.ReportFolder()));
                var children = rs.ListChildren(root, true)
                               .Where(c => c.Type == ItemTypeEnum.Report)
                               .Where(c => !c.Hidden);

                log.AppendLine(String.Format("Retrieved {0} items.", children.Count()));

                var filtered = FilterItemsByString(children, log, searchString, IsReportName);
                items = FilterItemsByRole(filtered, log);
            }
            catch (Exception ex)
            {
                var exLog = new StringBuilder(log.ToString());
                exLog.AppendLine("Credentials:");
                exLog.AppendLine(String.Format("\tUser: {0}", CommonFunction.Instance.ReportUser()));
                exLog.AppendLine(String.Format("\tPassword: {0}", CommonFunction.Instance.ReportPass()));
                exLog.AppendLine(String.Format("\tDomain: {0}", CommonFunction.Instance.DomainName()));

                Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception(exLog.ToString(), ex));

                items = new HashSet <CatalogItem>();
            }
            log.AppendLine(String.Format("Found {0} reports.", items.Count));
            ViewBag.Log = log.ToString();
            return(items);
        }
Esempio n. 12
0
        public override bool Execute()
        {
#if DEBUG
            ReportingService2005 rs2005 = new ReportingService2005();
            rs2005.Url = ReportServerUrl;
            rs2005.UseDefaultCredentials = UseDefaultCredentials;

            SortedList <string, string> ExistingDataSources = new SortedList <string, string>(StringComparer.InvariantCultureIgnoreCase);
            if (!Overwrite)
            {
                foreach (CatalogItem item in rs2005.ListChildren(TargetFolder, false))
                {
                    if (item.Type == ItemTypeEnum.DataSource)
                    {
                        ExistingDataSources[item.Name] = item.Name;
                    }
                }
            }

            foreach (ITaskItem ds in DataSources ?? new ITaskItem[0])
            {
                XPathDocument  doc = new XPathDocument(ds.ItemSpec);
                XPathNavigator nav = doc.CreateNavigator();
                nav.MoveToRoot();

                DataSourceDefinition dsd = new DataSourceDefinition();
                dsd.CredentialRetrieval = CredentialRetrievalEnum.Integrated;
                dsd.Enabled             = true;
                dsd.EnabledSpecified    = true;
                dsd.Prompt             = null;
                dsd.WindowsCredentials = false;

                foreach (XPathNavigator n in nav.Select("/RptDataSource/ConnecionProperties/*"))
                {
                    typeof(DataSetDefinition).InvokeMember(n.LocalName, System.Reflection.BindingFlags.SetProperty, null, dsd, new object[] { n.Value }, CultureInfo.InvariantCulture);
                }

                rs2005.CreateDataSource(nav.SelectSingleNode("/RptDataSource/Name").Value, TargetFolder, Overwrite, dsd, null);
            }
#endif
            return(true);
        }
Esempio n. 13
0
 private void EnsureDestDir(string path)
 {
     try
     {
         destRS.ListChildren(path, false);
     }
     catch (Exception)
     {
         //ensure parent folder
         var breatAt = path.LastIndexOf(PATH_SEPERATOR);
         var folder  = path.Substring(breatAt + 1);
         var parent  = path.Substring(0, breatAt);
         if (String.IsNullOrEmpty(parent))
         {
             parent = ROOT_FOLDER;
         }
         EnsureDestDir(parent);
         destRS.CreateFolder(folder, parent, null);
     }
 }
Esempio n. 14
0
        ///
        /// Cargar la lista de reportes en el dropdown
        ///
        protected void LoadReports(string _folder)
        {
            rs.Url         = "http://datos/ReportServer/reportservice2005.asmx";
            rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

            CatalogItem[] items = rs.ListChildren(folder, true);
            if (ddlReports.Items.Count == 0)
            {
                foreach (CatalogItem item in items.Where(x => x.Type == ItemTypeEnum.Folder).ToList())
                {
                    ddlFolders.Items.Add(new ListItem {
                        Text     = item.Path,
                        Selected = item.Path == _folder
                    });;
                }


                // TODO: SI NO EXISTE EL ddlFolders.SelectedItem , entonces seleccionar uno
                if (ddlFolders.SelectedItem != null)
                {
                    foreach (CatalogItem item in items.Where(x => x.Type == ItemTypeEnum.Report && x.Path == ddlFolders.SelectedItem.Text + "/" + x.Name).ToList())
                    {
                        ddlReports.Items.Add(new ListItem(item.Name, item.Path));
                    }
                }
                ddlFolders.Visible = true;
                ddlReports.Visible = true;
                ParamTable.Visible = true;
            }
            else
            {
                if (ddlReports.SelectedItem.Value.Replace(_folder + "/", "") != ddlReports.SelectedItem.Text)
                {
                    ddlReports.Items.Clear();
                    foreach (CatalogItem item in items.Where(x => x.Type == ItemTypeEnum.Report && x.Path == ddlFolders.SelectedItem.Text + "/" + x.Name).ToList())
                    {
                        ddlReports.Items.Add(new ListItem(item.Name, item.Path));
                    }
                }
            }
        }
Esempio n. 15
0
        public DataTable GetItems()
        {
            dtItems.Rows.Clear();
            //Adding parent
            DataRow dr = dtItems.NewRow();

            dr["Item"]     = "/";
            dr["Indented"] = "/";
            dr["Path"]     = "/";
            dr["Parent"]   = "";
            dr["Type"]     = ItemTypeEnum.Folder;
            dtItems.Rows.Add(dr);


            foreach (CatalogItem ci in rs.ListChildren("/", true))
            {
                //Adding folders or reports
                if (ci.Type == ItemTypeEnum.Folder || ci.Type == ItemTypeEnum.Report)
                {
                    dr             = dtItems.NewRow();
                    dr["Item"]     = ci.Name;
                    dr["Indented"] = ci.Name.PadLeft(ItemLevel(ci.Path) * 10);
                    dr["Path"]     = ci.Path;
                    dr["Type"]     = ci.Type;

                    int LastPosition = ci.Path.LastIndexOf("/");
                    if (LastPosition == 0)
                    {
                        dr["Parent"] = "/";
                    }
                    else
                    {
                        dr["Parent"] = ci.Path.Substring(0, LastPosition);
                    }

                    dtItems.Rows.Add(dr);
                }
            }
            return(dtItems);
        }
Esempio n. 16
0
        private void Click_btnBrowse(object sender, EventArgs e)
        {
            if (_rs != null)
            {
                CatalogItem[] folderList = _rs.ListChildren("/", false);
                string[]      folders    = new string[folderList.Length];
                for (int i = 0; i < folderList.Length; i++)
                {
                    if (!folderList[i].Hidden)
                    {
                        folders[i] = folderList[i].Name;
                    }
                }

                string folder = Form_SelectFolder.Process(folders, _tbTargetFolder.Text);

                if (folder.Length > 0)
                {
                    _tbTargetFolder.Text = folder;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                rs             = new ReportingService2005();
                rs.Credentials = System.Net.CredentialCache.DefaultCredentials;

                CatalogItem[] listItems = rs.ListChildren("/Pro_SSRS/Chapter_6", false);

                foreach (CatalogItem thisItem in listItems)
                {
                    if (thisItem.Type == ItemTypeEnum.Report)
                    {
                        ReportListing.Items.Add(thisItem.Name);
                    }
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Controllers.BovedaController tareas = new Controllers.BovedaController();
            Pendientes = string.Empty;
            //Pendientes = tareas.GetBovedaTareasPendientes(4);


            if (!IsPostBack)
            {
                ReportingService2005 service = new ReportingService2005();
                service.Timeout     = 10000;
                service.Url         = ConfigurationSettings.AppSettings["ReportServerWebService"];
                service.Credentials = new System.Net.NetworkCredential(ConfigurationSettings.AppSettings["ReportServerUser"], ConfigurationSettings.AppSettings["ReportServerPass"]);
                CatalogItem[] items = service.ListChildren("/MetroCambio", false);

                ddlReportes.Items.Add("Seleccione un Reporte");
                foreach (CatalogItem item in items)
                {
                    ddlReportes.Items.Add(item.Name);
                }
            }
        }
        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;
            }
        }
Esempio n. 20
0
        private void LoadTreeNode(string path, TreeNodeCollection nodes, ReportingService2005 rs, bool source = false)
        {
            CatalogItem[] items;
            try
            {
                items = rs.ListChildren(path, false);
            }
            catch (Exception x)
            {
                return;
            }

            foreach (var item in items)
            {
                if (source)
                {
                    lbSourceStatus.Text = String.Format("Source contains:{0} {1} reports{0} {2} folders{0} {3} datasources", Environment.NewLine,
                                                        _countReportsSource, _countFolderSource, _sourceServicesMgmt.DataSources.Count);
                }
                else
                {
                    lbDestStatus.Text = String.Format("Destination contains:{0} {1} reports{0} {2} folders{0} {3} datasources", Environment.NewLine,
                                                      _countReportsDest, _countFolderDest, _destServicesMgmt.DataSources.Count);
                }

                Application.DoEvents();
                var t = new TreeNode {
                    Text = item.Name, Name = item.Name
                };

                if (item.Type == ItemTypeEnum.DataSource)
                {
                    if (source)
                    {
                        if (!_sourceServicesMgmt.DataSources.ContainsKey(item.Name))
                        {
                            _sourceServicesMgmt.DataSources.Add(item.Name, item.Path);
                        }
                    }
                    else
                    {
                        if (!_destServicesMgmt.DataSources.ContainsKey(item.Name))
                        {
                            _destServicesMgmt.DataSources.Add(item.Name, item.Path);
                        }
                    }
                }

                if (item.Type != ItemTypeEnum.Model && item.Type != ItemTypeEnum.DataSource)
                {
                    nodes.Add(t);
                    if (source)
                    {
                        _countReportsSource++;
                    }
                    else
                    {
                        _countReportsDest++;
                    }
                }
                if (item.Type == ItemTypeEnum.Folder)
                {
                    LoadTreeNode(item.Path, t.Nodes, rs, source);
                    if (source)
                    {
                        _countFolderSource++;
                    }
                    else
                    {
                        _countFolderDest++;
                    }
                }
            }
        }
Esempio n. 21
0
        public ReportItemDTO[] ListChildren(string item, bool recursive)
        {
            var catItems = webserviceProxy.ListChildren(item, recursive);

            return(Array.ConvertAll(catItems, ConvertCatalogItemToReportItemDTO));
        }
        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;
            }
        }
Esempio n. 23
0
        private void LoadTreeNode(string path, TreeNodeCollection nodes, ReportingService2005 rs, bool source = false)
        {
            CatalogItem[] items;
            try
            {
                items = rs.ListChildren(path, false);
            }
            catch
            {
                return;
            }

            foreach (var item in items)
            {
                if (source)
                {
                    lbSourceStatus.Text = String.Format("Source contains:{0} {1} reports{0} {2} folders{0} {3} datasources", Environment.NewLine,
                                                        _countReportsSource, _countFolderSource, _sourceServicesMgmt.DataSources.Count);
                }
                else
                {
                    lbDestStatus.Text = String.Format("Destination contains:{0} {1} reports{0} {2} folders{0} {3} datasources", Environment.NewLine,
                                                      _countReportsDest, _countFolderDest, _destServicesMgmt.DataSources.Count);
                }

                Application.DoEvents();
                var t = new TreeNode {
                    Text = item.Name, Name = item.Name
                };

                if (item.Type == ItemTypeEnum.DataSource)
                {
                    if (source)
                    {
                        if (!_sourceServicesMgmt.DataSources.ContainsKey(item.Name))
                        {
                            _sourceServicesMgmt.DataSources.Add(item.Name, item.Path);
                        }
                    }
                    else
                    {
                        if (!_destServicesMgmt.DataSources.ContainsKey(item.Name))
                        {
                            _destServicesMgmt.DataSources.Add(item.Name, item.Path);
                        }
                    }
                }

                if (item.Type != ItemTypeEnum.Model && item.Type != ItemTypeEnum.DataSource)
                {
                    nodes.Add(t);
                    if (source)
                    {
                        _countReportsSource++;
                    }
                    else
                    {
                        _countReportsDest++;
                    }
                }

                if (item.Type == ItemTypeEnum.Folder)
                {
                    // Adds a "dummy" child node to flag that this node needs to be filled. The nodes are filled whenever
                    // they are expanded or checked.
                    t.Nodes.Add(new LoadingTreeNode(item.Path));

                    if (source)
                    {
                        _countFolderSource++;
                    }
                    else
                    {
                        _countFolderDest++;
                    }
                }
            }
        }
Esempio n. 24
0
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            if (!CheckActivationStatus(output))
            {
                return;
            }

            SetReportsLinksAndPaths(
                PropReportsPath,
                IsIntegratedMode,
                PropSRSUrl,
                UseDefaults,
                ref ReportingServicesURL,
                ref Integrated,
                ref ReportsRootFolderName);

            if (ReportingServicesURL == null || ReportingServicesURL == "")
            {
                output.Write("ReportingServicesURL has not been set.");
            }
            else
            {
                string username = "";
                string password = "";
                EPMLiveCore.ReportAuth _chrono = SPContext.Current.Site.WebApplication.GetChild <EPMLiveCore.ReportAuth>("ReportAuth");
                if (_chrono != null)
                {
                    username = _chrono.Username;
                    password = EPMLiveCore.CoreFunctions.Decrypt(_chrono.Password, "KgtH(@C*&@Dhflosdf9f#&f");
                }

                srs2005 = new ReportingService2005();
                srs2005.UseDefaultCredentials = true;
                string rptWS = ReportingServicesURL + "/ReportService2005.asmx";
                srs2005.Url = rptWS;

                /////////////////////////////////////////////////////////////////////
                //Code Here For Integrated Mode (If integrated checked, do the code below)
                /////////////////////////////////////////////////////////////////////
                if (Integrated)
                {
                    srs2006 = new ReportingService2006();
                    srs2006.UseDefaultCredentials = true;
                    rptWS       = ReportingServicesURL + "/ReportService2006.asmx";
                    srs2006.Url = rptWS;
                    try
                    {
                        curWeb = SPContext.Current.Web;
                        web    = curWeb.Site.RootWeb;

                        SPSecurity.RunWithElevatedPrivileges(delegate()
                        {
                            using (SPSite site = new SPSite(web.Url))
                            {
                                SPWebApplication app = site.WebApplication;
                                if (username != "")
                                {
                                    srs2006.UseDefaultCredentials = false;
                                    if (username.Contains("\\"))
                                    {
                                        srs2006.Credentials = new NetworkCredential(username.Substring(username.IndexOf("\\") + 1), password, username.Substring(0, username.IndexOf("\\")));
                                    }
                                    else
                                    {
                                        srs2006.Credentials = new NetworkCredential(username, password);
                                    }
                                }
                            }
                        });

                        if (tvReportView != null)
                        {
                            SPDocumentLibrary doc;

                            try
                            {
                                doc = (SPDocumentLibrary)web.Lists["Report Library"];
                            }
                            catch
                            {
                                throw new Exception("Document Library 'Report Library' does not exist.");
                            }

                            // Get the appropriate EPMLive folder
                            SPFolder reportFolder  = doc.RootFolder;
                            string   rootFolderURL = "Report Library" + this.ReportsFolderName;

                            foreach (SPListItem itemFolder in doc.Folders)
                            {
                                if (itemFolder.Url.ToLower() == rootFolderURL.ToLower())
                                {
                                    reportFolder = itemFolder.Folder;
                                    break;
                                }
                            }

                            if (reportFolder == doc.RootFolder)
                            {
                                throw new Exception("Folder '" + ReportsFolderName + "' does not exist.");
                            }

                            SPListItemCollection folderItems = doc.GetItemsInFolder(doc.DefaultView, reportFolder);

                            output.WriteLine("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\" height=\"100%\" ><tr><td id=\"coltohide\" style=\"vertical-align:top\" width=\"250\" height=\"100%\"><img src=\"/_layouts/images/blank.gif\" height=\"1\" width=\"250\">");

                            TreeNode tnTree = loadTree(folderItems, doc);
                            if (tnTree != null)
                            {
                                int iChildNodeCount = tnTree.ChildNodes.Count;
                                for (int i = 0; i < iChildNodeCount; i++)
                                {
                                    //It looks like we're adding the same node, but we're not
                                    //Each time you add a node, it removes it from tnTree
                                    tvReportView.Nodes.Add(tnTree.ChildNodes[0]);
                                }
                                tvReportView.DataBind();
                            }
                            tvReportView.RenderControl(output);
                            output.WriteLine("</td><td bgcolor=\"#D9D9D9\" onMouseOver=\"this.bgColor='#BBC4D9'\" onMouseOut=\"this.bgColor='#D9D9D9'\" width=\"10px\" height=\"100%\" onclick=\"show_hide_column1();\" align=\"center\">");
                            output.WriteLine("<img src=\"/_layouts/images/blank.gif\" height=\"1\" width=\"12\"><img src=\"/_layouts/epmlive/images/arrow.gif\" alt=\"\">");
                        }
                    }
                    catch (Exception ex)
                    {
                        output.Write(ex.Message);
                    }
                }
                ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                else
                {
                    ///SSRS Output
                    try
                    {
                        web = SPContext.Current.Web;

                        SPSecurity.RunWithElevatedPrivileges(delegate()
                        {
                            using (SPSite site = new SPSite(web.Url))
                            {
                                SPWebApplication app = site.WebApplication;

                                if (username != "")
                                {
                                    srs2005.UseDefaultCredentials = false;
                                    if (username.Contains("\\"))
                                    {
                                        srs2005.Credentials = new NetworkCredential(username.Substring(username.IndexOf("\\") + 1), password, username.Substring(0, username.IndexOf("\\")));
                                    }
                                    else
                                    {
                                        srs2005.Credentials = new NetworkCredential(username, password);
                                    }
                                }
                            }
                        });


                        SSRS2005.CatalogItem[] items;
                        //CatalogItem[] items;

                        // Retrieve a list of all items from the report server database.
                        try
                        {
                            items = srs2005.ListChildren(ReportsFolderName, true);
                            //items = srs2005.ListChildren(ReportsFolderName);
                            BuildTree(items);
                            output.Write(sbRptList.ToString());
                        }
                        catch (SoapException e)
                        {
                            output.Write("Soap Error: " + e.Detail.OuterXml);
                        }
                    }
                    catch
                    {
                        output.Write("Error connecting to Report Server");
                    }
                }

                output.WriteLine("</td><td width=\"100%\" height=\"100%\">");
                output.WriteLine("<iframe  id=\"Frameviewer\"  frameborder=\"0\"  vspace=\"0\"  hspace=\"0\"  marginwidth=\"0\" src=\"\"  marginheight=\"0\"");
                output.WriteLine("width=\"100%\"  scrolling=\"yes\"  height=\"100%\">");
                output.WriteLine("</iframe>");
                output.WriteLine("</td></tr></table>");
                output.WriteLine("<script>");
                //output.WriteLine("function show_hide_column1(td) {");
                //output.WriteLine("if(td.previousSibling.style.display==\"none\"){td.previousSibling.style.display = \"\";}");
                //output.WriteLine("else{td.previousSibling.style.display = \"none\";}}");
                output.WriteLine("function show_hide_column1() {");
                output.WriteLine("if(document.getElementById('coltohide').style.display==\"none\"){document.getElementById('coltohide').style.display=\"\";}");
                output.WriteLine("else{document.getElementById('coltohide').style.display=\"none\";}}");
                output.WriteLine("</script>");
                output.WriteLine("<script language=\"javascript\">");
                output.WriteLine("function frameview(link){");
                output.WriteLine("document.getElementById('Frameviewer').src=link;");
                output.WriteLine("document.getElementById('coltohide').style.display=\"none\";");
                output.WriteLine("}");
                output.WriteLine("</script>");
            }
        }
Esempio n. 25
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];
     }
 }
        protected override void RenderWebPart(HtmlTextWriter output)
        {
            if (!ReportViewer.CheckActivationStatus(output))
            {
                return;
            }

            ReportViewer.SetReportsLinksAndPaths(
                PropReportsPath,
                IsIntegratedMode,
                PropSRSUrl,
                UseDefaults,
                ref ReportingServicesURL,
                ref Integrated,
                ref ReportsRootFolderName);


            if (ReportingServicesURL == null || ReportingServicesURL == "")
            {
                output.Write("ReportingServicesURL has not been set.");
            }
            else
            {
                string username = "";
                string password = "";
                EPMLiveCore.ReportAuth _chrono = SPContext.Current.Site.WebApplication.GetChild <EPMLiveCore.ReportAuth>("ReportAuth");
                if (_chrono != null)
                {
                    username = _chrono.Username;
                    password = EPMLiveCore.CoreFunctions.Decrypt(_chrono.Password, "KgtH(@C*&@Dhflosdf9f#&f");
                }

                /////////////////////////////////////////////////////////////////////
                //Code Here For Integrated Mode (If integrated checked, do the code below)
                /////////////////////////////////////////////////////////////////////
                if (Integrated)
                {
                    srs2006 = new ReportingService2006();
                    srs2006.UseDefaultCredentials = true;
                    string rptWS = ReportingServicesURL + "/ReportService2006.asmx";
                    srs2006.Url = rptWS;

                    try
                    {
                        curWeb = SPContext.Current.Web;
                        web    = curWeb.Site.RootWeb;


                        SPSecurity.RunWithElevatedPrivileges(delegate()
                        {
                            using (SPSite site = new SPSite(web.Url))
                            {
                                SPWebApplication app = site.WebApplication;

                                if (password != "")
                                {
                                    srs2006.UseDefaultCredentials = false;
                                    if (username.Contains("\\"))
                                    {
                                        srs2006.Credentials = new NetworkCredential(username.Substring(username.IndexOf("\\") + 1), password, username.Substring(0, username.IndexOf("\\")));
                                    }
                                    else
                                    {
                                        srs2006.Credentials = new NetworkCredential(username, password);
                                    }
                                }
                            }
                        });

                        output.WriteLine("<script language=\"javascript\">");
                        output.WriteLine("function openWindow(report){");
                        //output.WriteLine("window.open(\"" + ReportingServicesURL + "?" + System.Web.HttpUtility.UrlEncode(web.Url + "/Report Library" + ReportsFolderName + "/") + "\" + report + \"" + "&rs:Command=Render&URL=" + HttpUtility.UrlEncode(web.ServerRelativeUrl) + "\",\"Report\",\"toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=yes\");");
                        output.WriteLine("window.open(\"" + ReportingServicesURL + "?" + System.Web.HttpUtility.UrlEncode(web.Url + "/") + "\" + report + \"" + "&rs:Command=Render&URL=" + HttpUtility.UrlEncode(SPContext.Current.Web.ServerRelativeUrl) + "\",\"Report\",\"toolbar=no, menubar=no, scrollbars=yes, resizable=yes,location=no, directories=no, status=yes\");");
                        output.WriteLine("}</script>");

                        if (tvReportView != null)
                        {
                            SPDocumentLibrary doc;

                            try
                            {
                                doc = (SPDocumentLibrary)web.Lists["Report Library"];
                            }
                            catch
                            {
                                throw new Exception("Document Library 'Report Library' does not exist.");
                            }

                            // Get the appropriate EPMLive folder
                            SPFolder reportFolder  = doc.RootFolder;
                            string   rootFolderURL = "Report Library" + this.ReportsFolderName;

                            foreach (SPListItem itemFolder in doc.Folders)
                            {
                                if (itemFolder.Url.ToLower() == rootFolderURL.ToLower())
                                {
                                    reportFolder = itemFolder.Folder;
                                    break;
                                }
                            }

                            if (reportFolder == doc.RootFolder)
                            {
                                throw new Exception("Folder '" + ReportsFolderName + "' does not exist.");
                            }

                            SPListItemCollection folderItems = doc.GetItemsInFolder(doc.DefaultView, reportFolder);

                            TreeNode tnTree = loadTree(folderItems, doc);
                            if (tnTree != null)
                            {
                                int iChildNodeCount = tnTree.ChildNodes.Count;
                                for (int i = 0; i < iChildNodeCount; i++)
                                {
                                    //It looks like we're adding the same node, but we're not
                                    //Each time you add a node, it removes it from tnTree
                                    tvReportView.Nodes.Add(tnTree.ChildNodes[0]);
                                }
                                tvReportView.DataBind();
                            }

                            tvReportView.RenderControl(output);
                        }
                    }
                    catch (Exception ex)
                    {
                        output.Write(ex.Message + ex.StackTrace);
                    }
                }
                else
                {
                    ///SSRS Output
                    try
                    {
                        web     = SPContext.Current.Web;
                        srs2005 = new ReportingService2005();
                        srs2005.UseDefaultCredentials = true;
                        string rptWS = ReportingServicesURL + "/ReportService2005.asmx";
                        srs2005.Url = rptWS;

                        SPSecurity.RunWithElevatedPrivileges(delegate()
                        {
                            using (SPSite site = new SPSite(web.Url))
                            {
                                SPWebApplication app = site.WebApplication;

                                if (password != "")
                                {
                                    srs2005.UseDefaultCredentials = false;
                                    if (username.Contains("\\"))
                                    {
                                        srs2005.Credentials = new NetworkCredential(username.Substring(username.IndexOf("\\") + 1), password, username.Substring(0, username.IndexOf("\\")));
                                    }
                                    else
                                    {
                                        srs2005.Credentials = new NetworkCredential(username, password);
                                    }
                                }
                            }
                        });

                        SSRS2005.CatalogItem[] items;
                        // Retrieve a list of all items from the report server database.
                        try
                        {
                            items = srs2005.ListChildren(ReportsFolderName, true);
                            BuildTree(items);
                            output.Write(sbRptList.ToString());
                        }
                        catch (SoapException e)
                        {
                            output.Write("Soap Error: " + e.Detail.OuterXml);
                        }
                    }
                    catch
                    {
                        output.Write("Error connecting to Report Server");
                    }
                }
                //////////
            }
        }
Esempio n. 27
0
        private static TreeNode FillTreeView(string path, TreeNode parentNode, ReportingService2005 reportingService2005, bool showDataSource)
        {
            try
            {
                CatalogItem[] catalogItems = reportingService2005.ListChildren(path, false);
                foreach (CatalogItem catalogItem in catalogItems)
                {
                    switch (catalogItem.Type)
                    {
                    case ItemTypeEnum.Folder:
                        TreeNode folderNode = new TreeNode(catalogItem.Name)
                        {
                            ImageIndex = 0,
                            // Tag = catalogItem,
                            Name = catalogItem.Path
                        };

                        folderNode.Tag = catalogItem.Type;
                        folderNode.SelectedImageIndex = folderNode.ImageIndex;
                        parentNode.Nodes.Add(FillTreeView(catalogItem.Path, folderNode, reportingService2005, showDataSource));
                        break;

                    case ItemTypeEnum.Report:
                        if (showDataSource)
                        {
                            break;
                        }
                        TreeNode reportNode = new TreeNode(catalogItem.Name)
                        {
                            ImageIndex = 1,
                            //Tag = catalogItem,
                            Name = catalogItem.Path
                        };

                        reportNode.Tag = catalogItem.Type;
                        reportNode.SelectedImageIndex = reportNode.ImageIndex;
                        parentNode.Nodes.Add(reportNode);
                        break;

                    case ItemTypeEnum.DataSource:
                        //if (showDataSource)
                        //{
                        TreeNode dataSourceNode = new TreeNode(catalogItem.Name)
                        {
                            ImageIndex = 2,
                            //Tag = catalogItem,
                            Name = catalogItem.Path,
                            Tag  = catalogItem.Type,
                        };

                        dataSourceNode.SelectedImageIndex = dataSourceNode.ImageIndex;
                        parentNode.Nodes.Add(dataSourceNode);
                        //}
                        break;
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(string.Format(@"The Reports Server {0} is not available. Exception details: {1}", reportingService2005.Url, exception.Message));
            }

            return(parentNode);
        }
Esempio n. 28
0
        public DataTable Get_List_Report(string condition, string orderColumn, string orderExpress, int selectedPage, int pageSize, out int totalRecords, out int totalPages)
        {
            totalPages   = 0;
            totalRecords = 0;
            DataTable dt = new DataTable();
            DataRow   dr = null;

            #region Create Columns in datatable
            dt.Columns.Add("id", Type.GetType("System.String"));
            dt.Columns.Add("reportname", Type.GetType("System.String"));
            dt.Columns.Add("reportpath", Type.GetType("System.String"));
            dt.Columns.Add("description", Type.GetType("System.String"));
            dt.Columns.Add("modifiedon", Type.GetType("System.DateTime"));
            dt.Columns.Add("createdon", Type.GetType("System.DateTime"));
            #endregion
            try
            {
                CatalogItem[] items = rs.ListChildren(WebConfigurationManager.AppSettings["ReportsRootPath"].ToString(), true);
                //where clause
                var query = (from r in items
                             where r.Type == ReportService2005.ItemTypeEnum.Report &&
                             (r.Name.ToLower().Contains(condition.ToLower().Trim()) ||
                              r.Description.ToLower().Contains(condition.ToLower().Trim()))
                             select new CatalogItem {
                    ID = r.ID, Name = r.Name, Path = r.Path, Description = r.Description, CreationDate = r.CreationDate, ModifiedDate = r.ModifiedDate
                });
                if (query.Any())
                {
                    //pagination info
                    totalRecords = query.Count <CatalogItem>();
                    totalPages   = totalRecords / pageSize;
                    if ((totalRecords % pageSize) > 0)
                    {
                        totalPages++;
                    }
                    //order clause
                    switch (orderColumn.Trim().ToLower())
                    {
                    case "reportname":
                        if (orderExpress.Trim().Equals("asc", StringComparison.OrdinalIgnoreCase))
                        {
                            query = query.OrderBy(r => r.Name);
                        }
                        else
                        {
                            query = query.OrderByDescending(r => r.Name);
                        }
                        break;

                    case "reportpath":
                        if (orderExpress.Trim().Equals("asc", StringComparison.OrdinalIgnoreCase))
                        {
                            query = query.OrderBy(r => r.Path);
                        }
                        else
                        {
                            query = query.OrderByDescending(r => r.Path);
                        }
                        break;

                    case "description":
                        if (orderExpress.Trim().Equals("asc", StringComparison.OrdinalIgnoreCase))
                        {
                            query = query.OrderBy(r => r.Description);
                        }
                        else
                        {
                            query = query.OrderByDescending(r => r.Description);
                        }
                        break;

                    case "modifiedon":
                        if (orderExpress.Trim().Equals("asc", StringComparison.OrdinalIgnoreCase))
                        {
                            query = query.OrderBy(r => r.ModifiedDate);
                        }
                        else
                        {
                            query = query.OrderByDescending(r => r.ModifiedDate);
                        }
                        break;

                    case "createdon":
                        if (orderExpress.Trim().Equals("asc", StringComparison.OrdinalIgnoreCase))
                        {
                            query = query.OrderBy(r => r.CreationDate);
                        }
                        else
                        {
                            query = query.OrderByDescending(r => r.CreationDate);
                        }
                        break;

                    default:
                        if (orderExpress.Trim().Equals("asc", StringComparison.OrdinalIgnoreCase))
                        {
                            query = query.OrderBy(r => r.Name);
                        }
                        else
                        {
                            query = query.OrderByDescending(r => r.Name);
                        }
                        break;
                    }
                    //pagination
                    query = query.Skip(selectedPage - 1).Take(pageSize);
                    if (query.Any())
                    {
                        //if (query.)
                        foreach (CatalogItem item in query.ToArray <CatalogItem>())
                        {
                            /// Create new row
                            dr               = dt.NewRow();
                            dr["id"]         = item.ID;
                            dr["reportname"] = item.Name;
                            //dr["reportpath"] = item.Path;
                            dr["description"] = item.Description;
                            dr["createdon"]   = item.CreationDate;
                            dr["modifiedon"]  = item.ModifiedDate;
                            /// Add row to table
                            dt.Rows.Add(dr);
                        }
                    }
                }
                return(dt);
            }
            catch
            {
                return(dt);
            }
        }