Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [WebGet( UriTemplate = "/gast/{customer_id}/{year}/{gast_id}", ResponseFormat = WebMessageFormat.Json )]
- [OperationContract]
- public acsEintrittGast GetGastInfo( string customer_id, string year, string gast_id ) {
- acsEintrittGast gast = new acsEintrittGast();
- gast.ID = Guid.Parse( gast_id );
- gast.Bitmap = File.ReadAllBytes( dataPath + customer_id + "\" + year + "\" + gast_id + ".jpg" );
- return gast;
- }
- [WebInvoke( UriTemplate = "/gast/{customer_id}/{year}",
- ResponseFormat = WebMessageFormat.Json,
- RequestFormat = WebMessageFormat.Json,
- BodyStyle = WebMessageBodyStyle.Wrapped,
- Method = "POST" )]
- [OperationContract]
- public acsEintrittGast SetGastInfo( string customer_id, string year, acsEintrittGast GastObject /*string GastString*/ ) {
- acsEintrittGast Gast = null;
- try {
- //Gast = JsonConvert.DeserializeObject<acsEintrittGast>( (string)GastObject);
- File.WriteAllBytes( dataPath + customer_id + "\" + year + "\" + Gast.ID.ToString() + ".jpg", Gast.Bitmap.ToArray<byte>() );
- }
- catch {
- }
- return Gast;
- }
- public async static Task<T> SetRESTData( string URI, T Content ) {
- T res = default( T );
- HttpClient httpClient = null;
- HttpResponseMessage response = null;
- StreamReader sr = null;
- StreamWriter writer = null;
- MemoryStream ms = null;
- try {
- httpClient = new HttpClient();
- string s = JsonConvert.SerializeObject( Content );
- StringContent theContent = new StringContent( s, System.Text.Encoding.UTF8, "application/json" );
- using( HttpRequestMessage request = new HttpRequestMessage( HttpMethod.Post, BaseURI + URI ) ) {
- request.Content = theContent;
- response = await httpClient.SendAsync( request );
- }
- }
- catch {
- }
- finally {
- if( sr != null ) {
- sr.Close();
- sr = null;
- }
- if( writer != null ) {
- writer.Close();
- writer = null;
- }
- if( ms != null ) {
- ms.Dispose();
- ms = null;
- }
- if( response != null ) {
- response.Dispose();
- response = null;
- }
- if( httpClient != null ) {
- httpClient.Dispose();
- httpClient = null;
- }
- }
- return res;
- }
- [DataContract( Name = "acsEintrittGast", Namespace = "" )]
- public class acsEintrittGast {
- private Guid id = Guid.NewGuid();
- [DataMember( Name = "id", Order = 1 )]
- public Guid ID {
- get { return id; }
- set { id = value; }
- }
- private Byte[] bitmap = null;
- [DataMember( Name = "bitmap", Order = 1 )]
- public Byte[] Bitmap {
- get { return bitmap; }
- set { bitmap = value; }
- }
- private DateTime lastEntry = new DateTime( 1900, 1, 1 );
- [DataMember( Name = "lastEntry", Order = 1 )]
- public DateTime LastEntry {
- get { return lastEntry; }
- set { lastEntry = value; }
- }
- }
- acsEintrittGast gast = new acsEintrittGast();
- gast.Bitmap = new byte[80455];
- gast.ID = Guid.NewGuid();
- await acsService.SetGastImfo( ftpLicID, currentYear, gast );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement