示例#1
0
        private void button3_Click_1(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            //Save();
            order             ord        = new order();
            XmlSerializer     serializer = new XmlSerializer(typeof(order));
            XmlReaderSettings settings   = new XmlReaderSettings();

            settings.ConformanceLevel = ConformanceLevel.Fragment;
            settings.IgnoreWhitespace = true;
            settings.IgnoreComments   = true;
            XmlReader xmlReader = XmlReader.Create("order.xml", settings);

            xmlReader.Read();
            ord = (order)serializer.Deserialize(xmlReader);
            RawPrinterHelper.SendStringToPrinter(comboBox1.SelectedItem.ToString(), ord.order_details);
            Cursor.Current = Cursors.Default;
        }
示例#2
0
        public static bool GetOrders(CustomerConfig configData, out bool hasOrder, out string retVal)
        {
            bool linkActive = false;

            retVal   = "OK";
            hasOrder = false;
            string resp = String.Empty;

            resp = String.Empty;
            //EventLog.WriteEntry("SplickIt Remote Printing", "HTTP Request");
            // prepare the web page we will be asking for
            String requestUriStr = "https://" + configData.Server +
                                   "/app2/messagemanager/getnextmessagebymerchantid/" +
                                   configData.Key +
                                   "/winapp/";
            HttpWebRequest request = (HttpWebRequest)
                                     WebRequest.Create(requestUriStr);

            try
            {
                request.Timeout = configData.Timeout_mSec; // 10 seconds
                // execute the request
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    // Get the stream associated with the response.
                    Stream receiveStream = response.GetResponseStream();

                    // Pipes the stream to a higher level stream reader with the required encoding format.
                    StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);
                    resp     = HttpUtility.UrlDecode(readStream.ReadToEnd());
                    hasOrder = resp.Contains("<order_id>");
                    if (hasOrder)
                    {
                        order ord = new order();
                        // Read a purchase order.
                        XmlSerializer serializer = new XmlSerializer(typeof(order));

                        XmlReaderSettings settings = new XmlReaderSettings();
                        settings.ConformanceLevel = ConformanceLevel.Fragment;
                        settings.IgnoreWhitespace = true;
                        settings.IgnoreComments   = true;

                        XmlReader xmlReader = XmlReader.Create(new StringReader(resp), settings);
                        xmlReader.Read();

                        ord = (order)serializer.Deserialize(xmlReader);
                        RawPrinterHelper.SendStringToPrinter(configData.Printer, ord.order_details);
                        retVal = ord.order_details;
                    }
                    else
                    {
                        retVal = "NO Order";
                    }
                    readStream.Close();
                    linkActive = true;
                }
                else
                {
                    //error
                    retVal     = "Error:" + response.StatusDescription;
                    linkActive = false;
                }
                response.Close();
            }
            catch (System.Net.WebException ex)
            {
                retVal     = "Error:" + ex.Message;
                linkActive = false;
            }

            return(linkActive);
        }