Example #1
0
        public Data_Net__04CheckTelNumbers ReadOne(NiceSystemInfo niceSystem, string fileName, IMyLog log)
        {
            try
            {
                WithAndWithoutUnderline ww = new WithAndWithoutUnderline(
                    FolderNames.GetFolder(niceSystem, MyFolders.ASP_QueuedMessages_),
                    fileName);
                Data_Net__04CheckTelNumbers o = null;

                Stream stream = OpenFile.ForRead(ww.Existing, false, false, log);
                if (stream == null)
                {
                    return(null);
                }
                using (BinaryReader br = new BinaryReader(stream))
                {
                    ASPTrayBase ox = ASPTrayBase.ReadOne(br);
                    if (ox.GetEnumType() == ASPTrayBase.eASPtrayType.CheckTelNumbers)
                    {
                        o = (Data_Net__04CheckTelNumbers)ox;
                    }
                }
                return(o);
            }
            catch (SystemException se)
            {
                log.Error("*** SystemException ***");
                log.Error(se.Message);
            }
            return(null);
        }
Example #2
0
        public string Process_CreateCheckTelFileForTestAccount(NiceSystemInfo niceSystem, MobileNoHandler XTelList, IMyLog log)
        {
            APIId = null;
            StringBuilder   sbInfo          = new StringBuilder();
            MobileNoHandler telForCheckFile = XTelList;

            try
            {
                timeNow = DateTime.UtcNow;

                string email = throw new NotImplementedException("not suitable for publication!");
                Data_Net__04CheckTelNumbers _04 = new Data_Net__04CheckTelNumbers(email, timeNow.Ticks, telForCheckFile.getVal, "");
                DSSwitch.msgFile04().Store(niceSystem, _04, log);
                sbInfo.AppendFormat("File {0} created\r\n", _04.GetFileName());
            }
            catch (ArgumentException ae)
            {
                sbInfo.Append(ae.Message);
            }
            catch (Exception)
            {
                sbInfo.Append("ERROR");
            }
            return(sbInfo.ToString());
        }
Example #3
0
 public void Store(NiceSystemInfo niceSystem, Data_Net__04CheckTelNumbers msg, IMyLog log)
 {
     try
     {
         MyFolders.ASP_QueuedMessages_.WriteToFile(niceSystem, msg, log);
     }
     catch (SystemException se)
     {
         log.Error("*** SystemException ***");
         log.Error(se.Message);
     }
 }
Example #4
0
        public static DirectTel_OutJson ProcessDirectTel(DirectTel_InJson inJson, IMyLog trayLog, LogForEmailSend log4Email, dOnAction onGet, dOnAction onAck)
        {
            trayLog.Debug("DirectTel: Loading " + inJson.SubSystem);
            NiceSystemInfo subSystem = inJson.SubSystem.GetSystemInfoFromTrayType();

            if (subSystem == null)
            {
                throw new Exception("subSystem == null");
            }

            switch (inJson.Inst)
            {
            case "Get":
            {
                // Update loopback file (with the data from the incoming object)
                if (onGet != null)
                {
                    onGet(subSystem);
                }

                // Prepare the object to be sent
                ASPTrayBase trayBase = MessageProcessing_TrayTo.GetFilesToSendToTray_ConsiderPriority(subSystem, 1, trayLog).FirstOrDefault();
                if (trayBase == null)
                {
                    // nothing, so just wait
                    return(new DirectTel_OutJson()
                        {
                            WaitSec = 10,
                        });
                }
                if (trayBase is Data_Net__00NormalMessage)
                {
                    Data_Net__00NormalMessage _00 = trayBase as Data_Net__00NormalMessage;
                    return(new DirectTel_OutJson()
                        {
                            Id = "00" + _00.GetFileName(),
                            Zapi = _00.DestMobile.Replace("+", ""),
                            Text = _00.Msg,
                            IsAddTelOnly = false,
                            WaitSec = 1,
                        });
                }
                if (trayBase is Data_Net__04CheckTelNumbers)
                {
                    Data_Net__04CheckTelNumbers _04 = trayBase as Data_Net__04CheckTelNumbers;
                    MobileNoHandler             h   = new MobileNoHandler(_04.TelList);
                    string firstTel = h.MobileNumberX_AsZapi(0);
                    return(new DirectTel_OutJson()
                        {
                            Id = "04" + _04.GetFileName(),
                            Zapi = firstTel,
                            Text = null,
                            IsAddTelOnly = true,
                            WaitSec = 1,
                        });
                }
            }
            break;

            case "Ack":
                // Update loopback file (with the data from the incoming object)
                if (onAck != null)
                {
                    onAck(subSystem);
                }

                MessageProcessing_TrayFrom proc   = new MessageProcessing_TrayFrom(subSystem, null, trayLog, log4Email);
                Data_Net_Tray2ASP          helper = new Data_Net_Tray2ASP();
                if (inJson.Id.StartsWith("00"))
                {
                    inJson.Id = inJson.Id.Substring(2);
                    Data_Net__01NormalMessageResult _01 = new Data_Net__01NormalMessageResult(inJson.Id, true);
                    helper.ObjectList.Add(_01);
                    proc.Process_TrayFrom(helper, true);
                    return(new DirectTel_OutJson());
                }
                else if (inJson.Id.StartsWith("04"))
                {
                    inJson.Id = inJson.Id.Substring(2);
                    Data_Net__05CheckTelNumbersResult _05 = new Data_Net__05CheckTelNumbersResult(inJson.Id, null, null, null);
                    helper.ObjectList.Add(_05);
                    proc.Process_TrayFrom(helper, true);
                    return(new DirectTel_OutJson());
                }
                else
                {
                }


                break;

            default:
                throw new Exception("Unknown inst");
            }

            return(null);
        }
Example #5
0
        private void processCheckTelNumbersResult(Data_Net__05CheckTelNumbersResult _05, bool sendEmails)
        {
            // 1) delete the triggering file
            ASPTrayBase.MsgFileParts    info  = ASPTrayBase.s_MsgFile_GetPartsFromMessageFile(_05.RequestFileName);//mg check this
            Data_Net__04CheckTelNumbers msg04 = DSSwitch.msgFile04().ReadOne(niceSystem, _05.RequestFileName, trayLog);

            DSSwitch.msgFile04().Delete(niceSystem, _05.RequestFileName, trayLog);

            string niceEmail                   = null;
            bool   sendWelcomeMessages         = false;
            string sendWelcomeMessages_GUID    = null;
            string sendWelcomeMessages_TelList = null;

            if ((_05.TelListOk == null) && (_05.TelListDoRetry == null) && (_05.TelListNotWorking == null))
            {
                // this is from directTel, so the first checked is not ok
                MobileNoHandler hOk   = new MobileNoHandler(msg04.TelListChecked);
                MobileNoHandler hToDo = new MobileNoHandler(msg04.TelList);
                hOk.AddIfNew(hToDo.RemoveAndReturnFirst());

                _05.TelListOk         = hOk.getVal;
                _05.TelListDoRetry    = hToDo.getVal;
                _05.TelListNotWorking = "";
            }

            // 2) do retry if not all worked and non failed
            if ((_05.TelListDoRetry.Length > 0) && (_05.TelListNotWorking.Length == 0))
            {
                // early retry
                Data_Net__04CheckTelNumbers _04 = new Data_Net__04CheckTelNumbers(info.Email, DateTime.UtcNow.Ticks, _05.TelListDoRetry, _05.TelListOk);
                DSSwitch.msgFile04().Store(niceSystem, _04, trayLog);
            }
            else
            {
                // open the userfile and merge
                MobileNoHandler doAgain = new MobileNoHandler(_05.TelListDoRetry);
                DSSwitch.appUser().Update_General(info.Email, delegate(Data_AppUserFile user, Object args)
                {
                    //  action
                    niceEmail = user.Email;
                    foreach (string telGood in (new MobileNoHandler(_05.TelListOk)).MobileNumberArray)
                    {
                        user.MobileNumbers_AllConfirmed__.AddIfNew(telGood);
                        user.MobileNumbers_AllUnConfirmed__.Remove(telGood);
                    }
                    foreach (string telNotWorking in (new MobileNoHandler(_05.TelListNotWorking)).MobileNumberArray)
                    {
                        user.AddCommentLine(telNotWorking + " not working", true);
                        user.MobileNumbers_AllUnConfirmed__.Remove(telNotWorking);
                        user.MobileNumbers_AllConfirmed__.Remove(telNotWorking);
                    }
                    foreach (string telAgain in user.MobileNumbers_AllUnConfirmed__.MobileNumberArray)
                    {
                        doAgain.AddIfNew(telAgain);
                    }

                    if (doAgain.MobileNumbersCount == 0)
                    {
                        // nothing elso to check, so make a desision
                        if (user.AccountStatus == Data_AppUserFile.eUserStatus.verified_checkingTelNumbers)
                        {
                            if (user.MobileNumbers_AllConfirmed__.MobileNumbersCount > 0)
                            {
                                // we have good numbers, so upgrade
                                user.AccountStatus = Data_AppUserFile.eUserStatus.free_account;
                                if (sendEmails)
                                {
                                    EMail.SendJustActivated(user, log4Email);
                                }
                                sendWelcomeMessages         = true;
                                sendWelcomeMessages_GUID    = user.ApiGuId;
                                sendWelcomeMessages_TelList = user.MobileNumbers_AllConfirmed__.getVal;
                            }
                            else
                            {
                                // we have no valid numbers, so block
                                user.AccountStatus = Data_AppUserFile.eUserStatus.blocked;
                                if (sendEmails)
                                {
                                    EMail.SendWrongTelRegistered(user, log4Email);
                                }
                            }
                        }
                        else if (user.AccountStatus == Data_AppUserFile.eUserStatus.free_account)
                        {
                            // this could be a free account number adding
                            if (sendEmails)
                            {
                                EMail.SendJustActivated(user, log4Email);
                            }
                            sendWelcomeMessages         = true;
                            sendWelcomeMessages_GUID    = user.ApiGuId;
                            sendWelcomeMessages_TelList = user.MobileNumbers_AllConfirmed__.getVal;
                        }
                    }
                }, null, delegate(Object args)
                {
                    // post user file processing
                    if (doAgain.MobileNumbersCount != 0)
                    {
                        // still unprocessed numbers
                        Data_Net__04CheckTelNumbers _04 = new Data_Net__04CheckTelNumbers(info.Email, DateTime.UtcNow.Ticks, doAgain.getVal, "");
                        DSSwitch.msgFile04().Store(niceSystem, _04, trayLog);
                    }
                    if (sendWelcomeMessages)
                    {
                        MessageProcessing_API api = new MessageProcessing_API(sendWelcomeMessages_GUID);
                        string additionalInfo;
                        api.SendWhatsApp(
                            niceSystem,
                            sendWelcomeMessages_TelList,
                            "Welcome to NiceApi.net\r\n",
                            true,
                            trayLog,
                            out additionalInfo);
                    }
                }, trayLog);
            }
        }
Example #6
0
        public string Process_Registration_JustVerified(NiceSystemInfo niceSystem, out bool ok, bool sendAdminNotification, bool sendAdminNotificationToWhatsapp, IMyLog log, LogForEmailSend log4Email)
        {
            StringBuilder sbInfo     = new StringBuilder();
            string        telToCheck = null;

            ok = false;
            string friendlyEmail = null;
            bool   okIntern      = false;

            try
            {
                timeNow = DateTime.UtcNow;
                // 1 extract (check) input data
                if (string.IsNullOrEmpty(APIId))
                {
                    throw new ArgumentException("X-APIId missing");
                }

                // 2 load user file and check guid
                string email = Data_AppUserFile.API_IdToEmail(APIId);
                if (email == null)
                {
                    throw new ArgumentException("X-APIId unknown");
                }
                DSSwitch.appUser().Update_General(email, delegate(Data_AppUserFile user, Object args)
                {
                    if (user == null)
                    {
                        throw new ArgumentException("X-APIId unknown");
                    }
                    if (user.ApiGuId != APIId)
                    {
                        throw new ArgumentException("X-APIId unknown");
                    }
                    if (user.AccountStatus != Data_AppUserFile.eUserStatus.email_sent_for_verification)
                    {
                        throw new ArgumentException("AccountStatus is wrong");
                    }

                    // 3 action, produce telCheck file and update AccountStatus
                    user.AccountStatus = Data_AppUserFile.eUserStatus.verified_checkingTelNumbers;
                    telToCheck         = user.MobileNumbers_AllConfirmed__.getVal + user.MobileNumbers_AllUnConfirmed__.getVal;
                    friendlyEmail      = user.Email;
                    okIntern           = true;
                }, null, delegate(Object args)
                {
                    // post process
                    if (log != null)
                    {
                        log.Info(friendlyEmail + " just verified his email");
                    }
                    if (sendAdminNotification)
                    {
                        EMail.SendAdminNotification(friendlyEmail + " just verified his email", log4Email);
                    }
                    if (sendAdminNotificationToWhatsapp)
                    {
                        NotificationInfo notificationInfo = DSSwitch.full().GetNotificationInfo();
                        NiceSystemInfo notifyToUse        = DSSwitch.full().GetSystems(false).FirstOrDefault(s => s.Name == notificationInfo.Name);
                        if (notifyToUse != null)
                        {
                            Data_Net__00NormalMessage msg = new Data_Net__00NormalMessage(
                                Data_AppUserFile.API_IdToEmail(notifyToUse.APIId),
                                "zapi_" + notificationInfo.RxTel,
                                DateTime.UtcNow.Ticks,
                                friendlyEmail + " just verified his email",
                                0, 10, true);
                            DSSwitch.msgFile00().Store(notifyToUse, msg, Data_Net__00NormalMessage.eLocation.Queued, log);
                        }
                    }
                    Data_Net__04CheckTelNumbers _04 = new Data_Net__04CheckTelNumbers(friendlyEmail, timeNow.Ticks, telToCheck, "");
                    DSSwitch.msgFile04().Store(niceSystem, _04, log);
                }, log);
            }
            catch (ArgumentException ae)
            {
                sbInfo.Append(ae.Message);
            }
            catch (Exception)
            {
                sbInfo.Append("ERROR");
            }
            ok = okIntern;
            return(sbInfo.ToString());
        }
Example #7
0
        public string Process_MGUseAddTelToFreeAccounts(NiceSystemInfo niceSystem, MobileNoHandler XTelList, int maxNumbers, IMyLog log)
        {
            StringBuilder   sbInfo          = new StringBuilder();
            MobileNoHandler telForCheckFile = new MobileNoHandler("");

            try
            {
                timeNow = DateTime.UtcNow;
                // 1 extract (check) input data
                #region 1 extract (check) input data
                if (string.IsNullOrEmpty(Email))
                {
                    throw new ArgumentException("X-APIId missing");
                }
                #endregion

                // 2 load user file and check guid
                #region 2 load user file and check guid
                DSSwitch.appUser().Update_General(Email, delegate(Data_AppUserFile user, Object args)
                {
                    if (user == null)
                    {
                        throw new ArgumentException("X-APIId unknown");
                    }
                    #endregion

                    // 3 action, add up to 5 numbers and produce telCheck file
                    #region 3 action, add up to 5 numbers and produce telCheck file
                    if (user.AccountStatus == Data_AppUserFile.eUserStatus.blocked)
                    {
                        // unblock, as this is an instraction from the admin
                        user.AccountStatus = Data_AppUserFile.eUserStatus.free_account;
                    }

                    if (user.AccountStatus != Data_AppUserFile.eUserStatus.free_account)
                    {
                        throw new ArgumentException("This applies only to free_account. Not to " + user.AccountStatus.ToString());
                    }
                    if ((
                            user.MobileNumbers_AllConfirmed__.MobileNumbersCount +
                            user.MobileNumbers_AllUnConfirmed__.MobileNumbersCount +
                            XTelList.MobileNumbersCount) > maxNumbers)
                    {
                        throw new ArgumentException("Only up to 5 numbers allowed");
                    }
                    foreach (string tel1 in XTelList.MobileNumberArray)
                    {
                        user.MobileNumbers_AllUnConfirmed__.Add(tel1);
                        telForCheckFile.Add(tel1);
                        sbInfo.AppendFormat("Added {0}\r\n", tel1);
                    }
                    sbInfo.AppendFormat("Now {0} # registered\r\n", (user.MobileNumbers_AllConfirmed__.MobileNumbersCount + user.MobileNumbers_AllUnConfirmed__.MobileNumbersCount));
                    #endregion
                }, null, delegate(Object args)
                                                  // 4 post user file handling, create telCheck file
                {
                    Data_Net__04CheckTelNumbers _04 = new Data_Net__04CheckTelNumbers(Email, timeNow.Ticks, telForCheckFile.getVal, "");
                    DSSwitch.msgFile04().Store(niceSystem, _04, log);
                    sbInfo.AppendFormat("File {0} created\r\n", _04.GetFileName());
                }, log);
            }
            catch (ArgumentException ae)
            {
                sbInfo.Append(ae.Message);
            }
            catch (Exception)
            {
                sbInfo.Append("ERROR");
            }
            return(sbInfo.ToString());
        }
Example #8
0
        public string Process_TelNumAPI(NiceSystemInfo niceSystem, string XAPIInstruction, string Message, IMyLog log)
        {
            StringBuilder sbRet = new StringBuilder();

            try
            {
                timeNow = DateTime.UtcNow;
                // 1 extract (check) input data
                #region 1 extract input data
                if (string.IsNullOrEmpty(APIId))
                {
                    throw new ArgumentException("X-APIId missing");
                }
                eTelNum_Instruction telNum_Instruction = castInstractionOrThrow(XAPIInstruction);
                MobileNoHandler     telNum_Handler     = new MobileNoHandler(Message.Replace(" ", "").Replace("\t", "").Replace("\r", "").Replace("\n", ""));
                #endregion

                // 2 load user file and check guid
                #region 2 load user file and check guid
                if (Email == null)
                {
                    throw new ArgumentException("X-APIId unknown");
                }
                MobileNoHandler telAddToCheckingFile = new MobileNoHandler("");
                DSSwitch.appUser().Update_General(Email, delegate(Data_AppUserFile user, Object args)
                {
                    if (user == null)
                    {
                        throw new ArgumentException("X-APIId unknown");
                    }
                    if (user.ApiGuId != APIId)
                    {
                        throw new ArgumentException("X-APIId unknown");
                    }
                    if (!user.IsAccountActive(""))
                    {
                        throw new ArgumentException("Account not active (8). " + user.AccountStatusExplained());
                    }
                    if (!user.AddNumber_AllowedWithAPI)
                    {
                        throw new ArgumentException("Not allowed for this account");
                    }
                    #endregion

                    // 3 action format retString according to telNum_Instruction
                    #region 3 action format retString according to telNum_Instruction
                    switch (telNum_Instruction)
                    {
                    case eTelNum_Instruction.ShowConfirmed:
                        sbRet.Append(user.MobileNumbers_AllConfirmed__.getVal);
                        break;

                    case eTelNum_Instruction.ShowUnconfirmed:
                        sbRet.Append(user.MobileNumbers_AllUnConfirmed__.getVal);
                        break;

                    case eTelNum_Instruction.Show:
                        sbRet.AppendLine("Plan: " + user.AccountStatus.ToString());
                        sbRet.AppendLine(String.Format("Counter: {0} / {1}", user.MobileNumbers_AllConfirmed__.MobileNumbersCount, user.MobileNumbers_AllUnConfirmed__.MobileNumbersCount));
                        sbRet.AppendLine("Confirmed: " + user.MobileNumbers_AllConfirmed__.getVal);
                        sbRet.AppendLine("Unconfirmed: " + user.MobileNumbers_AllUnConfirmed__.getVal);
                        break;

                    case eTelNum_Instruction.Add:
                        {
                            MobileNoHandler XTelList = new MobileNoHandler(Message, true);

                            foreach (string tel1 in XTelList.MobileNumberArray)
                            {
                                if (user.MobileNumbers_AllConfirmed__.Contains(tel1))
                                {
                                    sbRet.AppendLine(tel1 + " is already confirmed.");
                                }
                                else if (user.MobileNumbers_AllUnConfirmed__.Contains(tel1))
                                {
                                    sbRet.AppendLine(tel1 + " is already on the list.");
                                }
                                else if (!user.GetCheckerBase(true).FundManagement_CommitAddOneNumber(tel1))
                                {
                                    sbRet.AppendLine("Not enough funds to add " + tel1 + ".");
                                }
                                else
                                {
                                    sbRet.AppendLine(tel1 + " added.");
                                    user.MobileNumbers_AllUnConfirmed__.Add(tel1);
                                    telAddToCheckingFile.Add(tel1);
                                }
                            }
                        }
                        break;

                    case eTelNum_Instruction.Remove:
                        throw new ArgumentException("Remove not allowed for this account");
                    //break;

                    default:
                        throw new ArgumentException("Internel Error");
                    }
                    #endregion
                }, null, delegate(Object args)
                {
                    if (telAddToCheckingFile.MobileNumbersCount > 0)
                    {
                        Data_Net__04CheckTelNumbers _04 = new Data_Net__04CheckTelNumbers(Email, timeNow.Ticks, telAddToCheckingFile.getVal, "");
                        DSSwitch.msgFile04().Store(niceSystem, _04, log);
                    }
                }, log);
            }
            catch (ArgumentException ae)
            {
                sbRet = new StringBuilder();
                sbRet.Append(ae.Message);
            }
            catch (Exception)
            {
                sbRet = new StringBuilder();
                sbRet.Append("ERROR");
            }
            return(sbRet.ToString());;
        }
Example #9
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);
                }
            }
        }
Example #10
0
        private static int ComparisonWithPriority(ASPTrayBase x, ASPTrayBase y)
        {
            int ret = 0;

            if (ret == 0)
            {
                // consider file priority
                ret = (int)x.GetFilePriority() - (int)y.GetFilePriority();
            }
            if ((ret == 0) && (x.GetType() != y.GetType()))
            {
                Data_Net__00NormalMessage   n = null;
                Data_Net__04CheckTelNumbers t = null;
                if ((x.GetType() == typeof(Data_Net__00NormalMessage)) &&
                    (y.GetType() == typeof(Data_Net__04CheckTelNumbers)))
                {
                    n = (Data_Net__00NormalMessage)x;
                    t = (Data_Net__04CheckTelNumbers)y;

                    if (t.GetFailedCount() > 5)
                    {
                        ret = 1;
                    }
                    else
                    {
                        ret = -1;
                    }
                }
                if ((y.GetType() == typeof(Data_Net__00NormalMessage)) &&
                    (x.GetType() == typeof(Data_Net__04CheckTelNumbers)))
                {
                    n = (Data_Net__00NormalMessage)y;
                    t = (Data_Net__04CheckTelNumbers)x;

                    if (t.GetFailedCount() > 5)
                    {
                        ret = -1;
                    }
                    else
                    {
                        ret = 1;
                    }
                }
            }
            if (ret == 0)
            {
                // consider failed counter
                ret = x.GetFailedCount() - y.GetFailedCount();
            }
            if (ret == 0)
            {
                // consider file time
                if (
                    (x.GetEnumType() == ASPTrayBase.eASPtrayType.NormalMessage) &&
                    (y.GetEnumType() == ASPTrayBase.eASPtrayType.NormalMessage))
                {
                    Data_Net__00NormalMessage xn = (Data_Net__00NormalMessage)x;
                    Data_Net__00NormalMessage yn = (Data_Net__00NormalMessage)y;
                    if (ret == 0)
                    {
                        // compare the FailedConter
                        ret = xn.FailedCounter - yn.FailedCounter;
                    }
                    if (ret == 0)
                    {
                        // older message first
                        ret = (int)(xn.MsgTicks - yn.MsgTicks);
                    }
                }
                if (
                    (x.GetEnumType() == ASPTrayBase.eASPtrayType.CheckTelNumbers) &&
                    (y.GetEnumType() == ASPTrayBase.eASPtrayType.CheckTelNumbers))
                {
                    Data_Net__04CheckTelNumbers xt = (Data_Net__04CheckTelNumbers)x;
                    Data_Net__04CheckTelNumbers yt = (Data_Net__04CheckTelNumbers)y;
                    if (ret == 0)
                    {
                        // compare the FailedConter
                        ret = xt.GetFailedCount() - yt.GetFailedCount();
                    }
                    if (ret == 0)
                    {
                        // older message first
                        ret = (int)(xt.MsgTicks - yt.MsgTicks);
                    }
                }
            }
            return(ret);
        }