コード例 #1
0
        public static bool CreateRestClient(JiraConfiguration config)
        {
            bool ret = false;

            try
            {
                _settings = new JiraRestClientSettings();
                _settings.EnableUserPrivacyMode = true;

                _jiraRepo = new JiraRepo(config.jiraBaseUrl, config.jiraUserName, config.jiraAPIToken);

                if (_jiraRepo != null)
                {
                    var test = _jiraRepo.GetJira().IssueTypes.GetIssueTypesAsync().Result.ToList();
                    if (test != null && test.Count > 0)
                    {
                        ret = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.Beep();
                Console.Beep();
                Console.Error.WriteLine("Sorry, there seems to be a problem connecting to Jira with the arguments you provided. Error: {0}, {1}\r\n\r\n{2}", ex.Message, ex.Source, ex.StackTrace);
                return(false);
            }


            return(ret);
        }
コード例 #2
0
        private static JiraConfiguration LoadConfigFile(string configFilePath)
        {
            JiraConfiguration configuration = null;

            StreamReader reader = null;

            try
            {
                reader = new StreamReader(configFilePath);
                string line1 = reader.ReadLine();
                if (!string.IsNullOrWhiteSpace(line1))
                {
                    string[] arr = line1.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    configuration = BuildConfig(arr);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error Loading Config File: {0}", ex.Message);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
            }

            return(configuration);
        }
コード例 #3
0
        internal static JiraConfiguration BuildConfig(string[] args)
        {
            JiraConfiguration config = null;

            if (args.Length == 1)
            {
                return(LoadConfigFile(args[0]));
            }

            if (args.Length == 1)
            {
                config = LoadConfigFile(args[0]);
            }
            else if (args.Length == 3)
            {
                config = new JiraConfiguration(args[0], args[1], args[2]);
            }

            return(config);
        }
コード例 #4
0
        private static bool MainMenu()
        {
            if (!_initialized)
            {
                if (config == null && _args != null)
                {
                    config = ConfigHelper.BuildConfig(_args);
                }
                if (config == null)
                {
                    ConsoleUtil.BuildNotInitializedQueue();
                    ConsoleUtil.Lines.WriteQueuedLines(true);
                    string vs = Console.ReadLine();
                    if (string.IsNullOrWhiteSpace(vs))
                    {
                        vs = string.Empty;
                    }
                    string[] arr = vs.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                    config = ConfigHelper.BuildConfig(arr);

                    ConsoleUtil.Lines.configInfo = string.Format("User: {0}", config.jiraUserName);


                    if (config != null)
                    {
                        if (JiraUtil.CreateRestClient(config))
                        {
                            _initialized = true;
                            return(_initialized);
                        }
                        else
                        {
                            _initialized = false;
                            ConsoleUtil.WriteLine("Invalid arguments!", ConsoleColor.Yellow, ConsoleColor.DarkBlue, false);
                            ConsoleUtil.WriteLine("Enter path to config file");
                            ConsoleUtil.WriteLine("Do you want to try again? (Y/N):");
                            ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                            if (keyInfo.Key == ConsoleKey.Y)
                            {
                                return(true);
                            }
                            else
                            {
                                return(false);
                            }
                        }
                    }
                }

                else
                {
                    if (JiraUtil.CreateRestClient(config))
                    {
                        ConsoleUtil.WriteLine("Successfully connected to Jira as " + config.jiraUserName);
                        ConsoleUtil.Lines.configInfo = string.Format("User: {0}", config.jiraUserName);

                        _initialized = true;
                        return(_initialized);
                    }
                    else
                    {
                        _initialized = false;
                        ConsoleUtil.WriteLine("Invalid arguments!", ConsoleColor.Yellow, ConsoleColor.DarkBlue, false);
                        ConsoleUtil.WriteLine("Enter path to config file");
                        ConsoleUtil.WriteLine("Do you want to try again? (Y/N):");
                        ConsoleKeyInfo keyInfo = Console.ReadKey(true);
                        if (keyInfo.Key == ConsoleKey.Y)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                }
            }

            return(InitializedMenu());
        }