Esempio n. 1
0
        public void Backup(string publishPath)
        {
            _log.Trace($"{nameof(Backup)}");
            var subscriptionSettings = _client.ListSubscriptions();

            var folder = Path.Combine(publishPath, Subscriptions);

            _fileSystem.CreateFolder(folder);

            foreach (var settings in subscriptionSettings)
            {
                settings.Save(Path.Combine(folder, $"{settings.ReportName}-{settings.SubscriptionId}"));
            }
        }
Esempio n. 2
0
        public void Backup(string publishPath)
        {
            _log.Info("Backuping reports.");
            BackupType(_reportingServiceProxy.ListReports(), REPORTEXTENSION);
            _log.Info("Backuping datasets.");
            BackupType(_reportingServiceProxy.ListDatasets(), DATASETEXTENSION);
            _log.Info("Backuping datasources.");
            BackupType(_reportingServiceProxy.ListDatasources(), DATASOURCEEXTENSION);

            void CheckFolderNames(string name, string extension)
            {
                switch (extension)
                {
                case DATASETEXTENSION:
                    if (name != "Datasets")
                    {
                        _log.Warn($"All datasets should be in 'Datasets' folder, not in {name}");
                    }

                    break;

                case DATASOURCEEXTENSION:
                    if (name != "Data Sources")
                    {
                        _log.Warn($"All datasources should be in 'Data Sources' folder, not in {name}");
                    }

                    break;
                }
            }

            void BackupType(IEnumerable <string> items, string extension) =>
            Parallel.ForEach(items, (item) =>
            {
                var directory = Path.GetFileName(Path.GetDirectoryName(item));
                _fileSystemProxy.CreateFolder(Path.Combine(publishPath, directory));
                var reportName  = Path.GetFileName(item);
                var description = _reportingServiceProxy.GetItemDefinition(item);
                CheckFolderNames(directory, extension);
                _fileSystemProxy.WriteAllText(Path.Combine(publishPath, directory, reportName + extension), description);
            });
        }