コード例 #1
0
		public FindRevisionResponse FindRevisionForLane (WebServiceLogin login, int? revision_id, string revision, int? lane_id, string lane)
		{
			FindRevisionResponse response = new FindRevisionResponse ();

			using (DB db = new DB ()) {
				Authenticate (db, login, response, true);
				if ((revision_id == null || revision_id.Value <= 0) && string.IsNullOrEmpty (revision))
					return response;

				if ((lane_id == null || lane_id.Value <= 0) && string.IsNullOrEmpty (lane))
					return response;

				using (IDbCommand cmd = db.CreateCommand ()) {
					if (!lane_id.HasValue) {
						if (!revision_id.HasValue) {
							cmd.CommandText = "SELECT * FROM Revision INNER JOIN Lane ON Revision.lane_id = Lane.id WHERE Revision.revision = @revision AND Lane.lane = @lane;";
							DB.CreateParameter (cmd, "revision", revision);
						} else {
							cmd.CommandText = "SELECT * FROM Revision INNER JOIN Lane ON Revision.lane_id = Lane.id WHERE id = @id AND Lane.lane = @lane;";
							DB.CreateParameter (cmd, "id", revision_id.Value);
						}
						DB.CreateParameter (cmd, "lane", lane);
					} else {
						if (!revision_id.HasValue) {
							cmd.CommandText = "SELECT * FROM Revision WHERE revision = @revision AND lane_id = @lane_id;";
							DB.CreateParameter (cmd, "revision", revision);
						} else {
							cmd.CommandText = "SELECT * FROM Revision WHERE id = @id AND lane_id = @lane_id;";
							DB.CreateParameter (cmd, "id", revision_id.Value);
						}
						DB.CreateParameter (cmd, "lane_id", lane_id.Value);
					}
					DB.CreateParameter (cmd, "lane_id", lane_id);

					using (IDataReader reader = cmd.ExecuteReader ()) {
						if (reader.Read ()) {
							response.Revision = new DBRevision (reader);
						}
					}
				}
			}

			return response;
		}
コード例 #2
0
		public FindRevisionResponse FindRevision (WebServiceLogin login, int? revision_id, string revision)
		{
			FindRevisionResponse response = new FindRevisionResponse ();

			using (DB db = new DB ()) {
				Authenticate (db, login, response);
				if (!revision_id.HasValue)
					// DBRevisions are keyed by the hash and the lane, but we only have the hash.
					// Due to backwards compatibility, we can't add a parameter for the lane, so throw an error and direct
					// users to the proper API call.
					throw new ArgumentException ("revision_id is required. Use FindRevisionByHash instead for querying by hash.", "revision_id");
				response.Revision = FindRevision (db, revision_id.Value);
			}

			return response;
		}
コード例 #3
0
		public FindRevisionResponse FindRevisionByHash(WebServiceLogin login, DBLane lane, string revision)
		{
			FindRevisionResponse response = new FindRevisionResponse ();

			using (DB db = new DB ()) {
				Authenticate (db, login, response);
				response.Revision = FindRevision (db, lane, revision);
			}

			return response;
		}
コード例 #4
0
		public FindRevisionResponse FindRevision (WebServiceLogin login, int? revision_id, string revision)
		{
			FindRevisionResponse response = new FindRevisionResponse ();

			using (DB db = new DB ()) {
				Authenticate (db, login, response);
				response.Revision = FindRevision (db, revision_id, revision);
			}

			return response;
		}