private List<Dictionary<string, object>> RenderHostList(FrontPageResponse data, DBLane l, DBHostLane hl) { return FindRevisionWorkViews(data, hl.id).Select(w => RevisionWorkToDict(data, l, w)).ToList(); }
public DBHostLane GetHostLane (int host_id, int lane_id) { DBHostLane result; using (IDbCommand cmd = CreateCommand ()) { cmd.CommandText = "SELECT * FROM HostLane WHERE lane_id = @lane_id AND host_id = @host_id;"; DB.CreateParameter (cmd, "host_id", host_id); DB.CreateParameter (cmd, "lane_id", lane_id); using (IDataReader reader = cmd.ExecuteReader ()) { if (!reader.Read ()) return null; result = new DBHostLane (reader); if (reader.Read ()) throw new Exception (string.Format ("Found more than one HostLane with host_id {0} and lane_id {1}", host_id, lane_id)); } } return result; }
public DBLane CloneLane (int lane_id, string new_name, bool copy_files) { DBLane result = null; DBLane master = DBLane_Extensions.Create (this, lane_id); if (this.LookupLane (new_name, false) != null) throw new Exception (string.Format ("The lane '{0}' already exists.", new_name)); try { using (IDbTransaction transaction = BeginTransaction ()) { result = new DBLane (); result.lane = new_name; result.max_revision = master.max_revision; result.min_revision = master.min_revision; result.repository = master.repository; result.source_control = master.source_control; result.parent_lane_id = master.parent_lane_id; result.enabled = master.enabled; result.Save (this); foreach (DBLanefile filemaster in master.GetFiles (this, null)) { int fid; if (copy_files) { DBLanefile clone = new DBLanefile (); clone.contents = filemaster.contents; clone.mime = filemaster.mime; clone.name = filemaster.name; clone.Save (this); fid = clone.id; } else { fid = filemaster.id; } DBLanefiles lane_files = new DBLanefiles (); lane_files.lane_id = result.id; lane_files.lanefile_id = fid; lane_files.Save (this); } foreach (DBCommand cmdmaster in GetCommands (master.id)) { DBCommand clone = new DBCommand (); clone.lane_id = result.id; clone.alwaysexecute = cmdmaster.alwaysexecute; clone.arguments = cmdmaster.arguments; clone.command = cmdmaster.command; clone.filename = cmdmaster.filename; clone.nonfatal = cmdmaster.nonfatal; clone.sequence = cmdmaster.sequence; clone.timeout = cmdmaster.timeout; clone.working_directory = cmdmaster.working_directory; clone.upload_files = cmdmaster.upload_files; clone.Save (this); } foreach (DBHostLaneView hostlanemaster in master.GetHosts (this)) { DBHostLane clone = new DBHostLane (); clone.enabled = false; clone.lane_id = result.id; clone.host_id = hostlanemaster.host_id; clone.Save (this); } foreach (DBEnvironmentVariable env in master.GetEnvironmentVariables (this)) { DBEnvironmentVariable clone = new DBEnvironmentVariable (); clone.host_id = env.host_id; clone.lane_id = result.id; clone.name = env.name; clone.value = env.value; clone.Save (this); } foreach (DBLaneNotification notification in master.GetNotifications (this)) { DBLaneNotification clone = new DBLaneNotification (); clone.lane_id = result.id; clone.notification_id = notification.notification_id; clone.Save (this); } foreach (var tag in master.GetTags (this)) { var clone = new DBLaneTag (); clone.lane_id = result.id; clone.tag = tag.tag; clone.Save (this); } transaction.Commit (); } } catch { result = null; throw; } return result; }
void WriteHostLane (StringBuilder matrix, IEnumerable<DBHost> hosts, DBHostLane hl) { matrix.AppendFormat ("<td><a href='ViewTable.aspx?lane_id={1}&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"); }