コード例 #1
0
        private static void HandleInfo(VerificationCode verificationCode)
        {
            Console.WriteLine($"手机号:{verificationCode.PhoneNum}, 验证码:{verificationCode.Code}");

            try
            {
                var obj = new JObject()
                {
                    { "tasktype", (int)TaskType.SendVerificationCode }, { "txtmsg", verificationCode.Code }
                };
                var list = new JArray();
                obj.Add("list", list);

                int vmIndex = VmManager.Instance.VmModels.Values.FirstOrDefault(vm => vm.PhoneNumber == verificationCode.PhoneNum).Index;

                TaskSch taskSch = new TaskSch()
                {
                    Bodys       = obj.ToString(Formatting.None),
                    MobileIndex = vmIndex,
                    TypeId      = (int)TaskType.SendVerificationCode,
                    Status      = "waiting",
                };

                TasksBLL.CreateTask(taskSch);

                ConfigVals.IsRunning = 1;
                TasksSchedule tasks = new TasksSchedule();
                tasks.ProessTask();
            }
            catch (Exception ex)
            {
                LogUtils.Error($"{ex}");
            }
        }
コード例 #2
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;
        }
コード例 #3
0
        /// <summary>
        /// 接收客户端发送的消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void server_ClientDataReceived(object sender, TcpClientDataReceivedEventArgs e)
        {
            SockMsgJson actMsg = JsonBufHelper.BytesToObject <SockMsgJson>(e.Data, e.DataOffset, e.DataLength);

            if (actMsg == null)
            {
                return;
            }

            TasksSchedule tasksch = new TasksSchedule();

            Console.WriteLine("收到模拟器消息……");
            Console.WriteLine(actMsg.action + ":" + actMsg.tasknum + ":" + actMsg.context);
            switch (actMsg.action)
            {
            case SocketCase.Init:
                string imei        = actMsg.context;
                int    mobileIndex = VmManager.Instance.VmModels.Values.FirstOrDefault(vm => vm.Imei == imei).Index;
                AllConnectionKey.FirstOrDefault(p => p.Value.SessionKey == e.Session.SessionKey).Value.MobileIndex = mobileIndex;
                LogUtils.Information(string.Format("模拟器{0}绑定成功,IMEI{1}:", mobileIndex, imei));
                //writeLogs(string.Format("模拟器{0}绑定成功,IMEI{1}:", mobileIndex, imei));
                break;

            case SocketCase.ClientTask:          //更新任务状态
                int    tasknum = actMsg.tasknum;
                string status  = actMsg.context; //任务状态
                if (status != "")
                {
                    tasksch.UpdateTaskResval(tasknum, status);
                }
                break;

            case SocketCase.ClientPhone:                   //更新手机号码状态
                int phone   = actMsg.tasknum;
                int respone = Int32.Parse(actMsg.context); //响应状态
                tasksch.UpdatePhoneStatus(phone, respone);
                break;

            case SocketCase.ClientInitPhone:

                string[] datas     = actMsg.context.Split(new char[] { '|' });
                string   phoneImei = datas[0];
                string   phoneNum  = datas[1];

                var vmModel = VmManager.Instance.VmModels.Values.FirstOrDefault(vm => vm.Imei == phoneImei);
                if (vmModel != null)
                {
                    vmModel.PhoneNumber = phoneNum;
                }

                break;
            }
        }
コード例 #4
0
ファイル: TimedTaskManager.cs プロジェクト: wuscier/qunkong
        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;
        }
コード例 #5
0
 public async Task ProessTask()
 {
     ConfigVals.IsRunning = 1;
     await TasksSchedule.ProessTask();
 }
コード例 #6
0
 /// <summary>
 /// 启动已提交任务
 /// </summary>
 public async Task ProessTask()
 {
     ConfigVals.IsRunning = 1;
     //TasksSchedule tasks = new TasksSchedule();
     await TasksSchedule.ProessTask();
 }