private void uploadLogsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (tabControl1.TabPages.Count > 0)
            {
                if (tabControl1.TabPages[0].Controls.Count == 1)
                {
                    LogControl logControl = GetLogControlFromTabPage(tabControl1.TabPages[0]);

                    if (logControl != null)
                    {
                        using (ConfluenceService confluenceService = new ConfluenceService(logControl.m_logViews[0].m_logData))
                        {
                            if (confluenceService.TryLogin(false, "", ""))
                            {
                                confluenceService.PromptForUpload("" /*m_logfilepath*/);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        static bool UploadConfluenceData(string settingsfile, string logfile, string[] groups, string platform, string buildid, string metrics, bool uploadSummary)
        {
            string username    = string.Empty;
            string password    = string.Empty;
            string space       = string.Empty;
            string parent      = string.Empty;
            string pagepostfix = string.Empty;

            try
            {
                StreamReader stream    = new StreamReader(settingsfile);
                XmlDocument  xmlDoc    = new XmlDocument();
                String       xmlstring = stream.ReadToEnd();
                stream.Close();
                xmlDoc.LoadXml(xmlstring);
                XmlNode settings = xmlDoc.SelectSingleNode("/settings");

                stream    = new StreamReader(metrics);
                xmlDoc    = new XmlDocument();
                xmlstring = stream.ReadToEnd();
                stream.Close();
                xmlDoc.LoadXml(xmlstring);
                XmlNodeList metricNodes = xmlDoc.SelectNodes("//metrics");

                foreach (XmlAttribute attrib in settings.Attributes)
                {
                    if (attrib.Name == "username")
                    {
                        username = attrib.Value;
                    }

                    if (attrib.Name == "password")
                    {
                        password = attrib.Value;
                    }

                    if (attrib.Name == "space")
                    {
                        space = attrib.Value;
                    }

                    if (attrib.Name == "parent")
                    {
                        parent = attrib.Value;
                    }

                    if (attrib.Name == "pageuniqueid")
                    {
                        pagepostfix = attrib.Value;
                    }
                }

                FileLogProcessor logProcessor = new FileLogProcessor(logfile);
                LogData          logData      = logProcessor.ProcessLog();

                if (platform == string.Empty)
                {
                    platform = logData.BuildInfo.PlatformString + " - Auto-testing Statistics - ";
                }

                if (buildid == string.Empty)
                {
                    buildid = logData.BuildInfo.BuildNumberString + " - Auto-testing Statistics - ";
                }

                platform += pagepostfix;
                buildid  += pagepostfix;

                ConfluenceService confluence = new ConfluenceService(logData);
                if (confluence.TryLogin(true, username, password))
                {
                    UploadStatsPages(confluence, logData, groups, space, parent, platform, buildid, metricNodes, uploadSummary, logfile);
                }
            }
            catch (System.Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message + System.Environment.NewLine + "Stack: " + ex.StackTrace + System.Environment.NewLine);
                System.Environment.Exit(2);
            }
            return(true);
        }