Esempio n. 1
0
        public void InitializeJob(JobRequestMessage message, CancellationToken token)
        {
            // Validate/store parameters.
            Trace.Entering();
            ArgUtil.NotNull(message, nameof(message));
            ArgUtil.NotNull(message.Environment, nameof(message.Environment));
            ArgUtil.NotNull(message.Environment.SystemConnection, nameof(message.Environment.SystemConnection));
            ArgUtil.NotNull(message.Environment.Endpoints, nameof(message.Environment.Endpoints));
            ArgUtil.NotNull(message.Environment.Variables, nameof(message.Environment.Variables));

            CancellationToken = token;

            // Initialize the environment.
            Endpoints = message.Environment.Endpoints;

            // add system connect to the endpoint list.
            Endpoints.Add(message.Environment.SystemConnection);

            List <string> warnings;

            Variables = new Variables(HostContext, message.Environment.Variables, message.Environment.MaskHints, out warnings);

            // Initialize the job timeline record.
            // the job timeline record is at order 1.
            InitializeTimelineRecord(message.Timeline.Id, message.JobId, null, ExecutionContextType.Job, message.JobName, 1);

            // Log any warnings.
            foreach (string warning in (warnings ?? new List <string>()))
            {
                this.Warning(warning);
            }

            // Set system.debug
            WriteDebug = Variables.System_Debug ?? false;
        }
Esempio n. 2
0
        public List <Endpoint> GetEndpoints()
        {
            Console.WriteLine("Get list of endpoints");

            // Endpoint endpoint = new Endpoint(); ;

            foreach (Item item in Collection.Item)
            {
                //foreach with enpdoints

                Console.WriteLine("Parse endpoint: {0}", item.Name);

                if (item.item != null && item.item.Count > 0)
                {
                    foreach (Item item2 in item.item)
                    {
                        Endpoints.Add(ParseItem(item2));
                    }
                }
                else
                {
                    Endpoints.Add(ParseItem(item));
                }

                //Endpoint.add()
            }

            return(Endpoints);
        }
Esempio n. 3
0
 public void AddEndpoint(EndpointSettings endpointSettings)
 {
     if (!Endpoints.Any(e => e.Name !.Equals(endpointSettings.Name, GlobalSettings.ComparisonIgnoreCase) &&
                        e.Version !.Equals(endpointSettings.Version, GlobalSettings.ComparisonIgnoreCase)))
     {
         Endpoints.Add(endpointSettings);
     }
 }
        public void AddEndpoint(Endpoint endpoint)
        {
            if (DoesEndpointExist(endpoint.SipAddress))
            {
                throw new DomainRuleException(nameof(endpoint), "Endpoint already exists in conference");
            }

            Endpoints.Add(endpoint);
        }
Esempio n. 5
0
 public void Init()
 {
     WithLoading(() => {
         var loaded = LoadEndpoints();
         // ensure each endpoint has an ID
         var withIDs = EnsureAllHaveIDs(loaded);
         foreach (var e in withIDs)
         {
             Endpoints.Add(e);
         }
     });
 }
Esempio n. 6
0
        public ServiceDescription(IEnumerable <ServiceEndpoint> endpoints) : this()
        {
            if (endpoints == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(endpoints));
            }

            foreach (ServiceEndpoint endpoint in endpoints)
            {
                Endpoints.Add(endpoint);
            }
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="endpoint"></param>
        /// <returns>the index of the added endpoint</returns>
        public async Task AddAndSave(MusicEndpoint endpoint)
        {
            var sameName = Endpoints.FirstOrDefault(e => e.Name == endpoint.Name);

            if (sameName != null)
            {
                ThrowAlreadyExists(endpoint.Name);
            }
            Endpoints.Add(endpoint);
            await persist();

            OnEndpointAdded(endpoint);
        }
Esempio n. 8
0
        public SerialRgbDevice(string port)
        {
            CommunicationThread = new Thread(UpdateMessageThread);
            CommunicationThread.IsBackground = true;
            CommunicationThread.Start();
            // interpret xml data
            try
            {
                Port.PortName     = port;
                Port.BaudRate     = 9600;
                Port.Handshake    = Handshake.None;
                Port.ReadTimeout  = 500;
                Port.WriteTimeout = 500;
                Port.Open();
            }
            catch (Exception ex) when(ex is NullReferenceException || ex is FormatException || ex is IOException || ex is UnauthorizedAccessException)
            {
                throw new Exceptions.DeviceDisconnectedException();
                Port.Close();
            }
            // actually communicate with the device

            try
            {
                SendMessage(new InitialiseCommMessage());
            }
            catch (TimeoutException)
            {
                throw new Exceptions.NotADeviceException();
            }

            string response = ReceiveMessage();

            if (response != "OK")
            {
                throw new NotADeviceException();
            }

            SendMessage(new GetNameMessage());
            DeviceName = ReceiveMessage();

            // get the endpoints from the device
            SendMessage(new GetEndpointsMessage());
            string message = ReceiveMessage();

            foreach (string endpoint in message.Split(','))
            {
                Endpoints.Add(new RgbEndpoint(endpoint.Replace(";", ""), this));
            }
        }
Esempio n. 9
0
        public void Salvar(Endpoint endpoint)
        {
            var found = Obter(endpoint.ID);

            if (found != null)
            {
                found.Fornecedor = endpoint.Fornecedor;
                found.port       = endpoint.port;
                found.servidor   = endpoint.servidor;
                found.url        = endpoint.url;
            }
            else
            {
                Endpoints.Add(endpoint);
            }
            SaveChanges();
        }
        public void AddEndpoint(Endpoint endpoint)
        {
            if (DoesEndpointExist(endpoint.Sip))
            {
                throw new DomainRuleException(nameof(endpoint), "Endpoint already exists in the hearing");
            }

            Participant defenceAdvocate = null;

            if (endpoint.DefenceAdvocate != null)
            {
                defenceAdvocate = Participants.Single(x => x.Id == endpoint.DefenceAdvocate.Id);
            }

            Endpoints.Add(new Endpoint(endpoint.DisplayName, endpoint.Sip, endpoint.Pin, defenceAdvocate));
            UpdatedDate = DateTime.UtcNow;
        }
Esempio n. 11
0
        public void InitializeJob(JobRequestMessage message, CancellationToken token)
        {
            // Validate/store parameters.
            Trace.Entering();
            ArgUtil.NotNull(message, nameof(message));
            ArgUtil.NotNull(message.Environment, nameof(message.Environment));
            ArgUtil.NotNull(message.Environment.SystemConnection, nameof(message.Environment.SystemConnection));
            ArgUtil.NotNull(message.Environment.Endpoints, nameof(message.Environment.Endpoints));
            ArgUtil.NotNull(message.Environment.Variables, nameof(message.Environment.Variables));

            _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token);

            // Initialize the environment.
            Endpoints = message.Environment.Endpoints;

            // Add the system connection to the endpoint list.
            Endpoints.Add(message.Environment.SystemConnection);

            // Initialize the variables. The constructor handles the initial recursive expansion.
            List <string> warnings;

            Variables = new Variables(HostContext, message.Environment.Variables, message.Environment.MaskHints, out warnings);

            // Initialize the job timeline record.
            InitializeTimelineRecord(
                timelineId: message.Timeline.Id,
                timelineRecordId: message.JobId,
                parentTimelineRecordId: null,
                recordType: ExecutionContextType.Job,
                name: message.JobName,
                order: 1); // The job timeline record must be at order 1.

            // Initialize the logger before writing warnings.
            _logger = HostContext.CreateService <IPagingLogger>();
            _logger.Setup(_mainTimelineId, _record.Id);

            // Log any warnings from recursive variable expansion.
            warnings?.ForEach(x => this.Warning(x));

            // Initialize the verbosity (based on system.debug).
            WriteDebug = Variables.System_Debug ?? false;

            // Hook up JobServerQueueThrottling event, we will log warning on server tarpit.
            _jobServerQueue.JobServerQueueThrottling += JobServerQueueThrottling_EventReceived;
        }
Esempio n. 12
0
        public async Task AddNewEndpoint(string endpoint)
        {
            Endpoints.Add(endpoint);
            var ws = new WebSocketSharp.WebSocket(endpoint);

            ws.OnMessage += async(sender, e) =>
            {
                await HandleMessage(null, sender as WebSocketSharp.WebSocket, e.Data);
            };

            ws.Connect();
            await SendMessage(null, ws, new P2PMessage()
            {
                Type = MessageType.GetLastBlock
            }.ToJson());

            Peers.Add(ws);
        }
        /// <summary> Add a new single endpoint to this configuration </summary>
        /// <param name="Key"> Key used for subsequent lookups from this configuration </param>
        /// <param name="Endpoint"> Fully pre-constructed microservice client endpoint configuration object </param>
        public void Add_Endpoint(string Key, MicroservicesClient_Endpoint Endpoint)
        {
            // Check and build the dictionary as needed
            build_dictionary();

            // If a value already exists for this key, remove it from the list
            if (endpointsDictionary.ContainsKey(Key))
            {
                MicroservicesClient_Endpoint foundEndpoint = endpointsDictionary[Key];
                if (Endpoints.Contains(foundEndpoint))
                {
                    Endpoints.Remove(foundEndpoint);
                }
            }

            // Add this new value
            Endpoints.Add(Endpoint);
            endpointsDictionary[Key] = Endpoint;
        }
        public MvcDispatcherDataSource(
            IActionDescriptorCollectionProvider actions,
            IActionInvokerFactory invokerFactory)
        {
            if (actions == null)
            {
                throw new ArgumentNullException(nameof(actions));
            }

            if (invokerFactory == null)
            {
                throw new ArgumentNullException(nameof(invokerFactory));
            }

            _invokerFactory = invokerFactory;

            // note: this code has haxxx. This will only work in some constrained scenarios
            foreach (var action in actions.ActionDescriptors.Items)
            {
                Endpoints.Add(new HttpEndpoint(
                                  action.AttributeRouteInfo.Template,
                                  action.RouteValues,
                                  action.ActionConstraints?.OfType <HttpMethodActionConstraint>().FirstOrDefault()?.HttpMethods.FirstOrDefault(),
                                  async(context) =>
                {
                    var values    = context.Features.Get <IDispatcherFeature>().Values;
                    var routeData = new RouteData();
                    foreach (var kvp in values)
                    {
                        routeData.Values.Add(kvp.Key, kvp.Value);
                    }

                    var actionContext = new ActionContext(context, routeData, action);
                    var invoker       = _invokerFactory.CreateInvoker(actionContext);
                    await invoker.InvokeAsync();
                },
                                  action.DisplayName,
                                  action.FilterDescriptors.OrderBy(f => f, FilterDescriptorOrderComparer.Comparer).Select(f => f.Filter).ToArray()));
            }
        }
Esempio n. 15
0
        private void PopulateEndpoints(IReadOnlyCollection <MigoEndpoint> endpoints)
        {
            var selected = SelectedEndpoint;

            Endpoints.Clear();

            if (selected.IsValid())
            {
                Endpoints.Add(selected);
            }

            foreach (var endpoint in endpoints)
            {
                if (endpoint.Equals(selected))
                {
                    continue;
                }
                Endpoints.Add(endpoint);
            }

            SelectedEndpoint = selected;
        }
Esempio n. 16
0
        public void InitializeJob(JobRequestMessage message, CancellationToken token)
        {
            // Validate/store parameters.
            Trace.Entering();
            ArgUtil.NotNull(message, nameof(message));
            ArgUtil.NotNull(message.Environment, nameof(message.Environment));
            ArgUtil.NotNull(message.Environment.SystemConnection, nameof(message.Environment.SystemConnection));
            ArgUtil.NotNull(message.Environment.Endpoints, nameof(message.Environment.Endpoints));
            ArgUtil.NotNull(message.Environment.Variables, nameof(message.Environment.Variables));

            CancellationToken = token;

            // Initialize the environment.
            Endpoints = message.Environment.Endpoints;

            // Add the system connection to the endpoint list.
            Endpoints.Add(message.Environment.SystemConnection);

            // Initialize the variables. The constructor handles the initial recursive expansion.
            List <string> warnings;

            Variables = new Variables(HostContext, message.Environment.Variables, message.Environment.MaskHints, out warnings);

            // Initialize the job timeline record.
            InitializeTimelineRecord(
                timelineId: message.Timeline.Id,
                timelineRecordId: message.JobId,
                parentTimelineRecordId: null,
                recordType: ExecutionContextType.Job,
                name: message.JobName,
                order: 1); // The job timeline record must be at order 1.

            // Log any warnings from recursive variable expansion.
            warnings?.ForEach(x => this.Warning(x));

            // Initialize the verbosity (based on system.debug).
            WriteDebug = Variables.System_Debug ?? false;
        }
        public DiaggregatorDataSource(IEnumerable <DiaggregatorItem> items)
        {
            if (items == null)
            {
                throw new ArgumentNullException(nameof(items));
            }

            _items = items.OrderBy(i => i.Name).Where(i => i.GetType() != typeof(IndexEndpointHandler)).ToArray();

            var index = items.OfType <IndexEndpointHandler>().Single();

            Endpoints.Add(new HttpEndpoint("/diag", index.Invoke, index.DisplayName, Array.Empty <object>()));

            for (var i = 0; i < _items.Length; i++)
            {
                var item = _items[i];
                Endpoints.Add(new HttpEndpoint(
                                  GetTemplate(item),
                                  item.Invoke,
                                  item.DisplayName,
                                  item.GetType().GetCustomAttributes(inherit: true)));
            }
        }
        /// <summary> Reference a single microservices client endpoint configuration, via the lookup key </summary>
        /// <param name="Key"> Key to find the microservices client endpoint configuration </param>
        /// <returns> Specified microservices client endpoint configuration, or NULL </returns>
        public MicroservicesClient_Endpoint this[string Key]
        {
            get
            {
                // Check and build the dictionary as needed
                build_dictionary();

                // If no endpoint, return
                if (Endpoints.Count == 0)
                {
                    return(null);
                }

                // (endpoints dictionary ensured to be built now).. return endpoint by key
                return(endpointsDictionary.ContainsKey(Key) ? endpointsDictionary[Key] : null);
            }
            set
            {
                // Check and build the dictionary as needed
                build_dictionary();

                // If a value already exists for this key, remove it from the list
                if (endpointsDictionary.ContainsKey(Key))
                {
                    MicroservicesClient_Endpoint foundEndpoint = endpointsDictionary[Key];
                    if (Endpoints.Contains(foundEndpoint))
                    {
                        Endpoints.Remove(foundEndpoint);
                    }
                }

                // Add this new value
                Endpoints.Add(value);
                endpointsDictionary[Key] = value;
            }
        }
Esempio n. 19
0
        public void InitializeJob(JobRequestMessage message, CancellationToken token)
        {
            // Validation
            Trace.Entering();
            ArgUtil.NotNull(message, nameof(message));
            ArgUtil.NotNull(message.Environment, nameof(message.Environment));
            ArgUtil.NotNull(message.Environment.SystemConnection, nameof(message.Environment.SystemConnection));
            ArgUtil.NotNull(message.Environment.Endpoints, nameof(message.Environment.Endpoints));
            ArgUtil.NotNull(message.Environment.Variables, nameof(message.Environment.Variables));
            ArgUtil.NotNull(message.Plan, nameof(message.Plan));

            _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token);

            // Features
            Features = ApiUtil.GetFeatures(message.Plan);

            // Endpoints
            Endpoints = message.Environment.Endpoints;
            Endpoints.Add(message.Environment.SystemConnection);

            // Variables (constructor performs initial recursive expansion)
            List <string> warnings;

            Variables = new Variables(HostContext, message.Environment.Variables, message.Environment.MaskHints, out warnings);

            // Proxy variables
            var proxyConfiguration = HostContext.GetService <IProxyConfiguration>();

            if (!string.IsNullOrEmpty(proxyConfiguration.ProxyUrl))
            {
                Variables.Set(Constants.Variables.Agent.ProxyUrl, proxyConfiguration.ProxyUrl);
                Environment.SetEnvironmentVariable("VSTS_HTTP_PROXY", string.Empty);

                if (!string.IsNullOrEmpty(proxyConfiguration.ProxyUsername))
                {
                    Variables.Set(Constants.Variables.Agent.ProxyUsername, proxyConfiguration.ProxyUsername);
                    Environment.SetEnvironmentVariable("VSTS_HTTP_PROXY_USERNAME", string.Empty);
                }

                if (!string.IsNullOrEmpty(proxyConfiguration.ProxyPassword))
                {
                    Variables.Set(Constants.Variables.Agent.ProxyPassword, proxyConfiguration.ProxyPassword, true);
                    Environment.SetEnvironmentVariable("VSTS_HTTP_PROXY_PASSWORD", string.Empty);
                }
            }

            // Job timeline record.
            InitializeTimelineRecord(
                timelineId: message.Timeline.Id,
                timelineRecordId: message.JobId,
                parentTimelineRecordId: null,
                recordType: ExecutionContextType.Job,
                name: message.JobName,
                order: 1); // The job timeline record must be at order 1.

            // Logger (must be initialized before writing warnings).
            _logger = HostContext.CreateService <IPagingLogger>();
            _logger.Setup(_mainTimelineId, _record.Id);

            // Log warnings from recursive variable expansion.
            warnings?.ForEach(x => this.Warning(x));

            // Verbosity (from system.debug).
            WriteDebug = Variables.System_Debug ?? false;

            // Hook up JobServerQueueThrottling event, we will log warning on server tarpit.
            _jobServerQueue.JobServerQueueThrottling += JobServerQueueThrottling_EventReceived;
        }
        public void Register(Endpoint callback)
        {
            if (callback.ScriptBlock == null)
            {
                return;
            }

            logger.Debug($"Register() {callback.Name} {callback.Url} {callback.SessionId}");

            if (callback.Schedule != null)
            {
                _scheduledEndpoints.Add(callback);
            }
            else if (string.IsNullOrEmpty(callback.Url))
            {
                Unregister(callback.Name, callback.SessionId);

                if (callback.SessionId == null)
                {
                    Endpoints.Add(callback.Name, callback);
                }
                else
                {
                    lock (sessionLock)
                    {
                        if (!_sessionLocks.ContainsKey(callback.SessionId))
                        {
                            StartSession(callback.SessionId, callback.SessionId);
                        }
                    }

                    lock (_sessionLocks[callback.SessionId])
                    {
                        if (Sessions.ContainsKey(callback.SessionId))
                        {
                            var session = Sessions[callback.SessionId];
                            session.Endpoints.Add(callback.Name, callback);
                        }
                    }
                }
            }
            else
            {
                if (callback.UrlRegEx == null)
                {
                    callback.Parts = callback.Url.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries).Select(m => new Part(m, m.StartsWith(":"))).ToArray();

                    if (callback.Parts.GroupBy(m => m.Value).Any(m => m.Count() > 1))
                    {
                        throw new Exception("Duplicate variable name in URL.");
                    }
                }

                var existingEndpoint = _restEndpoints.FirstOrDefault(m => m.Method == callback.Method && m.Url.Equals(callback.Url, StringComparison.OrdinalIgnoreCase));

                if (existingEndpoint != null)
                {
                    _restEndpoints.Remove(existingEndpoint);
                }

                _restEndpoints.Add(callback);
            }
        }
 public void AddEndpoint(DeviceEndpoint endpoint)
 {
     Endpoints.Add(endpoint);
     ShowNoResultsMessage = false;
 }
Esempio n. 22
0
        public void InitializeJob(JobRequestMessage message, CancellationToken token)
        {
            // Validation
            Trace.Entering();
            ArgUtil.NotNull(message, nameof(message));
            ArgUtil.NotNull(message.Environment, nameof(message.Environment));
            ArgUtil.NotNull(message.Environment.SystemConnection, nameof(message.Environment.SystemConnection));
            ArgUtil.NotNull(message.Environment.Endpoints, nameof(message.Environment.Endpoints));
            ArgUtil.NotNull(message.Environment.Variables, nameof(message.Environment.Variables));
            ArgUtil.NotNull(message.Plan, nameof(message.Plan));

            _cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token);

            // Features
            Features = ApiUtil.GetFeatures(message.Plan);

            // Endpoints
            Endpoints = message.Environment.Endpoints;
            Endpoints.Add(message.Environment.SystemConnection);

            // SecureFiles
            SecureFiles = message.Environment.SecureFiles;

            // Variables (constructor performs initial recursive expansion)
            List <string> warnings;

            Variables = new Variables(HostContext, message.Environment.Variables, message.Environment.MaskHints, out warnings);

            // Prepend Path
            PrependPath = new List <string>();

            // Docker
            Container = new ContainerInfo()
            {
                ContainerImage = Variables.Get("_PREVIEW_VSTS_DOCKER_IMAGE"),
                ContainerName  = $"VSTS_{Variables.System_HostType.ToString()}_{message.JobId.ToString("D")}",
            };

            // Proxy variables
            var agentWebProxy = HostContext.GetService <IVstsAgentWebProxy>();

            if (!string.IsNullOrEmpty(agentWebProxy.ProxyAddress))
            {
                Variables.Set(Constants.Variables.Agent.ProxyUrl, agentWebProxy.ProxyAddress);
                Environment.SetEnvironmentVariable("VSTS_HTTP_PROXY", string.Empty);

                if (!string.IsNullOrEmpty(agentWebProxy.ProxyUsername))
                {
                    Variables.Set(Constants.Variables.Agent.ProxyUsername, agentWebProxy.ProxyUsername);
                    Environment.SetEnvironmentVariable("VSTS_HTTP_PROXY_USERNAME", string.Empty);
                }

                if (!string.IsNullOrEmpty(agentWebProxy.ProxyPassword))
                {
                    Variables.Set(Constants.Variables.Agent.ProxyPassword, agentWebProxy.ProxyPassword, true);
                    Environment.SetEnvironmentVariable("VSTS_HTTP_PROXY_PASSWORD", string.Empty);
                }

                if (agentWebProxy.ProxyBypassList.Count > 0)
                {
                    Variables.Set(Constants.Variables.Agent.ProxyBypassList, JsonUtility.ToString(agentWebProxy.ProxyBypassList));
                }
            }

            // Job timeline record.
            InitializeTimelineRecord(
                timelineId: message.Timeline.Id,
                timelineRecordId: message.JobId,
                parentTimelineRecordId: null,
                recordType: ExecutionContextType.Job,
                displayName: message.JobName,
                refName: message.JobRefName,
                order: null); // The job timeline record's order is set by server.

            // Logger (must be initialized before writing warnings).
            _logger = HostContext.CreateService <IPagingLogger>();
            _logger.Setup(_mainTimelineId, _record.Id);

            // Log warnings from recursive variable expansion.
            warnings?.ForEach(x => this.Warning(x));

            // Verbosity (from system.debug).
            WriteDebug = Variables.System_Debug ?? false;

            // Hook up JobServerQueueThrottling event, we will log warning on server tarpit.
            _jobServerQueue.JobServerQueueThrottling += JobServerQueueThrottling_EventReceived;
        }
Esempio n. 23
0
 public void AddEndpoint(KnownEndpoint endpoint, IBucketer bucketer)
 {
     Endpoints.Add(endpoint);
     Bucketers.Add(endpoint.Request.OriginalEndpoint, bucketer);
 }