Exemplo n.º 1
0
        private void log_in_to_accounts()
        {
            if (dataGridView1.Rows.Count < 2)
            {
                BeginInvoke(new Action(() => {
                    new ErrorMessageBox("Lütfen kullanıcı giriniz!", FormStartPosition.CenterParent).ShowDialog();
                }));
                return;
            }

            is_logging_in = true;

            BeginInvoke(new Action(() =>
            {
                button2.Enabled = false;
                button3.Enabled = true;
                PrintStatusToLog(richTextBox1, "Girişler yapılıyor!");
            }));

            ig_clients.Clear();
            BeginInvoke(new Action(() => { label10.Text = ig_clients.Count.ToString(); }));

            for (int i = 0; i < (dataGridView1.Rows.Count - 1); i++)
            {
                if (is_logging_in == false)
                {
                    return;
                }

                var row      = dataGridView1.Rows[i];
                var username = row.Cells[0].Value;
                var password = row.Cells[1].Value;
                var proxy    = row.Cells[2].Value;

                if (proxy == null)
                {
                    proxy = "Yok";
                }

                if (username == null || password == null)
                {
                    BeginInvoke(new Action(() =>
                    {
                        new ErrorMessageBox("Lütfen boş kutucuk bırakmayın!", FormStartPosition.CenterParent).ShowDialog();
                        button2.Enabled = true;
                        button3.Enabled = false;
                        is_logging_in   = false;
                        PrintErrorToLog(richTextBox1, "Girişler durduruldu!");
                    }));
                    return;
                }

                PrintStatusToLog(richTextBox1, "[" + username + "] " + "Giriş yapılıyor!");
                if (proxy.ToString().ToLower() == "yok")
                {
                    try
                    {
                        InstagramClient ig_client = new InstagramClient(username.ToString(), password.ToString(), 60);
                        ig_client.GetLoginPage();
                        ig_client.Login();
                        if (is_logging_in == false)
                        {
                            return;
                        }
                        ig_clients.Add(ig_client);
                        BeginInvoke(new Action(() => { label10.Text = ig_clients.Count.ToString(); }));
                        PrintSuccessToLog(richTextBox1, "[" + username + "] " + "Başarıyla giriş yaptı!");
                    }
                    catch (InvalidUsername)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Hatalı kullanıcı adı!");
                    }
                    catch (InvalidPassword)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Hatalı şifre: " + password);
                    }
                    catch (InvalidProxy)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Hatalı proxy: " + password);
                    }
                    catch (LoginFailed)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Giriş başarısız! Kullanıcı adı veya şifre hatalı!");
                    }
                    catch (WebException ex)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Bağlantı hatası: " + ex.Message);
                    }
                    catch (ResponseIsNotOK ex)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Bağlantı hatası: " + ex.Message);
                    } catch (CookieNotFound ex)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Bağlantı hatası: " + ex.Message);
                    }
                }
                else
                {
                    try
                    {
                        InstagramClient ig_client = new InstagramClient(username.ToString(), password.ToString(), proxy.ToString(), 60);
                        ig_client.GetLoginPage();
                        ig_client.Login();
                        if (is_logging_in == false)
                        {
                            return;
                        }
                        ig_clients.Add(ig_client);
                        BeginInvoke(new Action(() => { label10.Text = ig_clients.Count.ToString(); }));
                        PrintSuccessToLog(richTextBox1, "[" + username + "] " + "Başarıyla giriş yaptı!");
                    }
                    catch (InvalidUsername)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Hatalı kullanıcı adı!");
                    }
                    catch (InvalidPassword)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Hatalı şifre: " + password);
                    }
                    catch (CookieNotFound)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Giriş başarısız! Cookieler alınamadı!");
                    }
                    catch (LoginFailed)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Giriş başarısız! Kullanıcı adı veya şifre hatalı!");
                    }
                    catch (WebException ex)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Bağlantı hatası: " + ex.Message);
                    }
                    catch (ResponseIsNotOK ex)
                    {
                        PrintErrorToLog(richTextBox1, "[" + username + "] " + "Bağlantı hatası: " + ex.Message);
                    }
                    catch (TaskCanceledException) { }
                    catch (Exception ex)
                    {
                        PrintErrorToLog(richTextBox1, "\n\n[" + username + "] " + "Bu hatayı yapımcıya iletin!\n" + ex.Message + " " + ex.Source + " " + ex.StackTrace + "\n\n");
                    }
                }
            }
            PrintStatusToLog(richTextBox1, "Girişler tamamlandı!");
            BeginInvoke(new Action(() => {
                button2.Enabled = true;
                button3.Enabled = false;
                is_logging_in   = false;
            }));
        }