本文整理汇总了C#中UserGroup类的典型用法代码示例。如果您正苦于以下问题:C# UserGroup类的具体用法?C# UserGroup怎么用?C# UserGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserGroup类属于命名空间,在下文中一共展示了UserGroup类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: addUserGroup
public static bool addUserGroup(UserGroup userGroup, String connString)
{
bool rs = false;
using (SqlConnection conn = new SqlConnection(connString))
{
try
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sony_sp_add_user_group";
cmd.Parameters.AddWithValue("@groupname", userGroup.GroupName);
cmd.Parameters.AddWithValue("@issuper", userGroup.IsSuper ? 1 : 0);
cmd.Parameters.AddWithValue("@created", userGroup.Created);
cmd.Parameters.AddWithValue("@updated", userGroup.Updated);
SqlParameter returnVal = new SqlParameter("@indentity", SqlDbType.Int);
returnVal.Direction = ParameterDirection.Output;
cmd.Parameters.Add(returnVal);
cmd.ExecuteNonQuery();
rs = ((int)cmd.Parameters["@indentity"].Value != 0);
}
}
catch (Exception ex)
{
return false;
}
}
return rs;
}
示例2: UserGroupModel
public UserGroupModel(UserGroup ug)
{
Id = ug.Id;
Name = ug.Name;
Remark = ug.Remarks;
Roles = ug.GetAllRoles().ToArray();
}
示例3: vUserGroup
public vUserGroup(UserGroup group)
{
DB db = new DB();
this.ID = group.ID;
this.GroupName = group.GroupName;
this.LoginName = group.LoginName;
this.LoginPassword = group.LoginPassword;
this.Email = group.Email;
this.Phone = group.Phone;
this.Address = group.Address;
this.AddTime = group.AddTime;
this.Weibo = group.Weibo;
this.WhatApp = group.WhatApp;
this.Description = group.Description;
this.LastLogin = group.LastLoginTime;
this.City = group.City;
this.Picture = group.Picture;
this.Priority = group.Priority;
this.Industry = group.Industry;
this.TodayPV = group.TodayPV;
this.PV = group.PV;
this.Downs = group.Downs;
this.Ups = group.Ups;
this.Images = db.Images.Where(c => c.TID == group.ID).Where(c => c.ImageType == ImageType.UserGroup).ToList();
this.IsVerified = group.IsVerified;
}
示例4: getById
public static UserGroup getById(int id, String connString)
{
UserGroup usergroup = new UserGroup();
usergroup.Id = id;
using (SqlConnection conn = new SqlConnection(connString))
{
try
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sony_sp_get_user_group_by_id";
cmd.Parameters.AddWithValue("@id", id);
using (SqlDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
usergroup.Id = (int)reader["id"];
usergroup.GroupName = reader["groupname"].ToString();
usergroup.IsSuper = reader["issuper"].ToString().Equals("1") || reader["issuper"].ToString().Equals("True") ? true : false;
usergroup.Created = (DateTime)reader["created"];
usergroup.Updated = (DateTime)reader["updated"];
}
}
}
}
catch (Exception ex)
{
return new UserGroup();
}
}
return usergroup;
}
示例5: SetUp
public void SetUp()
{
Logger.Info("...begin setup...");
using (var session = CreateSession())
using (var transaction = session.BeginTransaction())
{
_user1 = new UserBuilder().WithUserName("u1").Build();
_user2 = new UserBuilder().WithUserName("u2").Build();
_userGroup1 = new UserGroupBuilder().WithName("g1").Build();
_userGroup2 = new UserGroupBuilder().WithName("g2").Build();
_user1.AddUserGroup(_userGroup1);
_user1.AddUserGroup(_userGroup2);
_user2.AddUserGroup(_userGroup1);
_user2.AddUserGroup(_userGroup2);
session.Save(_user1);
session.Save(_user2);
session.Save(_userGroup1);
session.Save(_userGroup2);
session.Flush();
session.Clear();
// make sure everything is present in the cache for the tests
session.QueryOver<User>().List();
session.QueryOver<UserGroup>().List();
transaction.Commit();
}
Logger.Info("...end setup...");
}
示例6: vCurrentUser
public vCurrentUser(UserGroup model)
{
this.ID = model.ID;
this.CurrentName = model.GroupName;
this.UserType = UserType.UserGroup;
this.Show = "/UserGroup/Show/" + model.ID;
}
示例7: Combine
private bool Combine(ArrayList groups, int binsize)
{
bool workdone=false;
int i;
for (i = 1; i < groups.Count; i++) {
UserGroup right = (UserGroup) groups[i];
UserGroup left = (UserGroup) groups[i-1];
//Can combine
if (right.Users.Count + left.Users.Count <= binsize) {
workdone=true;
UserGroup combine = new UserGroup();
combine.UpperBound = left.UpperBound;
combine.LowerBound = right.LowerBound;
combine.Users.AddRange(left.Users);
combine.Users.AddRange(right.Users);
groups.Remove(right);
groups.Remove(left);
groups.Insert(i-1, combine);
i--;
}
}
return workdone;
}
示例8: SetAdministratorsGroupDefaultPermissions
/// <summary>
/// Sets the default permissions for the administrators group, properly importing version 2.0 values.
/// </summary>
/// <param name="administrators">The administrators group.</param>
/// <returns><c>true</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public static bool SetAdministratorsGroupDefaultPermissions(UserGroup administrators)
{
// Administrators can do any operation
return AuthWriter.SetPermissionForGlobals(AuthStatus.Grant, Actions.FullControl, administrators);
// Settings.ConfigVisibleToAdmins is not imported on purpose
}
示例9: MatchRepositoryLoadMatchesListByUserRequest
public void MatchRepositoryLoadMatchesListByUserRequest()
{
UserGroup group=new UserGroup{Id = 1,Name = "Pune"};
User traveller = new User(new Email("[email protected]"), null, "password", group);
User requestor = new User(new Email("[email protected]"), null, "password", group);
Package package = new Package("Package", "Weight", "Dimensions");
Location origin = new Location("Origin", new TravelDate(DateTime.Today));
Location destination = new Location("Destination", new TravelDate(DateTime.Today.AddDays(1)));
Journey journey = new Journey(traveller, origin, destination);
Request request = new Request(requestor, package, origin, destination);
UserRepository.Instance.SaveUser(traveller);
UserRepository.Instance.SaveUser(requestor);
RequestRepository.Instance.Save(request);
JourneyRepository.Instance.Save(journey);
Match match = new Match(journey, request);
IMatchRepository repository = MatchRepository.Instance;
IList<Match> matchList = repository.LoadMatchesByUserRequest("[email protected]");
try
{
Assert.AreEqual(1, matchList.Count);
}
finally
{
repository.Delete(match);
}
}
示例10: PutUserGroup
// PUT api/UserGroups/5
public HttpResponseMessage PutUserGroup(int id, UserGroup usergroup)
{
if (!ModelState.IsValid)
{
return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
}
if (id != usergroup.Id)
{
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
db.Entry(usergroup).State = EntityState.Modified;
try
{
db.SaveChanges();
}
catch (DbUpdateConcurrencyException ex)
{
return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
}
return Request.CreateResponse(HttpStatusCode.OK);
}
示例11: SetAnonymousGroupDefaultPermissions
/// <summary>
/// Sets the default permissions for the anonymous users group, properly importing version 2.0 values.
/// </summary>
/// <param name="anonymous">The anonymous users group.</param>
/// <returns><c>true</c> if the operation succeeded, <c>false</c> otherwise.</returns>
public static bool SetAnonymousGroupDefaultPermissions(UserGroup anonymous)
{
bool done = true;
// Properly import Private/Public Mode wiki
if(Settings.PrivateAccess) {
// Nothing to do, because without any explicit grant, Anonymous users cannot do anything
}
else if(Settings.PublicAccess) {
// Public access, allow modification and propagate file management permissions if they were allowed for anonymous users
done &= AuthWriter.SetPermissionForNamespace(AuthStatus.Grant, null, Actions.ForNamespaces.ModifyPages, anonymous);
done &= AuthWriter.SetPermissionForNamespace(AuthStatus.Grant, null, Actions.ForNamespaces.DownloadAttachments, anonymous);
if(Settings.UsersCanCreateNewPages) {
done &= AuthWriter.SetPermissionForNamespace(AuthStatus.Grant, null, Actions.ForNamespaces.CreatePages, anonymous);
}
if(Settings.UsersCanCreateNewCategories || Settings.UsersCanManagePageCategories) {
done &= AuthWriter.SetPermissionForNamespace(AuthStatus.Grant, null, Actions.ForNamespaces.ManageCategories, anonymous);
}
if(Settings.FileManagementInPublicAccessAllowed) {
SetupFileManagementPermissions(anonymous);
}
}
else {
// Standard configuration, only allow read permissions
done &= AuthWriter.SetPermissionForNamespace(AuthStatus.Grant, null, Actions.ForNamespaces.ReadPages, anonymous);
done &= AuthWriter.SetPermissionForNamespace(AuthStatus.Grant, null, Actions.ForNamespaces.ReadDiscussion, anonymous);
done &= AuthWriter.SetPermissionForNamespace(AuthStatus.Grant, null, Actions.ForNamespaces.DownloadAttachments, anonymous);
foreach(IFilesStorageProviderV30 prov in Collectors.FilesProviderCollector.AllProviders) {
done &= AuthWriter.SetPermissionForDirectory(AuthStatus.Grant, prov, "/", Actions.ForDirectories.DownloadFiles, anonymous);
}
}
return done;
}
示例12: vPwdEdit
public vPwdEdit(UserGroup group)
{
this.ID = group.ID;
this.GroupName = group.GroupName;
this.Picture = group.Picture;
this.Password = group.LoginPassword;
}
示例13: Insert
public InsertResult Insert(UserGroup userGroup, Guid userId)
{
try
{
userGroup.Id = Guid.NewGuid();
userGroup.LastUpdate = DateTime.Now;
UserGroupDb.Insert
(
userGroup.Id,
userGroup.Description,
userGroup.Currency_Code,
userGroup.BackOfficeGroup
);
return new InsertResult();
}
catch (SqlException ex)
{
var entityError = new List<EntityError>();
entityError.Add(new EntityError("UserGroup", "Insert", ex.Message));
Logger.Instance.Log.ErrorException("Insert Delete", ex);
return new InsertResult(entityError);
}
}
示例14: User
public User(int id, string code, bool blocked, UserGroup userGroup)
{
Id = id;
Code = code;
Blocked = blocked;
Group = userGroup;
}
示例15: addEntry
/// <summary>
/// Add a new entry to one of the dropdown tables in the database.
/// </summary>
/// <param name="table">Table to add a new entry to.</param>
/// <param name="entry">
/// DropdownEntry containing the value and code,
/// if exists.
/// </param>
public void addEntry(Constants.DropdownTable table,
DropdownEntry entry)
{
switch (table) {
case Constants.DropdownTable.Keyword:
var kw = new Keyword {
KeywordValue = entry.value
};
_db.Keywords.InsertOnSubmit(kw);
break;
case Constants.DropdownTable.QuestionType:
var qType = new QuestionType {
Code = entry.code,
Value = entry.value
};
_db.QuestionTypes.InsertOnSubmit(qType);
break;
case Constants.DropdownTable.Region:
var region = new Region {
Code = entry.code,
Value = entry.value
};
_db.Regions.InsertOnSubmit(region);
break;
case Constants.DropdownTable.RequestorType:
var rType = new RequestorType {
Code = entry.code,
Value = entry.value
};
_db.RequestorTypes.InsertOnSubmit(rType);
break;
case Constants.DropdownTable.TumourGroup:
var tGroup = new TumourGroup {
Code = entry.code,
Value = entry.value
};
_db.TumourGroups.InsertOnSubmit(tGroup);
break;
case Constants.DropdownTable.UserGroup:
var uGroup = new UserGroup {
Code = entry.code,
Value = entry.value
};
_db.UserGroups.InsertOnSubmit(uGroup);
break;
}
_db.SubmitChanges();
}