private eI6Error processPreLogDone(string destMobile, string msg, Ix iAll) { if (iAll.TypeOfProcess == Ix.eTypeOfProcess.EmptyWakeUpTrigger) { // nothing else to do return(eI6Error.Success); } DateTime dtStart = DateTime.Now; eI6Error ret = eI6Error._notSet; _6WhatsAppProcess_RealData u = new _6WhatsAppProcess_RealData(destMobile, msg, s_WhatsAppProcessCounter++); u.MouseToPoint_UpdateExpectedPos(new Point(200, 200), -1, -1, iAll.iMouse); iAll.iDsp.FileLog_Info("Id: " + u.id.ToString() + " " + destMobile); iAll.iDsp.AddLine("Id: " + u.id.ToString()); iAll.iDsp.AddLine2(new DetailedData_ProcessingId(u.id)); iAll.iScreen.Debug_SetId(u.id, u.Msg_DestMobile); SpecificResult_SearchGlas _1GlasPos = null; Point _2TelLinePos; Point _4RightOfSmile; // Step 1 if (ret == eI6Error._notSet) { iAll.iDsp.FileLog_Debug("Step1 findSearchWindow and enter tel"); iAll.iDsp.AddLine("Step1 findSearchWindow and enter tel"); ret = GetScreenAndCheckLoop(new MyTimeControl(5000), 5000, iAll, 1, u, eI6Error.Step1Failed, delegate(int screenId, Ix ix, _6WhatsAppProcess_RealData data, ref bool increaseTimeoutOnce) { ix.iDsp.FileLog_Debug("Performing Step1..."); // delegate MyPic pic = ScreenGet(screenId, data); // 1) we search in the top left corner Size wholeScreenSize = pic.getDimenion(); Rectangle sa = new Rectangle(0, 0, wholeScreenSize.Width / 2, wholeScreenSize.Height / 2); MyPic sub = (MyPic)pic.getSubPic(sa.X, sa.Y, sa.Width, sa.Height); ScreenStoreSub(sub, screenId, data); // ((MyPic)sub.getClone()).Threshold_AlmostBlack().ToFile("1sub"); // 2) Call the Dll to search for the SearchGlas _1GlasPos = TextRecognitionLibrary.SpecificDetection.DetectSearchGlas(sub); // 3) Check the Dll´s result if (!_1GlasPos.XPos.IsEmpty) { // the x is there, so text was already entered ix.iDsp.FileLog_Debug("The x is there " + _1GlasPos.XPos.ToString()); ix.iDsp.AddLine("X detected, increasing timeout"); data.MouseToPoint_UpdateExpectedPos(_1GlasPos.XPos, screenId, 1, ix.iMouse); ix.iMouse.MouseClickAndWait(100, 300, ix); increaseTimeoutOnce = true; } else if (_1GlasPos.SearchGlasPos.IsEmpty) { // no Searchglas found ix.iDsp.FileLog_Debug("SearchGlasPos.IsEmpty"); } else if (_1GlasPos.SearchGlasInFactIsABack) { // the <- arror is there, so text was already entered, ix.iDsp.FileLog_Debug("<- detected at " + _1GlasPos.SearchGlasPos.ToString() + " / " + _1GlasPos.XPos.ToString()); data.MouseToPoint_UpdateExpectedPos(_1GlasPos.SearchGlasPos, screenId, 1, ix.iMouse); ix.iMouse.MouseClickAndWait(100, 300, ix); increaseTimeoutOnce = true; } else { // the SearchGlas is there, so click it ix.iDsp.FileLog_Debug("SearchGlas @ " + _1GlasPos.SearchGlasPos.ToString()); data.MouseToPoint_UpdateExpectedPos(_1GlasPos.SearchGlasPos, screenId, 2, ix.iMouse); ix.iDsp.Delay(300); Point pWhereText = _1GlasPos.SearchGlasPos; pWhereText.Offset(100, 0); ix.iDsp.FileLog_Debug("pWhereText.click(" + pWhereText.ToString() + ")"); data.MouseToPoint_UpdateExpectedPos(pWhereText, screenId, 3, ix.iMouse); ix.iMouse.MouseClickAndWait(100, 100, ix); // Now enter the tel no return(EnterTextAndCheckForMouseMove(data.Msg_DestMobile.Replace("+", ""), false, ix, data)); } ix.iDsp.FileLog_Debug("Early out: Reason above."); ix.iDsp.Delay(200); return(eI6Error._notSet); }); } if (ret == eI6Error._notSetBufOkSoFar) { ret = eI6Error._notSet; } // Step 2 if (ret == eI6Error._notSet) { iAll.iDsp.FileLog_Debug("Step2 findAccount and Click it"); iAll.iDsp.AddLine("Step2 findAccount and Click it"); ret = GetScreenAndCheckLoop(new MyTimeControl(5000), 5000, iAll, 2, u, eI6Error.Step2Failed, delegate(int screenId, Ix ix, _6WhatsAppProcess_RealData data, ref bool increaseTimeoutOnce) { ix.iDsp.FileLog_Debug("Performing Step2..."); // delegate MyPic pic = ScreenGet(screenId, data); // 1) we search in a limitted area Rectangle sa = new Rectangle(_1GlasPos.SearchGlasPos.X + 40, _1GlasPos.SearchGlasPos.Y + 10, 200, 250); MyPic sub = (MyPic)pic.getSubPic(sa.X, sa.Y, sa.Width, sa.Height); ScreenStoreSub(sub, screenId, data); // ((MyPic)sub.getClone()).Threshold_AlmostBlack().ToFile("4AlmostBlack"); // 2) Call the Dll to search for the text SpecificResult_Text rText = SpecificDetection.DetectText(sub); if (rText.TextPos.IsEmpty) { ix.iDsp.FileLog_Debug("Early out: TextPos.IsEmpty"); ix.iDsp.Delay(200); return(eI6Error._notSet); } ix.iDsp.FileLog_Info("Step2 tel text found: " + rText.Text); bool first12AreTheSame; if (!AreFirst12CharSame(data.Msg_DestMobile, rText.Text, out first12AreTheSame)) { ix.iDsp.FileLog_Debug("Early out: Text is wrong"); ix.iDsp.Delay(200); return(eI6Error._notSet); } if (first12AreTheSame) { ix.iDsp.FileLog_Debug("Text is not the same but we accept."); ix.iDsp.FileLog_Debug(data.Msg_DestMobile); ix.iDsp.FileLog_Debug(rText.Text); } _2TelLinePos = rText.TextPos; _2TelLinePos.Offset(sa.X, sa.Y); _2TelLinePos.Offset(0, 7); ix.iDsp.FileLog_Debug("Step2 TelLine detected at " + _2TelLinePos.ToString()); // 3) and click on top of the tel string data.MouseToPoint_UpdateExpectedPos(_2TelLinePos, screenId, 4, ix.iMouse); ix.iMouse.MouseClickAndWait(100, 100, ix); return(eI6Error._notSetBufOkSoFar); }); } if (ret == eI6Error._notSetBufOkSoFar) { ret = eI6Error._notSet; } // Step 3 if (ret == eI6Error._notSet) { iAll.iDsp.FileLog_Debug("Step3 verify account string top rigth position"); iAll.iDsp.AddLine("Step3 verify account string top rigth position"); ret = GetScreenAndCheckLoop(new MyTimeControl(5000), 5000, iAll, 3, u, eI6Error.Step3Failed, delegate(int screenId, Ix ix, _6WhatsAppProcess_RealData data, ref bool increaseTimeoutOnce) { ix.iDsp.FileLog_Debug("Performing Step3..."); // delegate MyPic pic = ScreenGet(screenId, data); // 1) we search in a limitted area //Rectangle sa = new Rectangle(400, 100, 280, 80); Rectangle sa = new Rectangle(475, 100, 200, 80); MyPic sub = (MyPic)pic.getSubPic(sa.X, sa.Y, sa.Width, sa.Height); ScreenStoreSub(sub, screenId, data); // 2) Call the Dll to search for the text SpecificResult_Text rText = SpecificDetection.DetectText(sub); if (rText.TextPos.IsEmpty) { ix.iDsp.FileLog_Debug("Early out: TextPos.IsEmpty"); ix.iDsp.Delay(200); return(eI6Error._notSet); } ix.iDsp.FileLog_Info("Step3 tel text fount: " + rText.Text); if (!rText.Text.Contains(data.Msg_DestMobile.Replace("zapi_", "").Replace("+", ""))) { ix.iDsp.FileLog_Debug("Early out: Text is wrong"); ix.iDsp.Delay(200); return(eI6Error._notSet); } return(eI6Error._notSetBufOkSoFar); }); } if (ret == eI6Error._notSetBufOkSoFar) { ret = eI6Error._notSet; } // Step 4 if ((ret == eI6Error._notSet) && (iAll.TypeOfProcess == Ix.eTypeOfProcess.TelNumberChecking)) { // we are done for tel checking ret = eI6Error.Success; } if (ret == eI6Error._notSet) { iAll.iDsp.FileLog_Debug("Step4 Find type-msg-here"); iAll.iDsp.AddLine("Step4 Find type-msg-here"); ret = GetScreenAndCheckLoop(new MyTimeControl(5000), 5000, iAll, 4, u, eI6Error.Step4Failed, delegate(int screenId, Ix ix, _6WhatsAppProcess_RealData data, ref bool increaseTimeoutOnce) { ix.iDsp.FileLog_Debug("Performing Step4..."); // delegate MyPic pic = ScreenGet(screenId, data); // 1) we serach in a specific area Size wholeScreenSize = pic.getDimenion(); // was {X = 0 Y = 568 Width = 1024 Height = 200} Rectangle sa = new Rectangle( 300, wholeScreenSize.Height - 100, wholeScreenSize.Width - 300, 100); MyPic sub = (MyPic)pic.getSubPic(sa.X, sa.Y, sa.Width, sa.Height); ScreenStoreSub(sub, screenId, data); // ((MyPic)sub.getClone()).Threshold_AlmostBlack().ToFile("8subAlmostBlac"); // 2) Call the Dll to search the simle and mic specificResult_SmileAndMic s = TextRecognitionLibrary.SpecificDetection.SpecificResult_SmileAndMic(sub); if (s.SmilePos.IsEmpty) { // no smile found ix.iDsp.FileLog_Debug("Early out: No smile"); return(eI6Error._notSet); } else if (s.MicPos.IsEmpty) { // we have a smile not no mic ==> rubbishtext is there. So delete it _4RightOfSmile = s.SmilePos; _4RightOfSmile.Offset(sa.X, sa.Y); _4RightOfSmile.Offset(300, 5); data.MouseToPoint_UpdateExpectedPos(_4RightOfSmile, screenId, 5, ix.iMouse); ix.iMouse.MouseClickAndWait(50, 50, ix); EnterTextAndCheckForMouseMove("\b\b\b\b\b\b\b\b\b", false, ix, data); ix.iDsp.FileLog_Debug("Early out: Rubbish text in chat box"); return(eI6Error._notSet); } // we have both, smile and mic _4RightOfSmile = s.SmilePos; _4RightOfSmile.Offset((s.MicPos.X - s.SmilePos.X) / 2, 0); _4RightOfSmile.Offset(sa.X, sa.Y); // 3) Set the mouse to the text box data.MouseToPoint_UpdateExpectedPos(_4RightOfSmile, screenId, 6, ix.iMouse); // 4) Click it ix.iMouse.MouseClickAndWait(50, 50, ix); // 5) And enter the text if (data.Msg_Msg.StartsWith("__NoSend")) { ix.iDsp.AddLine("__NoSend"); ix.iDsp.FileLog_Info("__NoSend"); } else { EnterTextAndCheckForMouseMove(data.Msg_Msg, true, ix, data); } return(eI6Error.Success); }); } // END, clean up TimeSpan duration = (DateTime.Now - dtStart); string strDurtion = duration.ToReadableString(); if (ret == eI6Error.Success) { // Success iAll.iDsp.Clear(); iAll.iDsp.AddLine("Done in " + strDurtion); iAll.iDsp.AddLine2(new DetailedData_LastGoodProcess(u.id, duration)); u.DumpImagesIfConfigured("NiceTray._6WhatsAppProcess_Real.DumpScreensOnSuccess", iAll); } else { // Problem iAll.iDsp.AddLine2(new DetailedData_LastBadProcess(u.id, duration)); u.DumpImagesIfConfigured("NiceTray._6WhatsAppProcess_Real.DumpScreensOnProblem", iAll); } iAll.iDsp.FileLog_Info( "_6WhatsAppProcess_Real.Process took " + strDurtion + " " + (ret == eI6Error.Success ? "Success" : ret.ToString()) ); return(ret); }
private eI6Error Process_NoLog(string destMobile, string msg, Ix iAll) { eI6Error ret = eI6Error._end; eI6Error eFirstInCheck = Child.Process(destMobile, msg, iAll); iAll.iDsp.FileLog_Debug(eFirstInCheck.ToString()); if (eFirstInCheck.IsGood()) { // Success ret = eFirstInCheck; } else if (eFirstInCheck.IsMayBeGood()) { // MayBe ret = eFirstInCheck; } else { // Bad iAll.iDsp.FileLog_Debug("1stCheck is Bad"); if (iAll.TypeOfProcess == Ix.eTypeOfProcess.Normal) { // normal prosessing ret = eFirstInCheck; } else { // tel number checking iAll.iDsp.FileLog_Info("1stCheck bad on TelNoChecking, checking KnowNumber1..."); eI6Error eKnown1 = Child.Process( "_6WhatsAppProcess_PreFoxStarter.KnowNumber1".GetConfig(), null, iAll); if (eKnown1.IsBad()) { // not even the know works, we are having a problem with Fox iAll.iDsp.FileLog_Debug("Not even the known1 works."); ret = eI6Error.FailedButNoLettingHostKnow_TelNotActive; } else if (eKnown1.IsMayBeGood()) { // this should never happen, it is a known number iAll.iDsp.FileLog_Error("How can a known1 return MayBe?"); ret = eI6Error.FailedButNoLettingHostKnow_TelNotActive; } else { // the known1 one worked iAll.iDsp.FileLog_Debug("Well, known1 worked. Checking KnowNumber2..."); eI6Error eKnown2 = Child.Process( "_6WhatsAppProcess_PreFoxStarter.KnowNumber2".GetConfig(), null, iAll); if (eKnown2.IsBad()) { // not even the know works, we are having a problem with Fox iAll.iDsp.FileLog_Debug("Not even the known2 works."); ret = eI6Error.FailedButNoLettingHostKnow_TelNotActive; } else if (eKnown2.IsMayBeGood()) { // this should never happen, it is a known number iAll.iDsp.FileLog_Error("How can a known2 return MayBe?"); ret = eI6Error.FailedButNoLettingHostKnow_TelNotActive; } else { // the known2 one worked iAll.iDsp.FileLog_Debug("Well, known2 worked too. Checking dest number again..."); eI6Error eSecondInCheck = Child.Process(destMobile, msg, iAll); if (eSecondInCheck.IsGood()) { // ok, now it worked iAll.iDsp.FileLog_Debug("Now the inNumber worked too."); ret = eSecondInCheck; } else if (eSecondInCheck.IsMayBeGood()) { // this cant really happen iAll.iDsp.FileLog_Debug("inNumber returned mayBe the second time."); ret = eSecondInCheck; } else { // it all works but this number, so fail forever iAll.iDsp.FileLog_Info("We fail this number forever."); ret = eSecondInCheck; } } } } } return(ret); }
void internalThread() { m_2iInfoDisplay.FileLog_Debug("internalThread start"); m_2iInfoDisplay.FileLog_Debug(Assembly.GetAssembly(typeof(IMyLog)).WriteAssemblyVersion()); m_2iInfoDisplay.ReturnWhenReady(); Ix iAll = new Ix(m_2iInfoDisplay, m_4Screen, m_5Mouse, m_6Process, m_8Updater, new C9_CPUSlowdown()); iAll.iSlowdown.Slowdown(iAll); processEmptyWakeUpTrigger(iAll); while (m_wantToStop.WaitOne(10, false) == false) { try { iAll.iSlowdown.Slowdown(iAll); m_2iInfoDisplay.LoopStart(); m_3iGetData.ExchangeDataWithServer(m_2iInfoDisplay, m_6Process); List <ASPTrayBase> serverFiles = m_3iGetData.GetServerFiles(iAll); if (serverFiles.Count == 0) { processEmptyWakeUpTrigger(iAll); } else { foreach (ASPTrayBase f1 in serverFiles) { m_2iInfoDisplay.FileLog_Info("".PadRight(50, '*')); m_2iInfoDisplay.FileLog_Info("processing start : " + f1.GetFileName()); iAll.iSlowdown.Slowdown(iAll); ASPTrayBase.eASPtrayType f1e = f1.GetEnumType(); switch (f1e) { case ASPTrayBase.eASPtrayType.ScreenShotRequest: { Data_Net__02ScreenshotRequest _02 = (Data_Net__02ScreenshotRequest)f1; m_2iInfoDisplay.FileLog_Info("processing screenshot start: " + _02.MsgTicks.ToString()); Bitmap bAll = ImageCapture.GetAll(); m_3iGetData.AddResultFile( new Data_Net__03ScreenshotResult( bAll.BmpToB64_Png(), _02.GetFileName())); m_2iInfoDisplay.FileLog_Info("processing done screenshot: " + _02.MsgTicks.ToString()); } break; case ASPTrayBase.eASPtrayType.NormalMessage: { Data_Net__00NormalMessage _00 = (Data_Net__00NormalMessage)f1; m_2iInfoDisplay.AddLine(_00.DestMobile); m_2iInfoDisplay.FileLog_Info(_00.DestMobile); if (_00.FailedCounter != 0) { m_2iInfoDisplay.FileLog_Info(String.Format("FailedCounter: {0} / {1}", _00.FailedCounter, _00.DisposeAfterNFailed)); } m_2iInfoDisplay.FileLog_Info("MSG: " + _00.Msg.MsgForLogFile()); int processId; bool use; m_3iGetData.Debug_GetProcessIdOfFile(f1, out processId, out use); if (use) { m_6Process.Debug_AmendProcessId(processId); } iAll.TypeOfProcess = Ix.eTypeOfProcess.Normal; eI6Error whatsAppRes = m_6Process.Process( _00.DestMobile, _00.Msg, iAll); m_2iInfoDisplay.AddLine(whatsAppRes.ToString()); switch (whatsAppRes) { case eI6Error.Success: m_3iGetData.AddResultFile(new Data_Net__01NormalMessageResult( _00.GetFileName(), true)); m_2iInfoDisplay.FileLog_Debug("processing done: " + _00.UniqueId()); break; case eI6Error.FailedButNoLettingHostKnow_TelNotActive: m_2iInfoDisplay.AddLine("No Tel in Android yet"); m_2iInfoDisplay.FileLog_Info("No Tel in Android yet"); break; default: // failed m_3iGetData.AddResultFile(new Data_Net__01NormalMessageResult( _00.GetFileName(), false)); m_2iInfoDisplay.FileLog_Debug("processing failed (interaction): " + _00.UniqueId() + " " + whatsAppRes.ToString()); break; } } break; case ASPTrayBase.eASPtrayType.CheckTelNumbers: { Data_Net__04CheckTelNumbers _04 = (Data_Net__04CheckTelNumbers)f1; m_2iInfoDisplay.AddLine("CheckTelNumbers:" + _04.GetFileName()); MobileNoHandler handleOk = new MobileNoHandler(_04.TelListChecked); MobileNoHandler handleRetryPlease = new MobileNoHandler(""); MobileNoHandler handleNotWorking = new MobileNoHandler(""); foreach (string toBeCheckedNoZap in new MobileNoHandler(_04.TelList).MobileNumberArray) { string toBeChecked = toBeCheckedNoZap.Zapi_Add(); m_2iInfoDisplay.AddLine("Checking " + toBeChecked); m_2iInfoDisplay.FileLog_Info("Checking " + toBeChecked); int processId; bool use; m_3iGetData.Debug_GetProcessIdOfFile(f1, out processId, out use); if (use) { m_6Process.Debug_AmendProcessId(processId); } iAll.TypeOfProcess = Ix.eTypeOfProcess.TelNumberChecking; eI6Error whatsAppRes = m_6Process.Process( toBeChecked, null, iAll); m_2iInfoDisplay.AddLine(whatsAppRes.ToString()); switch (whatsAppRes) { case eI6Error.Success: handleOk.Add(toBeCheckedNoZap); break; case eI6Error.FailedButNoLettingHostKnow_TelNotActive: handleRetryPlease.Add(toBeCheckedNoZap); break; default: // failed handleNotWorking.Add(toBeCheckedNoZap); break; } } m_3iGetData.AddResultFile( new Data_Net__05CheckTelNumbersResult( _04.GetFileName(), handleOk.getVal, handleRetryPlease.getVal, handleNotWorking.getVal)); } break; default: m_2iInfoDisplay.AddLine("UNKOWN FILE TYPE"); m_2iInfoDisplay.FileLog_Error("UNKOWN FILE TYPE"); break; } } } // delay if (m_3iGetData.DoWeHaveDataToSend()) { // we have data to send, so dont wait too long m_2iInfoDisplay.Delay(500); } else { m_2iInfoDisplay.Delay(2 * 1000); } } catch (SystemException se) { m_2iInfoDisplay.AddLine("SystemException"); m_2iInfoDisplay.AddLine(se.Message); m_2iInfoDisplay.AddLine(se.ToString()); if (!se.ToString().Contains("System.Net.WebException: The operation has timed out")) { m_2iInfoDisplay.FileLog_Error(se.Message + " - " + se.ToString()); } m_3iGetData.Reset_toASP(); m_2iInfoDisplay.Delay(5 * 1000); } } }