コード例 #1
0
        public Action <SmsMessage> SmsSubscribe(TextBoxOutput output = null)
        {
            return((s) =>
            {
                var r = s.Clone();
                r.ReceivedTime = DateTime.Now;
                r.Status = SmsMessage.MsgStatus.Received;

                foreach (Contact contact in phone.UseComponent <Memory>().Get <Contact>())
                {
                    foreach (var item in contact.SmsReceiver)
                    {
                        if (item == r.Sender)
                        {
                            r.ReceivedFrom = contact.Name;
                            break;
                        }
                    }
                }

                if (r.ReceivedFrom == null)
                {
                    Contact contact = new Contact($"Unknown{unknown}", r.Sender, null);
                    r.ReceivedFrom = contact.Name;
                    phone.AddContact(contact);
                    unknown++;
                }

                phone.UseComponent <Memory>().Add <SmsMessage>(r);
                output?.WriteLine(r.ToString());
            });
        }
コード例 #2
0
        public SendManySms()
        {
            InitializeComponent();

            smsPhone1 = new SmsPhone(FormFactor.Bar, "BP20200406");
            smsPhone1.AddSimCard(new SimCard(), output);
            smsPhone2 = new SmsPhone(FormFactor.Bar, "BP20200409");
            smsPhone2.AddSimCard(new SimCard(), output);
            smsPhone3 = new SmsPhone(FormFactor.Bar, "BP20200406");
            smsPhone3.AddSimCard(new SimCard(), output);
            smsPhone4 = new SmsPhone(FormFactor.Bar, "BP20200409");
            smsPhone4.AddSimCard(new SimCard(), output);

            output = new TextBoxOutput(this.receivedSms);

            var contact1 = smsPhone1.GetMyContact("Alex");
            var contact2 = smsPhone2.GetMyContact("Vova");
            var contact3 = smsPhone3.GetMyContact("Stas");
            var contact4 = smsPhone4.GetMyContact("Oleg");

            smsPhone1.AddContact(contact2, contact3, contact4);
            smsPhone2.AddContact(contact1);
            smsPhone3.AddContact(contact1);
            smsPhone4.AddContact(contact1);

            phones = new IPhone[] { smsPhone1, smsPhone2, smsPhone3, smsPhone4 };

            smsFormatting.DataSource = Enum.GetNames(typeof(TextBoxOutput.FormatingStyle));
            cmbWords.DataSource      = new List <string>()
            {
                FILTER_ALL_VALUES
            }.Concat(words).ToArray();
            cmbLogic.DataSource  = Enum.GetNames(typeof(LogicOperand));
            dtpFrom.CustomFormat = "dd/MM/yyyy hh:mm:ss";
            dtpTo.CustomFormat   = "dd/MM/yyyy hh:mm:ss";

            resetFilters();

            sendSms = delegate
            {
                int arrLength = words.Length - 1;
                smsPhone1.SendSms($"smsVSO|{words[random.Next(arrLength)]}|{smsCount++}", output, 0, "Vova", "Stas", "Oleg");
                smsPhone2.SendSms($"smsVA|{words[random.Next(arrLength)]}|{smsCount++}", output, 0, "Alex");
                smsPhone3.SendSms($"smsSA|{words[random.Next(arrLength)]}|{smsCount++}", output, 0, "Alex");
                smsPhone4.SendSms($"smsOA|{words[random.Next(arrLength)]}|{smsCount++}", output, 0, "Alex");

                cbxSubscribers.DataSource = getAllSenders(phones);
            };

            powerbank             = new PowerBank("PB20200430");
            powerbank.PluginToUse = Plugins.Usb;
        }
コード例 #3
0
        public SendSmsReceiveCalls()
        {
            InitializeComponent();

            outputEvents = new TextBoxOutput(this.receivedEvents);

            phone1 = new SmsCallPhone(FormFactor.Bar, "BP20200406");
            phone1.AddSimCard(new SimCard(), outputEvents);

            phone2 = new SmsCallPhone(FormFactor.Bar, "BP20200409");
            phone2.AddSimCard(new SimCard(), outputEvents);

            phone3 = new SmsCallPhone(FormFactor.Bar, "BP20200406");
            phone3.AddSimCard(new SimCard(), outputEvents);

            phone41 = new SmsCallPhone(FormFactor.Bar, "BP20200409");
            phone41.AddSimCard(new SimCard(), outputEvents);

            phone42 = new SmsCallPhone(FormFactor.Bar, "BP20200507");
            phone42.AddSimCard(new SimCard(), outputEvents);

            phone5 = new SmsCallPhone(FormFactor.Bar, "BP20200511");
            phone5.AddSimCard(new SimCard(), outputEvents);
            phone5.AddSimCard(new SimCard(), outputEvents);

            var contact1  = phone1.GetMyContact("Alex");
            var contact2  = phone2.GetMyContact("Vova");
            var contact3  = phone3.GetMyContact("Stas");
            var contact41 = phone41.GetMyContact("Oleg");
            var contact42 = phone42.GetMyContact("Oleg");
            var contact51 = phone5.GetMyContact("Roma");
            var contact52 = phone5.GetMyContact("Roma", 1);

            phone1.AddContact(contact2, contact42, contact51, contact52);
            phone2.AddContact(contact1);
            phone3.AddContact(contact1);
            phone41.AddContact(contact1);
            phone42.AddContact(contact1);
            phone5.AddContact(contact1);

            phones = new IPhone[] { phone1, phone2, phone3, phone41, phone42, phone5 };

            smsFormatting.DataSource = Enum.GetNames(typeof(TextBoxOutput.FormatingStyle));
            cmbWords.DataSource      = new List <string>()
            {
                FILTER_ALL_VALUES
            }.Concat(words).ToArray();
            cmbLogic.DataSource  = Enum.GetNames(typeof(LogicOperand));
            dtpFrom.CustomFormat = "dd/MM/yyyy hh:mm:ss";
            dtpTo.CustomFormat   = "dd/MM/yyyy hh:mm:ss";

            resetFilters();

            sendSms = delegate
            {
                int arrLength = words.Length - 1;
                phone1.SendSms($"smsVSOR|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Vova", "Oleg", "Roma");
                phone2.SendSms($"smsVA|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone3.SendSms($"smsSA|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone41.SendSms($"smsOA|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone42.SendSms($"smsOA|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone5.SetActiveSimCard(0).SendSms($"smsR1A|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");
                phone5.SetActiveSimCard(1).SendSms($"smsR2A|{words[random.Next(arrLength)]}|{smsCount++}", outputEvents, 0, "Alex");

                cbxSubscribers.DataSource = getAllSenders(phones);
            };

            var callers = new IPhone[] { phone2, phone41, phone42, phone5 };
            var callTo  = new string[] { "Vova", "Oleg", "Roma" };

            receiveCalls = delegate
            {
                callers[random.Next(3)].SetActiveSimCard(0).MakeCall(random.Next(300, 3000), "Alex", outputEvents);
                phone1.MakeCall(random.Next(300, 3000), callTo[random.Next(2)], outputEvents);

                phone5.SetActiveSimCard(0).MakeCall(random.Next(300, 3000), "Alex", outputEvents);
                phone5.SetActiveSimCard(1).MakeCall(random.Next(300, 3000), "Alex", outputEvents);

                phone1.MakeCall(random.Next(300, 3000), "Oleg", outputEvents);
                phone1.MakeCall(random.Next(300, 3000), "Roma", outputEvents, 1);
                phone1.MakeCall(random.Next(300, 3000), "Roma", outputEvents);


                phone3.MakeCall(111, "Alex", outputEvents);
                phone3.MakeCall(222, "Alex", outputEvents);

                phone41.MakeCall(333, "Alex", outputEvents);
                phone41.MakeCall(444, "Alex", outputEvents);

                cbxSubscribers.DataSource = getAllCallers(phones);
            };

            powerbank             = new PowerBank("PB20200430");
            powerbank.PluginToUse = Plugins.Usb;
        }