基本信息
源码名称:C# WPF 短信 语音 图像 警告效果
源码大小:8.71M
文件格式:.rar
开发语言:C#
更新时间:2018-07-25
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
WPF设计简单测试界面,利用cavans实现红色闪烁报警提示,及声音报警。同时可以利用腾讯云短信平台发送短信通告。实现了整套告警方法。

using qcloudsms;
using qcloudsms_csharp.httpclient;
using qcloudsms_csharp.json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WarmingdemoTDOA
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }


        // 短信应用SDK AppID
        int appid = "yourID";
        // 短信应用SDK AppKey
        string appkey = "yourkey";
        // 需要发送短信的手机号码
        string[] phoneNumbers = { "", ""};
        // 短信模板ID,需要在短信应用中申请
        int templateId = 150024; // NOTE: 这里的模板ID`7839`只是一个示例,真实的模板ID需要在短信控制台中申请


        public void sendSMS()
        {
            try
            {
                SmsMultiSender msender = new SmsMultiSender(appid, appkey);
                var sresult = msender.sendWithParam("86", phoneNumbers, templateId,
                    new[] { "123.000111","023.111222" }, "", "", "");
                Console.WriteLine(sresult);
            }
            catch (JSONException e)
            {
                Console.WriteLine(e);
            }
            catch (HTTPException e)
            {
                Console.WriteLine(e);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }

        private void btnTest_Click(object sender, RoutedEventArgs e)
        {
            sendSMS();
        }

        MediaPlayer player = new MediaPlayer();
        public async Task PlaysoundAsync(bool isloop)
        {
            bubble.Visibility = Visibility.Visible;
            player.Open(new Uri("sound.wav", UriKind.Relative));
            if (player.HasAudio == false)
            {
                player.Play();
            }
            await Task.Delay(2000);
            bubble.Visibility = Visibility.Hidden;
        }

        private void btnSound_Click(object sender, RoutedEventArgs e)
        {
            PlaysoundAsync(true);
        }


    }
}