Пример #1
0
        private async Task <HttpErr> isVip(string phoneNum)
        {
            HttpErr err = new HttpErr();

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(ConstInfo.URL_Base_Phone);
            Dictionary <string, string> dict = new Dictionary <string, string>();

            dict.Add("phoneNo", phoneNum);
            try
            {
                var response = await client.PostAsync(ConstInfo.URL_Phone, new FormUrlEncodedContent(dict));

                var result = await response.Content.ReadAsStringAsync();

                if (response.StatusCode == HttpStatusCode.OK)
                {
                    err = JsonConvert.DeserializeObject <HttpErr>(result);
                }
                else
                {
                    err.code = -2;
                    err.msg  = result;
                }
                return(err);
            }
            catch (Exception ex) {
                err.code = -2;
                err.msg  = ex.Message;
                return(err);
            }
        }
Пример #2
0
        private async Task <HttpErr> saveInfo()
        {
            HttpErr err = new HttpErr();
            //HttpClient client = new HttpClient();
            //client.BaseAddress = new Uri(ConstInfo.URL_Base_Save);
            Dictionary <string, string> dict  = new Dictionary <string, string>();
            PassengerInfoParam          param = new PassengerInfoParam()
            {
                deptId             = ConstInfo.harbour,
                account            = phoneNum,
                groupPassengerInfo = new List <PassengerInfo>()
            };

            foreach (DataGridViewRow item in dgv_idData.Rows)
            {
                param.groupPassengerInfo.Add(
                    new PassengerInfo
                {
                    cardName = item.Cells["id_name"].Value.ToString(),
                    cardNo   = item.Cells["id_num"].Value.ToString()
                });
            }

            //dict.Add("jsonStr", JsonConvert.SerializeObject(param));
            //client.DefaultRequestHeaders.Add("SOAPAction", "TransactionOntimeService");
            //var response = await client.PostAsync(ConstInfo.URL_Save, new FormUrlEncodedContent(dict));
            //var result = await response.Content.ReadAsStringAsync();
            try
            {
                GroupCertificateServiceClient saveClient = new GroupCertificateServiceClient();
                var saveResponse = await saveClient.groupCertificateSaveAsync(JsonConvert.SerializeObject(param));

                err = JsonConvert.DeserializeObject <HttpErr>(saveResponse.Body.@return);
                //if (response.StatusCode == HttpStatusCode.OK)
                //{

                //    err = JsonConvert.DeserializeObject<HttpErr>(result);
                //}
                //else
                //{
                //    err.code = -1;
                //    err.msg = result;
                //}
            }
            catch (Exception e)
            {
                err.code = -1;
                err.msg  = e.Message + err;
            }

            return(err);
        }