private void SaveSubscriptions(ReportItem item)
 {
     // Todo
 }
        private void SaveReport(ReportItem item)
        {
            var path = GetItemPath(item, ".rdl");
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            var content = Encoding.UTF8.GetString(item.ReportDefinition);

            using (var file = File.CreateText(path))
            {
                file.Write(content);
                file.Flush();
                file.Close();
            }
        }
 private void SaveResource(ReportItem item)
 {
     // Todo
 }
 private void UploadSubscriptions(ReportItem item)
 {
     foreach (var subscription in item.Subscriptions)
     {
         UploadSubscription(item, subscription);
     }
 }
 public void LoadItem(ReportItem item)
 {
     switch (item.ItemType)
     {
         case ItemTypeEnum.Report:
         case ItemTypeEnum.LinkedReport:
             LoadReport(item);
             LoadSubscriptions(item);
             break;
         case ItemTypeEnum.Resource:
             LoadResource(item);
             break;
     }
 }
        private void UploadFolder(ReportItem item)
        {
            var exists = HasItem(item);
            if (exists)
            {
                return;
            }

            var parent = item.Parent;
            var parentPath = parent != null ? parent.Path : "/";
            _Service.CreateFolder(item.Name, parentPath, null);
        }
 private void UploadResource(ReportItem item)
 {
     _Service.CreateResource(item.Name, item.ParentPath, true, item.ResourceContents, item.ResourceType, null);
 }
 private void LoadReport(ReportItem item)
 {
     item.ReportDefinition = _Service.GetReportDefinition(item.Path);
     item.DataSources = _Service.GetItemDataSources(item.Path);
 }
        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;
        }
        private ReportItem AddReportItem(ReportItem parent, CatalogItem item, bool isDirectory)
        {
            var child = new ReportItem
                {
                    Key = item.Path.ToLowerInvariant(),
                    Name = item.Name,
                    Path = item.Path,
                    ParentPath = parent.Path,
                    Item = item,
                    ItemType = item.Type,
                    Parent = parent
                };
            parent.Children.Add(child);

            AllItems.Add(child.Key, child);
            return child;
        }
        private string GetItemPath(ReportItem item, string extension = null)
        {
            var basePath = BasePath;
            if (String.IsNullOrEmpty(basePath))
            {
                return string.Empty;
            }

            return String.Concat(BasePath, item.Path, extension);
        }
 public void UploadItem(ReportItem item)
 {
     switch (item.ItemType)
     {
         case ItemTypeEnum.Folder:
             UploadFolder(item);
             break;
         case ItemTypeEnum.Report:
         case ItemTypeEnum.LinkedReport:
             UploadReport(item);
             UploadSubscriptions(item);
             break;
         case ItemTypeEnum.Resource:
             UploadResource(item);
             break;
         case ItemTypeEnum.DataSource:
             UploadDataSource(item);
             break;
     }
 }
 public void SaveItem(ReportItem item)
 {
     switch (item.ItemType)
     {
         case ItemTypeEnum.Folder:
             SaveFolder(item);
             break;
         case ItemTypeEnum.Report:
         case ItemTypeEnum.LinkedReport:
             SaveReport(item);
             SaveSubscriptions(item);
             break;
         case ItemTypeEnum.Resource:
             SaveResource(item);
             break;
         case ItemTypeEnum.DataSource:
             SaveDataSource(item);
             break;
     }
 }
        public bool LoadReportItems()
        {
            AllItems.Clear();
            DataSources.Clear();

            var service = Service;
            var rootItem = new ReportItem
                {
                    Name = "/",
                    Path = "/",
                    ItemType = ItemTypeEnum.Unknown
                };
            RootItem = rootItem;

            return LoadReportItems(service, rootItem);
        }
 private void UploadDataSource(ReportItem item)
 {
     // Todo
     ////_Service.CreateDataSource(item.Name, item.ParentPath, true, );
 }
 private void LoadResource(ReportItem item)
 {
     string resourceType;
     item.ResourceContents = _Service.GetResourceContents(item.Path, out resourceType);
     item.ResourceType = resourceType;
 }
 private void UploadDataSources(ReportItem item)
 {
     // Todo
 }
        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 void UploadReport(ReportItem item)
        {
            _Service.CreateReport(item.Name, item.ParentPath, true, item.ReportDefinition, null);

            var dataSources = GetDataSources(item.DataSources);
            if (dataSources.Length > 0)
            {
                _Service.SetItemDataSources(item.Path, dataSources);
            }
        }
 private void SaveDataSource(ReportItem item)
 {
     // Todo
 }
        private void UploadSubscription(ReportItem item, SubscriptionItem subscription)
        {
            try
            {
                var schedule = Schedules.Select(s => s.Value)
                    .FirstOrDefault(s => String.Equals(s.Name, subscription.ScheduleName, StringComparison.InvariantCultureIgnoreCase));
                if (schedule == null)
                {
                    return;
                }

                _Service.CreateSubscription(item.Path, subscription.ExtensionSettings, subscription.Description,
                    subscription.EventType, schedule.ScheduleID, subscription.ParameterValues);
            }
            catch (Exception)
            {
                // Suppress
            }
        }
        private void SaveFolder(ReportItem item)
        {
            var path = GetItemPath(item);
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
        }
Example #23
0
        private void LoadTreeNodes(TreeNodeCollection tree, ReportItem parent)
        {
            foreach (var child in parent.Children)
            {
                var parentNode = new TreeNode
                    {
                        Name = child.Name,
                        Text = child.Name,
                        Tag = child
                    };
                tree.Add(parentNode);

                LoadTreeNodes(parentNode.Nodes, child);
            }
        }
 public bool HasItem(ReportItem item)
 {
     return AllItems.ContainsKey(item.Key);
 }