本文整理汇总了C#中MonkeyWrench.DataClasses.Logic.WebServiceResponse类的典型用法代码示例。如果您正苦于以下问题:C# WebServiceResponse类的具体用法?C# WebServiceResponse怎么用?C# WebServiceResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
WebServiceResponse类属于MonkeyWrench.DataClasses.Logic命名空间,在下文中一共展示了WebServiceResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: IsLoggedIn
public static bool IsLoggedIn (WebServiceResponse response)
{
if (response == null)
return false;
return !string.IsNullOrEmpty (response.UserName);
}
开发者ID:hackmp,项目名称:monkeywrench,代码行数:7,代码来源:Authentication.cs
示例2: IsInRole
public static bool IsInRole (WebServiceResponse response, string role)
{
if (response.UserRoles == null)
return false;
return Array.IndexOf (response.UserRoles, role) >= 0;
}
开发者ID:rolfbjarne,项目名称:monkeywrench,代码行数:7,代码来源:Authentication.cs
示例3: IsInRole
public static bool IsInRole (WebServiceResponse response, string role)
{
bool result;
if (response == null) {
log.Debug ("IsInRole: no response");
return false;
}
if (response.UserRoles == null) {
log.Debug ("IsInRole: no userroles");
return false;
}
result = Array.IndexOf (response.UserRoles, role) >= 0;
log.DebugFormat ("IsInRole ({0}) => {1} (roles: {2})", role, result, string.Join (";", response.UserRoles));
return result;
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:20,代码来源:Authentication.cs
示例4: IsInRole
public static bool IsInRole (WebServiceResponse response, string role)
{
bool result;
if (response == null) {
MonkeyWrench.Logger.Log (2, "IsInRole: no response");
return false;
}
if (response.UserRoles == null) {
MonkeyWrench.Logger.Log (2, "IsInRole: no userroles");
return false;
}
result = Array.IndexOf (response.UserRoles, role) >= 0;
MonkeyWrench.Logger.Log (2, "IsInRole ({0}) => {1} (roles: {2})", role, result, string.Join (";", response.UserRoles));
return result;
}
开发者ID:hackmp,项目名称:monkeywrench,代码行数:20,代码来源:Authentication.cs
示例5: Authenticate
/// <summary>
/// Authenticates the request with the provided user/pass.
/// If no user/pass is provided, the method returns a response
/// with no roles.
/// If a wrong user/pass is provided, the method throws an exception.
/// </summary>
/// <param name="db"></param>
/// <param name="login"></param>
/// <param name="response"></param>
public static void Authenticate (HttpContext Context, DB db, WebServiceLogin login, WebServiceResponse response, bool @readonly)
{
Authenticate (Context.Request.UserHostAddress, db, login, response, @readonly);
}
开发者ID:hackmp,项目名称:monkeywrench,代码行数:13,代码来源:Authentication.cs
示例6: Authenticate
internal void Authenticate (DB db, WebServiceLogin login, WebServiceResponse response, bool @readonly)
{
Authentication.Authenticate (Context, db, login, response, @readonly);
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:4,代码来源:WebServices.asmx.cs
示例7: MarkAsDontBuild
public WebServiceResponse MarkAsDontBuild (WebServiceLogin login, int lane_id)
{
WebServiceResponse response = new WebServiceResponse ();
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = "UPDATE RevisionWork SET state = 11 WHERE state = 0 AND lane_id = @lane_id;";
DB.CreateParameter (cmd, "lane_id", lane_id);
cmd.ExecuteNonQuery ();
}
}
return response;
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:15,代码来源:WebServices.asmx.cs
示例8: AddRelease
public WebServiceResponse AddRelease (WebServiceLogin login, DBRelease release)
{
WebServiceResponse response = new WebServiceResponse ();
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.BuildBot);
release.Save (db);
}
return response;
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:11,代码来源:WebServices.asmx.cs
示例9: EditNotification
public WebServiceResponse EditNotification (WebServiceLogin login, DBNotification notification)
{
WebServiceResponse response = new WebServiceResponse ();
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
notification.Save (db);
Notifications.Restart ();
}
return response;
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:12,代码来源:WebServices.asmx.cs
示例10: EditIdentity
public WebServiceResponse EditIdentity (WebServiceLogin login, DBIrcIdentity irc_identity, DBEmailIdentity email_identity)
{
WebServiceResponse response = new WebServiceResponse ();
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
if (irc_identity != null) {
irc_identity.Save (db);
}
if (email_identity != null) {
email_identity.Save (db);
}
}
return response;
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:17,代码来源:WebServices.asmx.cs
示例11: DeleteAllWorkForHost
public WebServiceResponse DeleteAllWorkForHost (WebServiceLogin login, int host_id)
{
WebServiceResponse response = new WebServiceResponse ();
try {
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = @"
DELETE FROM Work WHERE revisionwork_id IN (SELECT id FROM RevisionWork WHERE host_id = @host_id);
UPDATE RevisionWork SET state = 10, workhost_id = DEFAULT, completed = DEFAULT WHERE host_id = @host_id;
";
DB.CreateParameter (cmd, "host_id", host_id);
cmd.ExecuteNonQuery ();
}
}
} catch (Exception ex) {
response.Exception = new WebServiceException (ex);
}
return response;
}
开发者ID:vargaz,项目名称:monkeywrench,代码行数:22,代码来源:WebServices.asmx.cs
示例12: ClearAllWorkForHost
public WebServiceResponse ClearAllWorkForHost (WebServiceLogin login, int host_id)
{
WebServiceResponse response = new WebServiceResponse ();
try {
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = @"
UPDATE Work SET state = DEFAULT, summary = DEFAULT, starttime = DEFAULT, endtime = DEFAULT, duration = DEFAULT, logfile = DEFAULT, host_id = DEFAULT
WHERE Work.revisionwork_id IN (SELECT RevisionWork.id FROM RevisionWork WHERE RevisionWork.host_id = @host_id);
UPDATE RevisionWork SET state = DEFAULT, lock_expires = DEFAULT, completed = DEFAULT, workhost_id = DEFAULT WHERE host_id = @host_id;
";
DB.CreateParameter (cmd, "host_id", host_id);
cmd.ExecuteNonQuery ();
}
}
} catch (Exception ex) {
response.Exception = new WebServiceException (ex);
}
return response;
}
开发者ID:vargaz,项目名称:monkeywrench,代码行数:24,代码来源:WebServices.asmx.cs
示例13: VerifyUserInRole
public static void VerifyUserInRole (HttpContext Context, DB db, WebServiceLogin login, string role, bool @readonly)
{
WebServiceResponse dummy = new WebServiceResponse ();
Authenticate (Context, db, login, dummy, @readonly);
if (!dummy.IsInRole (role)) {
log.InfoFormat ("The user '{0}' has the roles '{1}', and requested role is: {2}", login.User, dummy.UserRoles == null ? "<null>" : string.Join (",", dummy.UserRoles), role);
throw new UnauthorizedException ("You don't have the required permissions.");
}
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:10,代码来源:Authentication.cs
示例14: Authenticate
/// <summary>
/// Authenticates the request with the provided user/pass.
/// If no user/pass is provided, the method returns a response
/// with no roles.
/// If a wrong user/pass is provided, the method throws an exception.
/// </summary>
/// <param name="db"></param>
/// <param name="login"></param>
/// <param name="response"></param>
public static void Authenticate (HttpContext Context, DB db, WebServiceLogin login, WebServiceResponse response, bool @readonly)
{
string ip = Context.Request.UserHostAddress;
int person_id;
DBLoginView view = null;
Console.WriteLine ("WebService.Authenticate (Ip4: {0}, UserHostAddress: {1}, User: {2}, Cookie: {3}, Password: {4}", login == null ? null : login.Ip4, Context.Request.UserHostAddress, login == null ? null : login.User, login == null ? null : login.Cookie, login == null ? null : login.Password);
// Check if credentials were passed in
if (login == null || string.IsNullOrEmpty (login.User) || (string.IsNullOrEmpty (login.Password) && string.IsNullOrEmpty (login.Cookie))) {
Console.WriteLine ("No credentials.");
return;
}
if (@readonly && string.IsNullOrEmpty (login.Password)) {
// Console.WriteLine ("Readonly authentication needs a password.");
return;
}
if (!string.IsNullOrEmpty (login.Ip4)) {
ip = login.Ip4;
} else {
ip = Context.Request.UserHostAddress;
}
if (@readonly) {
DBLogin result = DBLogin_Extensions.Login (db, login.User, login.Password, ip, @readonly);
if (result == null) {
// Console.WriteLine ("Incorrect Login/Password for readonly login");
return;
}
person_id = result.person_id;
} else {
if (!string.IsNullOrEmpty (login.Password)) {
DBLogin result = DBLogin_Extensions.Login (db, login.User, login.Password, ip, @readonly);
if (result != null)
view = DBLoginView_Extensions.VerifyLogin (db, login.User, result.cookie, ip);
} else {
view = DBLoginView_Extensions.VerifyLogin (db, login.User, login.Cookie, ip);
Console.WriteLine ("Verifying login, cookie: {0} user: {1} ip: {2}", login.Cookie, login.User, ip);
}
if (view == null) {
Console.WriteLine ("Invalid credentials.");
return;
}
person_id = view.person_id;
}
Console.WriteLine ("Valid credentials");
LoginResponse login_response = response as LoginResponse;
if (login_response != null) {
login_response.Cookie = view != null ? view.cookie : null;
login_response.FullName = view != null ? view.fullname : null;
login_response.ID = person_id;
}
DBPerson person = DBPerson_Extensions.Create (db, person_id);
Console.WriteLine ("Roles for '{0}': {1}", login.User, person.roles);
if (!string.IsNullOrEmpty (person.roles))
response.UserRoles = person.roles.Split (new char [] { ',' }, StringSplitOptions.RemoveEmptyEntries);
}
开发者ID:rolfbjarne,项目名称:monkeywrench,代码行数:73,代码来源:Authentication.cs
示例15: SetResponse
private void SetResponse (WebServiceResponse response)
{
this.response = response;
LoadView ();
}
开发者ID:DavidS,项目名称:monkeywrench,代码行数:5,代码来源:Master.master.cs
示例16: RemoveUserEmail
public WebServiceResponse RemoveUserEmail (WebServiceLogin login, int? id, string username, string email)
{
WebServiceResponse response = new WebServiceResponse ();
DBPerson user;
using (DB db = new DB ()) {
Authenticate (db, login, response, true);
user = FindUser (db, id, username);
if (user == null) {
/* user doesn't exist */
response.Exception = new WebServiceException (new HttpException (403, "You're not allowed to edit this user"));
} else if (Utilities.IsInRole (response, Roles.Administrator)) {
/* admin editing (or adming editing self) */
user.RemoveEmail (db, email);
} else if (response.UserName == user.login) {
/* editing self */
user.RemoveEmail (db, email);
} else {
/* somebody else editing some other person */
response.Exception = new WebServiceException (new HttpException (403, "You're not allowed to edit this user"));
}
}
return response;
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:27,代码来源:WebServices.asmx.cs
示例17: EditUser
public WebServiceResponse EditUser (WebServiceLogin login, DBPerson user)
{
WebServiceResponse response = new WebServiceResponse ();
using (DB db = new DB ()) {
Authenticate (db, login, response, true);
if (user.id == 0) {
/* new user, anybody can create new users */
/* create a new person object, and only copy over the fields self is allowed to edit */
if (string.IsNullOrEmpty (user.password) || user.password.Length < 8) {
response.Exception = new WebServiceException ("Password must be at least 8 characters long");
return response;
}
DBPerson person = new DBPerson ();
person.fullname = user.fullname;
person.login = user.login;
person.password = user.password;
person.irc_nicknames = user.irc_nicknames;
person.Save (db);
} else {
if (Utilities.IsInRole (response, Roles.Administrator)) {
/* admin editing (or adming editing self) */
user.Save (db); // no restrictions
} else if (response.UserName == user.login) {
/* editing self */
/* create another person object, and only copy over the fields self is allowed to edit */
DBPerson person = DBPerson_Extensions.Create (db, user.id);
person.fullname = user.fullname;
person.password = user.password;
person.irc_nicknames = user.irc_nicknames;
person.Save (db);
} else {
/* somebody else editing some other person */
response.Exception = new WebServiceException (new HttpException (403, "You're not allowed to edit this user"));
}
}
}
return response;
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:43,代码来源:WebServices.asmx.cs
示例18: DeleteAllRevisionsForLane
public WebServiceResponse DeleteAllRevisionsForLane (WebServiceLogin login, int lane_id)
{
WebServiceResponse response = new WebServiceResponse ();
try {
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = @"DELETE FROM Revision WHERE lane_id = @lane_id;";
DB.CreateParameter (cmd, "lane_id", lane_id);
cmd.ExecuteNonQuery ();
}
}
} catch (Exception ex) {
response.Exception = new WebServiceException (ex);
}
return response;
}
开发者ID:vargaz,项目名称:monkeywrench,代码行数:19,代码来源:WebServices.asmx.cs
示例19: RemoveIdentity
public WebServiceResponse RemoveIdentity (WebServiceLogin login, int? irc_identity, int? email_identity)
{
WebServiceResponse response = new WebServiceResponse ();
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = string.Empty;
if (irc_identity.HasValue) {
cmd.CommandText += "DELETE FROM IrcIdentity WHERE id = @irc_id;";
DB.CreateParameter (cmd, "irc_id", irc_identity.Value);
}
if (email_identity.HasValue) {
cmd.CommandText += "DELETE FROM EmailIdentity WHERE id = @email_id;";
DB.CreateParameter (cmd, "email_id", email_identity.Value);
}
cmd.ExecuteNonQuery ();
}
}
return response;
}
开发者ID:joewstroman,项目名称:monkeywrench,代码行数:25,代码来源:WebServices.asmx.cs
示例20: RemoveLaneNotification
public WebServiceResponse RemoveLaneNotification (WebServiceLogin login, int id)
{
WebServiceResponse response = new WebServiceResponse ();
try {
using (DB db = new DB ()) {
VerifyUserInRole (db, login, Roles.Administrator);
using (IDbCommand cmd = db.CreateCommand ()) {
cmd.CommandText = "DELETE FROM LaneNotification WHERE id = @id;";
DB.CreateParameter (cmd, "id", id);
cmd.ExecuteNonQuery ();
Notifications.Restart ();
}
}
} catch (Exception ex) {
response.Exception = new WebServiceException (ex);
}
return response;
}
开发者ID:vargaz,项目名称:monkeywrench,代码行数:21,代码来源:WebServices.asmx.cs
注:本文中的MonkeyWrench.DataClasses.Logic.WebServiceResponse类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论