本文整理汇总了C#中DB.Audit方法的典型用法代码示例。如果您正苦于以下问题:C# DB.Audit方法的具体用法?C# DB.Audit怎么用?C# DB.Audit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB.Audit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoginOpenId
public LoginResponse LoginOpenId (WebServiceLogin login, string email, string ip4)
{
LoginResponse response = new LoginResponse ();
using (DB db = new DB ()) {
try {
VerifyUserInRole (db, login, Roles.Administrator);
db.Audit (login, "WebServices.LoginOpenId (email: {0}, ip4: {1})", email, ip4);
DBLogin_Extensions.LoginOpenId (db, response, email, ip4);
} catch (Exception ex) {
response.Exception = new WebServiceException (ex);
}
return response;
}
}
示例2: RescheduleRevision
public void RescheduleRevision (WebServiceLogin login, int lane_id, int host_id, int revision_id)
{
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
db.Audit (login, "WebServices.RescheduleRevision (lane_id: {0}, host_id: {1}, revision_id: {2})", lane_id, host_id, revision_id);
db.DeleteFiles (host_id, lane_id, revision_id);
db.DeleteLinks (host_id, lane_id, revision_id);
db.ClearWork (lane_id, revision_id, host_id);
db.DeleteWork (lane_id, revision_id, host_id);
}
}
示例3: IgnoreRevision
public void IgnoreRevision (WebServiceLogin login, int lane_id, int host_id, int revision_id)
{
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
db.Audit (login, "WebServices.IgnoreRevision (lane_id: {0}, host_id: {1}, revision_id: {2})", lane_id, host_id, revision_id);
db.IgnoreWork (lane_id, revision_id, host_id);
}
}
示例4: DeattachFileFromLane
public void DeattachFileFromLane (WebServiceLogin login, int lane_id, int lanefile_id)
{
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
db.Audit (login, "WebServices.DeattachFileFromLane (lane_id: {0}, lanefile_id: {1})", lane_id, lanefile_id);
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = "DELETE FROM Lanefiles WHERE lane_id = @lane_id AND lanefile_id = @lanefile_id;";
DB.CreateParameter (cmd, "lane_id", lane_id);
DB.CreateParameter (cmd, "lanefile_id", lanefile_id);
cmd.ExecuteNonQuery ();
}
}
}
示例5: AttachFileToLane
public void AttachFileToLane (WebServiceLogin login, int lane_id, int lanefile_id)
{
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
db.Audit (login, "WebServices.AttachFileToLane (lane_id: {0}, lanefile_id: {1})", lane_id, lanefile_id);
DBLanefiles lanefile = new DBLanefiles ();
lanefile.lane_id = lane_id;
lanefile.lanefile_id = lanefile_id;
lanefile.Save (db);
}
}
示例6: DeattachFileFromLane
public void DeattachFileFromLane (WebServiceLogin login, int lane_id, int lanefile_id)
{
using (DB db = new DB ()) {
var lane = DBLane_Extensions.Create (db, lane_id);
VerifyUserInRoles (db, login, lane.additional_roles, false);
db.Audit (login, "WebServices.DeattachFileFromLane (lane_id: {0}, lanefile_id: {1})", lane.id, lanefile_id);
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = "DELETE FROM Lanefiles WHERE lane_id = @lane_id AND lanefile_id = @lanefile_id;";
DB.CreateParameter (cmd, "lane_id", lane_id);
DB.CreateParameter (cmd, "lanefile_id", lanefile_id);
cmd.ExecuteNonQuery ();
}
}
}
示例7: EditCommandDeadlockTimeout
public void EditCommandDeadlockTimeout (WebServiceLogin login, int command_id, int? deadlock_timeout)
{
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
db.Audit (login, "WebServices.EditCommandDeadlockTimeout (command_id: {0}, deadlock_timeout: {1})", command_id, deadlock_timeout);
DBCommand cmd = DBCommand_Extensions.Create (db, command_id);
cmd.deadlock_timeout = deadlock_timeout;
cmd.Save (db);
}
}
示例8: EditCommandSequence
public void EditCommandSequence (WebServiceLogin login, int command_id, int sequence)
{
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
db.Audit (login, "WebServices.EditCommandSequence (command_id: {0}, sequence: {1})", command_id, sequence);
DBCommand cmd = DBCommand_Extensions.Create (db, command_id);
cmd.sequence = sequence;
cmd.Save (db);
}
}
示例9: LoginDB
public static void LoginDB (DB db, LoginResponse response, string username, string roles, string ip4) {
// We now create an account with an empty password and the specified roles.
// Note that it is not possible to log into an account with an empty password
// using the normal login procedure.
DBPerson open_person = null;
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = @"SELECT * FROM Person WHERE login = @login;";
DB.CreateParameter (cmd, "login", username);
using (var reader = cmd.ExecuteReader ()) {
if (reader.Read ())
open_person = new DBPerson (reader);
}
}
if (open_person == null) {
open_person = new DBPerson ();
open_person.login = username;
open_person.roles = roles;
open_person.Save (db);
} else {
// only save if something has changed
if (open_person.roles != roles) {
open_person.roles = roles;
open_person.Save (db);
}
}
WebServiceLogin login = new WebServiceLogin ();
login.Ip4 = ip4;
login.User = open_person.login;
db.Audit (login, "DBLogin_Extensions.Login (username: {0}, ip4: {1})", username, ip4);
var result = new DBLogin ();
result.person_id = open_person.id;
result.ip4 = ip4;
result.cookie = CreateCookie ();
result.expires = DateTime.Now.AddDays (1);
result.Save (db);
response.User = username;
response.UserName = username;
response.UserRoles = open_person.Roles;
response.Cookie = result.cookie;
}
示例10: LoginOpenId
public static void LoginOpenId (DB db, LoginResponse response, string email, string ip4)
{
if (string.IsNullOrEmpty (Configuration.OpenIdProvider) && string.IsNullOrEmpty (Configuration.OauthClientId))
throw new Exception ("No OpenId provider available");
if (string.IsNullOrEmpty (Configuration.OpenIdRoles))
throw new Exception ("No OpenId roles specified");
if (string.IsNullOrEmpty (email))
throw new Exception ("OpenId authentication requires an email");
string [] specs = Configuration.OpenIdRoles.Split (';');
foreach (var spec in specs) {
// email:role1,role2
string [] split = spec.Split (':');
if (split.Length != 2) {
log.ErrorFormat ("AuthenticateOpenId: Invalid role spec: {0}", spec);
continue;
}
if (string.IsNullOrEmpty (split [1])) {
log.ErrorFormat ("AuthenticateOpenId: No roles specified for {0}", split [0]);
continue;
}
if (!Regex.IsMatch (email, split [0]))
continue;
// We now create an account with an empty password and the specified roles.
// Note that it is not possible to log into an account with an empty password
// using the normal login procedure.
DBPerson open_person = null;
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = @"SELECT * FROM Person WHERE login = @login;";
DB.CreateParameter (cmd, "login", email);
using (var reader = cmd.ExecuteReader ()) {
if (reader.Read ())
open_person = new DBPerson (reader);
}
}
if (open_person == null) {
open_person = new DBPerson ();
open_person.login = email;
open_person.roles = split [1];
open_person.Save (db);
} else {
// only save if something has changed
if (open_person.roles != split [1]) {
open_person.roles = split [1];
open_person.Save (db);
}
}
WebServiceLogin login = new WebServiceLogin ();
login.Ip4 = ip4;
login.User = open_person.login;
db.Audit (login, "DBLogin_Extensions.LoginOpenId (email: {0}, ip4: {1})", email, ip4);
var result = new DBLogin ();
result.person_id = open_person.id;
result.ip4 = ip4;
result.cookie = CreateCookie ();
result.expires = DateTime.Now.AddDays (1);
result.Save (db);
response.User = email;
response.UserName = email;
response.UserRoles = open_person.Roles;
response.Cookie = result.cookie;
return;
}
throw new Exception ("The provided email address is not allowed to log in");
}
示例11: EditCommandDeadlockTimeoutInLane
public void EditCommandDeadlockTimeoutInLane (WebServiceLogin login, int lane_id, int command_id, int? deadlock_timeout)
{
using (DB db = new DB ()) {
var lane = DBLane_Extensions.Create (db, lane_id);
VerifyUserInRoles (db, login, lane.additional_roles, false);
db.Audit (login, "WebServices.EditCommandDeadlockTimeout (command_id: {0}, deadlock_timeout: {1})", command_id, deadlock_timeout);
DBCommand cmd = DBCommand_Extensions.Create (db, command_id);
VerifyCommandIsForLane (cmd, lane_id);
cmd.deadlock_timeout = deadlock_timeout;
cmd.Save (db);
}
}
示例12: EditCommandArgumentsInLane
public void EditCommandArgumentsInLane (WebServiceLogin login, int lane_id, int command_id, string arguments)
{
using (DB db = new DB ()) {
var lane = DBLane_Extensions.Create (db, lane_id);
VerifyUserInRoles (db, login, lane.additional_roles, false);
db.Audit (login, "WebServices.EditCommandArguments (command_id: {0}, arguments: {1})", command_id, arguments);
DBCommand cmd = DBCommand_Extensions.Create (db, command_id);
VerifyCommandIsForLane (cmd, lane_id);
cmd.arguments = arguments;
cmd.Save (db);
}
}
示例13: EditCommandSequenceInLane
public void EditCommandSequenceInLane (WebServiceLogin login, int lane_id, int command_id, int sequence)
{
using (DB db = new DB ()) {
var lane = DBLane_Extensions.Create (db, lane_id);
VerifyUserInRoles (db, login, lane.additional_roles, false);
DBCommand cmd = DBCommand_Extensions.Create (db, command_id);
VerifyCommandIsForLane (cmd, lane_id);
db.Audit (login, "WebServices.EditCommandSequence (command_id: {0}, sequence: {1})", command_id, sequence);
cmd.sequence = sequence;
cmd.Save (db);
}
}
示例14: EditLaneFile
public void EditLaneFile (WebServiceLogin login, DBLanefile lanefile)
{
using (DB db = new DB ()) {
DBLanefile original = DBLanefile_Extensions.Create (db, lanefile.id);
VerifyUserInRoles (db, login, original.additional_roles, false);
db.Audit (login, "WebServices.EditLaneFile (lane_id: {0})", lanefile.id);
if (original.original_id == null) {// This is the latest version of the file
DBLanefile old_file = new DBLanefile ();
old_file.contents = lanefile.contents;
old_file.mime = lanefile.mime;
old_file.name = lanefile.name;
old_file.original_id = lanefile.id;
old_file.changed_date = DBRecord.DatabaseNow;
old_file.additional_roles = lanefile.additional_roles;
old_file.Save (db);
lanefile.Save (db);
} else {
throw new ApplicationException ("You can only change the newest version of a lane file.");
}
}
}
示例15: EditCommandInLane
public void EditCommandInLane (WebServiceLogin login, DBCommand command, int lane_id)
{
using (DB db = new DB ()) {
var lane = DBLane_Extensions.Create (db, lane_id);
VerifyUserInRoles (db, login, lane.additional_roles, false);
VerifyCommandIsForLane (command, lane_id);
db.Audit (login, "WebServices.EditCommand (command: {0})", command);
command.Save (db);
}
}