Ejemplo n.º 1
0
        /// <summary>
        /// Initialize logger library, create host build and asic token authentication.
        /// </summary>
        /// <returns>
        ///  Gets the token result.
        /// </returns>
        public static TokenResponse InitAsync(MemberInfo memberInfo, IHttpHandlerHelper httpHandler)
        {
            var tokenResponse = new TokenResponse();

            try
            {
                if (Utiles.IsValidPath(memberInfo.ConfigurationPath))
                {
                    LoggerAbstractions.SetupStaticLogger(memberInfo);
                    Log.Information("[Initialization][Service initiated with logging.]");

                    tokenResponse = httpHandler.GetToken(memberInfo.Version, memberInfo.ClientId, memberInfo.ClientSecret);
                    Log.Information("[Initialized][Service initialized with access token]");
                }
                else
                {
                    tokenResponse.StatusCode = StatusCode.Status412PreconditionFailed;
                }
            }
            catch (Exception ex)
            {
                Log.Error("[Initialization][Failed]" + ex);
                tokenResponse.StatusCode = StatusCode.Status502BadGateway;
            }

            return(tokenResponse);
        }
 /// <summary>
 ///   Initialization information for gateway service.
 ///</summary>
 public TestGatewayService(MemberInfo memberInfo)
 {
     MemberInfo    = memberInfo;
     HttpHandler   = new HttpHandlerHelper(MemberInfo.UriString);
     TokenResponse = ServiceInvoke.InitAsync(MemberInfo, HttpHandler);
     if (TokenResponse.StatusCode == 200)
     {
         LockerManager = new LockerManager(MemberInfo.ConfigurationPath);
     }
     if (LockerManager != null)
     {
         ScannerInit = ScannerServiceHelper.Start(LockerManager);
     }
 }