Commit 51a5a0bc by Tapio Haapala

lisää debuggia

1 parent 21017ed4
...@@ -220,6 +220,8 @@ namespace MoyaAdminLib ...@@ -220,6 +220,8 @@ namespace MoyaAdminLib
} }
public void Delete() public void Delete()
{ {
APIreference.Delete();
Cache.Remove(this); Cache.Remove(this);
} }
public static List<ComputerPlace> Cache = new List<ComputerPlace>(); public static List<ComputerPlace> Cache = new List<ComputerPlace>();
......
...@@ -67,6 +67,13 @@ namespace MoyaAdminUI.MoyaAPI ...@@ -67,6 +67,13 @@ namespace MoyaAdminUI.MoyaAPI
RestClient client = new RestClient(RestClient.ApiURL, HttpVerb.PUT); RestClient client = new RestClient(RestClient.ApiURL, HttpVerb.PUT);
string json = client.MakeRequest("placeadmin/place/" + id + "/reserve/" + userid); string json = client.MakeRequest("placeadmin/place/" + id + "/reserve/" + userid);
} }
public void Delete()
{
//ComputerPlace.Cache.Clear();
RestClient client = new RestClient(RestClient.ApiURL, HttpVerb.DELETE);
string json = client.MakeRequest("placeadmin/place/" + id);
}
} }
} }
...@@ -108,7 +108,7 @@ namespace MoyaAdminLib ...@@ -108,7 +108,7 @@ namespace MoyaAdminLib
request.ContentLength = 0; request.ContentLength = 0;
request.ContentType = ContentType; request.ContentType = ContentType;
if (!string.IsNullOrEmpty(PostData) && (Method == HttpVerb.POST || Method == HttpVerb.PUT)) if (!string.IsNullOrEmpty(PostData) && (Method == HttpVerb.POST || Method == HttpVerb.PUT ))
{ {
var encoding = new UTF8Encoding(); var encoding = new UTF8Encoding();
var bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(PostData); var bytes = Encoding.GetEncoding("iso-8859-1").GetBytes(PostData);
...@@ -120,6 +120,9 @@ namespace MoyaAdminLib ...@@ -120,6 +120,9 @@ namespace MoyaAdminLib
} }
} }
try
{
using (var response = (HttpWebResponse)request.GetResponse()) using (var response = (HttpWebResponse)request.GetResponse())
{ {
var responseValue = string.Empty; var responseValue = string.Empty;
...@@ -133,20 +136,51 @@ namespace MoyaAdminLib ...@@ -133,20 +136,51 @@ namespace MoyaAdminLib
// grab the response // grab the response
//if (response.ContentLength > 0) //if (response.ContentLength > 0)
//{ //{
using (var responseStream = response.GetResponseStream()) using (var responseStream = response.GetResponseStream())
{ {
if (responseStream != null) if (responseStream != null)
using (var reader = new StreamReader(responseStream)) using (var reader = new StreamReader(responseStream))
{ {
responseValue = reader.ReadToEnd(); responseValue = reader.ReadToEnd();
} }
} }
//} //}
return responseValue; return responseValue;
} }
}
catch (WebException e)
{
Stream responseStream = ((WebException)e).Response.GetResponseStream();
if (responseStream != null)
{
string responseValue = StreamToString(responseStream);
Console.WriteLine("Response was " + responseValue);
throw new Exception(responseValue);
}
throw e;
}
} }
/// <summary>
/// Convert streams from web to string
/// </summary>
/// <param name="responseStream">Webresponse stream</param>
/// <returns>string</returns>
private string StreamToString(Stream responseStream)
{
StreamReader reader = new StreamReader(responseStream);
string responseString = reader.ReadToEnd();
responseStream.Close();
reader.Close();
return responseString;
}
} // class } // class
} }
...@@ -13,3 +13,10 @@ I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaA ...@@ -13,3 +13,10 @@ I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaA
I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.csproj.GenerateResource.Cache I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.csproj.GenerateResource.Cache
I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.dll I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.dll
I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.pdb I:\devel\proj\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.pdb
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.Controls.EventUserEditor.resources
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.csproj.GenerateResource.Cache
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.dll
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\bin\Debug\MoyaAdminLib.dll.config
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\bin\Debug\MoyaAdminLib.dll
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\bin\Debug\MoyaAdminLib.pdb
D:\Devel\proj\moya-info-tools\moya-info-tools\MoyaAdmin\MoyaAdminUI\MoyaAdminLib\obj\Debug\MoyaAdminLib.pdb
...@@ -19,6 +19,7 @@ namespace MoyaAdminUI ...@@ -19,6 +19,7 @@ namespace MoyaAdminUI
{ {
int newPlaceHeight = 10; int newPlaceHeight = 10;
int newPlaceWidth = 10; int newPlaceWidth = 10;
int defaultProductId = 470;
Point clickedLocation; Point clickedLocation;
List<ComputerPlace> gridPreview = new List<ComputerPlace>(); List<ComputerPlace> gridPreview = new List<ComputerPlace>();
ComputerPlaceGridSettings gridSettingsForm; ComputerPlaceGridSettings gridSettingsForm;
...@@ -302,7 +303,7 @@ namespace MoyaAdminUI ...@@ -302,7 +303,7 @@ namespace MoyaAdminUI
ComputerPlace place = new ComputerPlace(); ComputerPlace place = new ComputerPlace();
place.MapId = SelectedMap.Id; place.MapId = SelectedMap.Id;
place.ProductId = 262; place.ProductId = 470;
this.unsavedComputerPlaces.Add(place); this.unsavedComputerPlaces.Add(place);
//place.Coord = location; //place.Coord = location;
place.MapX = location.X; place.MapX = location.X;
...@@ -513,7 +514,7 @@ namespace MoyaAdminUI ...@@ -513,7 +514,7 @@ namespace MoyaAdminUI
ComputerPlace p = new ComputerPlace(); ComputerPlace p = new ComputerPlace();
p.MapId = SelectedMap.Id; p.MapId = SelectedMap.Id;
p.ProductId = 262; p.ProductId = defaultProductId;
p.Width = newPlaceWidth; p.Width = newPlaceWidth;
p.Height = newPlaceHeight; p.Height = newPlaceHeight;
int xcoord = 0; int xcoord = 0;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!