private bool autoSend() { bool abl = false; if (getABBNO()) { var restClient = new RestClient("http://5cosmeda.homeunix.com:89/ApiFromPOS/api/POS/InsertBill"); //var restClient = new RestClient("http://192.168.10.202/ApiFromPOS/api/POS/InsertBill"); var request = new RestRequest(Method.POST); request.RequestFormat = DataFormat.Json; var json = JsonConvert.SerializeObject(ListPOS); JSONSTRING ss = new JSONSTRING(); ss.DATAJSON = json; //request.AddJsonBody(ss); request.AddBody(ss); var response = restClient.Execute(request); JsonDeserializer deserial = new JsonDeserializer(); if ((int)response.StatusCode == 200) { List <Result> bl = deserial.Deserialize <List <Result> >(response); var item = bl.FirstOrDefault(); if (item.StatusCode == "1") { upPosUL(); sms = "สำเร็จ"; abl = true; uplog(Whcode, sms); } else if (item.StatusCode == "2") { if (item.Messages.Substring(0, 9) == "Violation" || item.Messages == "Object reference not set to an instance of an object.") { sms = item.Messages; uplog(Whcode, sms); } else { upPosUL(); uplog(Whcode, "สำเร็จ"); } } else { sms = item.Messages; abl = false; uplog(Whcode, sms); } } else { sms = response.ErrorException.Message; abl = false; uplog(Whcode, sms); } } return(abl); }
private void noBillSend() { var restClient = new RestClient("http://5cosmeda.homeunix.com:89/ApiFromPOS/api/POS/InsertBill"); //var restClient = new RestClient("http://192.168.10.202/ApiFromPOS/api/POS/InsertBill"); var request = new RestRequest(Method.POST); request.RequestFormat = DataFormat.Json; int _wh_id = cmd.DEF_LOCALs.Select(s => s.WH_ID).FirstOrDefault(); string sbrand = ""; string fstr; fstr = Whcode.Substring(0, 1); if (fstr == "1" || fstr == "3") { sbrand = "BB"; } else if (fstr == "5") { sbrand = "BC"; } else { sbrand = "BM"; } POSPTENDDAY PEnd = new POSPTENDDAY { WH_ID = _wh_id, ENDDAY = "Y", ENDDAY_BY = Stcode, BRAND = sbrand }; var json = JsonConvert.SerializeObject(PEnd); JSONSTRING ss = new JSONSTRING(); ss.DATAJSON = ""; ss.POSENDDAY = PEnd; //request.AddJsonBody(ss); request.AddBody(ss); var response = restClient.Execute(request); JsonDeserializer deserial = new JsonDeserializer(); if ((int)response.StatusCode == 200) { List <Result> bl = deserial.Deserialize <List <Result> >(response); var item = bl.FirstOrDefault(); if (item.StatusCode == "1") { sms = "สำเร็จ"; } else { sms = item.Messages + "debug1"; } } else { sms = response.ErrorException.Message + "Pro1"; } }