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 ToolViewModel(DBPostPlugin plugin) { this._Plugin = plugin; this.Proxy = new Proxy(plugin); }