本文整理汇总了C#中MonkeyWrench.DataClasses.DBLane类的典型用法代码示例。如果您正苦于以下问题:C# DBLane类的具体用法?C# DBLane怎么用?C# DBLane使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DBLane类属于MonkeyWrench.DataClasses命名空间,在下文中一共展示了DBLane类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsBranchProtected
bool IsBranchProtected(DBLane lane)
{
if (!lane.repository.Contains("github")) return false;
var repo = ParseRepo(lane.repository);
var branch = ParseBranch(lane.max_revision);
var key = repo + ":" + branch;
var token = Session["github_token"];
var url = "https://api.github.com/repos/" + repo + "/branches/" + branch + "/protection";
var client = WebRequest.Create(url) as HttpWebRequest;
client.Accept = "application/vnd.github.loki-preview+json";
client.ContentType = "application/json";
client.Method = WebRequestMethods.Http.Get;
client.PreAuthenticate = true;
client.UserAgent = "app";
client.Headers.Add("Authorization", "token " + token);
if (protectedBranches.ContainsKey(key)) client.Headers.Add("If-None-Match", protectedBranches[key]);
try {
var resp = client.GetResponse() as HttpWebResponse;
if (resp.Headers.AllKeys.Contains("Etag"))
protectedBranches.Add(key, resp.Headers["Etag"]);
return resp.StatusCode == HttpStatusCode.OK || resp.StatusCode == HttpStatusCode.NotModified;
} catch (WebException) {
return false;
}
}
示例2: CheckCmdExists
bool CheckCmdExists (DBLane lane, string cmd_name) {
var res = ws.GetLaneForEdit (login, lane.id, null);
var cmd = (from c in res.Commands where c.command == cmd_name select c).FirstOrDefault ();
if (cmd != null)
Console.WriteLine ("Step '" + cmd_name + "' already exists in lane '" + lane.lane + "'");
return cmd == null;
}
示例3: PrintLaneTree
void PrintLaneTree (Dictionary<DBLane, List<DBLane>> tree, DBLane lane, int level) {
for (int i = 0; i < level; ++i)
Console.Write (' ');
Console.WriteLine (lane.lane);
foreach (var l in tree [lane])
PrintLaneTree (tree, l, level + 1);
}
示例4: FindCmdByName
DBCommand FindCmdByName (DBLane lane, string cmd_name) {
var res = ws.GetLaneForEdit (login, lane.id, null);
var cmd = (from c in res.Commands where c.command == cmd_name select c).FirstOrDefault ();
if (cmd == null)
Console.WriteLine ("Step '" + cmd_name + "' not found in lane '" + lane.lane + "'");
return cmd;
}
示例5: Query
/// <summary>
///
/// </summary>
/// <param name="db"></param>
/// <param name="lane"></param>
/// <param name="host"></param>
/// <param name="limit"></param>
/// <param name="page">First page = 0, second page = 1, etc.</param>
/// <returns></returns>
public static List<DBRevisionWorkView> Query (DB db, DBLane lane, DBHost host, int limit, int page)
{
Console.WriteLine ("Query {0} {1} {2} {3}", lane, host, limit, page);
List<DBRevisionWorkView> result = new List<DBRevisionWorkView> ();
using (IDbTransaction transaction = db.BeginTransaction ()) {
using (IDbCommand cmd = db.CreateCommand ()) {
// copy&paste from CustomTypes.sql
cmd.CommandText = @"
SELECT RevisionWork.id, Revision.revision
INTO TEMP revisionwork_temptable
FROM RevisionWork
INNER JOIN Revision on RevisionWork.revision_id = Revision.id
WHERE RevisionWork.lane_id = @lane_id AND RevisionWork.host_id = @host_id
ORDER BY Revision.date DESC LIMIT @limit OFFSET @offset;
-- For some reason postgresql thinks the temp table has 1230 entries, while it usually has about 20 entries,
-- and decides to do a sequential scan on the work tabe. Analyze it to make it realize its untrue presumptions.
ANALYZE revisionwork_temptable;
SELECT
Work.id, Work.command_id, Work.state, Work.starttime, Work.endtime, Work.duration, Work.logfile, Work.summary,
Host.host,
Lane.lane,
Revision.author, Revision.revision,
Command.command,
Command.nonfatal, Command.alwaysexecute, Command.sequence, Command.internal,
RevisionWork.lane_id, RevisionWork.host_id, RevisionWork.revision_id,
RevisionWork.state AS revisionwork_state,
WorkHost.host AS workhost
FROM Work
INNER JOIN RevisionWork ON Work.revisionwork_id = RevisionWork.id
INNER JOIN Revision ON RevisionWork.revision_id = Revision.id
INNER JOIN Lane ON RevisionWork.lane_id = Lane.id
INNER JOIN Host ON RevisionWork.host_id = Host.id
LEFT JOIN Host AS WorkHost ON RevisionWork.workhost_id = WorkHost.id
INNER JOIN Command ON Work.command_id = Command.id
WHERE
Work.revisionwork_id IN (SELECT id FROM revisionwork_temptable)
ORDER BY Revision.date DESC;
";
DB.CreateParameter (cmd, "lane_id", lane.id);
DB.CreateParameter (cmd, "host_id", host.id);
DB.CreateParameter (cmd, "limit", limit);
DB.CreateParameter (cmd, "offset", page * limit);
using (IDataReader reader = cmd.ExecuteReader ()) {
while (reader.Read ()) {
result.Add (new DBRevisionWorkView (reader));
}
}
}
return result;
}
}
示例6: LaneTreeNode
public LaneTreeNode (DBLane lane, IEnumerable<DBHostLane> hostlanes){
this.Lane = lane;
if (hostlanes != null && lane != null) {
foreach (DBHostLane hl in hostlanes) {
if (hl.lane_id != lane.id)
continue;
HostLanes.Add (hl);
}
}
}
示例7: GenerateHeader
public string GenerateHeader (GetViewWorkTableDataResponse response, DBLane lane, DBHost host, DBCommand command)
{
if (!Authentication.IsInRole (response, MonkeyWrench.DataClasses.Logic.Roles.Administrator)) {
return string.Format (@"
<h2>Step {4} on lane '{2}' on '{3}' (<a href='ViewTable.aspx?lane_id={0}&host_id={1}'>table</a>)</h2><br/>", lane.id, host.id, lane.lane, host.host, command.command);
} else {
return string.Format (@"
<h2>Step {4} on lane '<a href='EditLane.aspx?lane_id={0}'>{2}</a>' on '<a href='EditHost.aspx?host_id={1}'>{3}</a>'
(<a href='ViewTable.aspx?lane_id={0}&host_id={1}'>table</a>)</h2><br/>", lane.id, host.id, lane.lane, host.host, command.command);
}
}
示例8: Find
public static List<DBLaneDeletionDirectiveView> Find (DB db, DBLane lane)
{
List<DBLaneDeletionDirectiveView> result = new List<DBLaneDeletionDirectiveView> ();
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = @"SELECT * FROM LaneDeletionDirectiveView WHERE lane_id = @lane_id";
DB.CreateParameter (cmd, "lane_id", lane.id);
using (IDataReader reader = cmd.ExecuteReader ()) {
while (reader.Read ())
result.Add (new DBLaneDeletionDirectiveView (reader));
}
}
return result;
}
示例9: GetDependencies
/// <summary>
/// Returns a list of all the dependencies for the specified lane.
/// Returns null if there are no dependencies for the lane.
/// </summary>
/// <param name="lane"></param>
/// <returns></returns>
public static List<DBLaneDependency> GetDependencies (DB db, DBLane lane)
{
List<DBLaneDependency> result = null;
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = "SELECT * FROM LaneDependency";
if (lane != null) {
cmd.CommandText += " WHERE lane_id = @lane_id";
DB.CreateParameter (cmd, "lane_id", lane.id);
}
cmd.CommandText += ";";
using (IDataReader reader = cmd.ExecuteReader ()) {
while (reader.Read ()) {
if (result == null)
result = new List<DBLaneDependency> ();
result.Add (new DBLaneDependency (reader));
}
}
}
return result;
}
示例10: FindRevisionByHash
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;
}
示例11: GenerateHeader
public static string GenerateHeader (GetViewLaneDataResponse response, DBLane lane, DBHost host, DBRevision revision, string description)
{
if (!Authentication.IsInRole (response, MonkeyWrench.DataClasses.Logic.Roles.Administrator)) {
return string.Format (@"
<h2>{4} revision <a href='ViewLane.aspx?lane_id={0}&host_id={1}&revision_id={6}'>{5}</a> on lane '{2}' on '<a href='ViewHostHistory.aspx?host_id={1}'>{3}</a>'
(<a href='ViewTable.aspx?lane_id={0}&host_id={1}'>table</a>)</h2><br/>", lane.id, host.id, lane.lane, host.host, description, revision.revision, revision.id);
} else {
return string.Format (@"
<h2>{4} revision <a href='ViewLane.aspx?lane_id={0}&host_id={1}&revision_id={6}'>{5}</a> on lane '<a href='EditLane.aspx?lane_id={0}'>{2}</a>' on '<a href='ViewHostHistory.aspx?host_id={1}'>{3}</a>'
(<a href='ViewTable.aspx?lane_id={0}&host_id={1}'>table</a>)</h2><br/>", lane.id, host.id, lane.lane, host.host, description, revision.revision, revision.id);
}
}
示例12: FindPeopleForCommit
public static void FindPeopleForCommit (DBLane lane, DBRevision revision, List<DBPerson> people)
{
DBPerson person;
try {
foreach (string repository in lane.repository.Split (new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries)) {
string cache_dir = Configuration.GetSchedulerRepositoryCacheDirectory (repository);
if (!Directory.Exists (cache_dir))
continue;
using (Process git = new Process ()) {
DateTime git_start = DateTime.Now;
git.StartInfo.FileName = "git";
git.StartInfo.Arguments = "log -1 --pretty=format:'%aE%n%aN%n%cE%n%cN' " + revision.revision;
git.StartInfo.WorkingDirectory = cache_dir;
git.StartInfo.UseShellExecute = false;
git.StartInfo.RedirectStandardOutput = true;
git.Start ();
string author_email = git.StandardOutput.ReadLine ();
string author_name = git.StandardOutput.ReadLine ();
string committer_email = git.StandardOutput.ReadLine ();
string committer_name = git.StandardOutput.ReadLine ();
// Wait 10 minutes for git to finish, otherwise abort.
if (!git.WaitForExit (1000 * 60 * 10)) {
GITUpdater.log.Error ("Getting commit info took more than 10 minutes, aborting.");
try {
git.Kill ();
git.WaitForExit (10000); // Give the process 10 more seconds to completely exit.
} catch (Exception ex) {
GITUpdater.log.ErrorFormat ("Aborting commit info retrieval failed: {0}", ex.ToString ());
}
}
if (git.HasExited && git.ExitCode == 0) {
GITUpdater.log.InfoFormat ("Got commit info successfully in {0} seconds", (DateTime.Now - git_start).TotalSeconds);
person = new DBPerson ();
person.fullname = author_name;
person.Emails = new string [] { author_email };
people.Add (person);
if (author_name != committer_name && !string.IsNullOrEmpty (committer_name)) {
person = new DBPerson ();
person.fullname = committer_name;
person.Emails = new string [] {committer_email};
people.Add (person);
}
GITUpdater.log.DebugFormat ("Git commit info for {0}: author_name = {1} author_email: {2} committer_name: {3} committer_email: {4}", revision.revision, author_name, author_email, committer_name, committer_email);
} else {
GITUpdater.log.ErrorFormat ("Didn't get commit info, HasExited: {0}, ExitCode: {1}", git.HasExited, git.HasExited ? git.ExitCode.ToString () : "N/A");
}
}
}
} catch (Exception ex) {
GITUpdater.log.ErrorFormat ("Exception while trying to get commit info: {0}", ex.ToString ());
}
}
示例13: GetGITLog
private List<GitEntry> GetGITLog (DBLane dblane, string repository, string min_revision, string max_revision)
{
List<GitEntry> result = null;
try {
GITUpdater.log.InfoFormat ("Retrieving log for '{0}', repository: '{1}', min_revision: {2} max_revision: {3}", dblane.lane, repository, min_revision, max_revision);
// Updating the repository cache
string cache_dir = Configuration.GetSchedulerRepositoryCacheDirectory (repository);
if (!Directory.Exists (cache_dir))
Directory.CreateDirectory (cache_dir);
// Download/update the cache
using (Process git = new Process ()) {
DateTime git_start = DateTime.Now;
if (fetched_directories.Contains (repository)) {
GITUpdater.log.DebugFormat ("Not fetching repository '{0}', it has already been fetched in this run", repository);
} else {
git.StartInfo.FileName = "git";
if (!Directory.Exists (Path.Combine (cache_dir, ".git"))) {
git.StartInfo.Arguments = "clone -q --no-checkout " + repository + " .";
} else {
git.StartInfo.Arguments = "fetch";
}
git.StartInfo.WorkingDirectory = cache_dir;
git.StartInfo.UseShellExecute = false;
git.StartInfo.RedirectStandardOutput = true;
git.StartInfo.RedirectStandardError = true;
git.StartInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;
git.StartInfo.StandardErrorEncoding = System.Text.Encoding.UTF8;
GITUpdater.log.DebugFormat ("Executing: '{0} {1}' in {2}", git.StartInfo.FileName, git.StartInfo.Arguments, cache_dir);
git.OutputDataReceived += delegate (object sender, DataReceivedEventArgs e)
{
if (e.Data == null)
return;
GITUpdater.log.DebugFormat ("FETCH: {0}", e.Data);
};
git.ErrorDataReceived += delegate (object sender, DataReceivedEventArgs e)
{
if (e.Data == null)
return;
GITUpdater.log.WarnFormat ("FETCH STDERR: {0}", e.Data);
};
git.Start ();
git.BeginOutputReadLine ();
git.BeginErrorReadLine ();
if (!git.WaitForExit (1000 * 60 * 10 /* 10 minutes */)) {
GITUpdater.log.ErrorFormat ("Could not fetch repository, git didn't finish in 10 minutes.");
return null;
}
if (!git.HasExited || git.ExitCode != 0) {
GITUpdater.log.ErrorFormat ("Could not fetch repository, HasExited: {0}, ExitCode: {1}", git.HasExited, git.HasExited ? git.ExitCode.ToString () : "N/A");
return null;
}
fetched_directories.Add (repository);
GITUpdater.log.InfoFormat ("Fetched git repository in {0} seconds", (DateTime.Now - git_start).TotalSeconds);
}
}
string range = string.Empty;
if (string.IsNullOrEmpty (min_revision)) {
range = max_revision;
} else {
range = min_revision + "^.." + max_revision;
}
using (Process git = new Process ()) {
DateTime git_start = DateTime.Now;
git.StartInfo.FileName = "git";
// --reverse: git normally gives commits in newest -> oldest, we want to add them to the db in the reverse order
git.StartInfo.Arguments = "rev-list --reverse --header ";
if (!dblane.traverse_merge)
git.StartInfo.Arguments += "--first-parent ";
git.StartInfo.Arguments += range;
GITUpdater.log.DebugFormat ("Executing: '{0} {1}' in {2}", git.StartInfo.FileName, git.StartInfo.Arguments, cache_dir);
git.StartInfo.WorkingDirectory = cache_dir;
git.StartInfo.UseShellExecute = false;
git.StartInfo.RedirectStandardOutput = true;
git.StartInfo.RedirectStandardError = true;
git.StartInfo.WorkingDirectory = cache_dir;
Thread stdout = new Thread (delegate ()
{
StringBuilder builder = new StringBuilder ();
GitEntry current = new GitEntry ();
bool in_header = true;
bool done = false;
while (!done) {
int ch = 0;
if (git.StandardOutput.EndOfStream) {
done = true;
} else {
ch = git.StandardOutput.Read ();
}
if (ch == 0) {
/* end of record */
//.........这里部分代码省略.........
示例14: OnInit
protected override void OnInit (EventArgs e)
{
base.OnInit (e);
try {
TableRow row;
GetLaneForEditResponse response;
txtID.Attributes ["readonly"] = "readonly";
string action = Request ["action"];
string command_id = Request ["command_id"];
int id;
int sequence;
int timeout;
tblCommands.Visible = true;
tblFiles.Visible = true;
int.TryParse (Request ["lane_id"], out id);
response = Master.WebService.GetLaneForEdit (Master.WebServiceLogin, id, Request ["lane"]);
lane = response.Lane;
if (lane == null) {
Response.Redirect ("EditLanes.aspx", false);
return;
}
lblH2.Text = "Lane: " + lane.lane;
lblDeletionDirectiveErrors.Visible = false;
// find possible parent lanes
lstParentLane.Items.Clear ();
lstParentLane.Items.Add (new ListItem ("None", "0"));
foreach (DBLane l in response.Lanes) {
if (l.id == lane.id)
continue;
if (Utils.IsDescendentLaneOf (response.Lanes, lane, l, 0))
continue; // our descendents can't be our parents too.
lstParentLane.Items.Add (new ListItem (l.lane, l.id.ToString ()));
if (!IsPostBack) {
if (lane.parent_lane_id.HasValue && lane.parent_lane_id.Value == l.id)
lstParentLane.SelectedIndex = lstParentLane.Items.Count - 1;
}
}
if (!IsPostBack) {
for (int i = 0; i < cmbSourceControl.Items.Count; i++) {
cmbSourceControl.Items [i].Selected = lane.source_control == cmbSourceControl.Items [i].Text;
}
txtRepository.Text = lane.repository;
txtCommitFilter.Text = lane.commit_filter;
txtMinRevision.Text = lane.min_revision;
txtMaxRevision.Text = lane.max_revision;
txtLane.Text = lane.lane;
txtID.Text = lane.id.ToString ();
// find (direct) child lanes
foreach (DBLane l in response.Lanes) {
if (l.parent_lane_id.HasValue && l.parent_lane_id.Value == lane.id) {
if (!string.IsNullOrEmpty (lblChildLanes.Text))
lblChildLanes.Text += ", ";
lblChildLanes.Text += l.lane;
}
}
}
if (!string.IsNullOrEmpty (action)) {
switch (action) {
case "createFile":
Master.WebService.CreateLanefile (Master.WebServiceLogin, lane.id, Request ["filename"]);
break;
case "addFile":
if (int.TryParse (Request ["lanefile_id"], out id))
Master.WebService.AttachFileToLane (Master.WebServiceLogin, lane.id, id);
break;
case "deleteFile":
if (int.TryParse (Request ["file_id"], out id))
Master.WebService.DeattachFileFromLane (Master.WebServiceLogin, lane.id, id);
break;
case "editCommandFilename":
if (int.TryParse (command_id, out id))
Master.WebService.EditCommandFilename (Master.WebServiceLogin, id, Request ["filename"]);
break;
case "editCommandSequence":
if (int.TryParse (command_id, out id)) {
if (int.TryParse (Request ["sequence"], out sequence))
Master.WebService.EditCommandSequence (Master.WebServiceLogin, id, sequence);
}
break;
case "editCommandArguments":
if (int.TryParse (command_id, out id))
Master.WebService.EditCommandArguments (Master.WebServiceLogin, id, Request ["arguments"]);
break;
case "editCommandTimeout":
if (int.TryParse (command_id, out id)) {
if (int.TryParse (Request ["timeout"], out timeout))
//.........这里部分代码省略.........
示例15: GenerateHeader
public string GenerateHeader (GetViewTableDataResponse response, DBLane lane, DBHost host, bool horizontal)
{
string result;
string format;
string disabled_msg = string.Empty;
if (!response.Enabled)
disabled_msg = " (Disabled)";
if (Authentication.IsInRole (response, MonkeyWrench.DataClasses.Logic.Roles.Administrator)) {
format = @"<h2>Build Matrix for <a href='EditLane.aspx?lane_id={0}'>'{2}'</a> on <a href='EditHost.aspx?host_id={5}'>'{4}'</a>{6}</h2><br/>";
} else {
format = @"<h2>Build Matrix for '{2}' on '{4}'{6}</h2><br/>";
}
format += @"<a href='ViewTable.aspx?lane_id={0}&host_id={1}&horizontal={3}'>Reverse x/y axis</a><br/>";
if (Authentication.IsInRole (response, MonkeyWrench.DataClasses.Logic.Roles.Administrator))
format += string.Format (@"<a href='javascript:clearRevisions ({0}, {1})'>Clear selected revisions</a><br/>", lane.id, host.id);
format += "<br/>";
result = string.Format (format, lane.id, host.id, lane.lane, horizontal ? "false" : "true", host.host, host.id, disabled_msg);
return result;
}