Ejemplo n.º 1
0
Archivo: CALL.cs Proyecto: wpmyj/OF2.0
        public void fillqueue(CallObj call, int Priority)
        {
            PortNum     = call.PortNum;
            BaudRate    = call.BaudRate;
            DataBits    = call.DataBits;
            Parity      = call.Parity;
            StopBits    = call.StopBits;
            ReadTimeout = call.ReadTimeout;
            if (Priority == 1)
            {
                NormalPriority.Enqueue(call);
            }
            else
            {
                HighPriority.Enqueue(call);
            }


            if (!IsThreadOn)
            {
                IsThreadOn = true;
                Sendsms    = new Thread(SendCallThread);
                Sendsms.Start();
            }
        }
Ejemplo n.º 2
0
        /*以下三个函数是 获取 电话,短信,邮件 物理地址信息,*/
        /*如果XML配置文件配置正常,则返回正常的信息实体数据,如果XML数据损坏,则返回NULL,请调用的注意判断*/
        //获取电话配置信息
        public static CallObj GetPhoneInfo()
        {
            XmlDocument xmlDocument = GetXmlDocument();

            if (xmlDocument == null)
            {
                return(null);
            }
            CallObj cobj = new CallObj();

            try
            {
                XmlElement rootElement = xmlDocument.DocumentElement;
                XmlNode    PhoneNode   = rootElement.SelectSingleNode("PhoneAlarmConfig");
                cobj.BaudRate = Convert.ToInt32(PhoneNode.FirstChild.FirstChild.Value);
                cobj.DataBits = Convert.ToByte(PhoneNode.ChildNodes[1].FirstChild.Value);
                cobj.StopBits = Convert.ToByte(PhoneNode.ChildNodes[2].FirstChild.Value);
                cobj.Parity   = Convert.ToByte(PhoneNode.ChildNodes[3].FirstChild.Value);
                cobj.PortNum  = PhoneNode.ChildNodes[4].FirstChild.Value;
            }
            catch (Exception)
            {
                return(null);
            }
            return(cobj);
        }
Ejemplo n.º 3
0
        /*以下三个函数是修改配置信息,修改完成返回真,否则返回假*/
        //修改电话配置
        public static Boolean ModifyPhoneInfo(CallObj cobj_para)
        {
            XmlDocument xmlDocument = GetXmlDocument();

            if (xmlDocument == null)
            {
                return(false);
            }
            try
            {
                XmlElement rootElement = xmlDocument.DocumentElement;
                XmlNode    PhoneNode   = rootElement.SelectSingleNode("PhoneAlarmConfig");
                PhoneNode.FirstChild.FirstChild.InnerText    = (cobj_para.BaudRate).ToString();
                PhoneNode.ChildNodes[1].FirstChild.InnerText = ((int)(cobj_para.DataBits)).ToString();
                PhoneNode.ChildNodes[2].FirstChild.InnerText = ((int)(cobj_para.StopBits)).ToString();
                PhoneNode.ChildNodes[3].FirstChild.InnerText = ((int)(cobj_para.Parity)).ToString();
                PhoneNode.ChildNodes[4].FirstChild.InnerText = cobj_para.PortNum;
                xmlDocument.Save(GetFilePath());
            }
            catch (Exception)
            {
                return(false);
            }

            return(true);
        }
Ejemplo n.º 4
0
Archivo: CALL.cs Proyecto: wpmyj/OF2.0
        /// <summary>
        /// 打电话
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Send(CallObj callobj)
        {
            bool opened = false;

            opened = InitCom(PortNum, BaudRate, DataBits, Parity, StopBits, ReadTimeout);
            if (opened)
            {
                ss_port.Write(Encoding.ASCII.GetBytes("ATD" + callobj.phoneNumber + ";\r"));//发送打电话指令
                Thread.Sleep(3000);
                ss_port.Close();
            }
        }
Ejemplo n.º 5
0
        //初始化相关数据结构
        public static void Inition()
        {
            sobj = OperateAlarmConfigClass.GetSMSinfo();
            mobj = OperateAlarmConfigClass.GetMailInfo();
            cobj = OperateAlarmConfigClass.GetPhoneInfo();

            LAM = OperateAlarmConfigClass.GetAlarmModes();

            CallObj callObj = new CallObj();

            callObj.BaudRate = 1200;
            callObj.DataBits = (byte)8;
            callObj.StopBits = (byte)1;
            callObj.Parity   = (byte)0;
            callObj.PortNum  = "COM1";
            OperateAlarmConfigClass.ModifyPhoneInfo(callObj);

            SmsObj smsObj = new SmsObj();

            smsObj.BaudRate = 1200;
            smsObj.databits = (byte)8;
            smsObj.stopBits = (byte)1;
            smsObj.parity   = (byte)4;
            smsObj.portName = "COM6";
            OperateAlarmConfigClass.ModifySMSinfo(smsObj);

            MailObj mailObj = new MailObj();

            mailObj.From     = "*****@*****.**";
            mailObj.FromName = "East";
            mailObj.PassWord = "******";
            mailObj.Host     = "192.168.1.81";
            mailObj.Subject  = "这是自动报警邮件";
            mailObj.TimeOut  = 8;
            OperateAlarmConfigClass.ModifyMailInfo(mailObj);
        }