Пример #1
0
        private void button_login_Click(object sender, EventArgs e)
        {
            if (isAvailable())
            {
                String phone = phone_text.Text;
                String pass  = password_text.Text;
                Match  m     = reg.Match(phone);
                if (m.Success && pass.Length > 4)
                {
                    if (progress == null)
                    {
                        var context = TaskScheduler.FromCurrentSynchronizationContext();
                        progress       = new Progress();
                        progress.Owner = this;
                        progress.Show();
                        req = new HttpReqest();
                        Task newtask = Task.Factory.StartNew(() =>
                        {
                            res = req.sendAuthenticatioReqest(phone, pass, "cse");
                        }

                                                             ).ContinueWith(_ =>
                        {
                            progress.Close();
                            progress = null;
                            if (!res.Equals("0"))
                            {
                                Main main        = new Main(phone, pass, res);
                                main.FormClosed += new FormClosedEventHandler(mainClose);
                                main.Show();
                                this.Hide();
                            }
                            else
                            {
                                errorDilog.setMsg("Error", "Phone or Password does't match");
                                errorDilog.ShowDialog();
                            }
                        }, context);
                    }
                    else
                    {
                        progress.Activate();
                    }
                }
                else
                {
                    error_label.Text = "Invalid phone or password";
                }
            }
            else
            {
                errorDilog.setMsg("Error", "Internet connections are not available");
                errorDilog.ShowDialog();
            }
        }
Пример #2
0
        private void spinner_dept_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (counter != 0)
            {
                if (Login.isAvailable())
                {
                    if (progress == null)
                    {
                        var context = TaskScheduler.FromCurrentSynchronizationContext();
                        progress       = new Progress();
                        progress.Owner = this;
                        progress.Show();
                        String de = spinner_dept.SelectedItem.ToString().ToLower();
                        Console.WriteLine("Conbobox selection " + de);

                        Task newtask = Task.Factory.StartNew(() =>
                        {
                            res = req.sendAuthenticatioReqest(this.phone, this.password, de);
                        }).ContinueWith(_ =>
                        {
                            progress.Close();
                            progress = null;
                            if (res != null && res != null)
                            {
                                updateTable(res);
                            }
                            else
                            {
                                errorDialog.setMsg("Error", "Failed to featched information");
                                errorDialog.ShowDialog();
                            }
                        }, context);
                    }
                    else
                    {
                        progress.Activate();
                    }
                }
                else
                {
                    errorDialog.setMsg("Error", "Internet connections are not available");
                    errorDialog.ShowDialog();
                }
            }
            counter++;
        }
Пример #3
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);
            }
        }
Пример #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Match m  = reg.Match(beg_id.Text);
            Match m2 = reg.Match(end_id.Text);

            if (dept != null)
            {
                if (type != null)
                {
                    if (type == "result")
                    {
                        name = "Final Result";
                        send();
                    }
                    else
                    {
                        if (m.Success && m2.Success)
                        {
                            try
                            {
                                String[] s  = (beg_id.Text).Split("-".ToCharArray());
                                String[] s1 = (end_id.Text).Split("-".ToCharArray());
                                id1 = Convert.ToInt32(s[2]);
                                id2 = Convert.ToInt32(s1[2]);;
                            } catch (StackOverflowException ee) {}
                            if (id1 <= id2)
                            {
                                if (type == "text")
                                {
                                    path = msg.Text;
                                }
                                send();
                            }
                            else
                            {
                                errorMsg.setMsg("Error", "Ending id must be equal or greater then begnning id");
                                errorMsg.ShowDialog();
                            }
                        }
                        else
                        {
                            errorMsg.setMsg("Error", "Invalid id");
                            errorMsg.ShowDialog();
                        }
                    }
                }
                else
                {
                    errorMsg.setMsg("Error", "Select notice type");
                    errorMsg.ShowDialog();
                }
            }
            else
            {
                errorMsg.setMsg("Error", "Select department");
                errorMsg.ShowDialog();
            }
        }
Пример #5
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");
            }
        }
Пример #6
0
 private void showErrorDialog(String msg)
 {
     errorMsg = new DialogMessage(msg);
     errorMsg.ShowDialog();
 }