//public async Task<PosSetting> GetByID(int posSettingId) //{ // PosSetting obj = new PosSetting(); // // ... Use HttpClient. // ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; // using (var client = new HttpClient()) // { // ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; // client.BaseAddress = new Uri(Global.APIUri); // client.DefaultRequestHeaders.Clear(); // client.DefaultRequestHeaders.Add("Connection", "Keep-Alive"); // client.DefaultRequestHeaders.Add("Keep-Alive", "3600"); // HttpRequestMessage request = new HttpRequestMessage(); // request.RequestUri = new Uri(Global.APIUri + "PosSetting/GetByID?posSettingId=" + posSettingId); // request.Headers.Add("APIKey", Global.APIKey); // request.Method = HttpMethod.Get; // client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // var response = await client.SendAsync(request); // if (response.IsSuccessStatusCode) // { // var jsonString = await response.Content.ReadAsStringAsync(); // obj = JsonConvert.DeserializeObject<PosSetting>(jsonString); // return obj; // } // return obj; // } //} public async Task <PosSetting> GetByposId(int posId) { PosSetting item = new PosSetting(); Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("posId", posId.ToString()); //################# IEnumerable <Claim> claims = await APIResult.getList("PosSetting/GetByposId", parameters); foreach (Claim c in claims) { if (c.Type == "scopes") { item = JsonConvert.DeserializeObject <PosSetting>(c.Value, new IsoDateTimeConverter { DateTimeFormat = "dd/MM/yyyy" }); break; } } return(item); //PosSetting obj = new PosSetting(); //// ... Use HttpClient. //ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; //using (var client = new HttpClient()) //{ // ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; // client.BaseAddress = new Uri(Global.APIUri); // client.DefaultRequestHeaders.Clear(); // client.DefaultRequestHeaders.Add("Connection", "Keep-Alive"); // client.DefaultRequestHeaders.Add("Keep-Alive", "3600"); // HttpRequestMessage request = new HttpRequestMessage(); // request.RequestUri = new Uri(Global.APIUri + "PosSetting/GetByposId?posId=" + posId); // request.Headers.Add("APIKey", Global.APIKey); // request.Method = HttpMethod.Get; // client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // var response = await client.SendAsync(request); // if (response.IsSuccessStatusCode) // { // var jsonString = await response.Content.ReadAsStringAsync(); // obj = JsonConvert.DeserializeObject<PosSetting>(jsonString); // return obj; // } // return obj; //} }
public async Task <int> Save(PosSetting obj) { Dictionary <string, string> parameters = new Dictionary <string, string>(); string method = "PosSetting/Save"; var myContent = JsonConvert.SerializeObject(obj); parameters.Add("Object", myContent); return(await APIResult.post(method, parameters)); //// ... Use HttpClient. //ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true; //// //var myContent = JsonConvert.SerializeObject(obj); //using (var client = new HttpClient()) //{ // ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12; // client.BaseAddress = new Uri(Global.APIUri); // client.DefaultRequestHeaders.Clear(); // client.DefaultRequestHeaders.Add("Connection", "Keep-Alive"); // client.DefaultRequestHeaders.Add("Keep-Alive", "3600"); // HttpRequestMessage request = new HttpRequestMessage(); // // encoding parameter to get special characters // myContent = HttpUtility.UrlEncode(myContent); // request.RequestUri = new Uri(Global.APIUri + "PosSetting/Save?Object=" + myContent); // request.Headers.Add("APIKey", Global.APIKey); // request.Method = HttpMethod.Post; // //set content type // client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // var response = await client.SendAsync(request); // if (response.IsSuccessStatusCode) // { // var message = await response.Content.ReadAsStringAsync(); // message = JsonConvert.DeserializeObject<string>(message); // return message; // } // return ""; //} }
public PosSetting MaindefaultPrinterSetting(PosSetting oldsetting) { PosSetting defpossetting = new PosSetting(); defpossetting = oldsetting; //defpossetting.posId = oldsetting.posId; //defpossetting.posSettingId = oldsetting.posSettingId; //defpossetting.posSerial = oldsetting.posSerial; //defpossetting.posSettingId = oldsetting.posSettingId; string printname = getdefaultPrinters(); Printers defpr = new Printers(); defpr.name = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(printname)); if (oldsetting.saleInvPrinterId == null) { defpossetting.salname = defpr.name; } if (oldsetting.reportPrinterId == null) { defpossetting.repname = defpr.name; } if (oldsetting.saleInvPapersizeId == null) { defpossetting.saleSizeValue = "A4"; } if (oldsetting.docPapersizeId == null) { defpossetting.docPapersize = "A5"; } return(defpossetting); }