Пример #1
0
        static int Main(string[] args)
        {
            if (args.Length < numberOfDefaultParameters)
            {
                Console.Error.WriteLine("Need at least " + numberOfDefaultParameters + " arguments");
                return(1);
            }

            var queries = GetPossibleQueries();

            string[] parameters;
            var      api = LeanKit.Model.LeanKitFactory.Instance.CreateApi("absw", Properties.Settings.Default.LeanKitUsername, Properties.Settings.Default.LeanKitPassword);

            parameters = new string[args.Length - numberOfDefaultParameters];
            Array.Copy(args, numberOfDefaultParameters, parameters, 0, args.Length - numberOfDefaultParameters);

            Type queryType;

            try
            {
                queryType = queries[args[0].ToLower()];
            }
            catch (KeyNotFoundException)
            {
                ShowInvalidCommand(queries.Keys, Console.Error);
                return(1);
            }

            try
            {
                ILeanKitQuery query = (ILeanKitQuery)Activator.CreateInstance(queryType);
                return(query.RunQuery(api, parameters, Console.Out, Console.Error));
            }
            catch (LeanKit.API.Client.Library.Exceptions.UnauthorizedAccessException)
            {
                Console.Error.WriteLine("Invalid Username or Password");
                return(1);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine("Unknown exception thrown");
                Console.Error.WriteLine("Type        : " + ex.GetType().ToString());
                Console.Error.WriteLine("Message     : " + ex.Message);
                Console.Error.WriteLine("Stack trace : " + ex.StackTrace);
                return(1);
            }
        }
 private int RunQuery()
 {
     return(target.RunQuery(mockApi.Object, parameters, output, error));
 }