public static string PostLocation(GPSTrackPoint location, string icon) { string result = ""; // HTTP用WebRequestの作成 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(PostURI); req.Method = WebRequestMethods.Http.Post; req.Credentials = new NetworkCredential(Properties.Settings.Default.User, Properties.Settings.Default.Password); req.PreAuthenticate = true; req.Timeout = 6000; req.ContentType = "application/x-www-form-urlencoded"; req.UserAgent = version + " " + Properties.Settings.Default.User; if (Properties.Settings.Default.ProxyServer.Length > 0) { req.Proxy = new WebProxy(string.Format("http://{0}:{1}", Properties.Settings.Default.ProxyServer, Properties.Settings.Default.ProxyPort)); } // HTTPで送信するデータ string body = location.GetHttpParameter() + "&save=" + (Properties.Settings.Default.ServerSave ? "1" : "0") + "&t=" + Util.GetIconType(icon); // 送信データを書き込む req.ContentLength = body.Length; using (StreamWriter sw = new StreamWriter(req.GetRequestStream())) { sw.Write(body); } // レスポンスを取得 WebResponse res = req.GetResponse(); using (StreamReader sr = new StreamReader(res.GetResponseStream())) { result = sr.ReadLine(); if (result == null) { result = "null result."; } } if (Properties.Settings.Default.SoundPost != "") { Util.PlaySEFromFile(Properties.Settings.Default.SoundPost); } else { Util.PlaySE("PCGPS.Resources.b_067.wav"); } return(result); }
public static string PostLocation(GPSTrackPoint location, string icon) { string result = ""; // HTTP用WebRequestの作成 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(PostURI); req.Method = WebRequestMethods.Http.Post; req.Credentials = new NetworkCredential(Properties.Settings.Default.User, Properties.Settings.Default.Password); req.PreAuthenticate = true; req.Timeout = 6000; req.ContentType = "application/x-www-form-urlencoded"; req.UserAgent = version + " " + Properties.Settings.Default.User; if (Properties.Settings.Default.ProxyServer.Length > 0) { req.Proxy = new WebProxy(string.Format("http://{0}:{1}", Properties.Settings.Default.ProxyServer, Properties.Settings.Default.ProxyPort)); } // HTTPで送信するデータ string body = location.GetHttpParameter() + "&save=" + (Properties.Settings.Default.ServerSave ? "1" : "0") +"&t=" + Util.GetIconType(icon); // 送信データを書き込む req.ContentLength = body.Length; using (StreamWriter sw = new StreamWriter(req.GetRequestStream())) { sw.Write(body); } // レスポンスを取得 WebResponse res = req.GetResponse(); using (StreamReader sr = new StreamReader(res.GetResponseStream())) { result = sr.ReadLine(); if (result == null) { result = "null result."; } } if (Properties.Settings.Default.SoundPost != "") { Util.PlaySEFromFile(Properties.Settings.Default.SoundPost); } else { Util.PlaySE("PCGPS.Resources.b_067.wav"); } return result; }