Ejemplo n.º 1
0
        public static void UpdateGonews(string deviceID, Bitmap Updatecapnhat3gach, Bitmap Updatecapnhattatca, Bitmap Updatekhongcobancapnhatnao)
        {
            KAutoHelper.ADBHelper.Tap(deviceID, 60, 180);
            Common.DelayMiliSecond(500);
            KAutoHelper.ADBHelper.Tap(deviceID, 290, 320);
            Common.DelayMiliSecond(500);
            var find3gach = WaitForFindOneBitmap(deviceID, Updatecapnhat3gach, 10, 1);

            if ((find3gach.X + find3gach.Y) == 0)
            {
                GhiLog.Write(deviceID, $"Update --- Không thấy buttom 3 gạch, tap vào màn hình");
                KAutoHelper.ADBHelper.Tap(deviceID, 76, 78);
            }
            else
            {
                GhiLog.Write(deviceID, $"Update --- Tìm thấy buttom 3 gạch, tap vào màn hình");
                KAutoHelper.ADBHelper.Tap(deviceID, find3gach.X, find3gach.Y);
            }
            Common.DelayMiliSecond(200);
            KAutoHelper.ADBHelper.Tap(deviceID, 130, 170);
            GhiLog.Write(deviceID, $"Update --- tìm cap nhat tat cả hoặc không cớ cập nhật nào");
            var find2Bitmap = WaitForFindTwoBitmap(deviceID, Updatecapnhattatca, Updatekhongcobancapnhatnao, 10, 1);

            if (find2Bitmap.sttBitmap == 0)
            {
                GhiLog.Write(deviceID, $"Update --- Lỗi............. update không thành công kiểm tra lại");
            }
            else if (find2Bitmap.sttBitmap == 1)
            {
                GhiLog.Write(deviceID, $"Update --- tìm thấy button cập nhật tất cả");
                KAutoHelper.ADBHelper.Tap(deviceID, find2Bitmap.X, find2Bitmap.Y);
                var find = WaitForFindOneBitmap(deviceID, Updatekhongcobancapnhatnao, 20, 2);
                if (find.X + find.Y != 0)
                {
                    GhiLog.Write(deviceID, $"Update --- tìm thấy button không có bản cập nhật nào --- cập nhật thành công");
                }
                else
                {
                    GhiLog.Write(deviceID, $"Update --- Lỗi............. update không thành công kiểm tra lại");
                }
            }
            else
            {
                GhiLog.Write(deviceID, $"Update --- tìm thấy button không có bản cập nhật nào --- cập nhật thành công");
            }
        }
Ejemplo n.º 2
0
        public void Chay()
        {
            var taiKhoanSapChay = GhiLog.GetAccount(listDevicesRunning, pathListAccount);

            if (taiKhoanSapChay.deviceId == "")
            {
                return;
            }
            //mở gia lap lên và chờ quét thiết bị
            GhiLog.Write(taiKhoanSapChay.deviceId, $"tài khoản chạy --- {taiKhoanSapChay.nameShotcut} --- {taiKhoanSapChay.deviceId}");
            var myProcess = new Process
            {
                StartInfo = { FileName = $"{Environment.CurrentDirectory}\\fileshotcut\\{taiKhoanSapChay.nameShotcut}" }
            };

            myProcess.Start();
            Auto(taiKhoanSapChay.deviceId, myProcess);
        }
Ejemplo n.º 3
0
        // return true nếu click được
        private bool clickNew(string deviceID)
        {
            GhiLog.Write(deviceID, $"Đi tìm bài báo mới và click nó");
            var screen = KAutoHelper.ADBHelper.ScreenShoot(deviceID);

            lock (TRUOC_BMP)
            {
                GhiLog.Write(deviceID, $"Đang khóa ảnh trước của bài báo");
                var truocPoint = KAutoHelper.ImageScanOpenCV.FindOutPoint(screen, TRUOC_BMP);
                if (truocPoint != null)
                {
                    KAutoHelper.ADBHelper.Tap(deviceID, truocPoint.Value.X + 150, truocPoint.Value.Y);
                    return(true);
                }
            }
            GhiLog.Write(deviceID, $"Không tìm thấy bài báo mới nào");
            return(false);
        }
Ejemplo n.º 4
0
        //return true là đã tìm thấy và click được
        private bool findNewAndClick(string deviceID, ref int solanlap, ref int demsolanchay, Process processName)
        {
            int i = 0;

            while (i < 10)
            {
                if (clickNew(deviceID))
                {
                    GhiLog.Write(deviceID, $"Tìm thấy bài báo mới tiếp theo ---- dọc bài báo mới");
                    solanlap = 0;
                    demsolanchay++;
                    return(true);
                }
                HanhDong.KeoXuongFind(deviceID);
                HanhDong.KeoXuongFind(deviceID);
                HanhDong.KeoXuongFind(deviceID);
                HanhDong.KeoXuongFind(deviceID);
                HanhDong.KeoXuongFind(deviceID);
                HanhDong.KeoXuongFind(deviceID);
                i++;
            }
            while (i < 12)
            {
                if (clickNew(deviceID))
                {
                    GhiLog.Write(deviceID, $"Tìm thấy bài báo mới tiếp theo ---- dọc bài báo mới");
                    solanlap = 0;
                    demsolanchay++;
                    return(true);
                }
                HanhDong.KeoLenFind(deviceID);
                HanhDong.KeoLenFind(deviceID);
                HanhDong.KeoLenFind(deviceID);
                i++;
            }
            // tắt app gonews và click gonews chạy lại
            GhiLog.Write(deviceID, $"Không tìn thấy bài báo mới tắt gải lập đi chạy lại ------ ");
            GhiLog.GhiFileList(deviceID, pathListAccount, "notfinish", true);
            TatGiaLapvaChayLai(deviceID, processName);
            return(false);
        }
Ejemplo n.º 5
0
        private void Auto(string deviceID, Process processName)
        {
            listDevicesRunning.Add(deviceID);
            GhiLog.Write(deviceID, $"danh sách thiết bị đang chạy {listDevicesRunning.Count()}");
            Thread t = new Thread(() =>
            {
                #region tìm device
                // tìm devices
                List <string> decices = KAutoHelper.ADBHelper.GetDevices();
                var soLanTimDevice    = 0;
                while (soLanTimDevice < 30 && !decices.Contains(deviceID))
                {
                    decices = KAutoHelper.ADBHelper.GetDevices();
                    soLanTimDevice++;
                    Common.Delay(2);
                    GhiLog.Write(deviceID, $"Tìm thiết bị lần {soLanTimDevice}");
                }
                if (soLanTimDevice >= 30)
                {
                    GhiLog.Write(deviceID, $"Tìm thiết bị thất bại ---- đóng chạy lại");
                    GhiLog.GhiFileList(deviceID, pathListAccount, "notfinish", true);
                    TatGiaLapvaChayLai(deviceID, processName);
                    return;
                }
                #endregion

                #region tim gonews sau do click
                var findGonews = HanhDong.WaitForFindOneBitmap(deviceID, GO_NEWS_BMP, 10, 2);
                if (findGonews.X == findGonews.Y && findGonews.Y == 0)
                {
                    HanhDong.XoaTatCa(deviceID);
                    GhiLog.Write(deviceID, $"Tìm app Gonews thất bại --- Bắt đầu tìm kiếm ảnh đóng giao diện người dùng");
                    var fileDongGiaoDienNgDung = HanhDong.WaitForFindOneBitmap(deviceID, DONG_GIAO_DIEN_NGUOI_DUNG_BMP, 1, 1);
                    if (fileDongGiaoDienNgDung.X == fileDongGiaoDienNgDung.Y && fileDongGiaoDienNgDung.Y == 0)
                    {
                        GhiLog.Write(deviceID, $"Không thấy ảnh đóng giao diện người dùng --- bỏ qua");
                    }
                    else
                    {
                        GhiLog.Write(deviceID, $"Tìm thấy ảnh đóng giao diện người dùng --- click đóng");
                        KAutoHelper.ADBHelper.Tap(deviceID, fileDongGiaoDienNgDung.X, fileDongGiaoDienNgDung.Y);
                    }
                    GhiLog.Write(deviceID, $"Tìm app gonews lần nữa");
                    findGonews = HanhDong.WaitForFindOneBitmap(deviceID, GO_NEWS_BMP, 10, 2);
                    if (findGonews.X + findGonews.Y == 0)
                    {
                        GhiLog.Write(deviceID, $"sau khi cài đặt vẫn không thấy gonews --- kiểm tra lại appgonews --- update bản mới nhất --- bỏ qua thiết bị này");
                        GhiLog.GhiFileList(deviceID, pathListAccount, "notfinish", true);
                        TatGiaLapvaChayLai(deviceID, processName);
                        return;
                    }
                }

                #region update gonews bản mới nhất
                bool?isCheckUpdateversion = false;
                this.checkUpdateVersion.Dispatcher.Invoke(() =>
                {
                    isCheckUpdateversion = checkUpdateVersion.IsChecked;
                });


                this.checkGhiLog.Dispatcher.Invoke(() =>
                {
                    ischeckGhiLog = checkGhiLog.IsChecked;
                });

                if (isCheckUpdateversion == true)
                {
                    GhiLog.Write(deviceID, $"Yêu cầu update gonews bản mới nhất");
                    HanhDong.UpdateGonews(deviceID, UPDATE3GACH_BMP, UPDATECAPNHATATCA_BMP, UPDATEKHONGCOBANCAPNHATNAO_BMP);
                    HanhDong.XoaTatCa(deviceID);
                }

                #endregion

                KAutoHelper.ADBHelper.Tap(deviceID, findGonews.X, findGonews.Y);
                GhiLog.Write(deviceID, $"Tìm thấy app Gonews click vào -- đợi lòa gonews");
                #endregion

                GhiLog.Write(deviceID, $"Đi điểm danh");
                DiemDanh(deviceID);
                GhiLog.Write(deviceID, $"điểm danh xong");
                GOTO_MO_LAI_GO_NEW:
                int demluottimbao = 0;
                while (!clickNew(deviceID) && demluottimbao < 30)
                {
                    demluottimbao++;
                    Common.Delay(2);
                }
                if (demluottimbao >= 20)
                {
                    #region Kiểm tra gonews có bị treo app haytự đóng ứng dụng không nếu có đóng ứng dụng bật lại
                    var timtreoapp = HanhDong.WaitForFindTwoBitmap(deviceID, DONG_GIAO_DIEN_NGUOI_DUNG_BMP, GO_NEWS_BMP, 1, 1);
                    if (timtreoapp.sttBitmap == 0)
                    {
                        // không tìm thấy bỏ qua
                    }
                    else if (timtreoapp.sttBitmap == 1)
                    {
                        KAutoHelper.ADBHelper.Tap(deviceID, timtreoapp.X, timtreoapp.Y);
                        if (ClickAppGonews(deviceID))
                        {
                            goto GOTO_MO_LAI_GO_NEW;
                        }
                    }
                    else
                    {
                        if (ClickAppGonews(deviceID))
                        {
                            goto GOTO_MO_LAI_GO_NEW;
                        }
                    }
                    #endregion

                    GhiLog.Write(deviceID, $"Không tìm thấy bài viết sau 30 lần -- 2s/lần, xóa đi chạy lai");
                    GhiLog.GhiFileList(deviceID, pathListAccount, "notfinish", true);
                    TatGiaLapvaChayLai(deviceID, processName);
                    return;
                }
                HanhDong.TangCochu(deviceID);
                int solanlap       = 0;
                var solanhoanthanh = 0;
                while (true)
                {
                    // tắt app
                    this.Dispatcher.Invoke(() =>
                    {
                        if (checkTatApp.IsChecked == true && timeoffApp.Value < DateTime.Now)
                        {
                            TatApp.HenGioTatApp();
                        }
                    });

                    if (isStop)
                    {
                        return;
                    }

                    if (solanhoanthanh >= 1)
                    {
                        int solandachay = GhiLog.GhiFileList(deviceID, pathListAccount); //ghifile

                        int soJobMaxTrongNgay = 300;
                        this.soJobTrongNgay.Dispatcher.Invoke(() =>
                        {
                            soJobMaxTrongNgay = Convert.ToInt32(soJobTrongNgay.Text);
                        });

                        if (solandachay >= soJobMaxTrongNgay)
                        {
                            // ddax max so luong ngay
                            GhiLog.Write(deviceID, $"Hoàn thành số job của {deviceID} --- {solandachay} đã chạy hôm nay");
                            GhiLog.GhiFileList(deviceID, pathListAccount, "finish"); //ghifile
                            TatGiaLapvaChayLai(deviceID, processName);
                            return;
                        }
                    }


                    GhiLog.Write(deviceID, $"đọc bài báo 4 lần");
                    HanhDong.readNew(deviceID);  //   đọc bài báo 4 lần
                    HanhDong.readNew2(deviceID); //   đọc bài báo 4 lần
                    HanhDong.readNew2(deviceID); //   đọc bài báo 4 lần
                    HanhDong.readNew4(deviceID); //   đọc bài báo 4 lần
                    var screen2 = KAutoHelper.ADBHelper.ScreenShoot(deviceID);

                    var bandadocbainayPoint = KAutoHelper.ImageScanOpenCV.FindOutPoint(screen2, BAN_DA_DOC_BAI_NAY_BMP);
                    if (bandadocbainayPoint == null)
                    {
                        // nếu chạy 4 lần trên chưa tìm thấy thì chạy thêm lượt nữa
                        GhiLog.Write(deviceID, $"Đọc thêm lần 5");
                        HanhDong.readNew3(deviceID);
                        screen2             = KAutoHelper.ADBHelper.ScreenShoot(deviceID);
                        bandadocbainayPoint = KAutoHelper.ImageScanOpenCV.FindOutPoint(screen2, BAN_DA_DOC_BAI_NAY_BMP);
                    }
                    if (bandadocbainayPoint == null)
                    {
                        // nếu chạy 5 lần trên chưa tìm thấy thì chạy thêm lượt nữa
                        GhiLog.Write(deviceID, $"Đọc thêm lần 6");
                        HanhDong.readNew3(deviceID);
                        screen2             = KAutoHelper.ADBHelper.ScreenShoot(deviceID);
                        bandadocbainayPoint = KAutoHelper.ImageScanOpenCV.FindOutPoint(screen2, BAN_DA_DOC_BAI_NAY_BMP);
                    }

                    GhiLog.Write(deviceID, $"---------------solanlap -------------{solanlap}");
                    if (bandadocbainayPoint != null || solanlap > 1)
                    {
                        if (solanlap > 1)
                        {
                            #region Kiểm tra gonews có bị treo app haytự đóng ứng dụng không nếu có đóng ứng dụng bật lại
                            var timtreoapp = HanhDong.WaitForFindTwoBitmap(deviceID, DONG_GIAO_DIEN_NGUOI_DUNG_BMP, GO_NEWS_BMP, 1, 1);
                            if (timtreoapp.sttBitmap == 0)
                            {
                                // không tìm thấy bỏ qua
                            }
                            else if (timtreoapp.sttBitmap == 1)
                            {
                                KAutoHelper.ADBHelper.Tap(deviceID, timtreoapp.X, timtreoapp.Y);
                                if (ClickAppGonews(deviceID))
                                {
                                    Common.Delay(7);
                                    goto GOTO_TIMBAIBAOVACLICKNO;
                                }
                            }
                            else
                            {
                                if (ClickAppGonews(deviceID))
                                {
                                    Common.Delay(7);
                                    goto GOTO_TIMBAIBAOVACLICKNO;
                                }
                            }
                            #endregion


                            #region check treo hoàn toàn giả lập không thao tác được gì
                            // check treo app
                            // trả về true là bị treo
                            GhiLog.Write(deviceID, $"Kiểm tra xem app có bị treo không");
                            if (checkTreoApp(deviceID))
                            {
                                // nếu treo tắt thiết bị chạy lại
                                GhiLog.Write(deviceID, $"App bị treo, xóa đi chạy lai");
                                Task b = new Task(() => { Common.Delay(30); Chay(); });
                                b.Start();
                                processName.Kill();
                                listDevicesRunning.Remove(deviceID);
                                return;
                            }
                            #endregion
                        }
                        GOTO_TIMBAIBAOVACLICKNO:
                        if (!findNewAndClick(deviceID, ref solanlap, ref solanhoanthanh, processName))
                        {
                            return;
                        }
                        GhiLog.Write(deviceID, $"Tìm thâí bài báo sau {solanlap} số lần lặp");
                    }
                    solanlap++;
                }
            });

            t.SetApartmentState(ApartmentState.STA);
            t.Start();
            Common.Delay(1);
        }
Ejemplo n.º 6
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     GhiLog.ResetFileLog(pathListAccount);
     DeleteFileGhilog($"{Environment.CurrentDirectory}\\{pathGhilog}");
 }
Ejemplo n.º 7
0
 private void Cap_nhat_danh_sach_thiet_bi(object sender, RoutedEventArgs e)
 {
     GhiLog.Cap_nhat_danh_sach_thiet_bi(pathListAccount, pathShotcut);
 }