Пример #1
0
        public SmsServiceControl(ISmsServices smsServices)
        {
            InitializeComponent();
            _smsServices = smsServices;

            cmbCountry.DataSource    = CountryItem.GetCountryItems();
            cmbCountry.DisplayMember = "Text";
            cmbCountry.SelectedIndex = 0;

            var smsServiceItems = SmsServiceItem.GetSmsServiceItems();

            cmbSmsService.DataSource    = smsServiceItems;
            cmbSmsService.DisplayMember = "Text";
            cmbSmsService.SelectedIndex = 0;

            _requestsBindingSource.DataSource = _phoneNumberRequestItems;
            dgvRequests.DataSource            = _requestsBindingSource;

            btnExecute.Click += BtnExecute_Click;
            btnSave.Click    += BtnSave_Click;

            _bw.WorkerSupportsCancellation = false;
            _bw.WorkerReportsProgress      = true;
            _bw.DoWork          += bw_DoWork;
            _bw.ProgressChanged += bw_ProgressChanged;
            _bw.RunWorkerAsync();
        }
Пример #2
0
        private async void FormLoad()
        {
            var smsServiceItems = SmsServiceItem.GetSmsServiceItems();

            cmbSmsService.DataSource    = smsServiceItems;
            cmbSmsService.DisplayMember = "Text";
            cmbSmsService.SelectedIndex = 0;

            var browserProfileItems = BrowserProfileItem.GetItems(_browserProfileService);

            cmbBrowserProfile.DataSource    = browserProfileItems;
            cmbBrowserProfile.DisplayMember = "Text";
            cmbBrowserProfile.SelectedIndex = 0;

            var browserFetcher = new BrowserFetcher();

            browserFetcher.DownloadProgressChanged += OnDownloadProgressChanged;
            GetBrowserLastVersion(browserFetcher);
            //init ServiceInfoList
            await _smsServices.GetServiceInfoList(ServiceCode.MailRu);

            foreach (SmsServiceCode smsServiceCode in Enum.GetValues(typeof(SmsServiceCode)))
            {
                var balance = await _smsServices.GetSmsService(smsServiceCode).GetBalance();

                if (balance < 5)
                {
                    textBox1.AppendText($@"Low balance {smsServiceCode} {balance} - {DateTime.Now} {Environment.NewLine}");
                    _smsServices.RemoveSmsServiceLowBalance(smsServiceCode);
                }
            }
        }