private void LoadSubscriptions(ReportItem item) { var subscriptions = _Service.ListSubscriptions(item.Path, Username); foreach (var subscription in subscriptions) { ExtensionSettings extensionSettings; string description; ActiveState active; string status; string eventType; string matchData; ParameterValue[] values; var result = _Service.GetSubscriptionProperties(subscription.SubscriptionID, out extensionSettings, out description, out active, out status, out eventType, out matchData, out values); var subscriptionItem = new SubscriptionItem { ExtensionSettings = extensionSettings, Description = description, ActiveState = active, Status = status, EventType = eventType, MatchData = matchData, ParameterValues = values }; item.Subscriptions.Add(subscriptionItem); var schedule = Schedules.Select(s => s.Value) .FirstOrDefault(s => s.ScheduleID == matchData); if (schedule != null) { subscriptionItem.ScheduleName = schedule.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; } }
private void syncTreeNodes(string destPath, TreeNodeCollection nodes) { foreach (TreeNode node in nodes) { if ((bool)node.Tag) { if (node.Nodes.Count > 0) { var childPath = destPath; if (node.Checked) { if (destPath.Equals(ROOT_FOLDER)) { childPath = ROOT_FOLDER + node.Text; } else { childPath = destPath + PATH_SEPERATOR + node.Text; } } syncTreeNodes(childPath, node.Nodes); } else { if (!existingPaths.Contains(destPath)) { EnsureDestDir(destPath); existingPaths.Add(destPath); } var itemPath = ROOT_FOLDER + node.FullPath.Replace("\\", PATH_SEPERATOR); var itemType = sourceRS.GetItemType(itemPath); if (itemType == ItemTypeEnum.Resource) { //Download the resource string resourceType; var contents = sourceRS.GetResourceContents(itemPath, out resourceType); uploadResource(destPath, node.Text, resourceType, contents); processedNodeCount++; continue; } var reportDef = sourceRS.GetReportDefinition(itemPath); uploadReport(destPath, node.Text, reportDef); //Sync subscriptions ExtensionSettings extSettings; string desc; ActiveState active; string status; string eventType; string matchData; ParameterValue[] values = null; Subscription[] subscriptions = null; ParameterValueOrFieldReference[] extensionParams = null; var destReportPath = destPath; if (destReportPath.EndsWith("/")) { destReportPath += node.Text; } else { destReportPath += "/" + node.Text; } subscriptions = sourceRS.ListSubscriptions(itemPath, txtSourceUser.Text); foreach (var subscription in subscriptions) { sourceRS.GetSubscriptionProperties(subscription.SubscriptionID, out extSettings, out desc, out active, out status, out eventType, out matchData, out values); if (extSettings.Extension == "Report Server FileShare") { ParameterValue para = new ParameterValue(); para.Name = "PASSWORD"; para.Value = txtDestPassword.Text; ParameterValueOrFieldReference[] exParams = new ParameterValueOrFieldReference[extSettings.ParameterValues.Length + 1]; Array.Copy(extSettings.ParameterValues, exParams, extSettings.ParameterValues.Length); exParams[extSettings.ParameterValues.Length] = para; extSettings.ParameterValues = exParams; } destRS.CreateSubscription(destReportPath, extSettings, desc, eventType, matchData, values); } processedNodeCount++; bwSync.ReportProgress(processedNodeCount * 100 / selectedNodeCount); } } } }
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; } }