public byte[] ExportSettingsAsZippedBytes(ImportExportSettings settingsToExport, NodeVisit visit)
        {
            ValidateByRole(visit, SystemRoleType.Admin);

            NodeSettings nodeSettings = new NodeSettings();

            string errorMessage = null;

            if (EnumUtils.IsFlagSet(settingsToExport, ImportExportSettings.GlobalArguments))
            {
                nodeSettings.SetGlobalArguments(ConfigManager.Get(ConfigurationType.All));
            }
            if (EnumUtils.IsFlagSet(settingsToExport, ImportExportSettings.DataSources))
            {
                nodeSettings.SetDataSources(DataProviderManager.Get());
            }
            if (EnumUtils.IsFlagSet(settingsToExport, ImportExportSettings.NetworkPartners))
            {
                nodeSettings.SetNetworkPartners(PartnerManager.Get());
            }
            bool exportExchanges = EnumUtils.IsFlagSet(settingsToExport, ImportExportSettings.Exchanges);
            bool exportServices  = EnumUtils.IsFlagSet(settingsToExport, ImportExportSettings.Services);

            if (exportExchanges || exportServices)
            {
                IList <DataFlow> flows = FlowManager.GetAllDataFlows(exportServices, false);
                if (exportExchanges)
                {
                    nodeSettings.SetExchanges(flows);
                }
                if (exportServices)
                {
                    nodeSettings.SetServices(flows);
                }
            }
            if (EnumUtils.IsFlagSet(settingsToExport, ImportExportSettings.Schedules))
            {
                IDictionary <string, string> flowIdToNameMap    = FlowManager.GetAllFlowsIdToNameMap();
                IDictionary <string, string> serviceIdToNameMap = ServiceManager.GetAllServicesIdToNameMap();
                IDictionary <string, string> partnerIdToNameMap = PartnerManager.GetAllPartnersIdToNameMap();

                nodeSettings.SetSchedules(ScheduleManager.GetSchedules(), flowIdToNameMap, serviceIdToNameMap,
                                          partnerIdToNameMap, out errorMessage);
            }

            string tempFilePath = SettingsProvider.NewTempFilePath();

            _compressionHelper.Compress("Settings.xml", _serializationHelper.SerializeWithLineBreaks(nodeSettings),
                                        tempFilePath);
            if (errorMessage != null)
            {
                _compressionHelper.Compress("Errors.txt", Encoding.UTF8.GetBytes(errorMessage), tempFilePath);
            }

            byte[] zippedData = File.ReadAllBytes(tempFilePath);

            ActivityManager.LogAudit(NodeMethod.None, null, visit, "{0} exported the following node settings: {1}.",
                                     visit.Account.NaasAccount, settingsToExport);
            return(zippedData);
        }
Пример #2
0
        //---------------------------------------------------------------------
        static void AppendImportExportSettings(
            CommandLineBuilder builder,
            ImportExportSettings settings)
        {
            AppendArgumentCollection(builder, InputCoverageFlag, settings.InputCoverages);

            foreach (var export in settings.Exports)
            {
                var path = export.Path;
                if (!string.IsNullOrWhiteSpace(path))
                {
                    var type = export.Type.ToString().ToLowerInvariant();
                    builder.AppendArgument(ExportTypeFlag,
                                           type + ExportTypeSeparator + path);
                }
            }

            if (settings.CoverChildrenProcesses)
            {
                builder.AppendArgument(CoverChildrenFlag, null);
            }
            if (!settings.AggregateByFile)
            {
                builder.AppendArgument(NoAggregateByFileFlag, null);
            }
        }
Пример #3
0
        public static void InstantiateImportExport(ProjectorBrain projectorBrain, ProjectorMount mount, KinectBrain kinectBrain, string name, string path)
        {
            GameObject go = new GameObject(name + " ImportExport");

            go.transform.position = Vector3.zero;

            ImportExportSettings asset = ScriptableObject.CreateInstance <ImportExportSettings>();

            AssetDatabase.CreateAsset(asset, "Assets/" + path + "/Import_Export_Settings.asset");
            EditorUtility.SetDirty(asset);

            ImportExportSystem importExport = go.AddComponent <ImportExportSystem>();

            importExport.Settings       = asset;
            importExport.EnableInEditor = false;
            importExport.Entries        = new List <ImportExportEntry>();

            importExport.Entries.Add(new ImportExportEntry(projectorBrain.gameObject, projectorBrain.Settings));

            ProjectorEmitter[] emitters = mount.Get();

            for (int i = emitters.Length - 1; i >= 0; --i)
            {
                importExport.Entries.Add(new ImportExportEntry(emitters[i].gameObject, emitters[i].Configuration));
            }

            importExport.Entries.Add(new ImportExportEntry(kinectBrain.gameObject, kinectBrain.Settings));
        }
        protected void OnImport(object sender, EventArgs e)
        {
            if (divPageError.Visible || !Page.IsValid)
            {
                // Error on page, get out of here
                return;
            }
            try
            {
                ImportExportSettings settingsToImport     = GetImportSettings();
                ImportSettingsAction importSettingsAction = GetImportSettingsAction();

                string errorText =
                    _importExportSettingsService.ImportSettings(fileUpload.FileBytes, settingsToImport,
                                                                importSettingsAction, VisitHelper.GetVisit());
                divPageNote.Visible = true;
                if (string.IsNullOrEmpty(errorText))
                {
                    divPageNote.InnerText = "The settings were successfully imported!";
                }
                else
                {
                    divPageNote.InnerText = "Some settings were successfully imported!";
                    SetDivPageErrorFormat(errorText);
                }
            }
            catch (Exception ex)
            {
                SetDivPageError(ex);
            }
        }
Пример #5
0
        public IndexImporter(ImportExportSettings settings, ILoggerFactory loggerFactory)
        {
            this.settings = settings;
            log           = loggerFactory.CreateLogger <IndexImporter>();

            httpClient = new HttpClient();
            httpClient.DefaultRequestHeaders.Add("api-key", settings.TargetAdminKey);
        }
        //---------------------------------------------------------------------
        void AddBinaryOutput(
            ImportExportSettings importExportSettings,
            TemporaryFile coveragePath)
        {
            var exports = importExportSettings.Exports.ToList();

            exports.Add(new ImportExportSettings.Export
            {
                Type = ImportExportSettings.Type.Binary,
                Path = coveragePath.Path
            });
            importExportSettings.Exports = exports;
        }
Пример #7
0
        //---------------------------------------------------------------------
        string AddBinaryOutput(ImportExportSettings importExportSettings)
        {
            var coveragePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            var exports = importExportSettings.Exports.ToList();

            exports.Add(new ImportExportSettings.Export
            {
                Type = ImportExportSettings.Type.Binary,
                Path = coveragePath
            });
            importExportSettings.Exports = exports;
            return(coveragePath);
        }
        public ImportExportTest()
        {
            Startup            startup  = new Startup();
            IServiceCollection services = new ServiceCollection();

            startup.ConfigureServices(services);
            IServiceProvider provider = services.BuildServiceProvider();

            log      = provider.GetService <ILoggerFactory>().CreateLogger <ImportExportTest>();
            settings = provider.GetService <ImportExportSettings>();
            importer = provider.GetService <IndexImporter>();


            targetSearchClient = new SearchServiceClient(settings.TargetSearchServiceName, new SearchCredentials(settings.TargetAdminKey));
            targetIndexClient  = targetSearchClient.Indexes.GetClient(settings.TargetIndexName);
        }
        protected static ImportExportSettings GetImportExportSettings(CheckBoxList boxList)
        {
            if (boxList.SelectedIndex < 0)
            {
                return(ImportExportSettings.None);
            }
            ImportExportSettings settings = ImportExportSettings.None;

            foreach (ListItem listItem in boxList.Items)
            {
                if (listItem.Selected)
                {
                    settings = EnumUtils.SetFlag(settings, EnumUtils.FromDescription <ImportExportSettings>(listItem.Text));
                }
            }
            return(settings);
        }
        public string ImportSettings(byte[] settingsFileBytes, ImportExportSettings settingsToImport,
                                     ImportSettingsAction importAction, NodeVisit visit)
        {
            ValidateByRole(visit, SystemRoleType.Admin);

            if (settingsToImport == ImportExportSettings.None)
            {
                return(null);
            }
            if (_compressionHelper.IsCompressed(settingsFileBytes))
            {
                try
                {
                    settingsFileBytes = _compressionHelper.UncompressDeep(settingsFileBytes);
                }
                catch (Exception e)
                {
                    throw new ArgException("Failed to uncompress zip file content: " + e.Message);
                }
            }
            NodeSettings nodeSettings;

            try
            {
                nodeSettings = _serializationHelper.Deserialize <NodeSettings>(settingsFileBytes);
            }
            catch (Exception e)
            {
                throw new ArgException("Failed to deserialize node settings content: " + e.Message);
            }
            string   errorMessage = null;
            DateTime modifiedOn   = DateTime.Now;
            string   modifiedById = visit.Account.Id;

            if (EnumUtils.IsFlagSet(settingsToImport, ImportExportSettings.GlobalArguments))
            {
                IList <ConfigItem> list =
                    NodeSettings.GetGlobalArguments(nodeSettings.GlobalArguments, modifiedById,
                                                    modifiedOn);
                ConfigManager.Import(list, importAction);
            }
            return(errorMessage);
        }
        protected void OnExport(object sender, EventArgs e)
        {
            if (divPageError.Visible || !Page.IsValid)
            {
                // Error on page, get out of here
                return;
            }
            try
            {
                ImportExportSettings settingsToExport = GetExportSettings();

                byte[] exportSettingsZipFileBytes =
                    _importExportSettingsService.ExportSettingsAsZippedBytes(settingsToExport, VisitHelper.GetVisit());

                DoDownloadResponse(exportSettingsZipFileBytes, "Settings.zip", CommonContentType.ZIP);
            }
            catch (Exception ex)
            {
                SetDivPageError(ex);
            }
        }
        public Startup()
        {
            IConfigurationBuilder builder = new ConfigurationBuilder().AddJsonFile("local.appsettings.json");

            configuration = builder.Build();

            settings = new ImportExportSettings();
            configuration.GetSection("ImportExportSettings").Bind(settings);

            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console()
                         .WriteTo.Debug()
                         .WriteTo.File($"{configuration["Logging:FilePath"]}\\log.txt")
                         .CreateLogger();

            Logger = LoggerFactory.Create(builder =>
            {
                builder
                .AddConsole()
                .AddSerilog()
                .AddDebug();
            });
        }