示例#1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            int EffectiveSMScout = 0;

            Encryption ecry = new Encryption();
            SMSFirewall smsf = new SMSFirewall();
            string SiD = "0";
            string del = "��";
            if (axSzhtoSms1.smsStatus != "") return;
            axSzhtoSms1.YhReadSms(SiD, del);
            string RsTel = "";
            string Rsdate = "";
            string RsCon = "";

            if (int.Parse(SiD) > 0)
            {
                RsTel = axSzhtoSms1.RsTel.ToString();
                Rsdate = axSzhtoSms1.RsDate.ToString();
                RsCon = axSzhtoSms1.RsCon.ToString();
                if (smsf.FilterPhone(RsTel, filternum))
                {
                    if (CheckFaulttimes(RsTel) > everyrecivetime)
                    {
                        if (axSzhtoSms1.smsStatus != "") return;
                        listBox1.Items.Add(SendWarmingSms(sCen, RsTel, sCon, 0));

                    }
                    else
                    {
                        Unclassified_FaultManager1.Addnewfault( RsCon, Rsdate, RsTel);
                    }
                }
                else
                {
                    listBox1.Items.Add("�ɹ�����");
                }

            }
            else
            {  //�������ŷָ�
                if (axSzhtoSms1.RsId != "")
                {
                    string[] Ri = axSzhtoSms1.RsId.Split('');
                    string[] RC = axSzhtoSms1.RsCenterNo.Split('');
                    string[] RT = axSzhtoSms1.RsTel.Split('');
                    string[] RD = axSzhtoSms1.RsDate.Split('');
                    string[] RCon = axSzhtoSms1.RsCon.Split('');

                    Unclassified_FaultManager1.SetFaultToBeOld();

                    for (int i = 0; i < Ri.Length; i++)
                    {

                        RsCon = RCon[i].ToString();
                        RsTel = RT[i].ToString();
                        Rsdate = RD[i].ToString();
                        if (smsf.FilterPhone(RsTel, filternum))
                        {
                            if (CheckFaulttimes(RsTel) > everyrecivetime)
                            {

                                listBox1.Items.Add("============================================================");
                                listBox1.Items.Add("[" + DateTime.Now + "]");
                                listBox1.Items.Add("�����ı�����Ϣ");
                                listBox1.Items.Add("���ϵ绰��" + RsTel.ToString());
                                listBox1.Items.Add("�������ݣ�" + RsCon.ToString());
                                listBox1.Items.Add("��������" + Rsdate.ToString());
                                listBox1.Items.Add("----------------------------------------------------------------");
                                listBox1.Items.Add(axSzhtoSms1.YhSendSms(sCen, RsTel, sCon, 0));

                            }
                            else
                            {
                                try
                                {
                                    listBox1.Items.Add("============================================================");
                                    listBox1.Items.Add("[" + DateTime.Now + "]");

                                    Unclassified_FaultManager1.Addnewfault(RsCon, Rsdate, RsTel);
                                    listBox1.Items.Add("���ϵ绰��" + RsTel.ToString());
                                    listBox1.Items.Add("�������ݣ�" + RsCon.ToString());
                                    listBox1.Items.Add("��������" + Rsdate.ToString());
                                    listBox1.Items.Add("���Ž��ճɹ�");
                                    listBox1.Items.Add("----------------------------------------------------------------");
                                    EffectiveSMScout++;
                                }
                                catch (Exception ex)
                                {
                                    MessageBox.Show(ex.Message, "����", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                }
                            }
                        }
                        else
                        {
                            listBox1.Items.Add("============================================================");
                            listBox1.Items.Add("[" + DateTime.Now + "]");
                            listBox1.Items.Add("�ɹ����˶���");
                            listBox1.Items.Add("���ϵ绰��" + RsTel.ToString());
                            listBox1.Items.Add("�������ݣ�" + RsCon.ToString());
                            listBox1.Items.Add("��������" + Rsdate.ToString());
                        }
                    }

                    if (EffectiveSMScout > 0)
                    {
                        SqlConnection conn = DBHelper.getConnection(Connectionstring);
                        conn.Open();
                        string sql = "select IPAddress from Users where Status='����'";
                        SqlDataAdapter ds = new SqlDataAdapter(sql, conn);
                        DataTable dt = new DataTable();
                        ds.Fill(dt);
                        for (int j = 0; j < dt.Rows.Count; j++)
                        {
                            newmessage nmg = new newmessage();
                            nmg.Kind = "����è��ܰ��ʾ";
                            nmg.Messagecontent = "���µĹ�����Ϣ����ע����գ�";
                            nmg.Date = DateTime.Now.ToString();
                            //nmg.Phone = "asdas";
                            Sendinfor(dt.Rows[j]["IPAddress"].ToString().Trim(), nmg);
                        }
                    }

                }

            }
        }
示例#2
0
        /// <summary>
        /// ������µ���Ϣ����֪ͨ�ͻ���
        /// </summary>
        private void Sendinfor(string clientip, newmessage newsmessage1)
        {
            Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            IPEndPoint ipe1 = new IPEndPoint(IPAddress.Parse(clientip), 8562);
            try
            {
                socket.Connect(ipe1);
                if (socket.Connected == true)
                {
                    newmessage newmessage1 = new newmessage();
                    newmessage1 = newsmessage1;
                    MemoryStream stream = new MemoryStream();
                    IFormatter formatmatter = new BinaryFormatter();
                    formatmatter.Serialize(stream, newmessage1);
                    stream.Flush();
                    byte[] newsms = stream.ToArray();

                    socket.Send(newsms);
                }

            }
            catch (SocketException ex)
            {

                listBox1.Items.Add("============================================================");
                listBox1.Items.Add("[" + DateTime.Now + "]");
                listBox1.Items.Add("������Ϣ��������");
                listBox1.Items.Add(ex.Message.ToString());
            }
        }