public static SEVClient CreateSession(bool firstTry = true)
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("SEV.TestConsole.json", optional: true, reloadOnChange: true)
                                .Build();

            var sevClient = new SEVClient(configuration["UserName"], configuration["Password"]);

            if (!string.IsNullOrEmpty(sevClient._userName) && !string.IsNullOrEmpty(sevClient._password) && firstTry)
            {
                Console.WriteLine($"Start login for user { sevClient._userName }");
                session = SessionConfig.GetSessionConfigAsync(sevClient._userName, sevClient._password).Result;
            }
            else
            {
                Console.WriteLine("Enter your API user name:");
                string userName = Console.ReadLine();
                Console.WriteLine("Enter your API password:"******"Login failed incorrect user name or password!");
                Console.WriteLine("Please try again.");
                ActionSeporator();
                session = null;
                CreateSession(false);
                return(sevClient);
            }

            ActionSeporator();
            Console.ForegroundColor = CCSuccesful;
            Console.WriteLine("Login successfully");
            ActionSeporator();

            return(sevClient);
        }
Пример #2
0
        private static void ExecuteCommand(SEVClient client, string[] anwser)
        {
            switch (anwser[0].Trim())
            {
            case "getlist":
                client.GetProductList();
                break;

            case "getproduct":
                client.GetProduct(anwser[1].Trim());
                break;

            case "buyproduct":
                if (anwser.Length < 4)
                {
                    client.BuyVoucher(anwser[1].Trim(), anwser[2]);
                }
                else
                {
                    client.BuyVoucher(anwser[1].Trim(), anwser[2], anwser[3]);
                }
                break;

            case "getbalance":
                client.GetCurrentBalance();
                break;

            case "getsliptext":
                client.GetProduct(anwser[1].Trim());
                break;

            case "getsessioninfo":
                client.GetLogonInformation();
                break;

            case "exit":
                client.Exit();
                Environment.Exit(0);
                return;

            default:
                Console.ForegroundColor = CCWarning;
                Console.WriteLine($"Invalid command, please try again.");
                break;
            }
        }
Пример #3
0
        public static void Options(SEVClient sevClient = null)
        {
            SEVClient client = sevClient ?? GetSession();

            Console.ForegroundColor = CCCommands;
            Console.WriteLine($"{Environment.NewLine}Enter 1 of the following commands:{Environment.NewLine}");
            Console.WriteLine($"GetList");
            Console.WriteLine($"GetProduct /PRODUCTNUMBER");
            Console.WriteLine($"BuyProduct /PRODUCTNUMBER /QUANTITY");
            Console.WriteLine($"GetBalance");
            Console.WriteLine($"GetSessionInfo");
            Console.WriteLine($"Exit");
            Console.WriteLine();

            Console.ForegroundColor = CCDefault;
            var anwser = Console.ReadLine().ToLower().Split('/');

            ResultSeporator();

            ExecuteCommand(client, anwser);

            ResultSeporator();
            Options(client);
        }
Пример #4
0
 private static SEVClient GetSession()
 {
     return(SEVClient.CreateSession());
 }