コード例 #1
0
    private void WriteLanes(List <StringBuilder> header_rows, LaneTreeNode node, int level, int depth)
    {
        if (header_rows.Count <= level)
        {
            header_rows.Add(new StringBuilder());
        }

        foreach (LaneTreeNode n in node.Children)
        {
            header_rows [level].AppendFormat("<td colspan='{0}'>{1}</td>", n.Leafs == 0 ? 1 : n.Leafs, n.Lane.lane);

            WriteLanes(header_rows, n, level + 1, depth);
        }

        if (node.Children.Count == 0)
        {
            for (int hl = 0; hl < node.HostLanes.Count; hl++)
            {
                for (int i = level; i < depth; i++)
                {
                    if (header_rows.Count <= i)
                    {
                        header_rows.Add(new StringBuilder());
                    }
                    header_rows [i].Append("<td colspan='1'>-</td>");
                }
            }
        }
    }
コード例 #2
0
ファイル: Master.master.cs プロジェクト: obandox/monkeywrench
    public void WriteTree(LaneTreeNode node, Table tableMain, int level, int max_level, Panel containing_div)
    {
        Panel div = new Panel();

        div.ID = "tree_node_" + (++counter).ToString();

        foreach (LaneTreeNode n in node.Children)
        {
            bool hiding = true;
            if (!string.IsNullOrEmpty(Request ["lane"]))
            {
                if (n.Lane.lane == Request ["lane"] || n.Find((v) => v.Lane.lane == Request ["lane"]) != null)
                {
                    hiding = false;
                }
            }

            containing_div.Controls.Add(CreateTreeViewRow(string.Format("index.aspx?lane={0}", HttpUtility.UrlEncode(n.Lane.lane)), n.Lane.lane, level, max_level, n.Children.Count > 0, div, hiding));

            if (n.Children.Count > 0)
            {
                containing_div.Controls.Add(div);
                WriteTree(n, tableMain, level + 1, max_level, div);
                div    = new Panel();
                div.ID = "tree_node_" + (++counter).ToString();
            }
        }
    }
コード例 #3
0
ファイル: Master.master.cs プロジェクト: cadsit/monkeywrench
    private void CreateTree()
    {
        if (this.response != null)
        {
            return;
        }

        // we need to create a tree of the lanes
        LaneTreeNode root;
        Panel        div;

        // Remove disabled lanes.
        var lanes = new List <DBLane> (tree_response.Lanes);

        for (int i = lanes.Count - 1; i >= 0; i--)
        {
            if (lanes [i].enabled)
            {
                continue;
            }
            lanes.RemoveAt(i);
        }
        root = LaneTreeNode.BuildTree(lanes, null);

        SetResponse(tree_response);

        // layout the tree
        div    = new Panel();
        div.ID = "tree_root_id";

        tableMainTree.Rows.Add(Utils.CreateTableRow(CreateTreeViewRow("index.aspx?show_all=true", "All", 0, root.Depth, true, div, true)));

        tableMainTree.Rows.Add(Utils.CreateTableRow(div));
        WriteTree(root, tableMainTree, 1, root.Depth, div);

        // layout the tags
        div    = new Panel();
        div.ID = "tags_root_id";

        tableMainTree.Rows.Add(Utils.CreateTableRow(CreateTreeViewRow(null, "Tags", 0, 1, true, div, true)));
        tableMainTree.Rows.Add(Utils.CreateTableRow(div));
        WriteTags(tree_response.Tags, tableMainTree, 1, div);
    }
コード例 #4
0
    public static LaneTreeNode BuildTree(IEnumerable <DBLane> lanes, IEnumerable <DBHostLane> host_lanes)
    {
        // we need to create a tree of the lanes
        LaneTreeNode root = new LaneTreeNode(null);
        Dictionary <int, LaneTreeNode> nodes = new Dictionary <int, LaneTreeNode> ();
        List <DBLane> lanes_clone            = FilterToLatestMonth(lanes);

        while (lanes_clone.Count != 0)
        {
            int c = lanes_clone.Count;
            for (int i = lanes_clone.Count - 1; i >= 0; i--)
            {
                DBLane lane = lanes_clone [i];
                if (!lane.parent_lane_id.HasValue)
                {
                    LaneTreeNode node = new LaneTreeNode(lane, host_lanes);
                    root.Children.Add(node);
                    nodes [lane.id] = node;
                    lanes_clone.RemoveAt(i);
                    continue;
                }

                if (nodes.ContainsKey(lane.parent_lane_id.Value))
                {
                    LaneTreeNode node = new LaneTreeNode(lane, host_lanes);
                    nodes [lane.parent_lane_id.Value].Children.Add(node);
                    nodes [lane.id] = node;
                    lanes_clone.RemoveAt(i);
                    continue;
                }
            }
            if (c == lanes_clone.Count)
            {
                Console.WriteLine("Infinite recursion detected");
                break;
            }
        }

        root.Sort();

        return(root);
    }
コード例 #5
0
ファイル: Master.master.cs プロジェクト: obandox/monkeywrench
    private void CreateTree()
    {
        if (this.response != null)
        {
            return;
        }

        GetLanesResponse response;
        // we need to create a tree of the lanes
        LaneTreeNode root;
        Panel        div;

        try {
            response = WebService.GetLanes(WebServiceLogin);

            // Reomve disabled lanes.
            var lanes = new List <DBLane> (response.Lanes);
            for (int i = lanes.Count - 1; i >= 0; i--)
            {
                if (lanes [i].enabled)
                {
                    continue;
                }
                lanes.RemoveAt(i);
            }
            root = LaneTreeNode.BuildTree(lanes, null);

            SetResponse(response);

            div    = new Panel();
            div.ID = "tree_root_id";

            // layout the tree
            tableMainTree.Rows.Add(Utils.CreateTableRow(CreateTreeViewRow("index.aspx?show_all=true", "All", 0, root.Depth, true, div, true)));

            tableMainTree.Rows.Add(Utils.CreateTableRow(div));
            WriteTree(root, tableMainTree, 1, root.Depth, div);
        } catch {
            tableMainTree.Visible = false;
        }
    }
コード例 #6
0
    private LaneTreeNode BuildTree(FrontPageResponse data)
    {
        LaneTreeNode result = LaneTreeNode.BuildTree(data.Lanes, data.HostLanes);

        if (data.Lane != null)
        {
            result = result.Find(v => v.Lane != null && v.Lane.id == data.Lane.id);
        }
        else if (data.SelectedLanes.Count > 1)
        {
            for (int i = result.Children.Count - 1; i >= 0; i--)
            {
                LaneTreeNode ltn = result.Children [i];
                if (!data.SelectedLanes.Exists((DBLane l) => l.id == ltn.Lane.id))
                {
                    result.Children.RemoveAt(i);
                }
            }
        }
        return(result);
    }
コード例 #7
0
    private void WriteHostLanes(StringBuilder matrix, LaneTreeNode node, IEnumerable <DBHost> hosts, List <int> hostlane_order)
    {
        node.ForEach(new Action <LaneTreeNode> (delegate(LaneTreeNode target)
        {
            if (target.Children.Count != 0)
            {
                return;
            }

            if (target.HostLanes.Count == 0)
            {
                matrix.Append("<td>-</td>");
            }
            else
            {
                foreach (DBHostLane hl in target.HostLanes)
                {
                    hostlane_order.Add(hl.id);
                    WriteHostLane(matrix, hosts, hl);
                }
            }
        }));
    }
コード例 #8
0
    private void WriteHostLanes(StringBuilder matrix, LaneTreeNode node, IEnumerable <DBHost> hosts, List <int> hostlane_order)
    {
        node.ForEach(new Action <LaneTreeNode> (delegate(LaneTreeNode target)
        {
            if (target.Children.Count != 0)
            {
                return;
            }

            if (target.HostLanes.Count == 0)
            {
                matrix.Append("<td>-</td>");
            }
            else
            {
                foreach (DBHostLane hl in target.HostLanes)
                {
                    hostlane_order.Add(hl.id);
                    matrix.AppendFormat("<td><a href='ViewTable.aspx?lane_id={1}&amp;host_id={2}' class='{3}'>{0}</a></td>", Utils.FindHost(hosts, hl.host_id).host, hl.lane_id, hl.host_id, hl.enabled ? "enabled-hostlane" : "disabled-hostlane");
                }
            }
        }));
    }
コード例 #9
0
ファイル: LaneTreeNode.cs プロジェクト: vargaz/monkeywrench
	public static LaneTreeNode BuildTree (IEnumerable<DBLane> lanes, IEnumerable<DBHostLane> host_lanes)
	{
		// we need to create a tree of the lanes
		LaneTreeNode root = new LaneTreeNode (null);
		Dictionary<int, LaneTreeNode> nodes = new Dictionary<int, LaneTreeNode> ();
		List<DBLane> lanes_clone = FilterToLatestMonth (lanes);

		while (lanes_clone.Count != 0) {
			int c = lanes_clone.Count;
			for (int i = lanes_clone.Count - 1; i >= 0; i--) {
				DBLane lane = lanes_clone [i];
				if (!lane.parent_lane_id.HasValue) {
					LaneTreeNode node = new LaneTreeNode (lane, host_lanes);
					root.Children.Add (node);
					nodes [lane.id] = node;
					lanes_clone.RemoveAt (i);
					continue;
				}

				if (nodes.ContainsKey (lane.parent_lane_id.Value)) {
					LaneTreeNode node = new LaneTreeNode (lane, host_lanes);
					nodes [lane.parent_lane_id.Value].Children.Add (node);
					nodes [lane.id] = node;
					lanes_clone.RemoveAt (i);
					continue;
				}
			}
			if (c == lanes_clone.Count) {
				Console.WriteLine ("Infinite recursion detected");
				break;
			}
		}

		root.Sort ();

		return root;
	}
コード例 #10
0
ファイル: index.aspx.cs プロジェクト: hackmp/monkeywrench
	private void WriteHostLanes (StringBuilder matrix, LaneTreeNode node, IEnumerable<DBHost> hosts, List<int> hostlane_order)
	{
		node.ForEach (new Action<LaneTreeNode> (delegate (LaneTreeNode target)
		{
			if (target.Children.Count != 0)
				return;

			if (target.HostLanes.Count == 0) {
				matrix.Append ("<td>-</td>");
			} else {
				foreach (DBHostLane hl in target.HostLanes) {
					hostlane_order.Add (hl.id);
					matrix.AppendFormat ("<td><a href='ViewTable.aspx?lane_id={1}&amp;host_id={2}' class='{3}'>{0}</a></td>", Utils.FindHost (hosts, hl.host_id).host, hl.lane_id, hl.host_id, hl.enabled ? "enabled-hostlane" : "disabled-hostlane");
				}
			}
		}));
	}
コード例 #11
0
ファイル: index.aspx.cs プロジェクト: hackmp/monkeywrench
	private void WriteLanes (List<StringBuilder> header_rows, LaneTreeNode node, int level, int depth)
	{
		if (header_rows.Count <= level)
			header_rows.Add (new StringBuilder ());

		foreach (LaneTreeNode n in node.Children) {
			header_rows [level].AppendFormat ("<td colspan='{0}'>{1}</td>", n.Leafs == 0 ? 1 : n.Leafs, n.Lane.lane);

			WriteLanes (header_rows, n, level + 1, depth);
		}

		if (node.Children.Count == 0) {
			for (int i = level; i < depth; i++) {
				if (header_rows.Count <= i)
					header_rows.Add (new StringBuilder ());
				header_rows [i].Append ("<td colspan='1'>-</td>");
			}
		}
	}
コード例 #12
0
ファイル: Master.master.cs プロジェクト: DavidS/monkeywrench
	public void WriteTree (LaneTreeNode node, Table tableMain, int level, int max_level, Panel containing_div)
	{
		Panel div = new Panel ();
		div.ID = "tree_node_" + (++counter).ToString ();

		foreach (LaneTreeNode n in node.Children) {
			bool hiding = true;
			if (!string.IsNullOrEmpty (Request ["lane"])) {
				if (n.Lane.lane == Request ["lane"] || n.Find ((v) => v.Lane.lane == Request ["lane"]) != null) {
					hiding = false;
				}
			}

			containing_div.Controls.Add (CreateTreeViewRow (string.Format ("index.aspx?lane={0}", HttpUtility.UrlEncode (n.Lane.lane)), n.Lane.lane, level, max_level, n.Children.Count > 0, div, hiding));
			
			if (n.Children.Count > 0) {
				containing_div.Controls.Add (div);
				WriteTree (n, tableMain, level + 1, max_level, div);
				div = new Panel ();
				div.ID = "tree_node_" + (++counter).ToString ();
			}
		}
	}
コード例 #13
0
ファイル: index.aspx.cs プロジェクト: MSylvia/monkeywrench
	private void WriteHostLanes (StringBuilder matrix, LaneTreeNode node, IEnumerable<DBHost> hosts, List<int> hostlane_order)
	{
		node.ForEach (new Action<LaneTreeNode> (delegate (LaneTreeNode target)
		{
			if (target.Children.Count != 0)
				return;

			if (target.HostLanes.Count == 0) {
				matrix.Append ("<td>-</td>");
			} else {
				foreach (DBHostLane hl in target.HostLanes) {
					hostlane_order.Add (hl.id);
					WriteHostLane (matrix, hosts, hl);
				}
			}
		}));
	}
コード例 #14
0
    public string GenerateOverview(FrontPageResponse data)
    {
        StringBuilder        matrix         = new StringBuilder();
        LaneTreeNode         tree           = BuildTree(data);
        List <StringBuilder> header_rows    = new List <StringBuilder> ();
        List <int>           hostlane_order = new List <int> ();

        if (tree == null)
        {
            return(string.Empty);
        }

        // This renders all the host header lanes
        WriteLanes(header_rows, tree, 0, tree.Depth);

        matrix.AppendLine("<table class='buildstatus'>");
        for (int i = 0; i < header_rows.Count; i++)
        {
            if (header_rows [i].Length == 0)
            {
                continue;
            }

            matrix.Append("<tr>");
            matrix.Append(header_rows [i]);
            matrix.AppendLine("</tr>");
        }

        // Renders all the hosts
        matrix.AppendLine("<tr>");
        WriteHostLanes(matrix, tree, data.Hosts, hostlane_order);
        matrix.AppendLine("</tr>");

        // Renders all the builds
        int           counter = 0;
        int           added   = 0;
        StringBuilder row     = new StringBuilder();

        do
        {
            added      = 0;
            row.Length = 0;

            for (int i = 0; i < hostlane_order.Count; i++)
            {
                int hl_id = hostlane_order [i];

                var rev = FindRevisionWorkViews(data, hl_id);
                DBRevisionWorkView2 work = null;

                if (rev != null && rev.Count > counter)
                {
                    work = rev [counter];
                    added++;
                }

                WriteWorkCell(row, work);
            }

            if (added > 0 && row.Length > 0)
            {
                matrix.Append("<tr>");
                matrix.Append(row.ToString());
                matrix.Append("</tr>");
            }

            counter++;
        } while (counter <= limit && added > 0);

        matrix.AppendLine("</table>");

        return(matrix.ToString());
    }
コード例 #15
0
    public string GenerateOverview(FrontPageResponse data)
    {
        StringBuilder        matrix         = new StringBuilder();
        LaneTreeNode         tree           = BuildTree(data);
        List <StringBuilder> header_rows    = new List <StringBuilder> ();
        List <int>           hostlane_order = new List <int> ();

        if (tree == null)
        {
            return(string.Empty);
        }

        WriteLanes(header_rows, tree, 0, tree.Depth);

        matrix.AppendLine("<table class='buildstatus'>");
        for (int i = 0; i < header_rows.Count; i++)
        {
            if (header_rows [i].Length == 0)
            {
                continue;
            }

            matrix.Append("<tr>");
            matrix.Append(header_rows [i]);
            matrix.AppendLine("</tr>");
        }

        matrix.AppendLine("<tr>");
        WriteHostLanes(matrix, tree, data.Hosts, hostlane_order);
        matrix.AppendLine("</tr>");

        int           counter = 0;
        int           added   = 0;
        StringBuilder row     = new StringBuilder();

        do
        {
            added      = 0;
            row.Length = 0;

            for (int i = 0; i < hostlane_order.Count; i++)
            {
                int hl_id = hostlane_order [i];

                List <DBRevisionWorkView2> rev  = null;
                DBRevisionWorkView2        work = null;

                for (int k = 0; k < data.RevisionWorkHostLaneRelation.Count; k++)
                {
                    if (data.RevisionWorkHostLaneRelation [k] == hl_id)
                    {
                        rev = data.RevisionWorkViews [k];
                        break;
                    }
                }

                if (rev != null && rev.Count > counter)
                {
                    work = rev [counter];
                    added++;
                }

                if (work != null)
                {
                    string  revision    = work.revision;
                    int     lane_id     = work.lane_id;
                    int     host_id     = work.host_id;
                    int     revision_id = work.revision_id;
                    DBState state       = work.State;
                    bool    completed   = work.completed;
                    string  state_str   = state.ToString().ToLowerInvariant();
                    bool    is_working;
                    string  str_date = string.Empty;

                    if (work.endtime.Year > 2000)
                    {
                        str_date = "<br/>" + TimeDiffToString(work.endtime, DateTime.UtcNow);
                    }

                    switch (state)
                    {
                    case DBState.Executing:
                        is_working = true;
                        break;

                    case DBState.NotDone:
                    case DBState.Paused:
                    case DBState.DependencyNotFulfilled:
                    case DBState.Ignore:
                        is_working = false;
                        break;

                    default:
                        is_working = !completed;
                        break;
                    }

                    long dummy;
                    if (revision.Length > 16 && !long.TryParse(revision, out dummy))
                    {
                        revision = revision.Substring(0, 8);
                    }

                    if (is_working)
                    {
                        row.AppendFormat(
                            @"<td class='{1}'>
								<center>
									<table class='executing'>
										<td>
											<a href='ViewLane.aspx?lane_id={2}&amp;host_id={3}&amp;revision_id={4}' title='{5}'>{0}{6}</a>
										</td>
									</table>
								<center>
							  </td>"                            ,
                            revision, state_str, lane_id, host_id, revision_id, "", str_date);
                    }
                    else
                    {
                        row.AppendFormat("<td class='{1}'><a href='ViewLane.aspx?lane_id={2}&amp;host_id={3}&amp;revision_id={4}' title='{5}'>{0}{6}</a></td>",
                                         revision, state_str, lane_id, host_id, revision_id, "", str_date);
                    }
                }
                else
                {
                    row.Append("<td>-</td>");
                }
            }

            if (added > 0 && row.Length > 0)
            {
                matrix.Append("<tr>");
                matrix.Append(row.ToString());
                matrix.Append("</tr>");
            }

            counter++;
        } while (counter <= limit && added > 0);

        matrix.AppendLine("</table>");

        return(matrix.ToString());
    }