Ejemplo n.º 1
0
 private void buttonAppiumContacts_Click(object sender, EventArgs e)
 {
     Invoke(
         new Action(() =>
                    appium = new AppiumDevice(Apps.Contacts, Apps.ContatsActivity_Main, new Device(comboBoxAppium.Text)
                                              )
                    )
         );
     ContactsScenario.ImportContacts(appium);
 }
Ejemplo n.º 2
0
        public static async Task <bool> Registration(
            DeviceController.DeviceController deviceController
            )
        {
            bool banned     = false;
            int  iterations = 0;

            string command = "emulator @" + deviceController.DeviceName;

            if (!deviceController.Proxy.IsNullOrEmpty())
            {
                command += " -http-proxy " + deviceController.AppiumDevice;
                System.IO.File.AppendAllText("usedproxy.txt", deviceController.Proxy + "\n");
                System.IO.File.AppendAllText("usedproxy.txt", "\n");
            }
            command += " -wipe-data -no-snapshot-load";
            deviceController.Log("Emulator starting");
            Logger.log("Emulator starting");
            CommandExecutor.ExecuteCommandAsync(command);
            await Task.Delay(5000);

            /*Open contacts*/
            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    deviceController.Log("Running Contacts app");
                    Logger.log("Running Contacts app");
                    deviceController.AppiumDevice = new AppiumDevice(Apps.Contacts,
                                                                     Apps.ContatsActivity_Main,
                                                                     new Device(deviceController.DeviceName),
                                                                     deviceController.Port
                                                                     );
                    ContactsScenario.GenerateVCard(deviceController);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }
            /*Import Contacts*/
            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    deviceController.Log("Importing contacts");
                    Logger.log("Importing contacts");
                    ContactsScenario.ImportContacts(deviceController.AppiumDevice);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(500);
                }
            }

            /*Get number to activate*/
            string number = "";

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    number = await deviceController.SmsRegistrator.GetNumber();

                    deviceController.Log("Recived number: " + number);
                    Logger.log("Recived number: " + number);
                    number = number.Remove(0, 1);
                    break;
                }
                catch
                {
                    iterations++;
                    if (iterations > 10)
                    {
                        throw new Exception("Sms registrator error");
                    }
                    await Task.Delay(2000);
                }
            }

            Random random = new Random();

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    deviceController.Log("Registration started");
                    Logger.log("Registration started");
                    deviceController.AppiumDevice = new AppiumDevice(Apps.WhatsApp,
                                                                     Apps.WhatsAppActivity_Eula,
                                                                     new Device(deviceController.DeviceName),
                                                                     deviceController.Port);
                    banned = await WhatsAppScenario.Registration(deviceController.AppiumDevice, number, "7");

                    if (banned)
                    {
                        deviceController.Log("Number is banned");
                        Logger.log("Number is banned");
                        deviceController.AppiumDevice.CloseApp();
                        deviceController.SmsRegistrator.SetStatus("7" + number, "10");
                        deviceController.SmsRegistrator.SetStatus("7" + number, "-1");
                        iterations = 0;
                        while (iterations < 60)
                        {
                            try
                            {
                                number = await deviceController.SmsRegistrator.GetNumber();

                                deviceController.Log("Waiting for code");
                                Logger.log("Waiting for code");
                                number = number.Remove(0, 1);
                                break;
                            }
                            catch
                            {
                                iterations++;
                                await Task.Delay(5000);
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }
                catch
                {
                    iterations++;
                    await Task.Delay(2000);
                }
            }

            deviceController.SmsRegistrator.PhoneReady("7" + number);

            iterations = 0;
            while (iterations < 1200)
            {
                try
                {
                    string code = await deviceController.SmsRegistrator.GetCode("7" + number);

                    if (code != "STATUS_WAIT_CODE")
                    {
                        WhatsAppScenario.VerifyCode(deviceController.AppiumDevice, code);
                        break;
                    }
                    else
                    {
                        iterations++;
                        await Task.Delay(1000);
                    }
                }
                catch
                {
                    iterations++;
                    await Task.Delay(1000);
                }
            }

            deviceController.SmsRegistrator.SetStatus("7" + number, "6");

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    WhatsAppScenario.WriteName(deviceController.AppiumDevice, deviceController.Nickname);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(500);

                    if (iterations > 55)
                    {
                        return(true);
                    }
                }
            }
            deviceController.Log("Registration finished");
            return(banned);
        }
Ejemplo n.º 3
0
        public async void AutomatizationCancellable(CancellationTokenSource cancellationTokenSource)
        {
            checkActivity.Enabled = true;
            bool banned = false;
            // string command = "cd " + textBoxAppiumSendKeys.Text;
            //CommandExecutor.ExecuteCommandAsync(command);
            int    iterations = 0;
            string command    = "emulator @" + comboBoxAppium.Text;

            if (textBoxProxy.Text != "")
            {
                command += " -http-proxy " + textBoxProxy.Text;
                System.IO.File.AppendAllText("usedproxy.txt", textBoxProxy.Text + "\n");
            }
            command += " -wipe-data -no-snapshot-load";

            CommandExecutor.ExecuteCommandAsync(command);
            await Task.Delay(25000);


            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    appium = new AppiumDevice(Apps.Contacts,
                                              Apps.ContatsActivity_Main,
                                              new Device(comboBoxAppium.Text));
                    SendVCard();
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(5000);
                }
            }
            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    ContactsScenario.ImportContacts(appium);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(5000);
                }
            }

            await Task.Delay(2000);


            string number = "";

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    number = await smsActivate.GetNumber();

                    number = number.Remove(0, 1);
                    break;
                }
                catch
                {
                    iterations++;
                    await Task.Delay(5000);
                }
            }
            do
            {
                Random random = new Random();
                iterations = 0;
                while (iterations < 60)
                {
                    try
                    {
                        appium = new AppiumDevice(Apps.WhatsApp,
                                                  Apps.WhatsAppActivity_Eula,
                                                  new Device(comboBoxAppium.Text));
                        // await Task.Delay(random.Next(4000, 6000));
                        banned = await WhatsAppScenario.Registration(appium, number, "7");

                        if (banned)
                        {
                            appium.CloseApp();
                            smsActivate.setStatus("7" + number, "10");
                            smsActivate.setStatus("7" + number, "-1");
                            iterations = 0;
                            while (iterations < 60)
                            {
                                try
                                {
                                    number = await smsActivate.GetNumber();

                                    number = number.Remove(0, 1);
                                    break;
                                }
                                catch
                                {
                                    iterations++;
                                    await Task.Delay(5000);
                                }
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                    catch (Exception ex)
                    {
                        iterations++;
                        await Task.Delay(5000);
                    }
                }
            } while (!banned);


            smsActivate.PhoneReady("7" + number);
            iterations = 0;
            while (iterations < 1200)
            {
                try
                {
                    string code = await smsActivate.GetCode("7" + number);

                    if (code != "STATUS_WAIT_CODE")
                    {
                        WhatsAppScenario.VerifyCode(appium, code);
                    }
                    else
                    {
                        iterations++;
                        await Task.Delay(1000);
                    }
                }
                catch (Exception ex)
                {
                    iterations++;

                    await Task.Delay(1000);
                }
            }

            smsActivate.setStatus("7" + number, "6");

            iterations = 0;
            while (iterations < 60)
            {
                try
                {
                    WhatsAppScenario.WriteName(appium, textBoxName.Text);
                }
                catch
                {
                    iterations++;
                    await Task.Delay(5000);
                }
            }

            System.Media.SoundPlayer player = new System.Media.SoundPlayer(Properties.Settings.Default.PathToDirectory + "/success.wav");
            player.Play();
            // devices.Add(new Device(comboBoxAppium.Text));
            // new DeviceForm(comboBoxAppium.Text, textBoxProxy.Text).Show();
        }