Exemple #1
0
        public override string GetCodeSms(string numer, long timer = 600000)
        {
            try
            {
                var url = "http://simsms.org/priemnik.php?" +
                          $"metod=get_sms&country=ru&service={ViberKey}&id={TzidNumbers[numer]}&apikey={ApiKey}";
                var answer = GetResponse(url);

                var sw = Stopwatch.StartNew();
                while (Regex.Match(answer, "(?<=response\":\").*?(?=\")").Value != "1" &&
                       (sw.ElapsedMilliseconds < timer))
                {
                    if (Regex.Match(answer, "(?<=response\":\").*?(?=\")").Value != "2")
                    {
                        return(null);
                    }
                    Thread.Sleep(20000);
                    answer = GetResponse(url);
                }
                sw.Stop();
                return(new Regex("(?<=sms\":\").*?(?=\")").Match(answer).Value);
            }catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SimSms)} {nameof(GetCodeSms)} {e}");
                return(null);
            }
        }
Exemple #2
0
        public override string GetCodeSms(string number, long timer = 600000)
        {
            try
            {
                string url = "http://sms-activate.ru/stubs/handler_api.php?" +
                             $"api_key={ApiKey}&action=setStatus&status=1&id={TzidNumbers[number]}";
                GetResponse(url);

                Stopwatch sw = Stopwatch.StartNew();
                url = "http://sms-activate.ru/stubs/handler_api.php?&" +
                      $"id={TzidNumbers[number]}&api_key={ApiKey}&action=getStatus";
                string answer = GetResponse(url);

                while (!answer.Contains("STATUS_OK") && (sw.ElapsedMilliseconds < timer))
                {
                    if (answer != "STATUS_WAIT_CODE")
                    {
                        return(null);
                    }
                    Thread.Sleep(10500);
                    answer = GetResponse(url);
                }
                return(new Regex("(?<=STATUS_OK:).*").Match(answer).Value);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SmsActivate)} {nameof(GetCodeSms)} {e}");
                return(null);
            }
        }
Exemple #3
0
        public override string GetNumber()
        {
            try
            {
                var answer =
                    GetResponse("http://simsms.org/priemnik.php?" +
                                $"metod=get_number&country=ru&service={ViberKey}&id=1&apikey={ApiKey}");
                if (Regex.Match(answer, "(?<=response\":\").*?(?=\")").Value != "1")
                {
                    return(null);
                }

                var tzid   = new Regex("(?<=id\":).*?(?=,)").Match(answer).Value;
                var number = new Regex("(?<=number\":\").*?(?=\")").Match(answer).Value;
                if (string.IsNullOrWhiteSpace(number))
                {
                    throw new Exception($"{nameof(SimSms)} {nameof(GetNumber)} Переменная {number} пуста");
                }
                if (TzidNumbers.ContainsKey(number))
                {
                    TzidNumbers[number] = tzid;
                }
                else
                {
                    TzidNumbers.Add(number, tzid);
                }
                return(number);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SimSms)} {nameof(GetNumber)} {e}");
                return(null);
            }
        }
 public override string GetCodeSms(string number, long timer = 600000)
 {
     try
     {
         Stopwatch sw  = Stopwatch.StartNew();
         string    url = "http://onlinesim.ru/api/getState.php?" +
                         $"tzid={TzidNumbers[number]}&message_to_code=1&apikey={ApiKey}";
         string answer = GetResponse(url);
         while (Regex.Match(answer, "(?<=response\":\").*?(?=\")").Value != "TZ_NUM_ANSWER" &&
                (sw.ElapsedMilliseconds < timer))
         {
             if (Regex.Match(answer, "(?<=response\":\").*?(?=\")").Value != "TZ_NUM_WAIT")
             {
                 return(null);
             }
             Thread.Sleep(10500);
             answer = GetResponse(url);
         }
         sw.Stop();
         GetResponse("http://onlinesim.ru/api/setOperationOk.php?" +
                     $"tzid={TzidNumbers[number]}&apikey={ApiKey}");
         return(new Regex("(?<=\"msg\":\").*?(?=\")").Match(answer).Value);
     }
     catch (Exception e)
     {
         Lgr?.Wl($"{nameof(OnlineSim)} {nameof(GetCodeSms)} {e}");
         return(null);
     }
 }
        public override string GetCodeSms(string number, long timer = 600000)
        {
            try
            {
                var url    = "http://api.sms-reg.com/setReady.php?" + $"tzid={TzidNumbers[number]}&apikey={ApiKey}";
                var answer = GetResponse(url);

                if (new Regex("(?<=response\":\").*?(?=\")").Match(answer).Value != "1")
                {
                    return(null);
                }

                url    = "http://api.sms-reg.com/getState.php?" + $"tzid={TzidNumbers[number]}&apikey={ApiKey}";
                answer = GetResponse(url);

                var sw = Stopwatch.StartNew();
                while (!answer.Contains("TZ_NUM_ANSWER") && (sw.ElapsedMilliseconds < timer))
                {
                    if (Regex.Match(answer, "(?<=response\":\").*?(?=\")").Value != "TZ_NUM_WAIT")
                    {
                        return(null);
                    }
                    Thread.Sleep(10500);
                    answer = GetResponse(url);
                }
                sw.Stop();
                return(new Regex("(?<=msg\":\").*?(?=\")").Match(answer).Value);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SmsReg)} {nameof(GetCodeSms)} {e}");
                return(null);
            }
        }
        internal PictureForm(Lgr currentLgr)
        {
            InitializeComponent();
            UpdateLgr(currentLgr);
            var graphics = CreateGraphics();

            _dpiX = graphics.DpiX / 96;
            _dpiY = graphics.DpiY / 96;
            graphics.Dispose();
        }
        public override string GetNumber()
        {
            try
            {
                var url    = "http://onlinesim.ru/api/getNum.php?" + $"service={ViberKey}&apikey={ApiKey}";
                var answer = GetResponse(url);

                if (Regex.Match(answer, "(?<=response\":\").*?(?=\")").Value != "1")
                {
                    return(null);
                }
                var tzid = Regex.Match(answer, "(?<=\"tzid\":).*?(?=})").Value;

                url    = "http://onlinesim.ru/api/getState.php?" + $"tzid={tzid}&apikey={ApiKey}";
                answer = GetResponse(url);
                var sw = Stopwatch.StartNew();
                while (Regex.Match(answer, "(?<=\"response\":\").*?(?=\")").Value != "1" &&
                       (sw.ElapsedMilliseconds < 60000))
                {
                    if (answer.Contains("TZ_INPOOL"))
                    {
                        Thread.Sleep(10500);
                        answer = GetResponse(url);
                        continue;
                    }
                    if (!answer.Contains("TZ_NUM_WAIT"))
                    {
                        return(null);
                    }
                    var number = new Regex("(?<=number\":\").*?(?=\")").Match(answer).Value;
                    if (string.IsNullOrWhiteSpace(number))
                    {
                        throw new Exception($"{nameof(OnlineSim)} {nameof(GetNumber)} Переменная {number} пуста");
                    }
                    if (TzidNumbers.ContainsKey(number))
                    {
                        TzidNumbers[number] = tzid;
                    }
                    else
                    {
                        TzidNumbers.Add(number, tzid);
                    }
                    return(number);
                }
                sw.Stop();
                return(null);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(OnlineSim)} {nameof(GetNumber)} {e}");
                return(null);
            }
        }
Exemple #8
0
        public override string GetNumber()
        {
            try
            {
                string url = "http://sms-activate.ru/stubs/handler_api.php?" +
                             $"api_key={ApiKey}&action=getNumber&service={ViberKey}";
                string answer = GetResponse(url);
                switch (answer)
                {
                case "NO_NUMBERS":
                    return(null);

                case "NO_BALANCE":
                    return(null);

                case "BAD_ACTION":
                    return(null);

                case "BAD_SERVICE":
                    return(null);

                case "BAD_KEY":
                    return(null);

                case "ERROR_SQL":
                    return(null);
                }
                var    tzid   = Regex.Match(answer, "(?<=ACCESS_NUMBER:).*?(?=:)").Value;
                string number = Regex.Match(answer, "(?<=\\d:).*").Value;
                if (string.IsNullOrWhiteSpace(number))
                {
                    throw new Exception($"{nameof(SmsActivate)} {nameof(GetNumber)} Переменная {number} пуста");
                }
                if (TzidNumbers.ContainsKey(number))
                {
                    TzidNumbers[number] = tzid;
                }
                else
                {
                    TzidNumbers.Add(number, tzid);
                }
                return(number);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SmsActivate)} {nameof(GetNumber)} {e}");
                return(null);
            }
        }
        //重写基类的异常处理方法
        public override void OnException(HttpActionExecutedContext actionExecutedContext)
        {
            //1.异常日志记录
            var sb = new StringBuilder();

            sb.AppendLine("ExceptionType: " + actionExecutedContext.Exception.GetType().ToString());
            sb.AppendLine("Message: " + actionExecutedContext.Exception.Message);
            sb.AppendLine("Stack Trace: " + actionExecutedContext.Exception.StackTrace);
            Lgr.Error(sb);
            //返回自定义error信息
            if (actionExecutedContext.Response == null)
            {
                actionExecutedContext.Response = new HttpResponseMessage(System.Net.HttpStatusCode.InternalServerError);
            }
            actionExecutedContext.Response.Content = new StringContent(new Serialize().SerializeJson(new ApiResultDto()
            {
                code = (int)ERROR_CODE.ERROR, msg = actionExecutedContext.Exception.Message
            }));
        }
Exemple #10
0
        public bool SetPWMOutputEnable(PWMOutputConfig? /*enabled?*/ Enb, bool /*confirm*/ Cnf)
        {
            string /*trace text*/ trc = MethodBase.GetCurrentMethod().Name + "(" +
                                        ((Enb != null) ? Enb.ToString() : "null") + ", " + Cnf.ToString() + ")";
            bool /*status (returned)*/ sts = false;

            try
            {
                CommandDefinition.CommandFormat /*command */ cmd = ConstructCommand(
                    CommandEnum.PWMOutput,
                    BooleanValue.True,
                    ActionEnum.Set,
                    (byte)Enb);
                CommandDefinition.CommandFormat? /*response*/ rsp = SendCommand(cmd, Cnf);
                sts = !Cnf || ConfirmSetActionResponse(rsp, CommandEnum.PWMOutput, (byte)Enb);
            }
            catch (Exception ex) { Lgr.LogError(ex); }
            return(sts);
        }
Exemple #11
0
        public override string GetCodeSms(string number, long timer = 600000)
        {
            try
            {
                string url = "http://smslike.ru/index.php?mode=api" +
                             $"&apikey={ApiKey}&action=setready&tz={TzidNumbers[number]}";
                var answer = GetResponse(url);

                if (!answer.Contains("OK_READY"))
                {
                    return(null);
                }

                url = "http://smslike.ru/index.php?mode=api" +
                      $"&apikey={ApiKey}&action=getstate&tz={TzidNumbers[number]}";
                answer = GetResponse(url);

                Stopwatch sw = Stopwatch.StartNew();
                while (!answer.Contains("TZ_NUM_ANSWER") && (sw.ElapsedMilliseconds < timer))
                {
                    if (!answer.Contains("TZ_NUM_WAIT"))
                    {
                        return(null);
                    }
                    Thread.Sleep(10000);
                    answer = GetResponse(url);
                }
                sw.Stop();
                if (answer.Contains("TZ_OVER_EMPTY"))
                {
                    return(null);
                }
                return(new Regex("(?<=TZ_NUM_ANSWER:).*").Match(answer).Value);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SmsLike)} {nameof(GetCodeSms)} {e}");
                return(null);
            }
        }
Exemple #12
0
        public override string GetNumber()
        {
            try
            {
                string tzid;
                string url = "http://smslike.ru/index.php?mode=api" +
                             $"&apikey={ApiKey}&action=regnum&lc=0&s={ViberKey}";
                var answer = GetResponse(url);
                var check  = Regex.IsMatch(answer, "OK");
                switch (answer)
                {
                case "BEFORE_REQUEST_NEW_REPLY_COMPLE_REQUESTED_BEFORE":
                    return(null);

                case "ACTIVE_REQUESTS_LIMIT":
                    return(null);

                case "WARNING_LOW_BALANCE":
                    return(null);

                case "WARNING_NO_NUMS":
                    return(null);

                default:
                    if (check)
                    {
                        tzid = answer.Split(':')[1].Trim();
                    }
                    else
                    {
                        return(null);
                    }
                    break;
                }

                url    = "http://smslike.ru/index.php?mode=api" + $"&apikey={ApiKey}&action=getstate&tz={tzid}";
                answer = GetResponse(url);
                var sw = Stopwatch.StartNew();
                while (!answer.Contains("TZ_NUM_PREPARE") && (sw.ElapsedMilliseconds < 60000))
                {
                    if (answer != "TZ_NUM_WAIT_NUMBER")
                    {
                        return(null);
                    }
                    Thread.Sleep(10500);
                    answer = GetResponse(url);
                }
                sw.Stop();
                var number = Regex.Match(answer, "(?<=TZ_NUM_PREPARE:).*").Value;
                if (string.IsNullOrWhiteSpace(number))
                {
                    throw new Exception($"{nameof(SmsLike)} {nameof(GetNumber)} Переменная {number} пуста");
                }
                if (TzidNumbers.ContainsKey(number))
                {
                    TzidNumbers[number] = tzid;
                }
                else
                {
                    TzidNumbers.Add(number, tzid);
                }
                return(number);
            }
            catch (Exception e)
            {
                Lgr?.Wl($"{nameof(SmsLike)} {nameof(GetNumber)} {e}");
                return(null);
            }
        }
Exemple #13
0
 internal void UpdateLgr(Lgr newLgr)
 {
     _currentLgr = newLgr;
     UpdatePictureLists();
     TextureButtonCheckedChanged();
 }
Exemple #14
0
 internal PictureForm(Lgr currentLgr)
 {
     InitializeComponent();
     UpdateLgr(currentLgr);
 }
Exemple #15
0
        public void Dispose()
        {
            _cancel.Cancel();
            _cancelEvent.Set();

            if (_signOfLifeTimer != null)
            {
                _signOfLifeTimer.Dispose();
            }
            _signOfLifeTimer = null;

            if (_sendConfigDataThread != null)
            {
                if (_sendConfigDataThread.IsAlive)
#if true
                { _sendConfigDataThread.Join(/*1s*/ 1000 /*ms*/); }
            }
#else
                { if (!_sendConfigDataThread.Join(ApcsDelay))
                  {
                      ;
                  }
                }_sendConfigDataThread.Abort();
#endif
            _sendConfigDataThread = null;

            if (_responseThread != null)
            {
                if (_responseThread.IsAlive)
#if true
                { _responseThread.Join(/*1s*/ 1000 /*ms*/); }
            }
#else
                { if (!_responseThread.Join(ApcsDelay))
                  {
                      _responseThread.Abort();
                  }
                }
#endif
            _responseThread = null;

            if (_connectionThread != null)
            {
                if (_connectionThread.IsAlive)
#if true
                { _connectionThread.Join(/*1s*/ 1000 /*ms*/); }
            }
#else
                { if (!_connectionThread.Join(ApcsDelay))
                  {
                      _connectionThread.Abort();
                  }
                }
#endif
            _connectionThread = null;

            Disconnect();

            if (_responseEvent != null)
            {
                _responseEvent.Dispose();
            }
            _responseEvent = null;

            Debug.Assert(Lgr != null);
            Lgr.LogInfo("ApcsAccess.Dispose");
            Lgr = null;
        }