Click here to Skip to main content
15,886,100 members
Articles / Desktop Programming / Windows Forms

Atlassian Jira - TortoiseSVN Plugin for Issue Tracking and Easy Linking of Subversion Project with Jira Issue

Rate me:
Please Sign up or sign in to vote.
4.57/5 (5 votes)
30 Mar 2009CPOL 113.3K   3.3K   22  
Atlassian Jira - TortoiseSVN Plugin for Issue Tracking and Easy Linking of Subversion Project with Jira Issue
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Reflection;

namespace CloseIssueConsole
{
    public class ReadWriteXML
    {
        public string _jiraURL;

        public string JiraURL()
        {
            if (_jiraURL == null)
            {
                string filePath = Assembly.GetCallingAssembly().Location;
                string sStartupPath = System.IO.Path.GetDirectoryName(filePath);
                using (XmlTextReader objXmlTextReader = new XmlTextReader(sStartupPath + @"\Config.xml"))
                {
                    string sName = "";
                    while (objXmlTextReader.Read())
                    {
                        switch (objXmlTextReader.NodeType)
                        {
                            case XmlNodeType.Element:
                                sName = objXmlTextReader.Name;
                                break;
                            case XmlNodeType.Text:
                                switch (sName)
                                {
                                    case "jiraURL":
                                        _jiraURL = objXmlTextReader.Value;
                                        break;
                                }
                                break;
                        }
                    }
                }
            }
            return _jiraURL;
        }
        public string _jirausername;

        public string Jirausername()
        {
            if (_jirausername == null)
            {
                string filePath = Assembly.GetCallingAssembly().Location;
                string sStartupPath = System.IO.Path.GetDirectoryName(filePath);
                using (XmlTextReader objXmlTextReader = new XmlTextReader(sStartupPath + @"\Config.xml"))
                {
                    string sName = "";
                    while (objXmlTextReader.Read())
                    {
                        switch (objXmlTextReader.NodeType)
                        {
                            case XmlNodeType.Element:
                                sName = objXmlTextReader.Name;
                                break;
                            case XmlNodeType.Text:
                                switch (sName)
                                {
                                    case "username":
                                        _jirausername = objXmlTextReader.Value;
                                        break;
                                }
                                break;
                        }
                    }
                }
            }
            return _jirausername;
        }//
        public string _jiraPassword;

        public string JiraPassword()
        {
            if (_jiraPassword == null)
            {
                string filePath = Assembly.GetCallingAssembly().Location;
                string sStartupPath = System.IO.Path.GetDirectoryName(filePath);
                using (XmlTextReader objXmlTextReader = new XmlTextReader(sStartupPath + @"\Config.xml"))
                {
                    string sName = "";
                    while (objXmlTextReader.Read())
                    {
                        switch (objXmlTextReader.NodeType)
                        {
                            case XmlNodeType.Element:
                                sName = objXmlTextReader.Name;
                                break;
                            case XmlNodeType.Text:
                                switch (sName)
                                {
                                    case "password":
                                        _jiraPassword = objXmlTextReader.Value;
                                        break;
                                }
                                break;
                        }
                    }
                }
            }
            return _jiraPassword;
        }
        public string _jiraDefaultFilter;

        public string JiraDefaultFilter()
        {
            if (_jiraDefaultFilter == null)
            {
                string filePath = Assembly.GetCallingAssembly().Location;
                string sStartupPath = System.IO.Path.GetDirectoryName(filePath);
                using (XmlTextReader objXmlTextReader = new XmlTextReader(sStartupPath + @"\Config.xml"))
                {
                    string sName = "";
                    while (objXmlTextReader.Read())
                    {
                        switch (objXmlTextReader.NodeType)
                        {
                            case XmlNodeType.Element:
                                sName = objXmlTextReader.Name;
                                break;
                            case XmlNodeType.Text:
                                switch (sName)
                                {
                                    case "defaultFilter":
                                        _jiraDefaultFilter = objXmlTextReader.Value;
                                        break;
                                }
                                break;
                        }
                    }
                }
            }
            return _jiraDefaultFilter;
        }

        public void WriteXMLFile()
        {
            try
            {
                string filePath = Assembly.GetCallingAssembly().Location;
                string sStartupPath = System.IO.Path.GetDirectoryName(filePath);

                using (XmlTextWriter objXmlTextWriter = new XmlTextWriter(sStartupPath + @"\Config.xml", null))
                {
                    objXmlTextWriter.Formatting = Formatting.Indented;
                    objXmlTextWriter.WriteStartDocument();
                    objXmlTextWriter.WriteStartElement("settings");
                    objXmlTextWriter.WriteStartElement("jiraURL");
                    objXmlTextWriter.WriteString(_jiraURL);
                    objXmlTextWriter.WriteEndElement();
                    objXmlTextWriter.WriteStartElement("username");
                    objXmlTextWriter.WriteString(_jirausername);
                    objXmlTextWriter.WriteEndElement();
                    objXmlTextWriter.WriteStartElement("password");
                    objXmlTextWriter.WriteString(_jiraPassword);
                    objXmlTextWriter.WriteEndElement();
                    objXmlTextWriter.WriteStartElement("defaultFilter");
                    objXmlTextWriter.WriteString(_jiraDefaultFilter);
                    objXmlTextWriter.WriteEndElement();
                    objXmlTextWriter.WriteEndElement();
                    objXmlTextWriter.WriteEndDocument();
                    objXmlTextWriter.Flush();
                    objXmlTextWriter.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Istanbul Bilgi University
Turkey Turkey
- Software developer from İstanbul/Turkey
- Programmed with C#.NET, ASP.NET, ASP, PHP, T-SQL
- SQL Server Administration
- Experiencing about NHibernate

Comments and Discussions