コード例 #1
0
ファイル: VkApi.cs プロジェクト: VladimirTyrin/vk
        /// <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;
        }
コード例 #2
0
        /// <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;
        }
コード例 #3
0
ファイル: User.cs プロジェクト: radtek/canon
        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();
        }
コード例 #4
0
ファイル: VkApi.cs プロジェクト: 8Observer8/vk
        /// <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;
        }
コード例 #5
0
ファイル: VkApi.cs プロジェクト: ShamilS/vk
        /// <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);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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");
            }
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
ファイル: VkApi.cs プロジェクト: Dramacydal/vk
        /// <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;
        }
コード例 #11
0
 internal UsersCategoryExtended(UsersCategory usersCategory, VkApi vk)
 {
     _users = usersCategory;
     _vk = vk;
 }
コード例 #12
0
 public JsonResult GetUsers(string snpPattern, UsersCategory usersCategory = UsersCategory.ActiveUsers)
 {
     return(Json(_userService.FindUsers(snpPattern, usersCategory, 10),
                 JsonRequestBehavior.AllowGet));
 }
コード例 #13
0
ファイル: User.cs プロジェクト: ddksaku/canon
 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();
 }
コード例 #14
0
ファイル: VkApi.cs プロジェクト: Casper-SC/vk
        /// <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;
        }
コード例 #15
0
        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);
        }
コード例 #16
0
 private IEnumerable <LdapUser> FindActiveDirectoryUsers(string snpPattern, UsersCategory usersCategory, int maxCount)
 {
     return(_ldapRepository.FindUsers(snpPattern, usersCategory, GetLdapDepartmentFilter(), maxCount));
 }
コード例 #17
0
ファイル: VkApi.cs プロジェクト: justloot/vk
        /// <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";
        }
コード例 #18
0
        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);
        }