internal void Initialize(IBuildDetail bd)
        {
            var statuses = new BuildDetailSectionStatus[2];

            statuses[0] = this.controlSummary.Initialize(bd);
            statuses[1] = this.controlBuildSteps.Initialize(bd, this.imageList);

            for (int i = 0; i < this.sectionIcons.Length; i++)
            {
                LinkLabel sectionIcon = this.sectionIcons[i];
                BuildDetailSectionStatus sectionStatus = statuses[i];

                sectionIcon.Left = this.controlSummary.ValueColumnLeftPos;
                UpdateSectionIcon(sectionIcon, sectionStatus);
            }
        }
Beispiel #2
0
        internal BuildDetailSectionStatus Initialize(IBuildDetail bd)
        {
            var result = new BuildDetailSectionStatus();

            bd.RefreshAllDetails();

            var workItemsOpened = new StringBuilder();
            List <IBuildInformationNode> workItemsOpenedNodes = bd.Information.GetNodesByType("OpenedWorkItem");

            workItemsOpenedNodes.ForEach(node =>
            {
                workItemsOpened.AppendFormat("{0} ({1}/{2}) ; ",
                                             node.Fields["WorkItemId"],
                                             node.Fields["Status"],
                                             node.Fields["AssignedTo"]);
            });

            List <IBuildInformationNode> steps = bd.Information.GetNodesByType("BuildStep");
            IBuildInformationNode        buildCompletedNode = steps.Find(node =>
            {
                return(node.Fields["Name"] == "BuildCompleted");
            });

            if (buildCompletedNode != null)
            {
                result.Success = (buildCompletedNode.Fields["Status"].ToLower() == "succeeded");
                result.Message = buildCompletedNode.Fields["Message"];
            }
            else
            {
                result.Success = false;
                result.Message = string.Empty;
            }


            // build name link label
            var control_BuildName = new LinkLabel();

            control_BuildName.BackColor = Color.Transparent;
            control_BuildName.Text      = bd.BuildNumber;
            control_BuildName.AutoSize  = true;
            control_BuildName.Tag       = bd.DropLocation;
            control_BuildName.Click    += BuildName_Click;

            // log file link label
            var control_Log = new LinkLabel();

            control_Log.BackColor = Color.Transparent;
            control_Log.Text      = bd.LogLocation;
            control_Log.AutoSize  = true;
            control_Log.Click    += LogFile_Click;

            var itemValues = new List <object>
            {
                control_BuildName, bd.RequestedBy, bd.BuildDefinition.TeamProject,
                bd.BuildDefinition.Name,
                string.Empty,                  //bd.BuildAgent.Name,
                string.Empty,                  //bd.CommandLineArguments,
                bd.StartTime.ToString(), bd.FinishTime.ToString(), bd.LastChangedBy,
                bd.LastChangedOn.ToString(), bd.Quality,
                workItemsOpened.ToString(), bd.SourceGetVersion, control_Log
            };

            this.lvItems.BeginUpdate();
            try
            {
                this.lvItems.Controls.Clear();
                this.table.Rows.Clear();
                for (int i = 0; i < this.itemNames.Length; i++)
                {
                    string itemName  = this.itemNames[i];
                    var    itemValue = (itemValues[i] is string?itemValues[i] : string.Empty) as string;

                    var newRow = new Row();
                    newRow.Cells.Add(new Cell(itemName));
                    var cell = new Cell(itemValue);
                    newRow.Cells.Add(cell);
                    this.table.Rows.Add(newRow);

                    if (itemValues[i] is Control)
                    {
                        Rectangle cellRect = this.lvItems.CellRect(cell);
                        var       control  = itemValues[i] as Control;
                        this.lvItems.Controls.Add(control);
                        control.Location = new Point(cellRect.X, cellRect.Y - 1);
                        control.BringToFront();
                    }
                }
            }
            finally
            {
                this.lvItems.EndUpdate();
                Rectangle rectangle = this.lvItems.ColumnRect(1);
                this.ValueColumnLeftPos = rectangle.Left + 14;
            }

            #region debug

            //                        Debug.WriteLine(new string('-', 120));
            //                        foreach (var node in bd.Information.Nodes)
            //                        {
            //                            Debug.WriteLine(string.Format("Type: {0}", node.Type));
            //                            foreach (var field in node.Fields)
            //                            {
            //                                Debug.WriteLine(string.Format("  Field: {0} | Value: {1}", field.Key, field.Value));
            //                            }
            //                            Debug.WriteLine(new string('=', 120));
            //                        }

            #endregion

            return(result);
        }
 private void UpdateSectionIcon(LinkLabel icon, BuildDetailSectionStatus status)
 {
     icon.ImageIndex = status.Success ? 1 : 0;
     icon.Text       = status.Message;
 }
        internal BuildDetailSectionStatus Initialize(IBuildDetail bd, ImageList imageList)
        {
            var result = new BuildDetailSectionStatus();

            this.imageList = imageList;

            bd.RefreshAllDetails();
            List <IBuildInformationNode> stepsNodes = BuildStepsNodes(bd);

            int successedCount = 0;

            this.lvItems.BeginUpdate();
            try
            {
                this.lvItems.Controls.Clear();
                this.table.Rows.Clear();
                stepsNodes.ForEach(node =>
                {
                    var newRow = new Row();
                    //newRow.Height = 20;

                    // icon cell
                    var iconCell = new Cell();
                    newRow.Cells.Add(iconCell);

                    // Build step message cell
                    string message  = node.Fields["Message"];
                    var messageCell = new Cell(message);
                    newRow.Cells.Add(messageCell);

                    // Completed On cell
                    string finishTime    = node.Fields["FinishTime"];
                    DateTime completedOn = DateTime.Parse(finishTime);
                    var completedOnCell  = new Cell(completedOn.ToString());
                    newRow.Cells.Add(completedOnCell);

                    this.table.Rows.Add(newRow);

                    // icon cell image
                    string status         = node.Fields["Status"];
                    bool successed        = status.ToLower() == "succeeded";
                    LinkLabel iconControl = CreateIcon(successed);
                    this.lvItems.Controls.Add(iconControl);
                    Rectangle iconCellRect = this.lvItems.CellRect(iconCell);
                    iconControl.Location   = new Point(iconCellRect.X, iconCellRect.Y + 1);
                    iconControl.BringToFront();

                    if (successed)
                    {
                        successedCount++;
                    }
                });

                result.Success = successedCount == stepsNodes.Count;
                result.Message = string.Format("{0} succeeded, {1} failed", successedCount,
                                               stepsNodes.Count - successedCount);
            }
            finally
            {
                this.lvItems.EndUpdate();
            }

            return(result);
        }