public async Task UpdateSupervisorAsync(string supervisorId,
     [FromBody] [Required] SupervisorUpdateApiModel request) {
     if (request == null) {
         throw new ArgumentNullException(nameof(request));
     }
     await _supervisors.UpdateSupervisorAsync(supervisorId,
         request.ToServiceModel());
 }
 /// <summary>
 /// Convert to service model
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static SupervisorUpdateModel ToServiceModel(
     this SupervisorUpdateApiModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new SupervisorUpdateModel {
         SiteId = model.SiteId,
         LogLevel = (IIoT.OpcUa.Registry.Models.TraceLogLevel?)model.LogLevel
     });
 }
        /// <inheritdoc/>
        public async Task UpdateSupervisorAsync(string supervisorId,
                                                SupervisorUpdateApiModel content, CancellationToken ct)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }
            if (string.IsNullOrEmpty(supervisorId))
            {
                throw new ArgumentNullException(nameof(supervisorId));
            }
            var request = _httpClient.NewRequest($"{_serviceUri}/v2/supervisors/{supervisorId}",
                                                 _resourceId);

            request.SetContent(content);
            var response = await _httpClient.PatchAsync(request, ct).ConfigureAwait(false);

            response.Validate();
        }
Beispiel #4
0
        public void SetScanStatus(string supervisorId, string scanStatus, string ipMask, string portRange)
        {
            SupervisorUpdateApiModel model = new SupervisorUpdateApiModel();

            model.DiscoveryConfig = new DiscoveryConfigApiModel();
            model.DiscoveryConfig.AddressRangesToScan = "";
            model.DiscoveryConfig.PortRangesToScan    = "";


            if ((ipMask != null) && (ipMask != string.Empty))
            {
                model.DiscoveryConfig.AddressRangesToScan = ipMask;
            }
            if ((portRange != null) && (portRange != string.Empty))
            {
                model.DiscoveryConfig.PortRangesToScan = portRange;
            }

            if (scanStatus == "true")
            {
                model.Discovery = DiscoveryMode.Fast;
            }
            else
            {
                model.Discovery = DiscoveryMode.Off;
            }

            try
            {
                RegistryService.UpdateSupervisor(supervisorId, model);
            }
            catch (Exception exception)
            {
                string errorMessageTrace = string.Format(Strings.BrowserConnectException, exception.Message,
                                                         exception.InnerException?.Message ?? "--", exception?.StackTrace ?? "--");
                Trace.TraceError(errorMessageTrace);
            }
        }
Beispiel #5
0
        public void SetScanStatus(string supervisorId, string scanStatus)
        {
            SupervisorUpdateApiModel model = new SupervisorUpdateApiModel();

            if (scanStatus == "true")
            {
                model.Discovery = DiscoveryMode.Fast;
            }
            else
            {
                model.Discovery = DiscoveryMode.Off;
            }

            try
            {
                RegistryService.UpdateSupervisor(supervisorId, model);
            }
            catch (Exception exception)
            {
                string errorMessageTrace = string.Format(Strings.BrowserConnectException, exception.Message,
                                                         exception.InnerException?.Message ?? "--", exception?.StackTrace ?? "--");
                Trace.TraceError(errorMessageTrace);
            }
        }
Beispiel #6
0
 public void UpdateSupervisor(string supervisorId, SupervisorUpdateApiModel model)
 {
     Task t = Task.Run(() => _registryServiceHandler.UpdateSupervisorAsync(supervisorId, model));
 }
Beispiel #7
0
 public async Task UpdateSupervisorAsync(string supervisorId, SupervisorUpdateApiModel model)
 {
     await _registryServiceHandler.UpdateSupervisorAsync(supervisorId, model).ConfigureAwait(false);
 }