public void EditEnvironmentVariable (WebServiceLogin login, DBEnvironmentVariable variable)
		{
			using (DB db = new DB ()) {
				VerifyUserInRole (db, login, Roles.Administrator);
				variable.Save (db);
			}
		}
		public int AddEnvironmentVariable (WebServiceLogin login, int? lane_id, int? host_id, string name, string value)
		{
			using (DB db = new DB ()) {
				VerifyUserInRole (db, login, Roles.Administrator);

				DBEnvironmentVariable var = new DBEnvironmentVariable ();
				var.name = name;
				var.value = value;
				var.host_id = host_id;
				var.lane_id = lane_id;
				var.Save (db);
				return var.id;
			}
		}
Example #3
0
		public void EditEnvironmentVariableInLane (WebServiceLogin login, DBEnvironmentVariable variable, int lane_id)
		{
			using (DB db = new DB ()) {
				var lane = DBLane_Extensions.Create (db, lane_id);
				VerifyUserInRoles (db, login, lane.additional_roles, false);
				VerifyEnvironmentVariableIsForLane (variable, lane_id);
				variable.Save (db);
			}
		}
Example #4
0
		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;
		}
Example #5
0
		public int AddEnvironmentVariableInLane (WebServiceLogin login, int lane_id, int? host_id, string name, string value)
		{
			using (DB db = new DB ()) {
				var lane = DBLane_Extensions.Create (db, lane_id);
				VerifyUserInRoles (db, login, lane.additional_roles, false);

				DBEnvironmentVariable var = new DBEnvironmentVariable ();
				var.name = name;
				var.value = value;
				var.host_id = host_id;
				var.lane_id = lane_id;
				var.Save (db);
				return var.id;
			}
		}