Inheritance: IPerformanceTest
Esempio n. 1
0
 public Form1()
 {
     InitializeComponent();
     //初始化委托字段
     labeladd = new LabelAdd(labeladdstr);
     listadd  = new ListAdd(ListAddstr);
 }
Esempio n. 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            listAdd = new ListAdd(ListAddStr);
            IPAddress[] ips  = Dns.GetHostAddresses("");
            int         port = 51883;

            txtLocalIP.Text    = ips[3].ToString();
            txtLocalPort.Text  = port.ToString();
            txtRemoteIP.Text   = ips[3].ToString();
            txtRemotePort.Text = port.ToString();
        }
Esempio n. 3
0
 private void ReceiveMsg()
 {
     while (receiveFlag)
     {
         try
         {
             IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
             Byte[]     receiveBytes     = udpClient.Receive(ref RemoteIpEndPoint);
             //ReceiveData:0000;
             if (receiveFlag)
             {
                 if (receiveBytes.Length > 4)
                 {
                     if (RemoteIpEndPoint.Address.ToString() != IPAddress.Any.ToString())
                     {
                         using MemoryStream memoryStream = new MemoryStream(receiveBytes);
                         using BinaryReader binaryReader = new BinaryReader(memoryStream);
                         string IPAddr = RemoteIpEndPoint.Address.ToString();
                         MKInfo mkInfo = new MKInfo()
                         {
                             IPAddr = IPAddr
                         };
                         //TLV格式的数据指针偏移4
                         binaryReader.BaseStream.Position = 4;
                         //开始读取TLV格式的数据
                         //递归方法读取二进制流的数据。
                         ReadBytes(binaryReader, ref mkInfo);
                         foreach (MKInfo t in mkInfos)
                         {
                             if (t.IPAddr == mkInfo.IPAddr && t.MacAddr == mkInfo.MacAddr)
                             {
                                 int        i  = mkInfos.IndexOf(t);
                                 ListRemove lr = new ListRemove(MKInfoRemove);
                                 lr(i);
                                 break;
                             }
                         }
                         ListAdd la = new ListAdd(MKInfoAdd);
                         la(mkInfo);
                     }
                 }
             }
         }
         catch (ObjectDisposedException) { }
         catch (SocketException) { }
     }
     udpClient.Dispose();
 }
Esempio n. 4
0
    public static int Main()
    {
        ListAdd test = new ListAdd();

        TestLibrary.TestFramework.BeginTestCase("ListAdd");

        if (test.RunTests())
        {
            TestLibrary.TestFramework.EndTestCase();
            TestLibrary.TestFramework.LogInformation("PASS");
            return(100);
        }
        else
        {
            TestLibrary.TestFramework.EndTestCase();
            TestLibrary.TestFramework.LogInformation("FAIL");
            return(0);
        }
    }
Esempio n. 5
0
        private void InsertSMSClick()
        {
            var email   = new EmailAddressAttribute();
            var website = new UrlAttribute();

            if (email.IsValid(TBoxSender))
            {
                string[] Body = TBoxBody.Split(' ');
                foreach (string word in Body)
                {
                    WebCheck = word;
                    if (website.IsValid(word) || word.Contains("www"))
                    {
                        ListAdd Quarantine = new ListAdd();
                        {
                            Quarantine.ListType = word;
                            Quarantine.Count    = "1";
                        }
                        ListType = "Q";
                        ListQuarantine.Add(Quarantine);

                        SaveToList Q = new SaveToList();

                        if (!Q.WriteToCSV(ListQuarantine, ListType))
                        {
                            MessageBox.Show("Error while saving\n" + Q.ErrorCode);
                        }
                        else
                        {
                            Q = null;
                        }

                        WebCheck = WebCheck.Replace(WebCheck, "<URL Quarantined>");
                        MessageBox.Show(WebCheck);
                        for (int x = 0; x < Body.Length; x++)
                        {
                            if (Body[x] == word)
                            {
                                Body[x] = Body[x].Replace(word, WebCheck);
                            }
                        }
                    }
                }
                TBoxBody = string.Join(" ", Body);
                MessageBox.Show(TBoxBody);

                EmailAdd AddEmail = new EmailAdd();
                {
                    AddEmail.MessageID = "E" + TBoxMID;
                    AddEmail.Sender    = TBoxSender;
                    try
                    {
                        AddEmail.Subject = "SIR " + DPickerContent.ToString();
                        check            = true;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Please Select a date");
                        check = false;
                    }
                    AddEmail.Body = CentreCode + "" + Incident + "" + TBoxBody;
                }

                if (check == true)
                {
                    ListEmail.Add(AddEmail);

                    SaveToFile save = new SaveToFile();

                    if (!save.EmailToCSV(ListEmail, MessageType))
                    {
                        MessageBox.Show("Error while saving\n" + save.ErrorCode);
                    }
                    else
                    {
                        save = null;
                    }

                    ListAdd SIRList = new ListAdd();
                    {
                        SIRList.ListType = AddEmail.Subject;
                        SIRList.Count    = "66-666-99";
                    }

                    ListType = "S";
                    ListSIR.Add(SIRList);

                    SaveToList SIR = new SaveToList();
                    if (!SIR.WriteToCSV(ListSIR, ListType))
                    {
                        MessageBox.Show("Error while saving\n" + SIR.ErrorCode);
                    }
                    else
                    {
                        SIR = null;
                    }
                    MessageBox.Show("Order saved");
                }
            }
            else
            {
                MessageBox.Show("Wrong");
            }
        }
Esempio n. 6
0
 public void AddElement(T elem)
 {
     this.Add(elem);
     ListAdd.Raise(this, new ListChangedEventArg(this.Count - 1, elem));
 }
Esempio n. 7
0
 private void OnListAdd(EventArgs e)
 {
     ListAdd?.Invoke(this, e);
 }
        private void InsertSMSClick()
        {
            if (string.IsNullOrWhiteSpace(TBoxMID) || string.IsNullOrWhiteSpace(TBoxSender) || string.IsNullOrWhiteSpace(TBoxBody))
            {
                MessageBox.Show("Please fill out all boxes please");
                return;
            }

            MessageAdd AddMessage = new MessageAdd();

            {
                AddMessage.MessageID = "T" + TBoxMID;
                AddMessage.Sender    = "@" + TBoxSender;
                AddMessage.Body      = TBoxBody;
            }

            ListMessage.Add(AddMessage);

            SaveToFile File = new SaveToFile();

            if (!File.WriteToCSV(ListMessage, MessageType))
            {
                MessageBox.Show("Error while saving\n" + File.ErrorCode);
            }
            else
            {
                File = null;
            }

            ListAdd TweetMentions = new ListAdd();

            {
                TweetMentions.ListType = "@" + TBoxSender;
                TweetMentions.Count    = "1";
            }

            ListType = "M";
            ListMention.Add(TweetMentions);

            SaveToList Mention = new SaveToList();

            if (!Mention.WriteToCSV(ListMention, ListType))
            {
                MessageBox.Show("Error while saving\n" + Mention.ErrorCode);
            }
            else
            {
                Mention = null;
            }

            string[] body = AddMessage.Body.Split(' ');
            foreach (string wrd in body)
            {
                if (wrd.Contains("#"))
                {
                    Hashtag.Add(wrd);
                }
            }

            if (Hashtag.Count != 0)
            {
                foreach (string Hash in Hashtag)
                {
                    ListAdd TweetHashtag = new ListAdd();
                    {
                        TweetHashtag.ListType = Hash;
                        TweetHashtag.Count    = "1";
                    }

                    ListType = "H";
                    ListHashtag.Add(TweetHashtag);

                    SaveToList TweetHash = new SaveToList();

                    if (!TweetHash.WriteToCSV(ListHashtag, ListType))
                    {
                        MessageBox.Show("Error while saving\n" + TweetHash.ErrorCode);
                    }
                    else
                    {
                        TweetHash = null;
                    }
                }
            }
            MessageBox.Show("Order saved");
        }
Esempio n. 9
0
 public Form1()
 {
     InitializeComponent();
     //初始化委托类型字段
     listAdd = new ListAdd(ListAddStr);
 }
Esempio n. 10
0
 private void ReceiveMsg()
 {
     while (receiveFlag)
     {
         try
         {
             IPEndPoint RemoteIpEndPoint = new IPEndPoint(IPAddress.Any, 0);
             Byte[]     receiveBytes     = udpClient.Receive(ref RemoteIpEndPoint);
             //ReceiveData:0000;
             if (receiveFlag)
             {
                 if (receiveBytes.Length > 4)
                 {
                     //可能返回0.0.0.0未配置的设备。过滤掉。
                     if (IPAddress.Any.ToString() != RemoteIpEndPoint.Address.ToString())
                     {
                         using MemoryStream memoryStream = new MemoryStream(receiveBytes);
                         using BinaryReader binaryReader = new BinaryReader(memoryStream);
                         string IPAddr       = RemoteIpEndPoint.Address.ToString();
                         MKInfo mikroTikInfo = new MKInfo()
                         {
                             IPAddr = IPAddr
                         };
                         //TLV格式的数据指针偏移4
                         binaryReader.BaseStream.Position = 4;
                         //开始读取TLV格式的数据
                         //递归方法读取二进制流的数据。
                         ReadBytes(binaryReader, ref mikroTikInfo);
                         //注释掉
                         //逐一读取二进制流的数据
                         //ReadBytes_v2(binaryReader,ref mikroTikInfo);
                         //更新List集合里面的数据
                         //主要更新Uptime的数据
                         int i = int.MinValue;
                         foreach (MKInfo t in mikroTikInfos)
                         {
                             if (t.MacAddr == mikroTikInfo.MacAddr)
                             {
                                 //删除集合List的数据。
                                 i = mikroTikInfos.IndexOf(t);
                                 break;
                             }
                         }
                         if (i >= 0)
                         {
                             //删除集合中存在元素
                             ListRemove lr = new ListRemove(MikroTikInfoRemove);
                             lr(i);
                             //插入到删除元素得位置
                             ListInsert li = new ListInsert(MikroTikInfoInsert);
                             li(i, mikroTikInfo);
                         }
                         else
                         {
                             //追加集合List的数据
                             ListAdd la = new ListAdd(MikroTikInfoAdd);
                             la(mikroTikInfo);
                         }
                     }
                 }
             }
         }
         catch (ObjectDisposedException) { }
         catch (SocketException) { }
         catch (Exception) { }
     }
     udpClient.Dispose();
 }
Esempio n. 11
0
    public static int Main()
    {
        ListAdd test = new ListAdd();

        TestLibrary.TestFramework.BeginTestCase("ListAdd");

        if (test.RunTests())
        {
            TestLibrary.TestFramework.EndTestCase();
            TestLibrary.TestFramework.LogInformation("PASS");
            return 100;
        }
        else
        {
            TestLibrary.TestFramework.EndTestCase();
            TestLibrary.TestFramework.LogInformation("FAIL");
            return 0;
        }
    }