本文整理汇总了C#中MonkeyWrench.DataClasses.DBLane.Save方法的典型用法代码示例。如果您正苦于以下问题:C# DBLane.Save方法的具体用法?C# DBLane.Save怎么用?C# DBLane.Save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MonkeyWrench.DataClasses.DBLane
的用法示例。
在下文中一共展示了DBLane.Save方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditLaneWithTags
public void EditLaneWithTags (WebServiceLogin login, DBLane lane, string[] tags)
{
using (DB db = new DB ())
using (var transaction = db.BeginTransaction()) {
VerifyUserInRole (db, login, Roles.Administrator);
var oldLane = FindLane (db, lane.id, null);
lane.Save (db);
using (var cmd = db.CreateCommand ()) {
cmd.CommandText = "DELETE FROM LaneTag WHERE lane_id = @lane_id;";
DB.CreateParameter (cmd, "lane_id", lane.id);
cmd.ExecuteNonQuery ();
if (tags != null) {
cmd.CommandText = "INSERT INTO LaneTag (lane_id, tag) VALUES (@lane_id, @tag);";
var tagParam = cmd.CreateParameter ();
tagParam.ParameterName = "tag";
cmd.Parameters.Add (tagParam);
foreach (var tag in tags) {
tagParam.Value = tag;
cmd.ExecuteNonQuery ();
}
}
}
transaction.Commit ();
Audit (login, "edited lane `{0}` -> `{1}`",
Newtonsoft.Json.JsonConvert.SerializeObject(oldLane),
Newtonsoft.Json.JsonConvert.SerializeObject(lane)
);
}
}
示例2: AddLane
public int AddLane (WebServiceLogin login, string lane)
{
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
if (string.IsNullOrEmpty (lane))
throw new ArgumentOutOfRangeException ("name");
for (int i = 0; i < lane.Length; i++) {
if (char.IsLetterOrDigit (lane [i])) {
continue;
} else if (lane [i] == '-' || lane [i] == '_' || lane [i] == '.') {
continue;
} else {
throw new ArgumentOutOfRangeException (string.Format ("The character '{0}' isn't valid.", lane [i]));
}
}
if (db.LookupLane (lane, false) != null)
throw new ApplicationException (string.Format ("The lane '{0}' already exists.", lane));
DBLane dblane = new DBLane ();
dblane.lane = lane;
dblane.source_control = "svn";
dblane.Save (db);
return dblane.id;
}
}
示例3: EditLane
public void EditLane (WebServiceLogin login, DBLane lane)
{
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
var oldLane = FindLane (db, lane.id, null);
lane.Save (db);
Audit (login, "edited lane `{0}` -> `{1}`",
Newtonsoft.Json.JsonConvert.SerializeObject(oldLane),
Newtonsoft.Json.JsonConvert.SerializeObject(lane)
);
}
}
示例4: EditLaneWithTags
public void EditLaneWithTags (WebServiceLogin login, DBLane lane, string[] tags)
{
Logger.Log ("EditLaneWithTags ({0}, {1})", lane.id, tags == null ? "null" : tags.Length.ToString ());
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
lane.Save (db);
using (var cmd = db.CreateCommand ()) {
var cmdText = new StringBuilder ();
cmdText.AppendFormat ("DELETE FROM LaneTag WHERE lane_id = {0};", lane.id).AppendLine ();
if (tags != null) {
for (int i = 0; i < tags.Length; i++) {
cmdText.AppendFormat ("INSERT INTO LaneTag (lane_id, tag) VALUES ({0}, @tag{1});", lane.id, i).AppendLine ();
DB.CreateParameter (cmd, "tag" + i.ToString (), tags [i]);
}
}
cmd.CommandText = cmdText.ToString ();
cmd.ExecuteNonQuery ();
}
}
}
示例5: EditLane
public void EditLane (WebServiceLogin login, DBLane lane)
{
//WebServiceResponse response = new WebServiceResponse ();
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
lane.Save (db);
}
}
示例6: CloneLane
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;
}
示例7: EditLane
public void EditLane (WebServiceLogin login, DBLane lane)
{
using (DB db = new DB ()) {
var oldLane = FindLane (db, lane.id, null);
VerifyUserInRoles (db, login, oldLane.additional_roles, false);
lane.Save (db);
Audit (login, "edited lane `{0}` -> `{1}`",
Newtonsoft.Json.JsonConvert.SerializeObject(oldLane),
Newtonsoft.Json.JsonConvert.SerializeObject(lane)
);
}
}