//public static bool ZapisiPrekuWS(String kojSenzor, String podatok1, String podatok2,String podatok3)
        //{
        //    string url = "Sensor/" + kojSenzor + "/" + podatok1 + "/" + podatok2 + "/" + podatok3;
        //    return Prati(url);
        //}

        private static bool PratiDe(String spremnoUrl)
        {
            return true;
            try
            {
          
            // Creates a new web session
            HTTP_Client WebSession = new HTTP_Client(new IntegratedSocket("192.168.2.99", 80));
 
            // Requests the latest source
            HTTP_Client.HTTP_Response Response = WebSession.Get("/TestServis/Sensori.svc/" + spremnoUrl);

            // Did we get the expected response? (a "200 OK")
            //if (Response.ResponseCode != 200)
            //    throw new ApplicationException("Unexpected HTTP response code: " + Response.ResponseCode.ToString());

            // Fetches a response header
           // Debug.Print("Current date according to www.netmftoolbox.com: " + Response.ResponseHeader("date"));

            // Gets the response as a string
           // Debug.Print(Response.ToString());
            }
            catch (Exception ex)
            {
            }
            return true;
        }
Example #2
0
        public static string GetXmlString()
        {
            // Creates a new web session
            //http://query.yahooapis.com/v1/public/yql?q=select%20ChangePercentRealtime%20from%20yahoo.finance.quotes%20where%20symbol%20%3D%20'" + StockTicker + "'&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";

            HTTP_Client WebSession = new HTTP_Client(new IntegratedSocket("query.yahooapis.com", 80));

            while (true)
            {
                string StockTicker = "qqq";
                // Requests the latest source
                string getstring = "/v1/public/yql?q=select%20ChangePercentRealtime%20from%20yahoo.finance.quotes%20where%20symbol%20%3D%20'qqq'&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
                HTTP_Client.HTTP_Response Response = WebSession.Get(getstring);

                // Did we get the expected response? (a "200 OK")
                if (Response.ResponseCode != 200)
                    throw new ApplicationException("Unexpected HTTP response code: " + Response.ResponseCode.ToString());

                // Fetches a response header
                //Debug.Print("Current date according to www.netmftoolbox.com: " + Response.ResponseHeader("date"));

                // Gets the response as a string

                return Response.ToString();
            }
        }
Example #3
0
        public static void Main()
        {
            // Creates a new web session
            HTTP_Client WebSession = new HTTP_Client(new IntegratedSocket("www.netmftoolbox.com", 80));

            // Requests the latest source
            HTTP_Client.HTTP_Response Response = WebSession.Get("/helloworld/");

            // Did we get the expected response? (a "200 OK")
            if (Response.ResponseCode != 200)
                throw new ApplicationException("Unexpected HTTP response code: " + Response.ResponseCode.ToString());

            // Fetches a response header
            Debug.Print("Current date according to www.netmftoolbox.com: " + Response.ResponseHeader("date"));

            // Gets the response as a string
            Debug.Print(Response.ToString());
        }
Example #4
0
 private string NapkinGet(string path)
 {
     try
     {
         WiFlySocket socket = new WiFlySocket(NapkinServerName, NapkinServerPort, _wifly);
         HTTP_Client client = new HTTP_Client(socket);
         client.Authenticate(DeviceId, DeviceId);
         HTTP_Client.HTTP_Response response = client.Get(path);
         return response.ResponseBody;
     }
     catch (Exception ex)
     {
         Debug.Print("Exception in PingServer: " + ex.Message);
         return null;
     }
 }
        public static void WebGet(IndicatorData objIndicatorData)
        {
            try
            {
                var URL = Settings.ShopTrakTransactionsURL.SetParameters(new string[] { Settings.Job, Settings.Suffix.ToString(), Settings.Operation.ToString() });
                Debug.Print("WebGet URL is: " + URL);
                var objURI = new Uri(URL);
                var webClient = new HTTP_Client(new IntegratedSocket(objURI.Host, (ushort)objURI.Port));
                var response = webClient.Get(objURI.AbsolutePath);

                Debug.Print("Data recieved from URL is:\r\n" + response.ResponseBody);
                if (response.ResponseCode != 200) // Did we get the expected response? (a "200 OK")
                    throw new ApplicationException("HTTP Response: " + response.ResponseCode.ToString());
                else if (response.ResponseBody == "[]") //Does the REST Dataset return empty?
                    throw new ApplicationException("Nobody punched in that Job.");

                ArrayList arrayList = JsonSerializer.DeserializeString(response.ResponseBody) as ArrayList;
                Hashtable hashtable = arrayList[0] as Hashtable; //get the first row of records

                //Microsoft.SPOT.Time.TimeService.SetTimeZoneOffset(300);
                Settings.PrintDateTime = DateTimeExtensions.FromASPNetAjax(hashtable["CurrentDateTime"].ToString()).AddHours(-5);//Central Time Zone has 5 hour offset from UTC
                Settings.Item = hashtable["item"].ToString();

                StringBuilder strBldrEmployees = new StringBuilder();
                for (int intCounter = 0; intCounter < arrayList.Count; intCounter++) //iterate over all the rows to get the employees that are punched into the jobs
                {
                    hashtable = arrayList[intCounter] as Hashtable;
                    strBldrEmployees.Append(hashtable["emp_num"].ToString().Trim() + ",");
                }
                strBldrEmployees.Remove(strBldrEmployees.ToString().LastIndexOf(","), 1); //remove the last comma from the string
                Settings.Employees = strBldrEmployees.ToString();

                //Instantiate my label so that I can populate the Format property with the value pulled from the SDCard.
                var objLabel = new Label(new string[] { Settings.Item, Settings.JobNumber, Settings.OperationNumber.ToString("D3"), Settings.Employees,
                    Settings.PieceCount.ToString("N"), Settings.PrintDateTime.ToString("MM/dd/yy h:mm:ss tt"), Settings.PrintDateTime.ToString("dddd") });
                objLabel.LabelFormat = Settings.LabelFormat;
                Debug.Print("Data written to printer serial port is:\r\n" + objLabel.LabelText);
                mPrinterSerialPort.WriteString(objLabel.LabelText);
            }
            catch (Exception objEx)
            {
                Debug.Print("Exception caught in WebGet()\r\n");
                Debug.Print(objEx.Message);
                mMenu.DisplayError(objEx);
            }
        }