BEurtle.BEurtlePlugin.loadIssues C# (CSharp) Method

loadIssues() public method

public loadIssues ( IWin32Window hwnd, string rootdir = null ) : bool
hwnd IWin32Window
rootdir string
return bool
        public bool loadIssues(IWin32Window hwnd, string rootdir = null)
        {
            string arguments = "list --status=all --xml";
            if (rootdir == null) rootdir = rootpath;
            issues = null;
            creators = new AutoCompleteStringCollection();
            reporters = new AutoCompleteStringCollection();
            assigneds=new AutoCompleteStringCollection();
            authors = new AutoCompleteStringCollection();
            string xml = "unknown error";
            if (rootdir.EndsWith(".xml"))
            {   // This is a raw BE XML dump
                using (var fs = new StreamReader(rootdir))
                    xml = fs.ReadToEnd();
                VCSInfo = "Direct load of XML database";
            }
            else
            {
                FileInfo idcache=new FileInfo(rootdir + "\\.be\\id-cache"), bexmlcache=new FileInfo(rootdir + "\\.be\\bexml.xml");
                if (parameters.CacheBEXML && bexmlcache.Exists && (!idcache.Exists || bexmlcache.LastWriteTimeUtc > idcache.LastWriteTimeUtc) && nedprod.LastModifiedInDirs.FindLastModifiedSince(new DirectoryInfo(rootdir+"\\.be"), bexmlcache.LastWriteTimeUtc).Count==0)
                {   // There is a bexml.xml cache which isn't older than the id-cache nor BE repo contents, so we can use that
                    using (var fs = new StreamReader(rootdir + "\\.be\\bexml.xml"))
                        xml = fs.ReadToEnd();
                    VCSInfo = "Used up-to-date XML cache in .be\\bexml.xml";
                }
                else
                {
                    xml = callBEcmd(rootdir, new string[1] { arguments })[0];
                    string VCSVersion = callBEcmd(rootdir, new string[1] { "vcs version" })[0];
                    if (-1 == VCSVersion.IndexOf("RESULT:"))
                        VCSInfo = "VCS: Error reading VCS version";
                    else
                        VCSInfo = "VCS: " + VCSVersion.Substring(VCSVersion.IndexOf("RESULT:") + 8);
                    if (parameters.CacheBEXML && xml.StartsWith("<?xml version=\"1.0\" "))
                        using (var fs = new StreamWriter(rootdir + "\\.be\\bexml.xml"))
                            fs.Write(xml);
                }
            }
            if (!xml.StartsWith("<?xml version=\"1.0\" "))
            {
                VCSInfo = xml;
                if (xml.IndexOf("Connection Error") >= 0 && !rootdir.StartsWith("http://"))
                {
                    if (DialogResult.Yes == MessageBox.Show(hwnd, "BE repository not found at " + rootdir + ". Would you like me to create it there for you?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                    {
                        xml = callBEcmd(rootdir, new string[1] { "init" })[0];
                        MessageBox.Show(hwnd, xml);
                        return loadIssues(hwnd);
                    }
                }
                else
                    MessageBox.Show(hwnd, xml);
            }
            else
            {
                issues = new XPathDocument(new XmlTextReader(new StringReader(xml)));
                creators.AddRange(XMLitems(issues, "creator", true, true).ToArray());
                reporters.AddRange(XMLitems(issues, "reporter", true, true).ToArray());
                assigneds.AddRange(XMLitems(issues, "assigned", true, true).ToArray());
                authors.AddRange(XMLitems(issues, "author", true, true).ToArray());
                return true;
            }
            return false;
        }