예제 #1
0
        // -- some stuff goes here that keeps track of the task pool list and interacts with it.
        public void addTask()
        {
            ion.User u         = new ion.User();
            string   tmpTaskID = strings.TruncateString(u.genID, 10);

            string[] tmpout = outboundNumbers.Items.OfType <string>().ToArray();
            Spammer  sp     = new Spammer()
            {
                numberToCall = offenderNumberTxt.Text,
                recordAudio  = checkBox2.Checked,
                autoStart    = checkBox1.Checked,
                taskID       = tmpTaskID,
                //accountID = (string)ion2.settings.Get("accid"),
                accountID = textBox3.Text,
                //authToken = (string)ion2.settings.Get("authsecret"),
                authToken       = textBox4.Text,
                outgoingNumbers = tmpout,
                sayMessage      = voiceMsgTxt.Text
            };

            u = null;
            ListViewItem tmp = new ListViewItem()
            {
                Name = "JobTask_" + sp.taskID,
                Tag  = (string)sp.taskID,
                Text = sp.taskID
            };

            tmp.SubItems.Add("Idle");
            listView1.Items.Add(tmp);
            Q.Add(sp.taskID, sp.manualStart(sp.autoStart));
        }
        private void load(object s, EventArgs e)
        {
            u = new ion.User();
            ion2.loadSettings(); // automatically initialize settings class
            // then loads settings to dictionary object


            // --------
            listView1.ContextMenu = new ContextMenu()
            {
                Name = "taskListMenu"
            };

            MenuItem ls1 = new MenuItem("Remove Task");
            MenuItem ls2 = new MenuItem("Start Task");

            ls1.Click += (ee, bb) => {
                if (listView1.SelectedItems.Count < 1)
                {
                    return;
                }
                removeTask((string)listView1.SelectedItems[0].Tag);
            };
            ls2.Click += (ci, eo) => {
                if (listView1.SelectedItems.Count < 1)
                {
                    return;
                }
                startTask((string)listView1.SelectedItems[0].Tag);
            };
            listView1.ContextMenu.MenuItems.Add(ls1);
            listView1.ContextMenu.MenuItems.Add(ls2);
            listView1.ContextMenu.Popup += (df, vn) => {
                if (listView1.SelectedItems.Count < 1)
                {
                    return;
                }
            };

            // -------------
            FormClosing += (ee, vv) => {
                foreach (Spammer spc in Q.Values)
                {
                    spc.Stop();
                }
                ion2.saveSettings();
            };

            // -------------

            Q = new Dictionary <string, Spammer>();


            // -------------- timer 1
            System.Windows.Forms.Timer tt = new System.Windows.Forms.Timer();
            tt.Interval = 350;
            tt.Tick    += (df, gd) => {
                counterLbl.Text = (string)"Queue: " + Q.Count;
            };
            tt.Start();
            // -------------- status timer
            System.Windows.Forms.Timer ty = new System.Windows.Forms.Timer();
            ty.Interval = 1000;
            ty.Tick    += (em, cl) => {
                foreach (ListViewItem ii in listView1.Items)
                {
                    Spammer spc = Q[(string)ii.Tag];
                    ii.SubItems[1].Text = spc.Status();
                }
            };
            ty.Start();
        }