예제 #1
0
        public static (double, double) GetRate(TicketClientSettingsData clientData, int expire = 10000)//10 сек на случай зависона
        {
            string bin = Environment.CurrentDirectory + "/" + clientData.path;

            string[] path = clientData.path.Split('/');
            if (path.Count() > 0)
            {
                path = path.Take(path.Count() - 1).ToArray();
            }
            string dir        = Environment.CurrentDirectory + "/" + String.Join("/", path) + "/";
            string clientName = clientData
                                .path
                                .Split('/')
                                .Last()
                                .Replace(".exe", "");

            string response = Exec(clientName, bin, dir, "--rate", 100, expire);

            if (response == null || response == "expire")
            {
                return(0, 0);
            }

            RateParsedData model = JsonConvert.DeserializeObject <RateParsedData>(response);

            if (clientData.demping_percent > 0)
            {
                model.rate = model.rate - (model.rate / 100 * clientData.demping_percent);
            }

            return(model.rate, model.balance);
        }
예제 #2
0
        public void Check_btc_addresstype_TicketClient()
        {
            TicketClientSettingsData client = App
                                              .settings
                                              .data
                                              .ticket_clients
                                              .Where(
                el => el.btc_addresstype == TicketClientSettingsData.IS_GET_FROM_TICKET_CLIENT
                )
                                              .First();

            Assert.IsTrue(client.btc_addresstype == TicketClientSettingsData.IS_GET_FROM_TICKET_CLIENT);

            App.LAST_PARSED_RATE = new RateParsedData()
            {
                client = client
            };

            var response = App.ticketClient.GetTypeBtcAddress();

            Assert.IsTrue(response.target_currency_id > 0, "error: " + response.toJson());
        }
        public (double, double) GetRateBalance(TicketClientSettingsData client, bool rateWithDemping = true)
        {
            if (!bestchange.rates.FindRow(client.rate_path))
            {
                return(-1, -1);
            }

            bm_ratesData data = bestchange.rates.Get();

            if (data == null)
            {
                return(-1, -1);
            }

            double dempingValue = 0;

            if (rateWithDemping && client.demping_percent > 0)
            {
                dempingValue = data.cource / 100 * client.demping_percent;
            }

            return(data.cource - dempingValue, data.balance);
        }
예제 #4
0
        public List <KeyValuePair <EmailIdentity, TicketClientCreateResponse> > GetLastByClient(TicketClientSettingsData client)
        {
            List <KeyValuePair <EmailIdentity, TicketClientCreateResponse> > list = new List <KeyValuePair <EmailIdentity, TicketClientCreateResponse> >();

            foreach (var email in emails)
            {
                var text = email.ToMailMessage().Body;

                if (text.IndexOf(client.email_parser.is_client) == -1)
                {
                    continue;
                }

                string matchCodeRow = Regex.Match(text, client.email_parser.code[0]).Value;
                string matchCode    = Regex.Match(matchCodeRow, client.email_parser.code[1]).Value;

                string matchFromRow = Regex.Match(text, client.email_parser.from[0]).Value;
                string matchFrom    = Regex.Match(matchFromRow, client.email_parser.from[1]).Value;

                string matchToRow = Regex.Match(text, client.email_parser.to[0]).Value;
                string matchTo    = Regex.Match(matchToRow, client.email_parser.to[1]).Value;

                string matchBtcAmountRow = Regex.Match(text, client.email_parser.btc_amount[0]).Value;
                string matchBtcAmount    = Regex.Match(matchBtcAmountRow, client.email_parser.btc_amount[1]).Value;

                string matchBtcAddressRow = Regex.Match(text, client.email_parser.btc_address[0]).Value;
                string matchBtcAddress    = Regex.Match(matchBtcAddressRow, client.email_parser.btc_address[1]).Value;

                list.Add(new KeyValuePair <EmailIdentity, TicketClientCreateResponse>(
                             new EmailIdentity()
                {
                    btcAddr   = HTMLHelper.StripHTML(matchBtcAddress).Trim(),
                    phoneFrom = HTMLHelper.StripHTML(matchFrom).Trim()
                },
                             new TicketClientCreateResponse()
                {
                    account    = HTMLHelper.StripHTML(matchTo).Trim(),
                    comment    = HTMLHelper.StripHTML(matchCode).Trim(),
                    btc_amount = MoneyParser.ParseString(HTMLHelper.StripHTML(matchBtcAmount)),
                    email      = email.ToMailMessage().To.ToString().Trim()
                }
                             ));
            }

            return(list);
        }