Пример #1
0
        private async Task ProcessTasks(List <TaskSch> tobeRunGroup)
        {
            List <Task> taskList = new List <Task>();


            if (tobeRunGroup != null)
            {
                foreach (var task in tobeRunGroup)
                {
                    ProcessUtils.AdbOpenApps(task.MobileIndex, "com.facebook.katana");
                    taskList.Add(TasksSchedule.ProcessSingleTask(task));
                }

                await Task.Delay(8000);

                try
                {
                    LogUtils.Information($"count of tobeRunGroup:{taskList.Count}");
                    await Task.WhenAll(taskList);
                }
                catch (Exception ex)
                {
                    _previousGlobalTaskByGroupFinished = true;

                    LogUtils.Error($"{ex}");
                }
            }

            _previousGlobalTaskByGroupFinished = true;
        }
Пример #2
0
        private async void btnLaunchWhatsApp_Click(object sender, RoutedEventArgs e)
        {
            if (_runningGroupIndex == -1)
            {
                MessageBox.Show(resourceManager.GetString("Error_Please_Launch_A_Vm", cultureInfo));
                return;
            }

            string          packagename = "com.whatsapp";
            List <Phonenum> listPhon    = new PhonenumBLL().SelectPhoneNumber();

            for (int i = 0; i < VmManager.Instance.Column; i++)
            {
                int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i];

                //获取imei、androidid值
                di = new System.Collections.Generic.Dictionary <int, Wx.Qunkong360.Wpf.Abstract.VmModel>(VmManager.Instance._vmModels);

                if (vmIndex != -1)
                {
                    ProcessUtils.AdbOpenApps(vmIndex, packagename);
                }
                #region 获取登录信息
                List <Simulators> list = SimulatorsBLL.GetSimulatorsList();
                int listcount          = list.Count;
                if (listPhon.Count != 0)
                {
                    AppOptViewModel.simulators.Add(new Simulators()
                    {
                        id        = i + listcount + 1,
                        phonenum  = listPhon[i].PhoneNum.Substring(1),
                        imei      = di[i].Imei,
                        androidid = di[i].AndroidId,
                        created   = listPhon[i].Created
                    });
                }
                #endregion
            }

            string installNewestAppLog = await AppUpgradeHelper.Instance.InstallNewestApp();

            LogUtils.Information(installNewestAppLog);
        }
Пример #3
0
        private void btnLaunchWhatsApp_Click(object sender, RoutedEventArgs e)
        {
            if (_runningGroupIndex == -1)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Error_Please_Launch_A_Vm", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            string packagename = "com.whatsapp";

            for (int i = 0; i < VmManager.Instance.Column; i++)
            {
                int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i];

                if (vmIndex != -1)
                {
                    ProcessUtils.AdbOpenApps(vmIndex, packagename);
                }
            }
        }
Пример #4
0
        //启动App
        private void btn_startapps_Click(object sender, EventArgs e)
        {
            if (_runningGroupIndex == -1)
            {
                MessageBox.Show(resourceManager.GetString("Error_Please_Launch_A_Vm", cultureInfo));
                return;
            }

            string packagename = "com.whatsapp";

            for (int i = 0; i < VmManager.Instance.Column; i++)
            {
                int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i];

                if (vmIndex != -1)
                {
                    ProcessUtils.AdbOpenApps(vmIndex, packagename);
                }
            }
        }
Пример #5
0
        private async Task ProcessTasks(List <TaskSch> tasks)
        {
            List <Task> taskList = new List <Task>();


            if (tasks != null)
            {
                foreach (var task in tasks)
                {
                    ProcessUtils.AdbOpenApps(task.MobileIndex, "com.facebook.katana");
                    taskList.Add(TasksSchedule.ProcessSingleTask(task));
                }

                await Task.Delay(5000);

                try
                {
                    await Task.WhenAll(taskList);

                    foreach (var task in tasks)
                    {
                        TasksBLL.UpdateTimedTaskExecuteTime(task.Id);
                    }
                }
                catch (Exception ex)
                {
                    LogUtils.Error($"{ex}");

                    foreach (var task in tasks)
                    {
                        TasksBLL.UpdateTimedTaskExecuteTime(task.Id);
                    }

                    _previousTimedTaskByGroupFinished = true;
                }
            }

            _previousTimedTaskByGroupFinished = true;
        }
Пример #6
0
        private void btnLaunchMessenger_Click(object sender, RoutedEventArgs e)
        {
            if (_runningGroupIndex == -1)
            {
                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Error_Please_Launch_A_Vm", SystemLanguageManager.Instance.CultureInfo));
                return;
            }

            string packagename = "com.facebook.mlite";

            //List<Phonenum> listPhon = new PhonenumBLL().SelectPhoneNumber();

            for (int i = 0; i < VmManager.Instance.Column; i++)
            {
                int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i];
                if (vmIndex != -1)
                {
                    ProcessUtils.AdbOpenApps(vmIndex, packagename);
                }
            }

            //string installNewestAppLog = await AppUpgradeHelper.Instance.InstallNewestApp();
            //LogUtils.Information(installNewestAppLog);
        }
Пример #7
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            int    id     = dgAccountManagement.SelectedIndex;
            int    number = -1;
            int    num    = 555 + 2 * id;
            string port2  = "5" + num;

            SystemConfigBLL bLL = new SystemConfigBLL();

            Task.Run(() =>
            {
                List <string> devicesList = ProcessUtils.AdbDevices();
                foreach (string deviceIP in devicesList)
                {
                    if (deviceIP.IndexOf(port2) > 0)
                    {
                        string port                     = deviceIP.Remove(0, deviceIP.Length - 4);
                        string connectDeviceCmd         = string.Format("{0}/adb -s {1} shell", ProcessUtils.LDPath, deviceIP);
                        string cmdPs                    = string.Format("ps");
                        string cmdExit                  = string.Format("exit");
                        DeviceOperation deviceOperation = new DeviceOperation();
                        deviceOperation
                        .SetCmd(connectDeviceCmd)
                        .SetCmd(cmdPs)
                        .SetCmd(cmdExit)
                        .Run2(id, out number);

                        switch (number)
                        {
                        case 0:
                            List <SystemConfig> model = bLL.GetSystemConfigList(id);
                            if (model.Count > 0)
                            {
                                model[0].state = 0;
                                bLL.UpdateSystemConfig(model[0]);
                            }
                            else
                            {
                                SystemConfig sc = new SystemConfig();
                                sc.uid          = id;
                                sc.state        = 0;
                                bLL.AddSystemConfig(sc);
                            }
                            break;

                        case 1:
                            model = bLL.GetSystemConfigList(id);
                            if (model.Count > 0)
                            {
                                model[0].state = 1;
                                bLL.UpdateSystemConfig(model[0]);
                            }
                            else
                            {
                                SystemConfig sc = new SystemConfig();
                                sc.uid          = id;
                                sc.state        = 0;
                                bLL.AddSystemConfig(sc);
                            }
                            break;
                        }
                        //1表示已启动了0表示为没启动com.facebook.katana;判断模拟器是否启动facebook应用,有返回没启动

                        if (number == 0)
                        {
                            #region 启动Facebook
                            if (_runningGroupIndex == -1)
                            {
                                MessageDialogManager.ShowDialogAsync(SystemLanguageManager.Instance.ResourceManager.GetString("Error_Please_Launch_A_Vm", SystemLanguageManager.Instance.CultureInfo));
                                return;
                            }
                            string packagename       = "com.facebook.katana";
                            List <Phonenum> listPhon = new PhonenumBLL().SelectPhoneNumber();

                            for (int i = 0; i < VmManager.Instance.Column; i++)
                            {
                                int vmIndex = VmManager.Instance.VmIndexArray[_runningGroupIndex, i];
                                if (vmIndex != -1)
                                {
                                    ProcessUtils.AdbOpenApps(vmIndex, packagename);
                                }
                            }
                            break;
                            #endregion
                        }
                    }

                    LoginInfo li = new LoginInfo();
                    li.index     = id;
                    li.port      = port2;
                    if (th == null || !th.IsAlive)
                    {
                        th = new Thread(new  ParameterizedThreadStart(AutomaticLogin));
                        th.IsBackground = true;
                        th.Start(li);
                    }
                }
            });
        }