Ejemplo n.º 1
0
        public async Task <int> Delete(int Id, int userId)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("Id", Id.ToString());
            parameters.Add("userId", userId.ToString());

            string method = "setValue/Delete";

            return(await APIResult.post(method, parameters));



            //// ... 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 + "setValue/Delete?Id=" + Id + "&userId=" + userId );

            //    request.Headers.Add("APIKey", Global.APIKey);

            //    request.Method = HttpMethod.Post;

            //    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
            //    var response = await client.SendAsync(request);

            //    if (response.IsSuccessStatusCode)
            //    {
            //        return true;
            //    }
            //    return false;
            //}
        }
Ejemplo n.º 2
0
        public async Task <SendDetail> OfflineActivate(SendDetail SendDetaildata, string activeState)
        {
            SendDetail item = new SendDetail();
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            var myContent3 = JsonConvert.SerializeObject(SendDetaildata);

            parameters.Add("object", myContent3);
            parameters.Add("activeState", activeState);
            //#################
            IEnumerable <Claim> claims = await APIResult.getList("Activate/OfflineActivate", parameters);

            foreach (Claim c in claims)
            {
                if (c.Type == "scopes")
                {
                    item = JsonConvert.DeserializeObject <SendDetail>(c.Value, new JsonSerializerSettings {
                        DateParseHandling = DateParseHandling.None
                    });
                }
            }
            return(item);
        }
Ejemplo n.º 3
0
        public async Task <int> Sendserverkey(string skey)
        {
            int item = 0;
            // int res = 0;
            //  SendDetail item = new SendDetail();
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("skey", skey);
            //#################
            IEnumerable <Claim> claims = await APIResult.getList("Activate/Sendserverkey", parameters);

            foreach (Claim c in claims)
            {
                if (c.Type == "scopes")
                {
                    item = int.Parse(c.Value);
                    // item = JsonConvert.DeserializeObject<SendDetail>(c.Value, new JsonSerializerSettings { DateParseHandling = DateParseHandling.None });

                    break;
                }
            }
            return(item);
        }
Ejemplo n.º 4
0
        // email
        public async Task <List <SetValues> > GetBySetName(string name)
        {
            List <SetValues>            list       = new List <SetValues>();
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("name", name);
            //#################
            IEnumerable <Claim> claims = await APIResult.getList("setValues/GetBySetName", parameters);



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


            //List<SetValues> 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 + "setValues/GetBySetName?name=" + name);
            //    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<SetValues>>(jsonString, new IsoDateTimeConverter { DateTimeFormat = "dd/MM/yyyy" });
            //        return list;
            //    }
            //    else //web api sent error response
            //    {
            //       // SetValues sv = new SetValues();
            //    //    sv.notes =  await response.Content.ReadAsStringAsync();
            //       list = new List<SetValues>();
            //      //  list.Add(sv);

            //    }
            //    return list;
            //}
        }