Пример #1
0
        private static async Task <int> OutputStats(string baseUrl, string dataViewName, string username, string password)
        {
            using (LoggingHandler loggingHandler = new LoggingHandler())
            {
                ILogger <Program> logger = loggingHandler.CreateLogger <Program>();

                ApiConnectorFactory connectorFactory = new ApiConnectorFactory(baseUrl);
                LoginService        loginService     = new LoginService(connectorFactory, dataViewName);

                SessionDetails sessionDetails = await loginService.Login(username, password);

                if (sessionDetails == null)
                {
                    logger.LogError($"Couldn't log in to data view {dataViewName} as user {username}");
                    return(-1);
                }

                try
                {
                    StatsGatherer statsGatherer = new StatsGatherer(connectorFactory, dataViewName, loggingHandler.CreateLogger <StatsGatherer>());
                    bool          success       = await statsGatherer.OutputStats(sessionDetails, System.Console.Out);

                    return(success ? 0 : -1);
                }
                finally
                {
                    await loginService.Logout(sessionDetails);
                }
            }
        }
Пример #2
0
        private static async Task <int> OutputDataViews(string baseUrl)
        {
            using (LoggingHandler loggingHandler = new LoggingHandler())
            {
                ApiConnectorFactory connectorFactory = new ApiConnectorFactory(baseUrl);

                DataViewOutputer dataViewOutputer = new DataViewOutputer(connectorFactory, loggingHandler.CreateLogger <DataViewOutputer>());
                bool             success          = await dataViewOutputer.OutputDataViews(System.Console.Out);

                return(success ? 0 : -1);
            }
        }