Esempio n. 1
0
 public LoginFbForm(IAccountFacebookService accFbService, AccountFacebookView acc)
 {
     InitializeComponent();
     DialogResult  = DialogResult.Cancel;
     _accFbService = accFbService;
     _acc          = acc;
 }
Esempio n. 2
0
        public static List <AccountFacebookView> GetAccFbs()
        {
            List <AccountFacebookView> accs = new List <AccountFacebookView>();
            var acc1 = new AccountFacebookView()
            {
                ShopId   = 1111,
                Username = "******",
                Password = "******",
            };
            var acc2 = new AccountFacebookView()
            {
                ShopId   = 2222,
                Username = "******",
                Password = "******",
            };
            var acc3 = new AccountFacebookView()
            {
                ShopId   = 3333,
                Username = "******",
                Password = "******",
            };

            accs.Add(acc1);
            accs.Add(acc2);
            accs.Add(acc3);
            return(accs);
        }
Esempio n. 3
0
        private void LinkLogin_Click(object sender, EventArgs e)
        {
            try
            {
                LinkLabel           linkLabel = sender as LinkLabel;
                AccountFacebookView acc       = linkLabel.Links[0].LinkData as AccountFacebookView;

                if (acc.LoginStatus == LoginStatusConstant.NOTLOGIN)
                {
                    LoginFbForm loginFbForm = new LoginFbForm(_accFbService, acc);
                    var         result      = loginFbForm.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        linkLabel.Text = $"{acc.Username} ({acc.LoginStatus})";
                    }
                }
                else if (acc.LoginStatus == LoginStatusConstant.CHECKPOINT)
                {
                    _accFbService.OpenFacebook(acc);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 4
0
        private void addFriendListFbBtn_Click(object sender, EventArgs e)
        {
            List <Task> tasks = new List <Task>();

            foreach (var interact in _interacts)
            {
                AccountFacebookView acc = _accFbs.Find(x => x.ShopId == interact.ShopId);
                if (acc.LoginStatus == LoginStatusConstant.LOGGEDIN)
                {
                    tasks.Add(_accFbService.AddFriends(interact, acc.Username));
                }
            }
            Task.WaitAll(tasks.ToArray());
        }
Esempio n. 5
0
 public bool OpenFacebook(AccountFacebookView acc)
 {
     try
     {
         string         userProfilePath = $@"{UrlConstant.ProfileChromePath}\{acc.Username}";
         ChromeSelenium chrome          = new ChromeSelenium(userProfilePath, VarConstant.IsShowBrowser);
         // Go to fb
         chrome.Navigate(UrlConstant.FbLogin);
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 6
0
        public Task UpdateLoginStatus(AccountFacebookView acc)
        {
            return(Task.Run(() =>
            {
                string userProfilePath = $@"{UrlConstant.ProfileChromePath}\{acc.Username}";
                ChromeSelenium chrome = new ChromeSelenium(userProfilePath, VarConstant.IsShowBrowser);
                // Go to fb
                chrome.Navigate(UrlConstant.FbLogin);
                acc.LoginStatus = chrome.CheckLoginStatusFb();
                // chưa đăng nhập thực hiện đăng nhập
                if (acc.LoginStatus == LoginStatusConstant.NOTLOGIN)
                {
                    acc.LoginStatus = chrome.LoginFb(acc.Username, acc.Password);
                }

                chrome.Quit();
            }));
        }