private void auth_Click(object sender, RoutedEventArgs e)
        {
            session = new Connectors.VK.VKSession();


            var resp = session.Create(new CommonDataTypes.CreateSessionData()
            {
                Login    = txtLogin.Text,
                Password = txtPass.Password,
                TwoFactorAuthorization = () =>
                {
                    return(WPFControls.Windows.TwoFactorAuthorizationWindow.GetCode());
                }
            });

            if (resp.Type == CommonDataTypes.Enums.ResponseTypes.OK)
            {
                if (AuthorizationSuccess != null)
                {
                    AuthorizationSuccess(session);
                }
                txtLogin.Foreground   = Brushes.Green;
                lbLogin.Foreground    = Brushes.Green;
                txtPass.Foreground    = Brushes.Green;
                lbPassword.Foreground = Brushes.Green;
            }
            else
            {
                MessageBox.Show(resp.Message, resp.Type.ToString(), MessageBoxButton.OK, MessageBoxImage.Error);
                txtLogin.Foreground   = Brushes.Red;
                lbLogin.Foreground    = Brushes.Red;
                txtPass.Foreground    = Brushes.Red;
                lbPassword.Foreground = Brushes.Red;
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            // обработчик получения кода
            Func <string> code = () =>
            {
                Console.Write("Please enter code: ");
                string value = Console.ReadLine().Trim();
                return(value);
            };

            SocialNetworkCleaner.Connectors.VK.VKSession session = new Connectors.VK.VKSession();
            try
            {
                session.Create(new CommonDataTypes.CreateSessionData()
                {
                    Login    = "",
                    Password = "",
                    TwoFactorAuthorization = code
                });
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Message);
            }

            Connectors.IProcessor processor = new Connectors.VK.VKProcessor();
            processor.GetPostsNotificationEvent += Processor_GetPostsNotificationEvent;
            var user  = (new Connectors.VK.VKUser()).GetUserInfo();
            var posts = processor.GetAllPosts(user);

            var groups = processor.GetAllUsersGroups(user);

            posts = processor.AddInformationAboutSourceToPosts(posts, user, false);

            processor.SaveData(posts);
        }