/// <summary> /// Инициализирует новый экземпляр класса <see cref="VkApi"/>. /// </summary> public VkApi() { Browser = new Browser(); Users = new UsersCategory(this); Friends = new FriendsCategory(this); Status = new StatusCategory(this); Messages = new MessagesCategory(this); Groups = new GroupsCategory(this); Audio = new AudioCategory(this); Wall = new WallCategory(this); Database = new DatabaseCategory(this); Utils = new UtilsCategory(this); Fave = new FaveCategory(this); Video = new VideoCategory(this); Account = new AccountCategory(this); Photo = new PhotoCategory(this); Docs = new DocsCategory(this); Likes = new LikesCategory(this); Pages = new PagesCategory(this); Gifts = new GiftsCategory(this); Apps = new AppsCategory(this); NewsFeed = new NewsFeedCategory(this); Stats = new StatsCategory(this); Auth = new AuthCategory(this); Markets = new MarketsCategory(this); Execute = new ExecuteCategory(this); RequestsPerSecond = 3; }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="VkApi"/>. /// </summary> public VkApi(ICaptchaSolver captchaSolver = null) { Browser = new Browser(); Users = new UsersCategory(this); Friends = new FriendsCategory(this); Status = new StatusCategory(this); Messages = new MessagesCategory(this); Groups = new GroupsCategory(this); Audio = new AudioCategory(this); Wall = new WallCategory(this); Board = new BoardCategory(this); Database = new DatabaseCategory(this); Utils = new UtilsCategory(this); Fave = new FaveCategory(this); Video = new VideoCategory(this); Account = new AccountCategory(this); Photo = new PhotoCategory(this); Docs = new DocsCategory(this); Likes = new LikesCategory(this); Pages = new PagesCategory(this); Gifts = new GiftsCategory(this); Apps = new AppsCategory(this); NewsFeed = new NewsFeedCategory(this); Stats = new StatsCategory(this); Auth = new AuthCategory(this); Markets = new MarketsCategory(this); Execute = new ExecuteCategory(this); RequestsPerSecond = 3; MaxCaptchaRecognitionCount = 5; _captchaSolver = captchaSolver; }
public static void UpdateCategoryRelation(int userId, int catId, bool relationExist) { CanonDataContext db = Cdb.Instance; try { UsersCategory uc = db.UsersCategories.First(u => u.UserId == userId && u.CategoryId == catId); if (!relationExist) { db.UsersCategories.DeleteOnSubmit(uc); } } catch (Exception) { //there is no suc relation if (relationExist) { UsersCategory newUc = new UsersCategory(); newUc.CategoryId = catId; newUc.UserId = userId; db.UsersCategories.InsertOnSubmit(newUc); } } db.SubmitChanges(); }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="VkApi"/>. /// </summary> public VkApi() { Browser = new Browser(); Users = new UsersCategory(this); Friends = new FriendsCategory(this); Status = new StatusCategory(this); Messages = new MessagesCategory(this); Groups = new GroupsCategory(this); Audio = new AudioCategory(this); Wall = new WallCategory(this); Database = new DatabaseCategory(this); Utils = new UtilsCategory(this); Fave = new FaveCategory(this); Video = new VideoCategory(this); Account = new AccountCategory(this); Photo = new PhotoCategory(this); Docs = new DocsCategory(this); Likes = new LikesCategory(this); Pages = new PagesCategory(this); Gifts = new GiftsCategory(this); Apps = new AppsCategory(this); NewsFeed = new NewsFeedCategory(this); Stats = new StatsCategory(this); Auth = new AuthCategory(this); RequestsPerSecond = 3; }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="VkApi"/>. /// </summary> public VkApi() { Browser = new Browser(); Users = new UsersCategory(this); Friends = new FriendsCategory(this); Status = new StatusCategory(this); Messages = new MessagesCategory(this); Groups = new GroupsCategory(this); Audio = new AudioCategory(this); Wall = new WallCategory(this); Database = new DatabaseCategory(this); Utils = new UtilsCategory(this); Fave = new FaveCategory(this); Video = new VideoCategory(this); Account = new AccountCategory(this); }
public static string LabelToUserCategory(UsersCategory usersCategory) { switch (usersCategory) { case UsersCategory.ActiveUsers: return("Активные"); case UsersCategory.BlockedUsers: return("Заблокированные"); case UsersCategory.All: return("Все"); default: throw new ArgumentOutOfRangeException("usersCategory", usersCategory, null); } }
private IEnumerable <RequestUser> FindDbUsers(string snpPattern, UsersCategory usersCategory, int maxCount) { var users = _securityRepository.FilterUsers(_userRepository.FindUsers(snpPattern)); switch (usersCategory) { case UsersCategory.All: return(users.Take(maxCount)); case UsersCategory.ActiveUsers: return(users.Where(r => r.IsActive).Take(maxCount)); case UsersCategory.BlockedUsers: return(users.Where(r => !r.IsActive).Take(maxCount)); default: throw new ArgumentOutOfRangeException("usersCategory"); } }
public IEnumerable <RequestUser> FindUsers(string snpPattern, UsersCategory usersCategory, int maxCount) { var dbUsers = FilterUsersFields(FindDbUsers(snpPattern, usersCategory, maxCount)); var ldapUsers = FilterUsersFields(FindActiveDirectoryUsers(snpPattern, usersCategory, maxCount)); var maternityLeaveUsers = FilterUsersFields(_ldapRepository.FindMaternityLeaveUsers(snpPattern, GetLdapDepartmentFilter(), maxCount)); switch (usersCategory) { case UsersCategory.ActiveUsers: case UsersCategory.All: return(ldapUsers.Concat(dbUsers).Concat(maternityLeaveUsers).OrderBy(r => r.Snp).Distinct().Take(10)); case UsersCategory.BlockedUsers: return(ldapUsers.Concat(dbUsers).Except(maternityLeaveUsers).OrderBy(r => r.Snp).Distinct().Take(10)); default: throw new ArgumentOutOfRangeException("usersCategory", usersCategory, null); } }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="VkApi"/>. /// </summary> public VkApi() { ServicePointManager.ServerCertificateValidationCallback = new PositiveCertificatePolicy().ServerCertificateValidationCallback; Browser = new Browser(); Users = new UsersCategory(this); Friends = new FriendsCategory(this); Status = new StatusCategory(this); Messages = new MessagesCategory(this); Groups = new GroupsCategory(this); Audio = new AudioCategory(this); Wall = new WallCategory(this); Database = new DatabaseCategory(this); Utils = new UtilsCategory(this); Fave = new FaveCategory(this); Video = new VideoCategory(this); Account = new AccountCategory(this); Likes = new LikesCategory(this); Photo = new PhotoCategory(this); }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="VkApi"/>. /// </summary> public VkApi() { Browser = new Browser(); Users = new UsersCategory(this); Friends = new FriendsCategory(this); Status = new StatusCategory(this); Messages = new MessagesCategory(this); Groups = new GroupsCategory(this); Audio = new AudioCategory(this); Wall = new WallCategory(this); Database = new DatabaseCategory(this); Utils = new UtilsCategory(this); Fave = new FaveCategory(this); Video = new VideoCategory(this); Account = new AccountCategory(this); Photo = new PhotoCategory(this); Docs = new DocsCategory(this); RequestsPerSecond = 3; AutoTokenRefresh = false; }
internal UsersCategoryExtended(UsersCategory usersCategory, VkApi vk) { _users = usersCategory; _vk = vk; }
public JsonResult GetUsers(string snpPattern, UsersCategory usersCategory = UsersCategory.ActiveUsers) { return(Json(_userService.FindUsers(snpPattern, usersCategory, 10), JsonRequestBehavior.AllowGet)); }
public static void UpdateCategoryRelation(int userId, int catId, bool relationExist) { CanonDataContext db = Cdb.Instance; try { UsersCategory uc = db.UsersCategories.First(u => u.UserId == userId && u.CategoryId == catId); if (!relationExist) db.UsersCategories.DeleteOnSubmit(uc); } catch (Exception) { //there is no suc relation if (relationExist) { UsersCategory newUc = new UsersCategory(); newUc.CategoryId = catId; newUc.UserId = userId; db.UsersCategories.InsertOnSubmit(newUc); } } db.SubmitChanges(); }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="VkApi"/>. /// </summary> public VkApi() { Browser = new Browser(); Users = new UsersCategory(this); Friends = new FriendsCategory(this); Status = new StatusCategory(this); Messages = new MessagesCategory(this); Groups = new GroupsCategory(this); Audio = new AudioCategory(this); Wall = new WallCategory(this); Database = new DatabaseCategory(this); Utils = new UtilsCategory(this); Fave = new FaveCategory(this); Video = new VideoCategory(this); Account = new AccountCategory(this); Photo = new PhotoCategory(this); Docs = new DocsCategory(this); Likes = new LikesCategory(this); RequestsPerSecond = 3; }
void RemoveUser_ThrowsException(string identityNo, string password, string firstname, string lastname, UsersCategory usersCategory) { // Arrange var user = new UsersModel(new UsersProcessor(new MockLibsysRepo())) { Password = password, IdentityNO = identityNo, Firstname = firstname, Lastname = lastname, UsersCategory = (int)usersCategory }; var expected = new Users() { Password = password, IdentityNO = identityNo, Firstname = firstname, Lastname = lastname, UsersCategory = (int)usersCategory }; // Act Assert.Throws <Exception>(() => user.RemoveUser()); // Assert Assert.NotNull(user); }
private IEnumerable <LdapUser> FindActiveDirectoryUsers(string snpPattern, UsersCategory usersCategory, int maxCount) { return(_ldapRepository.FindUsers(snpPattern, usersCategory, GetLdapDepartmentFilter(), maxCount)); }
/// <summary> /// Инициализирует новый экземпляр класса <see cref="VkApi"/>. /// </summary> public VkApi() { Browser = new Browser(); Users = new UsersCategory(this); Friends = new FriendsCategory(this); Status = new StatusCategory(this); Messages = new MessagesCategory(this); Groups = new GroupsCategory(this); Audio = new AudioCategory(this); Wall = new WallCategory(this); Database = new DatabaseCategory(this); Utils = new UtilsCategory(this); Fave = new FaveCategory(this); Video = new VideoCategory(this); Account = new AccountCategory(this); ApiVersion = "5.9"; }
public IEnumerable <LdapUser> FindUsers(string snpPattern, UsersCategory usersCategory, IEnumerable <LdapDepartmentFilter> departemtnsFilter, int maxCount) { if (string.IsNullOrEmpty(snpPattern)) { throw new ArgumentNullException("snpPattern"); } var i = 0; var users = new List <LdapUser>(); var filters = departemtnsFilter.ToList(); var extFilter = ""; switch (usersCategory) { case UsersCategory.ActiveUsers: extFilter = "(!(useraccountcontrol:1.2.840.113556.1.4.803:=2))"; break; case UsersCategory.BlockedUsers: extFilter = "((useraccountcontrol:1.2.840.113556.1.4.803:=2))"; break; case UsersCategory.All: break; default: throw new ArgumentOutOfRangeException("usersCategory", usersCategory, null); } foreach (var domainName in GetDomains()) { var context = new DirectoryContext(DirectoryContextType.Domain, domainName, _userName, _password); using (var domain = System.DirectoryServices.ActiveDirectory.Domain.GetDomain(context)) using (var domainEntry = domain.GetDirectoryEntry()) { var domainLoginPrefix = domain.Name.Split('.')[0]; using (var searcher = new DirectorySearcher(domainEntry, "", _propertiesToLoad)) { searcher.SearchScope = SearchScope.Subtree; searcher.PageSize = maxCount; foreach (var filter in filters) { searcher.Filter = string.Format(CultureInfo.InvariantCulture, "(&(objectClass=user)(objectClass=person){1}{2}(displayName=*{0}*){3})", snpPattern, string.IsNullOrEmpty(filter.Company) ? "" : string.Format("(company={0})", filter.Company), string.IsNullOrEmpty(filter.Department) ? "" : string.Format("(department={0})", filter.Department), extFilter); var results = searcher.FindAll(); if (results.Count == 0) { continue; } foreach (SearchResult result in results) { var user = SearchResultToUser(result, domainLoginPrefix); users.Add(user); i++; if (i == maxCount) { break; } } if (i == maxCount) { break; } } if (i == maxCount) { break; } } } } return(users); }