示例#1
0
        public static bool TryGetArgumentsFromConfigFile(string[] args, string configFileName,
                                                         out MicroserverArguments arguments,
                                                         out string configFilePath)
        {
            arguments      = null;
            configFilePath = null;

            if (args.Length == 0)
            {
                _msg.InfoFormat("Getting server host/port parameters from configuration file.");

                configFilePath = GetConfigFilePath(configFileName, false);

                if (configFilePath != null)
                {
                    XmlSerializationHelper <MicroserverArguments> helper =
                        new XmlSerializationHelper <MicroserverArguments>();

                    arguments = helper.ReadFromFile(configFilePath);
                    return(true);
                }
            }

            return(false);
        }
        private static ClientChannelConfig GetClientChannelConfig([NotNull] string configFilePath)
        {
            ClientChannelConfig clientChannelConfig;

            _msg.DebugFormat("Geometry processing microservice configuration from {0}",
                             configFilePath);

            try
            {
                XmlSerializationHelper <ClientChannelConfigs> configHelper =
                    new XmlSerializationHelper <ClientChannelConfigs>();

                clientChannelConfig =
                    configHelper.ReadFromFile(configFilePath).Channels.First();
            }
            catch (Exception e)
            {
                _msg.Debug($"Error reading configuration from {configFilePath}.", e);
                throw new InvalidConfigurationException(
                          $"Error reading geometry processing microservice configuration from {configFilePath}",
                          e);
            }

            return(clientChannelConfig);
        }
示例#3
0
        public static XmlWorkListDefinition Import(string xmlFilePath)
        {
            var helper = new XmlSerializationHelper <XmlWorkListDefinition>();

            XmlWorkListDefinition definition = helper.ReadFromFile(xmlFilePath);

            definition.Path = xmlFilePath;
            return(definition);
        }
示例#4
0
        public static MicroserverArguments GetStartParameters([NotNull] string[] args,
                                                              [CanBeNull] string configFilePath,
                                                              int defaultPort = 5151)
        {
            MicroserverArguments result = null;

            if (args.Length == 0)
            {
                // Still parse the args, in case of --help or --version
                Parser.Default.ParseArguments <MicroserverArguments>(args);

                _msg.InfoFormat("No arguments provided. For help, start with --help");

                if (configFilePath != null && File.Exists(configFilePath))
                {
                    _msg.InfoFormat("Getting server parameters from {0}", configFilePath);

                    XmlSerializationHelper <MicroserverArguments> helper =
                        new XmlSerializationHelper <MicroserverArguments>();

                    result = helper.ReadFromFile(configFilePath);
                }
                else
                {
                    _msg.InfoFormat("No configuration file found at {0}. Using default parameters.",
                                    configFilePath);

                    result = new MicroserverArguments
                    {
                        HostName = "localhost",
                        Port     = defaultPort
                    };
                }
            }
            else
            {
                _msg.InfoFormat(
                    "Using arguments from command line (config file is ignored if it exists).");

                var parsedArgs = Parser.Default.ParseArguments <MicroserverArguments>(args);

                parsedArgs.WithParsed(arguments => { result = arguments; });

                bool helpArg = args.Any(
                    a => a != null &&
                    a.Equals("--help", StringComparison.InvariantCultureIgnoreCase));

                if (helpArg)
                {
                    // Lets exit after printing the help:
                    return(null);
                }
            }

            return(result);
        }
		public override bool IsContainer => false;//true;

		//TODO algr: this is necessary only for IsContainer = true
		public override void Fetch()
		{
			this.ClearChildren();

			// serialize configuration info
			var helper = new XmlSerializationHelper<IEnumerable<ProSuiteQAServerConfiguration>>();
			ServerConfigurations = helper.ReadFromFile(Path);

			// add subtype - ProSuiteProjectItemConfig?
		}
示例#6
0
        public static string GetXmlWorklistName(string worklistPath)
        {
            if (String.IsNullOrEmpty(worklistPath))
            {
                return(null);
            }

            var helper = new XmlSerializationHelper <XmlWorkListDefinition>();
            XmlWorkListDefinition definition = helper.ReadFromFile(worklistPath);

            return(definition.Name);
        }
示例#7
0
        public static string GetWorklistPath(string path)
        {
            if (!path.EndsWith("wl"))
            {
                return(path);
            }

            var helper = new XmlSerializationHelper <XmlWorkListDefinition>();

            XmlWorkListDefinition definition = helper.ReadFromFile(path);

            return(definition.Workspaces.Select(w => w.Path).FirstOrDefault());
        }
示例#8
0
        public static string GetWorklistName([NotNull] string worklistDefinitionFile)
        {
            Assert.ArgumentNotNullOrEmpty(worklistDefinitionFile, nameof(worklistDefinitionFile));

            if (!File.Exists(worklistDefinitionFile))
            {
                _msg.Debug($"{worklistDefinitionFile} does not exist");
                return(null);
            }

            var helper = new XmlSerializationHelper <XmlWorkListDefinition>();
            XmlWorkListDefinition definition = helper.ReadFromFile(worklistDefinitionFile);

            return(definition.Name);
        }
示例#9
0
        public static string GetIssueGeodatabasePath([NotNull] string worklistDefinitionFile)
        {
            Assert.ArgumentNotNullOrEmpty(worklistDefinitionFile, nameof(worklistDefinitionFile));

            if (!File.Exists(worklistDefinitionFile))
            {
                _msg.Debug($"{worklistDefinitionFile} does not exist");
                return(null);
            }

            string extension = Path.GetExtension(worklistDefinitionFile);

            if (!string.Equals(extension, ".iwl"))
            {
                _msg.Debug($"{worklistDefinitionFile} is no issue work list");
                return(null);
            }

            var helper = new XmlSerializationHelper <XmlWorkListDefinition>();

            XmlWorkListDefinition       definition = helper.ReadFromFile(worklistDefinitionFile);
            List <XmlWorkListWorkspace> workspaces = definition.Workspaces;

            string result = workspaces[0].ConnectionString;

            if (workspaces.Count > 0)
            {
                _msg.Info(
                    $"There are many issue geodatabases in {worklistDefinitionFile} but only one is expected. Taking the first one {result}");
            }
            else
            {
                _msg.Debug($"Found issue geodatabase {result} in {worklistDefinitionFile}");
            }

            return(result);
        }