Exemple #1
0
        private void btn_block_Click(object sender, EventArgs e)
        {
            String btext = btn_block.Text;

            if (progress == null)
            {
                var context = TaskScheduler.FromCurrentSynchronizationContext();
                progress       = new Progress();
                progress.Owner = this;
                progress.Show();
                if (btext.Equals("Block"))
                {
                    Task newtask = Task.Factory.StartNew(() =>
                    {
                        res = req.userBlock(this.phone, this.password, contact, "Block");
                    }).ContinueWith(_ => {
                        progress.Close();
                        progress = null;
                        if (res != "0")
                        {
                            btn_block.Text = "Unblock";
                            errorMsg       = new DialogMessage("Successful", "Blocked");
                            errorMsg.ShowDialog();
                        }
                        else
                        {
                            showErrorDialog("Failed");
                        }

                        Console.WriteLine("send result callBack " + res);
                    }, context);
                }
                else
                {
                    Task newtask = Task.Factory.StartNew(() =>
                    {
                        res = req.userBlock(this.phone, this.password, contact, "Hi");
                    }).ContinueWith(_ => {
                        progress.Close();
                        progress = null;
                        if (res != "0")
                        {
                            btn_block.Text = "Block";
                            errorMsg       = new DialogMessage("Successful", "Unblocked");
                            errorMsg.ShowDialog();
                        }
                        else
                        {
                            showErrorDialog("Failed");
                        }

                        Console.WriteLine("send result callBack " + res);
                    }, context);
                }
                Console.WriteLine("block result " + res);
            }
        }
Exemple #2
0
        private void btn_send_Click(object sender, EventArgs e)
        {
            if (dept != null && !dept.Equals(""))
            {
                if (progress == null)
                {
                    var context = TaskScheduler.FromCurrentSynchronizationContext();
                    progress       = new Progress();
                    progress.Owner = this;
                    progress.Show();

                    System.Threading.Tasks.Task task = System.Threading.Tasks.Task.Factory.StartNew(() =>
                    {
                        if (readDocx(path))
                        {
                            String json = createJsonArray();
                            Console.WriteLine("send ssd  " + json);
                            res = httpReq.sendNotice(this.phone, this.password, "Final Result", json, dept, "result");
                        }
                        Console.WriteLine("send ssd  ");
                    }).ContinueWith(_ => {
                        progress.Close();
                        progress = null;
                        if (res != "0")
                        {
                            errorMsg = new DialogMessage("Successful", "Result send");
                            errorMsg.ShowDialog();
                        }
                        else
                        {
                            showErrorDialog("Failed to send");
                        }


                        Console.WriteLine("send result callBack " + res);
                    }, context);
                }
            }
            else
            {
                showErrorDialog("Select department");
            }
        }
Exemple #3
0
 private void showErrorDialog(String msg)
 {
     errorMsg = new DialogMessage(msg);
     errorMsg.ShowDialog();
 }