コード例 #1
0
ファイル: HttpRequest.cs プロジェクト: Anthaax/Archi-Vite
        public static async Task<DocumentSerializableXML> HttpRequestSetDocument(DocumentSerializableXML documents)
        {
            bool ok = false;
            var client = new HttpClient(new NativeMessageHandler());
            client.BaseAddress = new Uri("http://"+ _serveur +":8080/");
            client.Timeout = new TimeSpan(0, 0, 50);
            client.MaxResponseContentBufferSize = long.MaxValue;
            if (documents.Message.Any())
            {
				string s = "api/Message";
                foreach (var message in documents.Message)
                {
                    string json = JsonConvert.SerializeObject(message);
					StringContent content = new StringContent(json, Encoding.UTF8, "application/json");
                    var response = await client.PutAsync(s, content);
                    if (response.IsSuccessStatusCode)
                    {
                        ok = true;
                    }
                }
            }
            if (documents.Prescription.Any())
            {
				string s = "api/Prescription";
                string xml = JsonConvert.SerializeObject(documents.Prescription);
                StringContent content = new StringContent(xml);
				var response = await client.PutAsync(s, content);
                if (response.IsSuccessStatusCode)
                {
                    ok = true;
                }
            }
            if(ok)
            {
                return documents;
            }
            return null;
        }
コード例 #2
0
ファイル: DataConvertor.cs プロジェクト: Anthaax/Archi-Vite
 public DocumentSerializableXML CreateDocumentSerializable(DocumentSerializable json)
 {
     List<MessageXML> m = CreateMessageList(json.Messages);
     List<PrescriptionXML> p = CreatePrescriptionList(json.Prescriptions);
     DocumentSerializableXML d = new DocumentSerializableXML();
     d.Message = m;
     d.Prescription = p;
     return d;
 }