Exemple #1
0
        private void getConfigdatafromWebservice()
        {
            bool hasNet = false;

            KPCLGate.appserver.Service1 details = new KPCLGate.appserver.Service1();
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://172.168.0.45/rfid-web/");
                request.Method = "GET";
                request.Accept = "text/html, application/xhtml+xml, */*";
                request.Proxy  = null;
                //request.Timeout = 5000;
                //request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        hasNet = true;
                        classLog.writeLog("Message @:Web Service Connected.");
                        classLog.writeLog("Message @:Reader IP: " + classLogin.ReaderIP.ToString());


                        DataSet ds = details.GetReaderDetails(classLogin.ReaderIP);
                        if (ds.Tables[0].Rows.Count == 0)
                        {
                            MessageBox.Show("Config Details Not found.");
                            classLog.writeLog("Message @:Config Details Not found.");
                        }
                        else
                        {
                            txtReaderNo.Text   = ds.Tables[0].Rows[0].ItemArray[0].ToString();
                            txtReaderName.Text = ds.Tables[0].Rows[0].ItemArray[1].ToString();
                            txtReaderIP.Text   = classLogin.ReaderIP;
                            txtMacAdd.Text     = ds.Tables[0].Rows[0].ItemArray[2].ToString();
                            txtServerIP.Text   = ds.Tables[0].Rows[0].ItemArray[3].ToString();
                            txtServerPort.Text = ds.Tables[0].Rows[0].ItemArray[4].ToString();
                            txtProcess.Text    = "ByRoad";
                            classLog.writeLog("Message @:Details Received from DB.");
                            clearlocaldb();
                            saveCofigdetailsinsdfdb();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Network Not Connected..");
                        classLog.writeLog("Error @:Network Not Connected..");
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "NetAvail2");
                classLog.writeLog("Error @:Web Service Not Connected."); //classLog.writeLog("Error @: " + ex.ToString());
            }
        }
Exemple #2
0
        private DataTable getDatafromWebservice(string getdetails)
        {
            bool hasNet = false; DataTable dt = new DataTable();

            KPCLGate.appserver.Service1 details = new KPCLGate.appserver.Service1();
            try
            {
                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(@"http://172.168.0.45/rfid-web/");
                request.Method = "GET";
                request.Accept = "text/html, application/xhtml+xml, */*";
                request.Proxy  = null;
                //request.Timeout = 5000;
                //request.UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
                using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                    {
                        hasNet = true;
                        classLog.writeLog("Message @:Web Service Connected.");
                        classLog.writeLog("Message @:GetDtails: " + getdetails.ToString());
                        dt = details.GetMasterDetails(getdetails);

                        if (dt.Rows.Count == 0)
                        {
                            //MessageBox.Show("Details Not found.");
                            lblStatus.Text = "Details Not found.";
                            classLog.writeLog("Message @: Master Details Not found.");
                        }
                        else
                        {
                            classLog.writeLog("Message @:Master Received from DB.");
                        }
                        //details.Dispose(); ds.Dispose();
                    }
                    else
                    {
                        //MessageBox.Show("Network Not Connected..");
                        lblStatus.Text = "Network Not Connected..";
                        classLog.writeLog("Error @:Network Not Connected..");
                    }
                }
            }
            catch (Exception ex)
            {
                //MessageBox.Show(ex.Message, "NetAvail2");
                lblStatus.Text = "Connection Failed.";
                classLog.writeLog("Error @:Web Service Not Connected."); classLog.writeLog("Error @: " + ex.ToString());
            }
            return(dt);
        }