Beispiel #1
0
 private void saveTreeNodes(TreeNodeCollection nodes)
 {
     foreach (TreeNode node in nodes)
     {
         var destPath = txtLocalPath.Text + "\\" + node.FullPath;
         if (node.Checked)
         {
             if (node.Nodes.Count > 0)
             {
                 //check if dir exists
                 if (!Directory.Exists(destPath))
                 {
                     Directory.CreateDirectory(destPath);
                 }
                 saveTreeNodes(node.Nodes);
             }
             else
             {
                 var itemPath = ROOT_FOLDER + node.FullPath.Replace("\\", "/");
                 var itemType = sourceRS.GetItemType(itemPath);
                 if (itemType == ItemTypeEnum.Resource)
                 {
                     //Download the resource
                     string resourceType;
                     var    contents = sourceRS.GetResourceContents(itemPath, out resourceType);
                     File.WriteAllBytes(destPath, contents);
                     continue;
                 }
                 else if (itemType == ItemTypeEnum.Report || itemType == ItemTypeEnum.LinkedReport)
                 {
                     var         reportDef = sourceRS.GetReportDefinition(itemPath);
                     XmlDocument rdl       = new XmlDocument();
                     rdl.Load(new MemoryStream(reportDef));
                     rdl.Save(destPath + ".rdl");
                 }
             }
             processedNodeCount++;
             bwDownload.ReportProgress(processedNodeCount * 100 / selectedNodeCount);
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// Checks if an item of the specified type exists at path.
        /// </summary>
        /// <param name="reportingService">The reporting service.</param>
        /// <param name="path">The path.</param>
        /// <param name="itemType">Type of the item.</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">reportingService</exception>
        private static bool ItemExists(ReportingService2005 reportingService, string path, ItemTypeEnum itemType)
        {
            if (reportingService == null)
            {
                throw new ArgumentNullException("reportingService");
            }

            ItemTypeEnum actualItemType = reportingService.GetItemType(path);

            if (itemType == actualItemType)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        private bool ItemExists(string item, ItemTypeEnum itemType)
        {
            ItemTypeEnum retType = _rs.GetItemType(item);

            return(itemType == retType);
        }
        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;
            }
        }
        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;
            }
        }