Пример #1
0
        public ConfluenceUploadForm(ConfluenceService confluenceService, LogData logData,
                                    string initialSpaceName, string initialRootPageName,
                                    string initialPlatformPageName, string initialBuildPageName, string logFilePath)
        {
            m_confluenceService       = confluenceService;
            m_logData                 = logData;
            m_logFilePath             = logFilePath;
            m_initialSpaceName        = initialSpaceName;
            m_initialRootPageName     = initialRootPageName;
            m_initialPlatformPageName = initialPlatformPageName + " - FPS data";
            m_initialBuildPageName    = initialBuildPageName + " - " + m_initialPlatformPageName;

            FormBorderStyle = FormBorderStyle.FixedDialog;
            InitializeComponent();

            foreach (FrameRecordRange frr in m_logData.LevelRanges)
            {
                LevelsCheckedListBox.Items.Add(frr.Name, CheckState.Checked);
            }

            SpaceComboBox.SelectedValueChanged    += new EventHandler(SpaceComboBox_SelectedValueChanged);
            RootPageComboBox.SelectedValueChanged += new EventHandler(RootPageComboBox_SelectedValueChanged);
            PlatformComboBox.SelectedValueChanged += new EventHandler(PlatformComboBox_SelectedValueChanged);
            BuildComboBox.SelectedValueChanged    += new EventHandler(BuildComboBox_SelectedValueChanged);

            SpaceComboBox.LostFocus    += new EventHandler(SpaceComboBox_SelectedValueChanged);
            RootPageComboBox.LostFocus += new EventHandler(RootPageComboBox_SelectedValueChanged);
            PlatformComboBox.LostFocus += new EventHandler(PlatformComboBox_SelectedValueChanged);
            BuildComboBox.LostFocus    += new EventHandler(BuildComboBox_SelectedValueChanged);

            SetSpaces();
        }
        public ConfluenceLoginForm(ConfluenceService confluenceService, string initialUsername, string initialPassword)
        {
            m_confluenceService = confluenceService;

            FormBorderStyle = FormBorderStyle.FixedDialog;
            InitializeComponent();

            UsernameTextBox.Text = initialUsername;
            PasswordTextBox.Text = initialPassword;
        }
        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*/);
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        static void UploadStatsPages(ConfluenceService confluence, LogData logData, string[] groups, string spaceName, string rootPageName, string platformPageName, string buildPageName, XmlNodeList metrics, bool uploadSummary, string logfile)
        {
            try
            {
                List <ConfluenceSOAP.RemoteSpaceSummary> spaces = confluence.GetSpaces();

                bool spaceExists        = false;
                bool rootPageExists     = false;
                bool platformPageExists = false;
                bool buildPageExists    = false;

                foreach (ConfluenceSOAP.RemoteSpaceSummary space in spaces)
                {
                    if (space.key == spaceName)
                    {
                        spaceExists = true;
                        break;
                    }
                }

                if (!spaceExists)
                {
                    confluence.CreateSpace(spaceName);
                }

                List <ConfluenceSOAP.RemotePageSummary> pages = confluence.GetPages(spaceName);

                foreach (ConfluenceSOAP.RemotePageSummary page in pages)
                {
                    if (page.title == rootPageName)
                    {
                        rootPageExists = true;
                    }

                    if (page.title == platformPageName)
                    {
                        platformPageExists = true;
                    }

                    if (page.title == buildPageName)
                    {
                        buildPageExists = true;
                    }
                }

                if (!rootPageExists)
                {
                    confluence.CreatePage(rootPageName, spaceName);
                }

                if (!platformPageExists)
                {
                    confluence.CreatePage(platformPageName, rootPageName, spaceName);
                }

                if (!buildPageExists)
                {
                    confluence.CreatePage(buildPageName, platformPageName, spaceName);
                }

                string timeDateString = DateTime.Now.ToString("dd/MM/yy hh:mm:ss \\(\\U\\T\\Cz\\)");

                ConfluenceService.PageContentMetaData pageContentMD = new ConfluenceService.PageContentMetaData(timeDateString, logData.Name, logData.BuildInfo.PlatformString, logData.BuildInfo.BuildNumberString, "", confluence.m_username, "automated build system", false);
                ConfluenceService.PageMetaData        pageMetaData  = new ConfluenceService.PageMetaData(spaceName, buildPageName, platformPageName, pageContentMD);
                confluence.UploadStatsDataPage(pageMetaData, logData, groups, metrics, uploadSummary);

                foreach (FrameRecordRange frr in logData.LevelRanges)
                {
                    LogData levelLogData = new LogData(logData, frr);
                    pageContentMD.m_levelName = levelLogData.Name;
                    ConfluenceService.PageMetaData levelPageMD = new ConfluenceService.PageMetaData(spaceName, levelLogData.Name + " - " + buildPageName, buildPageName, pageContentMD);
                    confluence.UploadStatsDataPage(levelPageMD, levelLogData, groups, metrics, true);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Something went wrong! :(\n\n" + ex.ToString() + Environment.NewLine + "Stack trace: " + ex.StackTrace);
                System.Environment.Exit(3);
            }
        }
Пример #5
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);
        }