Пример #1
0
        void createJsonArray()
        {
            var json = JsonConvert.SerializeObject(
                new {
                StudentId = ids,
                Header    = mme,
                Result    = results
            });
            //var jsonSerialiser = new JavaScriptSerializer();
            //  var json = jsonSerialiser.Serialize(data);
            HttpReqest h   = new HttpReqest();
            String     res = h.sendNotice("+8801736549421", "anwar", "test", json, "cse", "result");

            Console.Write("Http Request callback " + res);
            //  Console.Write("jasson array " + res);
        }
Пример #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");
            }
        }
Пример #3
0
        private void send()
        {
            if (progress == null)
            {
                var context = TaskScheduler.FromCurrentSynchronizationContext();
                progress       = new Progress();
                progress.Owner = this;
                progress.Show();
                ids.Clear();
                results.Clear();
                // MessageBox.Show(id1.ToString() + " " + id2.ToString(), "ids", MessageBoxButtons.OK, MessageBoxIcon.Error);
                System.Threading.Tasks.Task task = System.Threading.Tasks.Task.Factory.StartNew(() =>
                {
                    if (type == "image" || type == "pdf")
                    {
                        path = httpReq.uploadFile(path);
                    }
                    if (path != null && !path.Equals("0"))
                    {
                        if (type == "result")
                        {
                            readDocx(path);
                        }
                        else
                        {
                            String ii = beg_id.Text;
                            ii        = (ii.Substring(0, ii.LastIndexOf("-"))).Replace("-", "");
                            for (int i = id1; i <= id2; i++)
                            {
                                IdModel im = new IdModel();
                                im.id      = ii + i.ToString();
                                ids.Add(im);
                            }
                            mme.header = path;
                        }
                        String json = createJsonArray();
                        Console.WriteLine("send ssd  " + json);
                        Console.ReadLine();
                        res = httpReq.sendNotice(this.phone, this.password, name, json, dept, type);
                        Console.WriteLine("send ssd  ");
                    }
                }).ContinueWith(_ =>
                {
                    dept = null;
                    path = null;
                    type = null;
                    progress.Close();
                    progress = null;
                    if (res != "0")
                    {
                        errorMsg.setMsg("Successful", "Send");
                        errorMsg.ShowDialog();
                    }
                    else
                    {
                        errorMsg.setMsg("Error", "Failed");
                        errorMsg.ShowDialog();
                    }

                    Console.WriteLine("send result callBack " + res);
                }, context);
            }
            else
            {
                errorMsg.Activate();
            }
        }