示例#1
0
        public List <ASPTrayBase> GetServerFiles(Ix ix)
        {
            if (mFirstRound)
            {
                mFirstRound = false;

                if ("_3GetData.DebugHardcoded.WithDelay".IsConfiguredAndTRUE())
                {
                    ix.iDsp.AddLine("_3GetData_DebugHardcoded: Waiting 30 sec, Bring Firefox to front.");
                    ix.iDsp.Delay(10000);
                    ix.iDsp.AddLine("10 sec...");
                    ix.iDsp.Delay(10000);
                    ix.iDsp.AddLine("_3GetData_DebugHardcoded: Waiting 30 sec, Bring Firefox to front.");
                    ix.iDsp.AddLine("20 sec...");
                }
            }
            else
            {
                throw new ArgumentException("not mFirstRound");
            }

            List <ASPTrayBase> ret = new List <ASPTrayBase>();

            foreach (var e1 in toProcess.Values)
            {
                if (ret.Count > 5)
                {
                    break;
                }
                ASPTrayBase f1 = e1.To_MessageFile();
                ret.Add(f1);
            }
            return(ret);
        }
示例#2
0
 public eI6Error Process(string destMobile, string msg, Ix iAll)
 {
     using (var x = new LogPreText("Real", iAll))
     {
         return(processPreLogDone(destMobile, msg, iAll));
     }
 }
示例#3
0
        public void DumpImages(Ix ix)
        {
            foreach (var i1 in ImageList)
            {
                //IdAndStep s = new IdAndStep(i1.Key);
                //string fileName = String.Format("{0}_St{1}{2}_zapi_{3}.bmp",
                //    s.ProcessId,
                //    s.ScreenId,
                //    s.IsSub ? "Sub" : "",
                //    Msg_DestMobile.Replace("zapi_", "").Replace("+", ""));

                ix.iDsp.FileLog_Debug("Dumping file " + i1.Value.fileName);
                if (i1.Value.isSub)
                {
                    i1.Value.thePic.myPic.getClone().ToFile(i1.Value.fileName);
                }
                else
                {
                    MemoryStream ms = i1.Value.thePic.origStream;
                    using (FileStream fs = new FileStream(i1.Value.fileName + ".bmp", FileMode.Create))
                    {
                        ms.WriteTo(fs);
                    }
                    i1.Value.thePic.origStream.Seek(0, SeekOrigin.Begin);
                }
            }
        }
示例#4
0
 public override eI6Error Process(string destMobile, string msg, Ix iAll)
 {
     using (var x = new LogPreText("FoxS", iAll))
     {
         eI6Error stateThisTime = Process_NoLog(destMobile, msg, iAll);
         return(stateThisTime);
     }
 }
示例#5
0
 public void MouseClickAndWait(int delayPre, int delayPos, Ix ix)
 {
     ix.iSlowdown.Slowdown(ix);
     ix.iDsp.Delay(delayPre);
     ix.iDsp.FileLog_Debug(String.Format("MouseClick @ {0}", CurrentMousePos()));
     win32DLL_native.DoMouseClick();
     ix.iSlowdown.Slowdown(ix);
     ix.iDsp.Delay(delayPos);
 }
示例#6
0
        public LogPreText(string preText, Ix ix)
        {
            PreText = preText + ": ";
            Ix      = ix;

            ConstOld = ix.iDsp.FileLog_GetPreText();
            ConstNew = /*ConstOld + */ PreText;
            ix.iDsp.FileLog_SetPreText(ConstNew);
        }
示例#7
0
 public void DumpImagesIfConfigured(string ConfigId, Ix ix)
 {
     try
     {
         if (ConfigId.IsConfiguredAndTRUE())
         {
             DumpImages(ix);
         }
     }
     catch (Exception) { }
 }
示例#8
0
 private void processEmptyWakeUpTrigger(Ix iAll)//todo uncomment this produces a crash when something is received from the host
 {
     if ("_1Starter.UseEmptyWakeUpTrigger".IsConfiguredAndTRUE())
     {
         m_2iInfoDisplay.AddLine("processEmptyWakeUpTrigger");
         m_2iInfoDisplay.FileLog_Info("processEmptyWakeUpTrigger");
         iAll.TypeOfProcess = Ix.eTypeOfProcess.EmptyWakeUpTrigger;
         eI6Error whatsAppRes = m_6Process.Process(
             "", //_00.DestMobile,
             "", //_00.Msg,
             iAll);
         m_2iInfoDisplay.AddLine("processEmptyWakeUpTrigger Done");
     }
 }
示例#9
0
 private eI6Error GetAndSaveScreen(Ix ix, int screenId, _6WhatsAppProcess_RealData data)
 {
     try
     {
         ix.iDsp.FileLog_Debug("GetAndSaveScreen " + screenId.ToString());
         ScreenStore(ix.iScreen.GetScreenShot(screenId), screenId, data);
     }
     catch (SystemException ex)
     {
         ix.iDsp.FileLog_Error("GetScreenShot failed");
         ix.iDsp.AddLine("GetScreenShot failed");
         return(eI6Error.ScreenCaptureFailed);
     }
     return(eI6Error._notSet);
 }
示例#10
0
        private eI6Error GetScreenAndCheckLoop(
            MyTimeControl timeControl,
            int timeoutMs_,
            Ix ix,
            int screenId,
            _6WhatsAppProcess_RealData data,
            eI6Error onFailErrorCode,
            dCheck check)
        {
            ix.TimeControl = timeControl;
            bool     timeoutOnceIncreased = false;
            eI6Error err = eI6Error._notSet;

            ix.iScreen.Debug_ResetRetryCounter();
            while (err == eI6Error._notSet)
            {
                if (err == eI6Error._notSet)
                {
                    err = CheckMouseMoved(ix, data);
                }
                if (err == eI6Error._notSet)
                {
                    err = GetAndSaveScreen(ix, screenId, data);
                }
                if (err == eI6Error._notSet)
                {
                    bool increaseTimeoutOnce = false;
                    err = check(screenId, ix, data, ref increaseTimeoutOnce);
                    if ((!timeoutOnceIncreased) && (increaseTimeoutOnce))
                    {
                        timeoutOnceIncreased = true;
                        timeControl.AddSeconds(10);
                    }
                }
                if (err == eI6Error._notSet)
                {
                    err = CheckMouseMoved(ix, data);
                }
                if (err == eI6Error._notSet)
                {
                    if (timeControl.TimedOut)
                    {
                        return(onFailErrorCode);
                    }
                }
            }
            return(err);
        }
示例#11
0
        public void Slowdown(Ix iAll)
        {
            if (cpuCounter != null)
            {
                var cur = getCurrentCpuUsage();
                while (cur > maxCou)
                {
                    iAll.iDsp.FileLog_Debug($"Slowdown: {cur} > {maxCou}, Sleep({sleepTime})");

                    iAll.TimeControl?.AddMilliSeconds(sleepTime);
                    System.Threading.Thread.Sleep(sleepTime);
                    // next
                    cur = getCurrentCpuUsage();
                }
            }
        }
示例#12
0
 private eI6Error CheckMouseMoved(Ix ix, _6WhatsAppProcess_RealData data)
 {
     try
     {
         if (ix.iMouse.CurrentMousePos() == data.ExpectedMousePos)
         {
             // ok
             return(eI6Error._notSet);
         }
     }
     catch (SystemException)
     {
     }
     ix.iDsp.AddLine("Mouse moved");
     ix.iDsp.FileLog_Info("Mouse moved");
     return(eI6Error.MouseMoved);
 }
示例#13
0
        TimeSpan CheckInterval = new TimeSpan(0, 10, 0); //once every 10 minutes
        public override eI6Error Process(string destMobile, string msg, Ix iAll)
        {
            using (var x = new LogPreText("DelLog", iAll))
            {
                if (DateTime.UtcNow > (LastCheck + CheckInterval))
                {
                    LastCheck = DateTime.UtcNow;

                    long maxSize;
                    if (long.TryParse("_6WhatsAppProcess_Pre_DeleteLogFile.MaxSize".GetConfig(), out maxSize))
                    {
                        long currentSize = KnownFiles.ioSize(KnownFiles.eKnownFiles.Log);
                        if (currentSize > maxSize)
                        {
                            KnownFiles.ioDelete(KnownFiles.eKnownFiles.Log);
                        }
                    }
                }

                return(Child.Process(destMobile, msg, iAll));
            }
        }
示例#14
0
        TimeSpan CheckInterval = new TimeSpan(0, 10, 0); //once every 10 minutes
        public override eI6Error Process(string destMobile, string msg, Ix iAll)
        {
            using (var x = new LogPreText("DelB", iAll))
            {
                if (DateTime.UtcNow > (LastCheck + CheckInterval))
                {
                    LastCheck = DateTime.UtcNow;
                    int maxFiles = int.Parse("_6WhatsAppProcess_Pre_DeleteBmps.MaxFiles".GetConfig());
                    BmpFileHandler.PathAndDate[] files = new BmpFileHandler(".").GetSortedList();
                    iAll.iDsp.FileLog_Info(String.Format("{0} files on disk",
                                                         files.Length));
                    if (files.Length > maxFiles)
                    {
                        int toDelete = files.Length - maxFiles;
                        iAll.iDsp.FileLog_Info(String.Format("deleting {0} files",
                                                             toDelete));
                        for (int i = 0; i < toDelete; i++)
                        {
                            try
                            {
                                if (files[i].Path.Contains("zapi_"))
                                {
                                    File.Delete(files[i].Path);
                                }
                                else
                                {
                                    iAll.iDsp.FileLog_Debug("Not deleting as it does not contain the zapi text");
                                }
                            }
                            catch (SystemException)
                            { }
                        }
                    }
                }

                return(Child.Process(destMobile, msg, iAll));
            }
        }
示例#15
0
        public override eI6Error Process(string destMobile, string msg, Ix iAll)
        {
            using (var x = new LogPreText("FocusFox", iAll))
            {
                try
                {
                    IDictionary <IntPtr, string> wins = win32DLL_native._GetOpenWindows();
                    string active = win32DLL_native._GetActiveWindowTitle();

                    if (LogActiveWindowTitle)
                    {
                        iAll.iDsp.FileLog_Info($"Active: {active}");
                    }
                    if (LogAllWindows)
                    {
                        iAll.iDsp.FileLog_Info($"Wins.Count: {wins.Count}");
                        foreach (KeyValuePair <IntPtr, string> win in wins)
                        {
                            iAll.iDsp.FileLog_Info($"Wins: {win.Value}");
                        }
                    }
                    if (!active.EndsWith("- Mozilla Firefox"))
                    {
                        iAll.iDsp.FileLog_Info($"Bad - Needs refocue");
                        KeyValuePair <IntPtr, string> fox = wins.FirstOrDefault(w => w.Value.EndsWith("- Mozilla Firefox"));
                        iAll.iDsp.FileLog_Info($"Bad - Refocus {fox.Value}");
                        win32DLL_native.user32_SetForegroundWindow(fox.Key);
                    }
                    else
                    {
                        iAll.iDsp.FileLog_Info("Ok");
                    }
                }
                catch { }

                return(Child.Process(destMobile, msg, iAll));
            }
        }
示例#16
0
        public eI6Error Process(string destMobile, string msg, Ix iAll)
        {
            using (var x = new LogPreText("Simu", iAll))
            {
                iAll.iDsp.FileLog_Debug(destMobile);
                eI6Error ret = eI6Error.Success;
                Console.Clear();
                if (iAll.TypeOfProcess == Ix.eTypeOfProcess.TelNumberChecking)
                {
                    Console.WriteLine("TelNumberChecking");
                }
                Console.WriteLine(destMobile);
                Console.WriteLine(msg);
                Console.WriteLine();
                Question q = new Question();
                q.Add(new QuestionOption("Success", delegate(IMyLog log, QuestionOption it) { ret = eI6Error.Success; }));
                q.Add(new QuestionOption("TelNotActive", delegate(IMyLog log, QuestionOption it) { ret = eI6Error.FailedButNoLettingHostKnow_TelNotActive; }));
                q.Add(new QuestionOption("Step2Failed", delegate(IMyLog log, QuestionOption it) { ret = eI6Error.Step2Failed; }));
                q.AskAndAct("Action: ", null);

                return(ret);
            }
        }
示例#17
0
 public void MouseClickAndWait(int delayPre, int delayPos, Ix ix)
 {
     ix.iDsp.Delay(delayPre);
     ix.iDsp.FileLog_Debug(String.Format("MouseClick @ {0}", curPos));
     ix.iDsp.Delay(delayPos);
 }
示例#18
0
        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);
        }
示例#19
0
 public List <ASPTrayBase> GetServerFiles(Ix ix)
 {
     return(fromASP.ObjectList);
 }
示例#20
0
        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);
                }
            }
        }
示例#21
0
        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);
        }
示例#22
0
        public static eI6Error EnterTextAndCheckForMouseMove(string text, bool isMessageInput, Ix ix, _6WhatsAppProcess_RealData d)
        {
            int i = 0;

            ix.iDsp?.FileLog_Debug("Enter text at pos " + d.ExpectedMousePos.ToString());
            ix.iDsp?.FileLog_Debug("Text is: " + text.MsgForLogFileHideSpecial());
            if (isMessageInput)
            {
                // replace final \r\n and add a \0
                while (text.EndsWith("\n") || text.EndsWith("\r"))
                {
                    text = text.Substring(0, text.Length - 1);
                }
                text += "\0";

                // Filter start
                // Filter start
            }

            foreach (char c in text)
            {
                if ((d != null) && (ix.iMouse.CurrentMousePos() != d.ExpectedMousePos))
                {
                    ix?.iDsp.FileLog_Error("Mouse moved on text entry.");
                    ix?.iDsp.AddLine("Mouse moved on text entry.");
                    return(eI6Error.MouseMoved);
                }
                ix.iMouse.KeyBoardKeyAndWait(c, 5, ix.iDsp);
            }
            return(eI6Error._notSetBufOkSoFar);
        }
示例#23
0
        public override eI6Error Process(string destMobile, string msg, Ix iAll)
        {
            using (var x = new LogPreText("TelC", iAll))
            {
                // pre, initialise IFace
                if (IxFaces == null)
                {
                    using (var _lock = TheInfoList.GetLock())
                    {
                        IxFaces = iAll;
                    }
                }

                // pre, wait for the backgrount task to be up
                if (BackgroundRunning.WaitOne(1, false) == false)
                {
                    iAll.iDsp.AddLine("Waiting for background ...");
                    BackgroundRunning.WaitOne();
                    iAll.iDsp.AddLine("Waiting for background. Now up&running");
                }

                // 1) Check if tel is on android
                string telWithPlus = destMobile.Replace("zapi_", "");
                TelListController.OneTelEntry theTelEntry = null;

                using (var _lock = TheInfoList.GetLock())
                {
                    theTelEntry = _lock.Locked.GetEntry(telWithPlus);
                }
                if ((theTelEntry == null) || (!theTelEntry.IsOnAndroid)) // First round
                {
                    iAll.iDsp.AddLine("Tel not on Android ...");
                    iAll.iDsp.FileLog_Info("Tel not on Android");
                    // It seems this tel no is not on android,
                    // s1 ) refresh
                    List <string> retOnAndroid = null;
                    try
                    {
                        using (var com = IxFaces.iUpdater.Android())
                        {
                            retOnAndroid = com.GetCommand(iAll.iDsp);
                        }
                        using (var _lock = TheInfoList.GetLock())
                        {
                            _lock.Locked.Merge(null, retOnAndroid, false);
                            _lock.Locked.Verify();
                            // update e1
                            theTelEntry = _lock.Locked.GetEntry(telWithPlus);
                        }
                        iAll.iDsp.AddLine2(new DetailedData_AndroidCommunication(true));
                    }
                    catch (SocketException se)
                    {
                    }
                    TelControllerReportToFile(TheInfoList.LastVerifyResult.GetFullReport());
                }

                if ((theTelEntry == null) || (!theTelEntry.IsOnAndroid)) // secound round
                {
                    iAll.iDsp.AddLine("Adding # to Android");
                    iAll.iDsp.FileLog_Info("Adding # to Android");
                    try
                    {
                        using (var com = IxFaces.iUpdater.Android())
                        {
                            com.SetCommand(telWithPlus, IxFaces.iDsp);
                        }
                        using (var _lock = TheInfoList.GetLock())
                        {
                            _lock.Locked.AddOneAndroid(telWithPlus);
                            _lock.Locked.AddOneServer(telWithPlus);
                            _lock.Locked.Verify();
                            // update e1
                            theTelEntry = _lock.Locked.GetEntry(telWithPlus);
                        }
                        iAll.iDsp.AddLine2(new DetailedData_AndroidCommunication(true));
                    }
                    catch (SocketException)
                    {
                    }
                    TelControllerReportToFile(TheInfoList.LastVerifyResult.GetFullReport());
                }

                if (theTelEntry == null)
                {
                    // could not add the number to android, so the android is down
                    iAll.iDsp.FileLog_Debug("*************** BAD ERROR: ANDROID IS DOWN ************* ");
                    iAll.iDsp.AddLine2(new DetailedData_AndroidCommunication(false));
                    return(eI6Error.FailedButNoLettingHostKnow_TelNotActive);
                }

                eI6Error childResult = Child.Process(destMobile, msg, iAll);
                if (childResult == eI6Error.Step2Failed)
                {
                    // change the error code on recent added tel numbers, so we retry rather than fail
                    string why = null;
                    if ((theTelEntry == null) || (theTelEntry.RecentAddedToAndroid(out why)))
                    {
                        iAll.iDsp.FileLog_Debug("Deescalateing Step2Failed to TelNotActive");
                        childResult = eI6Error.FailedButNoLettingHostKnow_TelNotActive;
                    }
                    iAll.iDsp.FileLog_Debug("Why: " + why);
                }

                return(childResult);
            }
        }
示例#24
0
 public abstract eI6Error Process(string destMobile, string msg, Ix iAll);