public void createProfile() { try { System.Net.WebClient wclient = new System.Net.WebClient(); Uri uri = new Uri(ConfigManager.WebService + "/newProfile.php"); pref = Application.Context.GetSharedPreferences(ConfigManager.SharedFile, FileCreationMode.Private); edit = pref.Edit(); string id = pref.GetString("id", String.Empty); NameValueCollection param = new NameValueCollection(); param.Add("range", clientProfile.range.ToString()); param.Add("maxPrice", clientProfile.maxPrice.ToString()); param.Add("is24", clientProfile.is24.ToString()); param.Add("isCovered", clientProfile.isCovered.ToString()); param.Add("client_id", id); wclient.UploadValuesCompleted += Wclient_UploadValuesCompleted;; wclient.UploadValuesAsync(uri, param); } catch (Exception ex) { Managment.ActivityManager.ShowError(this, new Error(errCode, errMsg)); } }
public void Park() { try { mTimerControl.Enabled = false; mTimerWifi.Enabled = false; string vehicle = fm.GetValue("vehicle"); if (vehicle == string.Empty) { return; } System.Net.WebClient wclient = new System.Net.WebClient(); Uri uri = new Uri(ConfigManager.WebService + "/addHistoric.php"); NameValueCollection param = new NameValueCollection(); param.Add("id", mPositionID.ToString()); param.Add("vehicle_id", vehicle); wclient.UploadValuesCompleted += Wclient_UploadValuesCompleted;; wclient.UploadValuesAsync(uri, param); } catch (Exception ex) { Console.WriteLine("** Error al Cargar en Historial **"); } }
public void SendDb() { if (!Properties.Settings.Default.IsSendDb || string.IsNullOrEmpty(Properties.Settings.Default.DbAccessKey)) { return; } using (System.Net.WebClient wc = new System.Net.WebClient()) { NameValueCollection post = new NameValueCollection(); post.Add("token", Properties.Settings.Default.DbAccessKey); post.Add("agent", "byCEC6DSrXrTrKcADwT3"); // このクライアントのエージェントキー post.Add("url", EndPoint); string requestBody = System.Text.RegularExpressions.Regex.Replace(RequestBody, @"&api(_|%5F)token=[0-9a-f]+|api(_|%5F)token=[0-9a-f]+&?", ""); // api_tokenを送信しないように削除 post.Add("requestbody", requestBody); post.Add("responsebody", ResponseBody); wc.UploadValuesAsync(new Uri("http://api.kancolle-db.net/2/"), post); #if DEBUG Debug.WriteLine("=================================================="); Debug.WriteLine("Send to KanColle statistics database"); Debug.WriteLine("url: " + EndPoint); Debug.WriteLine("reqBody: " + requestBody); Debug.WriteLine("resBody: " + ResponseBody); Debug.WriteLine("=================================================="); #endif } }
public void OnLevelWasInitialized(int level) { var parameters = new NameValueCollection(); parameters.Add("INFO", "Level Initialized"); parameters.Add("level", level.ToString()); parameters.Add("timestamp", DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString()); System.Net.WebClient client = new System.Net.WebClient(); client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", parameters); }
// public event Action<NoteData, int> noteWasMissedEvent; public void HandleNoteWasMissedEvent(NoteData noteData, int number) { var parameters = new NameValueCollection(); parameters.Add("Event", "Note Missed"); parameters.Add("Number", number.ToString()); parameters.Add("Note ID", noteData.id.ToString()); parameters.Add("timestamp", DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString()); System.Net.WebClient client = new System.Net.WebClient(); client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", parameters); }
// public event Action<NoteData, NoteCutInfo, int> noteWasCutEvent; public void HandleNoteWasCutEvent(NoteData noteData, NoteCutInfo noteCutInfo, int number) { var parameters = new NameValueCollection(); parameters.Add("Event", "Note Cut"); parameters.Add("IsCutOK", noteCutInfo.speedOK && noteCutInfo.saberTypeOK && noteCutInfo.directionOK && !noteCutInfo.wasCutTooSoon && noteCutInfo.allIsOK ? "true" : "false"); parameters.Add("Note ID", noteData.id.ToString()); parameters.Add("timestamp", DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds.ToString()); System.Net.WebClient client = new System.Net.WebClient(); client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", parameters); }
public void BoomLogin(string Users) { while (true) { try { var tmp_Root = new NoHomework.Root_1(); System.Net.WebClient WebClientObj = new System.Net.WebClient(); System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection(); PostVars.Add("userPass", "a123456"); PostVars.Add("userName", Users); PostVars.Add("platform", "android"); WebClientObj.Encoding = Encoding.UTF8; string sRemoteInfo = string.Empty; WebClientObj.DownloadStringCompleted += (sender, e) => { //Console.WriteLine(sender.ToString()); //输出 System.Net.WebClient 触发事件的对象 //Console.WriteLine(e.Result); //输出页面源代码 sRemoteInfo = e.Result; Count++; }; WebClientObj.UploadValuesAsync(new Uri("http://xxzy.xinkaoyun.com:8081/holidaywork/login"), PostVars); byte[] byRemoteInfo = WebClientObj.UploadValues("http://xxzy.xinkaoyun.com:8081/holidaywork/login", "POST", PostVars); //下面都没用啦,就上面一句话就可以了 //sRemoteInfo = System.Text.Encoding.UTF8.GetString(byRemoteInfo); //JsonSerializerSettings jsonSerializerSettings = new JsonSerializerSettings(); //jsonSerializerSettings.NullValueHandling = NullValueHandling.Ignore; //tmp_Root = JsonConvert.DeserializeObject<NoHomework.Root_1>(sRemoteInfo, jsonSerializerSettings); Thread.Sleep(1); } catch (Exception) { throw; } } }
private async void SubmitGoogleDoc() { await System.Threading.Tasks.Task.Delay(0); try { System.Net.WebClient wc = new System.Net.WebClient(); var keyval = new System.Collections.Specialized.NameValueCollection(); keyval.Add("submit", "Submit"); wc.Headers.Add("Origin", "https://docs.google.com"); wc.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36"); wc.UploadValuesAsync(new Uri("https://docs.google.com/forms/d/e/1FAIpQLSfbLCkLabwKqAewyNN4swBISAHKg6HTA3CJF6a-7h-Q-rBS3Q/formResponse"), "POST", keyval, Guid.NewGuid().ToString()); } catch { } }
public Proxy(DBPostPlugin plugin) { this.plugin = plugin; this.SortWorker = new RecordSortWorker(); this.Records = new List<Record>(); var proxy = KanColleClient.Current.Proxy; var apis = Enum.GetValues(typeof(Api)).Cast<Api>().ToList(); foreach (var api in apis) { var url = api.GetUrl(); proxy.ApiSessionSource.Where(x => x.Request.PathAndQuery .StartsWith("/kcsapi/" + url)) .Subscribe(x => { if (ToolSettings.SendDb && !string.IsNullOrEmpty(ToolSettings.DbAccessKey)) { System.Collections.Specialized.NameValueCollection post = new System.Collections.Specialized.NameValueCollection(); post.Add("token", ToolSettings.DbAccessKey); post.Add("agent", "LZXNXVGPejgSnEXLH2ur"); post.Add("url", x.Request.PathAndQuery); string requestBody = System.Text.RegularExpressions.Regex.Replace( x.Request.BodyAsString, @"&api(_|%5F)token=[0-9a-f]+|api(_|%5F)token=[0-9a-f]+&?", ""); post.Add("requestbody", requestBody); post.Add("responsebody", x.Response.BodyAsString); #if DEBUG MessageBox.Show( string.Join( "\n", post.AllKeys.Select(key => key + ": " + post[key])), "この内容を送信します"); #else System.Net.WebClient wc = new System.Net.WebClient(); wc.UploadValuesAsync(new Uri("http://api.kancolle-db.net/2/"), post); #endif Records.Add(new Record(DateTime.Now, api, x)); this.UpdateRows(); if (ToolSettings.NotifyLog) this.Notify(Notification.Types.Test, "送信しました", x.Request.PathAndQuery); } }); } }
public void UpdateClientProfile() { string id = fm.GetValue("id"); System.Net.WebClient wclient = new System.Net.WebClient(); Uri uri = new Uri(ConfigManager.WebService + "/updProfile.php?client_id=" + id); NameValueCollection param = new NameValueCollection(); param.Add("range", mProfile.range.ToString()); param.Add("maxPrice", mProfile.maxPrice.ToString()); param.Add("is24", mProfile.is24.ToString()); param.Add("isCovered", mProfile.isCovered.ToString()); param.Add("client_id", id); wclient.UploadValuesCompleted += Wclient_UploadValuesCompleted; wclient.UploadValuesAsync(uri, param); }
public void login(string email, string password) { try { // Consulta Web Service con ese usuario y ese password System.Net.WebClient wclient = new System.Net.WebClient(); Uri uri = new Uri(ConfigManager.WebService + "/authenticate.php"); NameValueCollection param = new NameValueCollection(); param.Add("email", email); param.Add("password", password); wclient.UploadValuesCompleted += Wclient_UploadValuesCompleted; wclient.UploadValuesAsync(uri, param); } catch (Exception ex) { Managment.ActivityManager.TakeMeTo(this, typeof(LoginActivity), true); } }
public void AddVehicle(Vehicle vehicle) { try { System.Net.WebClient wclient = new System.Net.WebClient(); Uri uri = new Uri(ConfigManager.WebService + "/addVehicle.php"); NameValueCollection param = new NameValueCollection(); param.Add("name", vehicle.name); param.Add("client_id", mFile.GetValue("id")); param.Add("vehicle_type_id", vehicle.vehicleTypeID.ToString()); wclient.UploadValuesCompleted += Wclient_UploadValuesCompleted; wclient.UploadValuesAsync(uri, param); } catch (Exception ex) { Managment.ActivityManager.ShowError(this, new Error(errCode, errMsg)); } }
public void Login() { try { // Consulta Web Service con ese usuario y ese password System.Net.WebClient wclient = new System.Net.WebClient(); Uri uri = new Uri(ConfigManager.WebService + "/authenticate.php"); NameValueCollection param = new NameValueCollection(); param.Add("email", mClient.email); param.Add("password", mClient.HashPassword()); wclient.UploadValuesCompleted += Wclient_UploadValuesCompleted; wclient.UploadValuesAsync(uri, param); } catch (Exception ex) { Console.WriteLine(" ** ERROR ** : " + ex.Message); mTextError.Text = "Lo sentimos, ha ocurrido un error\nAguarde unos minutos e intente nuevamente"; mTextError.Visibility = ViewStates.Visible; } }
public static void ReportError(Exception ex, string password = "") { if (password != AccessManager.AccessKey) { if (!AccessManager.GetPluginPermission(AccessManager.PluginPermission.Environment_ReportError)) { throw new UnabletoAccessPermission(); } } if (RTAPI.WebAPI.CheckInternetConnection()) { System.Collections.Specialized.NameValueCollection data = new System.Collections.Specialized.NameValueCollection(); data.Add("entry.1674123617", ex.ToString()); data.Add("entry.713681991", Version); data.Add("entry.521569291", "false"); System.Net.WebClient wc = new System.Net.WebClient(); wc.UploadValuesAsync(new Uri("https://docs.google.com/forms/d/1K2hLlZmlCjur28khh8HYSCjPpl4kLz6nifWEVXKE1sE/formResponse"), "POST", data, Guid.NewGuid().ToString()); } LogManager.ExceptMessage(ex); frmError err = new frmError(ex.ToString()); err.ShowDialog(); }
private void SceneManagerOnActiveSceneChanged(Scene oldScene, Scene newScene) { if (newScene.buildIndex == 1) { // Loaded menu scene System.Net.WebClient client = new System.Net.WebClient(); var menuSceneSetupData = Resources.FindObjectsOfTypeAll <MenuSceneSetupData>().FirstOrDefault(); if (menuSceneSetupData.sceneState == MenuSceneSetupData.SceneState.Results) { // Send result data var twitchResults = new TwitchSongResults { Action = "SongResults", Results = menuSceneSetupData.levelCompletionResults, Timestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds }; var p = new NameValueCollection(); p.Add("Action", "SongResults"); p.Add("Data", JsonConvert.SerializeObject(twitchResults)); p.Add("Timestamp", twitchResults.Timestamp.ToString()); client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", p); } else { var twitchData = new TwitchSceneUpdate { Action = "Menu", Scene = menuSceneSetupData.sceneState, Timestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds }; var p = new NameValueCollection(); p.Add("Action", "SongResults"); p.Add("Data", JsonConvert.SerializeObject(twitchData)); p.Add("Timestamp", twitchData.Timestamp.ToString()); client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", p); } } else if (newScene.buildIndex == 4) { // Loaded game playing scene _mainSetupData = Resources.FindObjectsOfTypeAll <MainGameSceneSetupData>().FirstOrDefault(); _gameStaticData = Resources.FindObjectsOfTypeAll <GameStaticData>().FirstOrDefault(); _scoreController = Resources.FindObjectsOfTypeAll <ScoreController>().FirstOrDefault(); if (_mainSetupData == null || _gameStaticData == null || _scoreController == null) { Console.WriteLine("Twitch Overlay: Cannot load game data."); return; } // Attach note event handlers _scoreController.noteWasCutEvent += HandleNoteWasCutEvent; _scoreController.noteWasMissedEvent += HandleNoteWasMissedEvent; var song = _gameStaticData.GetLevelData(_mainSetupData.levelId); var songData = song.GetDifficultyLevel(_mainSetupData.difficulty).songLevelData.songData; var twitchSongUpdate = new TwitchSongUpdate { Action = "PlayingSong", SongId = song.levelId, SongName = song.songName, SongSubName = song.songSubName, AuthorName = song.authorName, Difficulty = LevelStaticData.GetDifficultyName(_mainSetupData.difficulty), SongLength = song.GetDifficultyLevel(_mainSetupData.difficulty).audioClip.length, GameMode = GetGameplayModeName(_mainSetupData.gameplayMode), IsCustomSong = song.levelId.Contains('∎'), IsNoFail = _mainSetupData.gameplayOptions.noEnergy, IsMirror = _mainSetupData.gameplayOptions.mirror, NotesCount = songData.notesCount, ObstaclesCount = songData.obstaclesCount, BPM = songData.BeatsPerMinute, SongData = songData.SongLinesData, Timestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds }; try { var p = new NameValueCollection(); p.Add("Action", "PlayingSong"); p.Add("Data", JsonConvert.SerializeObject(twitchSongUpdate)); p.Add("Timestamp", twitchSongUpdate.Timestamp.ToString()); System.Net.WebClient client = new System.Net.WebClient(); client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", p); } catch (Exception e) { var p = new NameValueCollection(); p.Add("state", "Error"); p.Add("Exception", e.ToString()); System.Net.WebClient client = new System.Net.WebClient(); client.UploadValuesAsync(new System.Uri("http://localhost:3000/gamedata"), "POST", p); } } }