Пример #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     //create the constructor with post type and few data
     MyWebRequest myRequest = new MyWebRequest(url+"/api/login.php", "POST", "p_id=" + textBox1.Text + "&password="******"fail")
     {
         Console.WriteLine("No such Store Manager");
         label3.Text = "No such Store Manager";
     }
     else
     {
         Console.WriteLine(res);
         label3.Text = "";
         Form syncForm = new sync(res);
         syncForm.Show();
         syncForm.Activate();
     }
 }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (foldername == "") MessageBox.Show("Please Enter the folder name");
            else
            {
                string newFile = "";
                string[] file = File.ReadAllLines(transfolder);

                foreach (string line in file)
                {
                    string[] words = line.Split(' ');
                    Console.WriteLine("Barcode:" + words[0]);
                    Console.WriteLine("Quantity:" + words[1]);
                    Console.WriteLine("Profits:" + words[2]);
                    Console.WriteLine("Transaction Id:" + words[3]);
                    Console.WriteLine("Time:" + words[4] + ' ' + words[5]);
                    if (words[6] == "0")
                    {
                        //create the constructor with post type and few data
                        MyWebRequest myRequest = new MyWebRequest(url+"/api/transaction.php", "POST", "s_id=" + s_id + "&i_id=" + words[0] + "&quantity=" + words[1] + "&profit=" + words[2] + "&trans_id=" + words[3] + "&trans_time=" + words[4] + " " + words[5]);
                        //show the response string on the console screen.
                        Console.WriteLine(myRequest.GetResponse());
                        words[6] = "1";
                        newFile += String.Join(" ", words);
                        newFile += "\r\n";
                        continue;
                    }

                    newFile += (line + "\r\n");

                }

                MessageBox.Show("Finished Transaction Syncrnization");
                File.WriteAllText(transfolder, newFile.ToString());
            }
        }
Пример #3
0
        // Specify what you want to happen when the Elapsed event is raised.
        private static void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            string newFile = "";
            string[] file = File.ReadAllLines(transfolder);
            foreach (string line in file)
            {
                string[] words = line.Split(' ');
                if (words[6] == "0")
                {
                    //create the constructor with post type and few data
                    MyWebRequest myRequest = new MyWebRequest(url+"/api/transaction.php", "POST", "s_id=" + s_id + "&i_id=" + words[0] + "&quantity=" + words[1] + "&profit=" + words[2] + "&trans_id=" + words[3] + "&trans_time=" + words[4] + " " + words[5]);
                    //show the response string on the console screen.
                    Console.WriteLine(myRequest.GetResponse());
                    words[6] = "1";
                    newFile += String.Join(" ", words);
                    newFile += "\r\n";
                    continue;
                }

                newFile += (line + "\r\n");

            }

            File.WriteAllText(transfolder, newFile.ToString());
            // used to build entire input
            StringBuilder sb = new StringBuilder();

            // used on each read operation
            byte[] buf = new byte[8192];

            // prepare the web page we will be asking for
            HttpWebRequest request = (HttpWebRequest)
                WebRequest.Create(url+"/api/price.php?s_id="+s_id);

            // execute the request
            HttpWebResponse response = (HttpWebResponse)
                request.GetResponse();

            // we will read data via the response stream
            Stream resStream = response.GetResponseStream();

            string tempString = null;
            int count = 0;

            do
            {
                // fill the buffer with data
                count = resStream.Read(buf, 0, buf.Length);

                // make sure we read some data
                if (count != 0)
                {
                    // translate from bytes to ASCII text
                    tempString = Encoding.ASCII.GetString(buf, 0, count);

                    // continue building the string
                    sb.Append(tempString);
                }
            }
            while (count > 0); // any more data to read?

            // Write the string to a file.
            System.IO.StreamWriter file2 = new System.IO.StreamWriter(pricefolder);
            file2.Write(sb.ToString());

            file2.Close();
            Console.WriteLine(sb.ToString());
        }