Exemplo n.º 1
0
        //
        public async Task <SysEmails> GetByBranchIdandSide(string side)
        {
            SysEmails item = new SysEmails();
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("side", side.ToString());

            //#################
            IEnumerable <Claim> claims = await APIResult.getList("SysEmails/GetByBranchIdandSide", parameters);

            foreach (Claim c in claims)
            {
                if (c.Type == "scopes")
                {
                    item = JsonConvert.DeserializeObject <SysEmails>(c.Value, new IsoDateTimeConverter {
                        DateTimeFormat = "dd/MM/yyyy"
                    });
                    break;
                }
            }
            return(item);
        }
Exemplo n.º 2
0
        public async Task <List <SettingCls> > GetByNotes(string notes)
        {
            List <SettingCls>           list       = new List <SettingCls>();
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("notes", notes);
            //#################
            IEnumerable <Claim> claims = await APIResult.getList("setting/GetByNotes", parameters);



            foreach (Claim c in claims)
            {
                if (c.Type == "scopes")
                {
                    list.Add(JsonConvert.DeserializeObject <SettingCls>(c.Value, new IsoDateTimeConverter {
                        DateTimeFormat = "dd/MM/yyyy"
                    }));
                }
            }
            return(list);


            //List<SettingCls> list = null;
            //// ... 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 + "setting/GetByNotes?notes="+notes);
            //    request.Headers.Add("APIKey", Global.APIKey);
            //    request.Method = HttpMethod.Get;
            //    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            //    HttpResponseMessage response = await client.SendAsync(request);

            //    if (response.IsSuccessStatusCode)
            //    {
            //        var jsonString = await response.Content.ReadAsStringAsync();
            //        jsonString = jsonString.Replace("\\", string.Empty);
            //        jsonString = jsonString.Trim('"');
            //        // fix date format
            //        JsonSerializerSettings settings = new JsonSerializerSettings
            //        {
            //            Converters = new List<JsonConverter> { new BadDateFixingConverter() },
            //            DateParseHandling = DateParseHandling.None
            //        };
            //        list = JsonConvert.DeserializeObject<List<SettingCls>>(jsonString, new IsoDateTimeConverter { DateTimeFormat = "dd/MM/yyyy" });
            //        return list;
            //    }
            //    else //web api sent error response
            //    {
            //        list = new List<SettingCls>();
            //    }
            //    return list;
            //}
        }