//public static string
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     if (opayid.Text.Length < 1)
     {
         MessageBox.Show("歐付寶 ID 沒填!!");
         return;
     }
     else if (channelname.Text.Length < 1)
     {
         MessageBox.Show("頻道 ID 沒填!!");
         return;
     }
     else if (username.Text.Length < 1)
     {
         MessageBox.Show("Twitch ID 沒填!!");
         return;
     }
     else if (twitchoauth.Text.Length < 1)
     {
         MessageBox.Show("OAuth沒填!!");
         return;
     }
     try
     {
         OpayCheckService opay = new OpayCheckService(opayid.Text, username.Text, twitchoauth.Text, channelname.Text, messagetemplate.Text);
         state.Text = "Twitch聊天室已連接...\n";
         System.Timers.Timer timer = new System.Timers.Timer(5000)
         {
             AutoReset = true,
             Enabled   = true
         };
         //timer.Elapsed += await opay.Timer_ElapsedAsync;
         state.Text += "歐付寶頁面擷取中...";
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Beispiel #2
0
        //public static string
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(opayid.Text) && string.IsNullOrWhiteSpace(ecpayid.Text))
            {
                MessageBox.Show("兩種付款服務ID請至少填一個");
                return;
            }
            else if (channelname.Text.Length < 1)
            {
                MessageBox.Show("頻道 ID 沒填!!");
                return;
            }
            else if (username.Text.Length < 1)
            {
                MessageBox.Show("Twitch ID 沒填!!");
                return;
            }
            else if (twitchoauth.Text.Length < 1)
            {
                MessageBox.Show("OAuth沒填!!");
                return;
            }

            try
            {
                TwitchIRCService irc = new TwitchIRCService(username.Text, twitchoauth.Text, channelname.Text);

                List <IOpayCheckService> paymentProviders = new List <IOpayCheckService>();

                if (!string.IsNullOrWhiteSpace(ecpayid.Text))
                {
                    IOpayCheckService ecpayCheckService = new ECpayCheckService(ecpayid.Text, channelname.Text, messagetemplate.Text, irc);

                    paymentProviders.Add(ecpayCheckService);
                }

                if (!string.IsNullOrWhiteSpace(opayid.Text))
                {
                    IOpayCheckService opayCheckService = new OpayCheckService(opayid.Text, channelname.Text, messagetemplate.Text, irc);

                    paymentProviders.Add(opayCheckService);
                }


                Task.Run(async() =>
                {
                    MessageBox.Show("start!");
                    while (true)
                    {
                        paymentProviders.ForEach(async provider =>
                        {
                            await provider.Timer_ElapsedAsync();
                        });

                        await Task.Delay(5000);
                    }
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }