Ejemplo n.º 1
0
 private void SaveSubscriptions(ReportItem item)
 {
     // Todo
 }
Ejemplo n.º 2
0
        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();
            }
        }
Ejemplo n.º 3
0
 private void SaveResource(ReportItem item)
 {
     // Todo
 }
Ejemplo n.º 4
0
 private void UploadSubscriptions(ReportItem item)
 {
     foreach (var subscription in item.Subscriptions)
     {
         UploadSubscription(item, subscription);
     }
 }
Ejemplo n.º 5
0
 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;
     }
 }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
 private void UploadResource(ReportItem item)
 {
     _Service.CreateResource(item.Name, item.ParentPath, true, item.ResourceContents, item.ResourceType, null);
 }
Ejemplo n.º 8
0
 private void LoadReport(ReportItem item)
 {
     item.ReportDefinition = _Service.GetReportDefinition(item.Path);
     item.DataSources = _Service.GetItemDataSources(item.Path);
 }
Ejemplo n.º 9
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;
        }
Ejemplo n.º 10
0
        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;
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
 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;
     }
 }
Ejemplo n.º 13
0
 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;
     }
 }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
 private void UploadDataSource(ReportItem item)
 {
     // Todo
     ////_Service.CreateDataSource(item.Name, item.ParentPath, true, );
 }
Ejemplo n.º 16
0
 private void LoadResource(ReportItem item)
 {
     string resourceType;
     item.ResourceContents = _Service.GetResourceContents(item.Path, out resourceType);
     item.ResourceType = resourceType;
 }
Ejemplo n.º 17
0
 private void UploadDataSources(ReportItem item)
 {
     // Todo
 }
Ejemplo n.º 18
0
        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;
                }
            }
        }
Ejemplo n.º 19
0
        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);
            }
        }
Ejemplo n.º 20
0
 private void SaveDataSource(ReportItem item)
 {
     // Todo
 }
Ejemplo n.º 21
0
        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
            }
        }
Ejemplo n.º 22
0
        private void SaveFolder(ReportItem item)
        {
            var path = GetItemPath(item);
            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 24
0
 public bool HasItem(ReportItem item)
 {
     return AllItems.ContainsKey(item.Key);
 }