Exemple #1
0
 private void button3_Click(object sender, EventArgs e)
 {
     ThreadPool.QueueUserWorkItem((obj) =>
     {
         log        += DateTime.Now.ToString() + ":Start to Dynamic Deal the Question\n";
         DateTime dt = DateTime.Now;
         int index   = listBox1.SelectedIndex;
         dataExtraction.dynamic_Deal(index);
         int result     = dataExtraction.get_Result(index);
         textBox2.Text  = result.ToString();
         int[] selected = dataExtraction.get_Route(index);
         listBox2.Items.Clear();
         for (int i = 0; i < dataExtraction.get_items_Set_Count(index); i++)
         {
             listBox2.Items.Add((i + 1).ToString() + ":" + selected[i].ToString());
         }
         DateTime dtt  = DateTime.Now;
         textBox3.Text = Convert.ToString((dtt - dt).TotalSeconds);
         log          += DateTime.Now.ToString() + ":Dynamic Deal Finished\n";
     });
 }
        public void DSW(string fn, int index)
        {
            try
            {
                int state = get_Connect_State();
                if (state == 1)
                {
                    send_Data_To_Server("DSW");
                    string temp = read_Data_From_Server();

                    if (temp.Equals("OK"))
                    {
                        int count = dataExtraction.get_items_Set_Count(index) * 3;
                        send_Data_To_Server(count.ToString());

                        temp = read_Data_From_Server();
                        if (temp.Equals("OK"))
                        {
                            int i = 0;
                            do
                            {
                                string[] send = dataExtraction.get_DSW_Str(index, i);
                                for (int j = 0; j < 3 && temp.Equals("OK"); j++)
                                {
                                    send_Data_To_Server(fn + "#" + index.ToString() + "#" + i.ToString() + "#" + send[j]);
                                    temp = read_Data_From_Server();
                                }


                                i++;
                            } while (temp.Equals("OK") && i < count);
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }