예제 #1
0
 public static void Save(VkApi api, User user)
 {
     saveData = new SaveData();
     saveData.Api = new VkApi();
     saveData.User = new User();
     saveData.Api = api;
     saveData.User = user;
 }
예제 #2
0
 public string OnlineStatus(VkNet.Model.User User)
 {
     if ((bool)User.Online)
     {
         return("Online");
     }
     else
     {
         return("Был в сети \n" + User.LastSeen.Time.ToString());
     }
 }
예제 #3
0
 private static UserInfo ConvertUserToUserInfo(User user)
 {
     return(new UserInfo
     {
         Id = user.Id,
         FirstName = user.FirstName,
         LastName = user.LastName,
         ScreenName = user.ScreenName,
         Photo = user.Photo100.ToString(),
         FriendsCount = user.Counters?.Friends
     });
 }
예제 #4
0
        public ReadOnlyCollection<Audio> GetAll(long uid, out User user, long? albumId = null, IEnumerable<long> aids = null)
        {
            const int count = 6000;
            var i = 0;
            var result = new List<Audio>();

            do
            {
                var currentItems = _audio.Get(uid, out user, albumId, aids, count, i * count);
                if (currentItems != null) result.AddRange(currentItems);
            } while ((++i * count < (_vk.CountFromLastResponse ?? 0)) && (i * count < 6000));

            return result.ToReadOnlyCollection();
        }
예제 #5
0
        private static OnlineInfo GetOnlineInfoByUser(User user)
        {
            bool online       = user.Online.HasValue && user.Online.Value;
            bool onlineMobile = user.OnlineMobile.HasValue && user.OnlineMobile.Value;
            bool onlineApp    = user.OnlineApp.HasValue;

            return(onlineMobile
                                ? OnlineInfo.OnlineMobile
                                : onlineApp
                                        ? OnlineInfo.OnlineApp
                                        : online
                                                ? OnlineInfo.Online
                                                : OnlineInfo.Offline);
        }
예제 #6
0
 public async static Task Try(User user, string[] fileNames, string message = null)
 {
     if (!user.CanPost)
     {
         Dispatcher.CurrentDispatcher.Invoke(() =>
         {
             MessageBox.Show(String.Format("Пользователь {0} {1} запретил добавление записей на своей странице", user.FirstName, user.LastName), "Ошибка доступа");
         });
         return;
     }
     Dispatcher.CurrentDispatcher.Invoke(() =>
     {
         var res = MessageBox.Show(String.Format("Вы действительно хотите загрузить {0} фото на стену пользователя {1} {2}?", fileNames.Length, user.FirstName, user.LastName), "Подтверждение", MessageBoxButton.YesNo);
         if (res != MessageBoxResult.Yes)
             return;
     });
     await VKPhotoUploader.UploadImages(user.Domain, fileNames, message, false, VkNet.Enums.VkObjectType.User, user.Id);
 }
예제 #7
0
		public PhotosPreview(long userId)
		{
			InitializeComponent();

			_user = UserManager.GetUser(userId);

			var bmp = new BitmapImage();
			bmp.BeginInit();
			bmp.UriSource = new Uri((_user.PhotoMaxOrig ?? _user.Photo400Orig ?? _user.Photo200Orig).OriginalString);
			bmp.EndInit();

			/*int count;
			var photos = App.VkApi.Photo.Get(out count, new PhotoGetParams()
			{
				OwnerId = _user.Id,
				PhotoSizes = true
			});*/

			CurrentImage.Source = bmp;
		}
 //Methods
 public SignInViewModel()
 {
     scope = Settings.All;
     User = new User();
     authInformation = new AuthInformation();
     api = new VkApi();
     MainWindow.messageManager = new MessageManager();
 }
예제 #9
0
 private string UserStr(VkNet.Model.User fr) =>
 $"{fr.FirstName} {fr.LastName} - /{fr.Id} -  {(fr.Online.Value ? "Онлайн" : $"Был{(fr.Sex == VkNet.Enums.Sex.Female ? "а" : "")} онлайн {fr.LastSeen?.Time?.ToString("dd.MM.yyyy HH-mm-ss")}")}";
예제 #10
0
        ////   private VkApi api;
        //   public VkNetAddition(VkApi vkApi) {
        //       now = DateTime.Now;
        //       api = vkApi;
        //   }
        public List<User> Search(VkApi api, out int itemsCount, string query = null, int count = 1000, int offset = 0, Dictionary<string, string> parameters = null)
        {
            List<User> users = new List<User>();
            StringBuilder sb = new StringBuilder("https://api.vk.com/method/users.search?");
            if (query != null)
                sb.AppendFormat("{0}={1}&", "q", query);
            if (parameters != null) {
                foreach (var parameter in parameters) {
                    sb.AppendFormat("{0}={1}&", parameter.Key, parameter.Value);
                }
            }

            sb.AppendFormat("v=5.37&access_token={0}", api.AccessToken);
            itemsCount = int.Parse(request(String.Format("{2}&{0}={1}", "count", count, sb.ToString()))["response"]["count"].ToString());

            JObject jUsers = request(String.Format("{2}&{0}={1}&{3}={4}", "count", count > 1000 ? 1000 : count, sb.ToString(), "offset", offset));
            Members[] members = JsonConvert.DeserializeObject<Members[]>(jUsers["response"]["items"].ToString());
            foreach (var member in members) {
                User user = new User();
                user.Id = member.id;
                user.FirstName = member.first_name;
                user.LastName = member.last_name;
                users.Add(user);

            }

            return users;
        }
예제 #11
0
		public ReadOnlyCollection<Audio> Get(long uid, out User user, long? albumId = null, IEnumerable<long> aids = null, uint? count = null, uint? offset = null)
		{
			return InternalGet("uid", (long)uid, out user, albumId, aids, true, count, offset);
		}
예제 #12
0
		private ReadOnlyCollection<Audio> InternalGet(
			string paramId,
			long id,
			out User user,
			long? albumId = null,
			IEnumerable<long> aids = null,
			bool? needUser = null,
			uint? count = null,
			uint? offset = null)
		{
			var parameters = new AudioGetParams
			{
				OwnerId = id,
				AlbumId = albumId,
				AudioIds = aids,
				NeedUser = needUser,
				Offset = offset,
				Count = count
			};

			return Get(out user, parameters);
		}
 public ShowableUser([NotNull] VkNetModel.User user)
 {
     User = user;
 }
예제 #14
0
        public double[] FillUserParams()
        {
            double[] x   = new double[17];
            var      api = Api.Get();

            VkNet.Model.User usr = api.Users.Get(new long[] { VkId }, ProfileFields.All)[0];
            WallGetObject    wall;

            //Предполагаю, что проверка на закрытость страницы уже пройдена
            try
            {
                wall = api.Wall.Get(new VkNet.Model.RequestParams.WallGetParams
                {
                    OwnerId = usr.Id
                });

                var posts         = wall.WallPosts;
                int ownPostsCount = 0;
                int repostsCount  = 0;
                foreach (var post in posts)
                {
                    if (post.CopyHistory.Count > 0)
                    {
                        repostsCount++;
                    }
                    else
                    {
                        ownPostsCount++;
                    }
                }
                //12:ownPosts
                x[12] = ownPostsCount;

                //13:reposts
                x[13] = repostsCount;

                int sum = 0;
                foreach (var post in posts)
                {
                    sum += post.Views?.Count ?? 0;
                }
                //14:views
                x[14] = sum;

                //16:own / repo
                //19 использовалось как макс. значение при обучении модели
                x[16] = repostsCount != 0 ? ownPostsCount / repostsCount : 19;
            }
            catch (Exception)
            {
                x[12] = 0;
                x[13] = 0;
                x[14] = 0;
                x[16] = 19;
            }
            //0:is_female
            x[0] = usr.Sex == VkNet.Enums.Sex.Female ? 1 : 0;
            //1:has_photo
            x[1] = usr.PhotoId != null ? 1 : 0;
            //15:social_networks
            //есть ли фб и тд
            x[15] = (usr.Connections.FacebookId != null) |
                    (usr.Connections.Instagram != null) |
                    (usr.Connections.Twitter != null) |
                    (usr.Connections.Skype != null) ? 1 : 0;
            //2:friends
            x[2] = usr.Counters.Friends ?? 0;
            //3:followers
            x[3] = usr.Counters.Followers ?? 0;
            //4:groups
            x[4] = usr.Counters.Groups ?? 0;
            //5:pages
            x[5] = usr.Counters.Pages ?? 0;
            //6:subscriptions
            x[6] = usr.Counters.Subscriptions ?? 0;
            //7:photos
            x[7] = usr.Counters.Photos ?? 0;
            //8:user_photo
            x[8] = usr.Counters.UserPhotos ?? 0;
            //9:audios
            x[9] = usr.Counters.Audios ?? 0;
            //10:videos
            x[10] = usr.Counters.Videos ?? 0;

            Regex linkMask = new Regex("id_?[0-9]+");

            //11:is_default_link
            x[11] = linkMask.IsMatch(usr.Domain) ? 1 : 0;

            UserNumericParams = x;
            return(x);
        }