Esempio n. 1
0
 public ChangeRequestMethods(SCSMClient scsmClient)
 {
     ScsmClient = scsmClient;
 }
Esempio n. 2
0
 public CommonMethods(SCSMClient scsmClient)
 {
     ScsmClient = scsmClient;
 }
Esempio n. 3
0
        private async Task BuildHarrrConnectionAsync(CancellationToken cancellationToken)
        {
            try
            {
                while (true && !cancellationToken.IsCancellationRequested)
                {
                    try
                    {
                        if (!String.IsNullOrWhiteSpace(_startUpConfiguration.ScsmProxy.Username) &&
                            !String.IsNullOrWhiteSpace(_startUpConfiguration.ScsmProxy.Password))
                        {
                            var creds = new NetworkCredential(_startUpConfiguration.ScsmProxy.Username, _startUpConfiguration.ScsmProxy.Password);
                            _scsmClient = new SCSMClient(_startUpConfiguration.ScsmProxy.ScsmServer, creds);
                        }
                        else
                        {
                            _scsmClient = new SCSMClient(_startUpConfiguration.ScsmProxy.ScsmServer);
                        }

                        _connection = HARRRConnection.Create(builder => builder
                                                             .WithUrl(_startUpConfiguration.MiddlerAgentUrl, options =>
                        {
                            options.HttpMessageHandlerFactory = (message) =>
                            {
                                if (message is HttpClientHandler clientHandler)
                                {
                                    // bypass SSL certificate
                                    clientHandler.ServerCertificateCustomValidationCallback +=
                                        (sender, certificate, chain, sslPolicyErrors) => { return(true); }
                                }
                                ;
                                return(message);
                            };
                            options.Headers["#Hostname"] = Environment.MachineName;
                        })
                                                             //.AddMessagePackProtocol()
                                                             .AddNewtonsoftJsonProtocol()
                                                             .ConfigureLogging(log =>
                        {
                            //log.AddProvider(_logger.AsLoggerProvider());
                            log.AddSerilog();
                        })
                                                             .WithAutomaticReconnect(new AlwaysRetryPolicy(TimeSpan.FromSeconds(10)))
                                                             , builder => builder.UseHttpResponse()
                                                             );

                        _connection.RegisterInterface <IObjectMethods, ObjectMethods>(_ => new ObjectMethods(_scsmClient));

                        _connection.RegisterInterface <IIncidentMethods, IncidentMethods>(_ => new IncidentMethods(_scsmClient));
                        _connection.RegisterInterface <IServiceRequestMethods, ServiceRequestMethods>(_ => new ServiceRequestMethods(_scsmClient));
                        _connection.RegisterInterface <IChangeRequestMethods, ChangeRequestMethods>(_ => new ChangeRequestMethods(_scsmClient));
                        _connection.RegisterInterface <ICommonMethods, CommonMethods>(_ => new CommonMethods(_scsmClient));
                        _connection.RegisterInterface <IRelationMethods, RelationMethods>(_ => new RelationMethods(_scsmClient));
                        _connection.RegisterInterface <IAttachmentMethods, AttachmentMethods>(_ => new AttachmentMethods(_scsmClient));



                        await _connection.StartAsync(cancellationToken);

                        break;
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        await Task.Delay(TimeSpan.FromSeconds(10), cancellationToken);
                    }
                }
            }
            catch (TaskCanceledException e)
            {
            }
        }
Esempio n. 4
0
 public ServiceRequestMethods(SCSMClient scsmClient)
 {
     ScsmClient = scsmClient;
 }
Esempio n. 5
0
 public ObjectMethods(SCSMClient scsmClient)
 {
     ScsmClient = scsmClient;
 }
Esempio n. 6
0
 public IncidentMethods(SCSMClient scsmClient)
 {
     ScsmClient = scsmClient;
 }
Esempio n. 7
0
 public RelationMethods(SCSMClient scsmClient)
 {
     ScsmClient = scsmClient;
 }
Esempio n. 8
0
 public AttachmentMethods(SCSMClient scsmClient)
 {
     ScsmClient = scsmClient;
 }