/// <summary> /// 对一条微博进行评论 /// </summary> /// <param name="id">需要评论的微博ID。</param> /// <param name="comment">评论内容,必须做URLencode,内容不超过140个汉字。 </param> /// <param name="commentOrigin">当评论转发微博时,是否评论给原微博,0:否、1:是,默认为0。 </param> /// <returns></returns> public dynamic Create(string id, string comment, bool commentOrigin = false) { return(DynamicJson.Parse(api.Create(id, comment, commentOrigin))); }
/// <summary> /// 获取 minion 的详细信息 /// </summary> /// <param name="minionName"> minion 名称</param> /// <returns></returns> public static dynamic MinionDetails(string minionName) { var r = JsonConvert.DeserializeObject <BaseType>(HttpUtilities.APIWebHelper(APIUrlSelect(APIType.MINIONS, minionName), HttpUtilities.HttpRequestMethod.GET)); return(DynamicJson.Parse(r.@return[0].ToString())); }
/// <summary> /// 获取一条原创微博的最新转发微博的ID /// </summary> /// <param name="id">需要查询的微博ID。</param> /// <param name="sinceID">若指定此参数,则返回ID比since_id大的微博(即比since_id时间晚的微博),默认为0。</param> /// <param name="maxID">若指定此参数,则返回ID小于或等于max_id的微博,默认为0。 </param> /// <param name="count">单页返回的记录条数,默认为50。 </param> /// <param name="page">返回结果的页码,默认为1。 </param> /// <param name="filterByAuthor">作者筛选类型,0:全部、1:我关注的人、2:陌生人,默认为0。 </param> /// <returns></returns> public dynamic RepostTimelineIDs(string id, string sinceID = "", string maxID = "", int count = 50, int page = 1, int filterByAuthor = 0) { return(DynamicJson.Parse(api.RepostTimelineIDs(id, sinceID, maxID, count, page, filterByAuthor))); }
public static async Task <Game> GetGameAsync(string gameId, int row, int col) { try { var json = await ApiRequest.CreateRequest() .WithMethod("api/game/" + gameId, "get") .GetResultAsync(); var result = DynamicJson.Parse(json); //check result if (result == null || result.Id == null || result.Cells == null) { return(null); } Game game = new Game(row, col); //load state game.State = (int)result.State; //load players int iPlayer = 0; if (result != null) { foreach (var item in result.Players) { iPlayer++; } } else { return(null); } if (result.Id.ToString() != game.Id || game.Players == null || game.Players.Count != iPlayer) { game.Players = new List <Player>(iPlayer); foreach (var item in result.Players) { Player player = new Player(); player.Index = (int)item.Index; player.Color = (int)item.Color; player.Name = item.Name.ToString(); game.Players.Add(player); } } //load cells foreach (var line in result.Cells) { foreach (var item in line) { int x = (int)item.X; int y = (int)item.Y; var cell = game.Locate(x, y); cell.Type = (int)item.Type; cell.State = (int)item.State; cell.OwnerIndex = (int)item.Owner; } } return(game); } catch { return(null); } }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); try { string jsonData = params_ht["json"].ToString(); dynamic jsonObj = DynamicJson.Parse(jsonData); string carId = ""; if (jsonObj.IsDefined("carId")) { carId = jsonObj.carId; } string csq = ""; if (jsonObj.IsDefined("csq")) { csq = jsonObj.csq; } string voltage = ""; if (jsonObj.IsDefined("voltage")) { voltage = jsonObj.voltage; } string dumpEle = ""; if (jsonObj.IsDefined("dumpEle")) { dumpEle = jsonObj.dumpEle; } VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByGPSNum(carId); if (vehicle_ht != null && vehicle_ht.Keys.Count > 0) { string strLastUpdateTime = SiteHelper.GetHashTableValueByKey(vehicle_ht, "LastUpdateTime"); int diffSecond = 5; if (!string.IsNullOrEmpty(strLastUpdateTime)) { DateTime lastUpdateTime = DateTime.Parse(strLastUpdateTime); diffSecond = SiteHelper.ExecDateDiffSecond(lastUpdateTime, DateTime.Now); } if (diffSecond > 3) { string vid = vehicle_ht["ID"].ToString(); Hashtable ht = new Hashtable(); if (!string.IsNullOrEmpty(dumpEle)) { double power = -1; double.TryParse(dumpEle, out power); if (power >= 0 && power <= 1) { ht["Electricity"] = (int)(power * 100); } } ht["LastUpdateTime"] = DateTime.Now; bool result = false; if (ht.Keys.Count > 0) { result = vm.AddOrEditVehicleInfo(ht, vid); } resp.Code = result ? "0" : "1"; } else { resp.Code = "3"; } } return(resp); } catch { resp.Code = "1"; return(resp); } }
/// <summary> /// 获取用户双向关注的用户ID列表,即互粉UID列表 /// </summary> /// <param name="uid">需要获取双向关注列表的用户UID。</param> /// <param name="count">单页返回的记录条数,默认为50,最大不超过2000。 </param> /// <param name="page">返回结果的页码,默认为1。</param> /// <param name="sort">排序类型,0:按关注时间最近排序,默认为0。 </param> /// <returns></returns> public dynamic FriendsOnBilateralIDs(string uid, int count = 50, int page = 1, bool sort = false) { return(DynamicJson.Parse(api.FriendsOnBilateralIDs(uid, count, page, sort))); }
public virtual async Task <IActionResult> Put(int id, dynamic json) { if (!(json is DynamicJson)) { json = DynamicJson.Parse(json.ToString()); } var entity = await DbEntityManager.SelectOne <T>(DbType, Db, nameof(Entity.Id), id); var ps = entity.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance); foreach (var property in ps) { var attrEditor = property.GetCustomAttribute(typeof(EditorAttribute)) as EditorAttribute; if (attrEditor != null && attrEditor.Editable) { if (json.TryGetValue(property.Name, out object value)) { if (property.PropertyType.IsEnum) { value = Enum.Parse(property.PropertyType, value.ToString()); } else if (property.PropertyType == typeof(bool)) { value = Convert.ToBoolean(value); } else if (property.PropertyType == typeof(short)) { value = Convert.ToInt16(value); } else if (property.PropertyType == typeof(int)) { value = Convert.ToInt32(value); } else if (property.PropertyType == typeof(long)) { value = Convert.ToInt64(value); } else if (property.PropertyType == typeof(float)) { value = Convert.ToSingle(value); } else if (property.PropertyType == typeof(double)) { value = Convert.ToDouble(value); } else if (property.PropertyType == typeof(decimal)) { value = Convert.ToDecimal(value); } else if (property.PropertyType == typeof(DateTime)) { value = Convert.ToDateTime(value); } property.SetValue(entity, value); } } } await DbEntityManager.Update(DbType, Db, entity); return(Ok(entity)); }
/// <summary> /// 获取最新的提到当前登录用户的评论,即@我的评论 /// </summary> /// <param name="sinceID">若指定此参数,则返回ID比since_id大的评论(即比since_id时间晚的评论),默认为0。</param> /// <param name="maxID">若指定此参数,则返回ID小于或等于max_id的评论,默认为0。 </param> /// <param name="count">单页返回的记录条数,默认为50。 </param> /// <param name="page">返回结果的页码,默认为1。 </param> /// <param name="filterByAuthor">作者筛选类型,0:全部、1:我关注的人、2:陌生人,默认为0。 </param> /// <param name="filterBySource">来源筛选类型,0:全部、1:来自微博的评论、2:来自微群的评论,默认为0。</param> /// <returns></returns> public dynamic Mentions(string sinceID = "", string maxID = "", int count = 50, int page = 1, int filterByAuthor = 0, int filterBySource = 0) { return(DynamicJson.Parse(api.Mentions(sinceID, maxID, count, page, filterByAuthor, filterBySource))); }
/// <summary> /// ボタン1 クリックイベント /// </summary> private void button1_Click(object sender, EventArgs e) { this.dataGridView1.DataSource = null; if (string.IsNullOrEmpty(this.tbDevId.Text)) { MessageBox.Show("アプリケーションIDを入力してください。"); return; } var appId = "&applicationId=" + this.tbDevId.Text; var getCnt = 30; string api = string.Format("{0}{1}{2}" , "https://app.rakuten.co.jp/services/api/Gora/GoraPlanSearch/20150706?format=json" , appId , "&playDate=" + DateTime.Today.AddMonths(1).ToString("yyyy-MM-dd") + "&areaCode=" + this.comboBox1.SelectedValue + "&hits=" + getCnt + "&sort=price" + "&formatVersion=2"); var req = WebRequest.Create(api); using (var res = req.GetResponse()) using (var s = res.GetResponseStream()) { dynamic json = DynamicJson.Parse(s); try { dynamic items = json.Items; DataTable dt = new DataTable(); dt.Columns.Add(COURSE, typeof(String)); //dt.Columns.Add(WEEKDAY_PRICE, typeof(String)); //dt.Columns.Add(IMG_URL, typeof(String)); dt.Columns.Add(IMG_URL, typeof(Image)); //dt.Columns.Add(LATITUDE, typeof(decimal)); //dt.Columns.Add(LONGITUDE, typeof(decimal)); for (int ix = 0; ix < json.hits; ix++) { DataRow dr = dt.NewRow(); dr[COURSE] = items[ix].golfCourseName + Environment.NewLine + Environment.NewLine + items[ix].golfCourseCaption; //dr[WEEKDAY_PRICE] = items[ix].displayWeekdayMinBasePrice; //dr[IMG_URL] = items[ix].golfCourseImageUrl; PictureBox pb = new PictureBox(); WebClient wc = new WebClient(); Stream stream = wc.OpenRead(items[ix].golfCourseImageUrl); Bitmap bitmap = new Bitmap(stream); stream.Close(); pb.Image = bitmap; dr[IMG_URL] = pb.Image; //dr[LATITUDE] = items[ix].latitude; //dr[LONGITUDE] = items[ix].longitude; dt.Rows.Add(dr); } this.dataGridView1.DataSource = dt; //this.dataGridView1.Columns[COURSE].AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells; this.dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; this.dataGridView1.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; this.dataGridView1.Columns[COURSE].DefaultCellStyle.WrapMode = DataGridViewTriState.True; } catch (Exception ex) { } } }
/// <summary> /// 获取当前登录用户所发出的评论列表 /// </summary> /// <param name="sinceID">若指定此参数,则返回ID比since_id大的评论(即比since_id时间晚的评论),默认为0。</param> /// <param name="maxID">若指定此参数,则返回ID小于或等于max_id的评论,默认为0。 </param> /// <param name="count">单页返回的记录条数,默认为50。</param> /// <param name="page">返回结果的页码,默认为1。</param> /// <param name="filterBySource">来源筛选类型,0:全部、1:来自微博的评论、2:来自微群的评论,默认为0。 </param> /// <returns></returns> public dynamic ByMe(string sinceID = "", string maxID = "", int count = 50, int page = 1, int filterBySource = 0) { return(DynamicJson.Parse(api.ByMe(sinceID, maxID, count, page, filterBySource))); }
/// <summary> /// 获取当前登录用户的最新评论包括接收到的与发出的 /// </summary> /// <param name="sinceID">若指定此参数,则返回ID比since_id大的评论(即比since_id时间晚的评论),默认为0。</param> /// <param name="maxID">若指定此参数,则返回ID小于或等于max_id的评论,默认为0。 </param> /// <param name="count">单页返回的记录条数,默认为50。 </param> /// <param name="page">返回结果的页码,默认为1。 </param> /// <returns>JSON</returns> public dynamic Timeline(string sinceID = "", string maxID = "", int count = 50, int page = 1) { return(DynamicJson.Parse(api.Timeline(sinceID, maxID, count, page))); }
/// <summary> /// 回复一条评论 /// </summary> /// <param name="cid">需要回复的评论ID。</param> /// <param name="id">需要评论的微博ID。</param> /// <param name="comment">回复评论内容,必须做URLencode,内容不超过140个汉字。 </param> /// <param name="withoutMention">回复中是否自动加入“回复@用户名”,0:是、1:否,默认为0。 </param> /// <param name="commentOrigin">当评论转发微博时,是否评论给原微博,0:否、1:是,默认为0。 </param> /// <returns></returns> public dynamic Reply(string cid, string id, string comment, bool withoutMention = false, bool commentOrigin = false) { return(DynamicJson.Parse(api.Reply(cid, id, comment, withoutMention, commentOrigin))); }
/// <summary> /// 根据评论ID批量删除评论 /// </summary> /// <param name="ids">需要删除的评论ID,最多20个。 </param> /// <returns></returns> public dynamic DestroyBatch(params string[] ids) { return(DynamicJson.Parse(api.DestroyBatch(ids))); }
/// <summary> /// 删除一条评论 /// </summary> /// <param name="cid">要删除的评论ID,只能删除登录用户自己发布的评论。 </param> /// <returns></returns> public dynamic Destroy(string cid) { return(DynamicJson.Parse(api.Destroy(cid))); }
/// <summary> /// 获取用户关注的用户UID列表 /// </summary> /// <param name="uid">需要查询的用户UID。 </param> /// <param name="screenName">需要查询的用户昵称。 </param> /// <param name="count">单页返回的记录条数,默认为500,最大不超过5000。 </param> /// <param name="cursor">返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。</param> /// <returns></returns> public dynamic FriendIDs(string uid = "", string screenName = "", int count = 50, int cursor = 0) { return(DynamicJson.Parse(api.FriendIDs(uid, screenName, count, cursor))); }
private void worker_DoWork(object sender, DoWorkEventArgs e) { { Regex regex = new Regex(@"^\s*?http://afreecatv\.jp/(\d+?)/v/(\d+?)\D*$", RegexOptions.Compiled); Match match = regex.Match(textBoxUrl.Text); if (!match.Success) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + "URLが正しいか確認して下さい。" + Environment.NewLine); return; } else { this.id = match.Groups[1].Value; this.vno = match.Groups[2].Value; } } button.Text = CANCEL_BUTTON_TEXT; button.Update(); textBoxUrl.ReadOnly = true; textBoxUrl.Update(); textBoxSaveTo.ReadOnly = true; textBoxSaveTo.Update(); try { this.tempPath = this.saveToPath + Path.DirectorySeparatorChar + "Temp"; if (Directory.Exists(this.tempPath)) { Directory.Delete(this.tempPath, true); } try { Directory.CreateDirectory(this.tempPath); } catch (Exception) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + "一時フォルダーの作成に失敗しました。" + Environment.NewLine); return; } String json = ""; // APIよりjsonをダウンロード using (WebClient wc1 = new WebClient()) { Int32 cnt = 0; String url = "http://api.afreecatv.jp/video/view_video.php"; // POSTのパラメータの生成 NameValueCollection postData = new NameValueCollection(); postData.Add("vno", this.vno); postData.Add("rt", "json"); postData.Add("lc", "ja_JP"); postData.Add("bid", this.id); postData.Add("pt", "view"); postData.Add("cptc", "HLS"); while (cnt <= RETRY_TIMES) { try { json = Encoding.UTF8.GetString(wc1.UploadValues(url, postData)); if (worker.CancellationPending) { AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "中止しました。" + Environment.NewLine); return; } break; } catch (WebException webEx) { if (cnt == RETRY_TIMES) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + url + "のダウンロードで問題が発生しました。" + webEx.Message + Environment.NewLine); return; } System.Threading.Thread.Sleep(RETRY_INTERVAL); cnt++; } } AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "動画情報" + new Uri(url).Segments.Last() + "をダウンロードしました。" + Environment.NewLine); UpdateMessageText(); } List <String> m3u8List = new List <string>(); List <String> chatList = new List <string>(); Dictionary <String, List <String> > tsDict = new Dictionary <String, List <String> >(); // jsonよりm3u8ファイルのURLを抽出 try { dynamic obj = DynamicJson.Parse(json); this.title = obj.channel.title; this.nick = obj.channel.nick; foreach (var elem in obj.channel.flist) { String file = elem.file; String chat = elem.chat; chatList.Add(chat); m3u8List.Add(file); } } catch (Exception ex) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + "動画URLの解析で問題が発生しました。" + ex.Message + Environment.NewLine); return; } foreach (String chat in chatList) { // 動画情報m3u8ファイルのダウンロード using (WebClient wc = new WebClient()) { Int32 cnt = 0; while (cnt <= RETRY_TIMES) { try { wc.Headers.Add("user-agent", USER_AGENT); wc.Proxy = null; wc.DownloadFile(chat, this.saveToPath + Path.DirectorySeparatorChar + SanitizeFileName(this.vno + " - " + this.nick + " - " + this.title + " - " + (chatList.IndexOf(chat) + 1).ToString() + ".xml")); if (worker.CancellationPending) { AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "中止しました。" + Environment.NewLine); return; } break; } catch (WebException webEx) { if (cnt == RETRY_TIMES) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + chat + "のダウンロードで問題が発生しました。" + webEx.Message + Environment.NewLine); // チャットログは落とせなくても続行とする。 } System.Threading.Thread.Sleep(RETRY_INTERVAL); cnt++; } } AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + (chatList.IndexOf(chat) + 1).ToString() + " / " + chatList.Count + " チャットログをダウンロードしました。" + Environment.NewLine); UpdateMessageText(); } } Int32 numTs = 0; Int32 numFinTs = 0; foreach (String m3u8 in m3u8List) { using (WebClient wc = new WebClient()) { Int32 cnt = 0; String baseUrl = "http://" + new Uri(m3u8).Host; String key = m3u8.Replace("/mp4hls/index.m3u8", ""); tsDict.Add(key, new List <string>()); String res = ""; while (cnt <= RETRY_TIMES) { try { wc.Headers.Add("user-agent", USER_AGENT); wc.Proxy = null; res = Encoding.UTF8.GetString(wc.DownloadData(m3u8)); if (worker.CancellationPending) { AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "中止しました。" + Environment.NewLine); return; } break; } catch (WebException webEx) { if (cnt == RETRY_TIMES) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + m3u8 + "のダウンロードで問題が発生しました。" + webEx.Message + Environment.NewLine); return; } System.Threading.Thread.Sleep(RETRY_INTERVAL); cnt++; } } AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "動画情報" + new Uri(key).Segments.Last() + "をダウンロードしました。" + Environment.NewLine); UpdateMessageText(); // m3u8ファイルよりtsファイルのURLを抽出 Regex regex = new Regex(@"(.+\d+\.ts)", RegexOptions.Compiled); MatchCollection matches = regex.Matches(res); foreach (Match match in matches) { if (match.Success) { tsDict[key].Add(baseUrl + match.Groups[1].Value); numTs++; } } } } String driveLetter = Application.ExecutablePath.Substring(0, 1); DriveInfo drive = new DriveInfo(driveLetter); // 4GB以上のファイルも扱うためRecフォルダがあるドライブのファイルシステムはNTFSかexFATのみ許可 if (drive.DriveFormat != "NTFS" && drive.DriveFormat != "exFAT") { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + "4GB以上のファイルを扱う可能性があるため、" + driveLetter + "ドライブはNTFSかexFATでフォーマットされている必要があります。" + Environment.NewLine); return; } // tsファイルの数より必要なディスク容量を算出 Int64 mb = (Int64)Math.Pow(1024, 2); Int64 gb = (Int64)Math.Pow(1024, 3); Int64 shortage = (numTs * (3 * mb) * 2) - drive.AvailableFreeSpace; if (shortage > 0) { Double shortageGb = Math.Round((Double)shortage / gb, 2); AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + driveLetter + "ドライブの空き容量が" + shortageGb.ToString() + "GB不足しています。" + Environment.NewLine); return; } AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "動画ファイルのダウンロードを開始します。" + Environment.NewLine); UpdateMessageText(); foreach (KeyValuePair <String, List <String> > kv in tsDict) { foreach (String ts in kv.Value) { // tsファイルのダウンロード using (WebClient wc = new WebClient()) { Int32 cnt = 0; // 長時間録画対応のため、ゼロパディングの数を4から5に変更 String zeroPadding = "00000"; String zeroAdded = zeroPadding + (numFinTs + 1).ToString(); String fileName = zeroAdded.Substring(zeroAdded.Length - zeroPadding.Length, zeroPadding.Length) + ".ts"; while (cnt <= RETRY_TIMES) { try { wc.Headers.Add("user-agent", USER_AGENT); wc.Proxy = null; wc.DownloadFile(ts, this.tempPath + Path.DirectorySeparatorChar + fileName); numFinTs++; AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + numFinTs.ToString() + " / " + numTs.ToString() + " 動画ファイルをダウンロードしました。" + Environment.NewLine); UpdateMessageText(); if (worker.CancellationPending) { AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "中止しました。" + Environment.NewLine); return; } break; } catch (WebException webEx) { // 末尾のTSファイルが無い場合があるので、404だったらbreakする。 if (webEx.Status == WebExceptionStatus.ProtocolError) { if (((HttpWebResponse)webEx.Response).StatusCode == HttpStatusCode.NotFound) { break; } } if (cnt == RETRY_TIMES) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + ts + "のダウンロードで問題が発生しました。" + webEx.Message + Environment.NewLine); return; } System.Threading.Thread.Sleep(RETRY_INTERVAL); cnt++; } } } } } AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "動画ファイルの結合を開始します。" + Environment.NewLine); UpdateMessageText(); try { // ファイル名昇順にソート var files = new DirectoryInfo(this.tempPath).GetFiles().OrderBy(file => file.Name); List <String> tsFiles = new List <String>(); List <String> concatFiles = new List <String>(); // 長時間録画対応のため、100ずつから200ずつに変更 Int32 numConcat = 200; Int32 cntConcat = 0; foreach (FileInfo file in files) { if (Regex.Match(file.Name, @"\d+\.ts").Success) { tsFiles.Add(file.Name); cntConcat++; if (tsFiles.Count == numConcat) { // tsファイルを200ずつ結合 // 一度に全部結合させない理由は、FFmpegのパラメータが長すぎると、 // Windowsの仕様で問題が起こるため // https://support.microsoft.com/ja-jp/kb/2823587/ja // m3u8をffmpegに直接入力させる方法は、 // 当方の環境で出力が2割ほど遅くなったため採用しなかった。 using (Process ps = new Process()) { String fileName = (cntConcat - numConcat + 1).ToString() + "_" + cntConcat.ToString() + ".ts"; ps.StartInfo.FileName = FFMPEG_EXE_PATH; // concat:を使うと無劣化結合できる ps.StartInfo.Arguments = "-y -i \"concat:" + String.Join("|", tsFiles.ToArray()) + "\" -c copy \"" + fileName + "\""; ps.StartInfo.WorkingDirectory = this.tempPath; ps.StartInfo.CreateNoWindow = true; ps.StartInfo.UseShellExecute = false; ps.Start(); System.Threading.Thread.Sleep(1000); while (true) { if (ps.HasExited) { foreach (String ts in tsFiles) { File.Delete(this.tempPath + Path.DirectorySeparatorChar + ts); } tsFiles = new List <String>(); if (ps.ExitCode != 0) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + cntConcat.ToString() + " / " + numFinTs.ToString() + " 動画ファイルの結合でエラーが発生しました。" + Environment.NewLine); return; } else { concatFiles.Add(fileName); AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + cntConcat.ToString() + " / " + numFinTs.ToString() + " 動画ファイルを結合しました。" + Environment.NewLine); UpdateMessageText(); } break; } if (worker.CancellationPending) { ps.Kill(); AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "中止しました。" + Environment.NewLine); return; } System.Threading.Thread.Sleep(100); } } } } } // 200ずつ処理した後の端数のtsファイルを結合 // tsファイル数が丁度200の倍数だった場合の条件分岐を追加 if (tsFiles.Count > 0 && tsFiles.Count < numConcat) { using (Process ps = new Process()) { String fileName = (cntConcat - (cntConcat % numConcat) + 1).ToString() + "_" + cntConcat.ToString() + ".ts"; ps.StartInfo.FileName = FFMPEG_EXE_PATH; ps.StartInfo.Arguments = "-y -i \"concat:" + String.Join("|", tsFiles.ToArray()) + "\" -c copy \"" + fileName + "\""; ps.StartInfo.WorkingDirectory = this.tempPath; ps.StartInfo.CreateNoWindow = true; ps.StartInfo.UseShellExecute = false; ps.Start(); System.Threading.Thread.Sleep(1000); while (true) { if (ps.HasExited) { foreach (String ts in tsFiles) { File.Delete(this.tempPath + Path.DirectorySeparatorChar + ts); } tsFiles = new List <String>(); if (ps.ExitCode != 0) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + cntConcat.ToString() + " / " + numFinTs.ToString() + " 動画ファイルの結合でエラーが発生しました。" + Environment.NewLine); return; } else { concatFiles.Add(fileName); AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + cntConcat.ToString() + " / " + numFinTs.ToString() + " 動画ファイルを結合しました。" + Environment.NewLine); UpdateMessageText(); } break; } if (worker.CancellationPending) { ps.Kill(); AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "中止しました。" + Environment.NewLine); return; } System.Threading.Thread.Sleep(100); } } } // 出力されるファイル名の形式 // 放送番号 - 放送者名 - 放送タイトル.mp4 String completeFileName = SanitizeFileName(this.vno + " - " + this.nick + " - " + this.title + ".mp4"); using (Process ps = new Process()) { String filePath = this.saveToPath + Path.DirectorySeparatorChar + completeFileName; ps.StartInfo.FileName = FFMPEG_EXE_PATH; if (concatFiles.Count > 1) { ps.StartInfo.Arguments = "-y -i \"concat:" + String.Join("|", concatFiles.ToArray()) + "\" -c copy -bsf:a aac_adtstoasc \"" + filePath + "\""; } else { ps.StartInfo.Arguments = "-y -i \"" + concatFiles[0] + "\" -c copy -bsf:a aac_adtstoasc \"" + filePath + "\""; } ps.StartInfo.WorkingDirectory = this.tempPath; ps.StartInfo.CreateNoWindow = true; ps.StartInfo.UseShellExecute = false; ps.Start(); AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "全動画ファイルの結合・MP4変換を開始しました。" + Environment.NewLine); System.Threading.Thread.Sleep(1000); while (true) { if (ps.HasExited) { foreach (String concat in concatFiles) { File.Delete(this.tempPath + Path.DirectorySeparatorChar + concat); } concatFiles = new List <String>(); if (ps.ExitCode != 0) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + "動画ファイルの結合でエラーが発生しました。" + Environment.NewLine); return; } else { this.isSuccess = true; AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "完了しました。ファイル名:" + completeFileName + Environment.NewLine); UpdateMessageText(); } break; } if (worker.CancellationPending) { ps.Kill(); AppendTextBoxMessageText(NORMAL_MESSAGE_PREFIX + "中止しました。" + Environment.NewLine); return; } System.Threading.Thread.Sleep(100); } } } catch (Exception ex) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + "動画ファイルの処理で問題が発生しました。" + ex.Message + Environment.NewLine); return; } } catch (Exception ex) { AppendTextBoxMessageText(ERROR_MESSAGE_PREFIX + "問題が発生しました。" + ex.Message + Environment.NewLine); return; } }
/// <summary> /// 获取两个用户之间的共同关注人列表 /// </summary> /// <param name="uid">需要获取共同关注关系的用户UID。</param> /// <param name="suid">需要获取共同关注关系的用户UID,默认为当前登录用户。</param> /// <param name="count">单页返回的记录条数,默认为50。 </param> /// <param name="page">返回结果的页码,默认为1。</param> /// <returns></returns> public dynamic FriendsInCommon(string uid = "", string suid = "", int count = 50, int page = 1) { return(DynamicJson.Parse(api.FriendsInCommon(uid, suid, count, page))); }
/// <summary> /// 获取用户的活跃粉丝列表 /// </summary> /// <param name="uid">需要查询的用户UID。 </param> /// <param name="count">返回的记录条数,默认为20,最大不超过200。 </param> /// <returns></returns> public dynamic FollowersInActive(string uid, int count = 20) { return(DynamicJson.Parse(api.FollowersInActive(uid, count))); }
/// <summary> /// 获取用户的粉丝列表 /// </summary> /// <param name="uid">需要查询的用户UID。 </param> /// <param name="screenName">需要查询的用户昵称。 </param> /// <param name="count">单页返回的记录条数,默认为50,最大不超过200。</param> /// <param name="cursor">返回结果的游标,下一页用返回值里的next_cursor,上一页用previous_cursor,默认为0。</param> /// <param name="trimStatus">返回值中user字段中的status字段开关,0:返回完整status字段、1:status字段仅返回status_id,默认为1。 </param> /// <returns></returns> public dynamic Followers(string uid = "", string screenName = "", int count = 50, int cursor = 0, bool trimStatus = true) { return(DynamicJson.Parse(api.Followers(uid, screenName, count, cursor, trimStatus))); }
/// <summary> /// 获取当前登录用户的关注人中又关注了指定用户的用户列表 /// </summary> /// <param name="uid">指定的关注目标用户UID。 </param> /// <param name="count">单页返回的记录条数,默认为50。 </param> /// <param name="page">返回结果的页码,默认为1。</param> /// <returns></returns> public dynamic FriendsChain(string uid, int count = 50, int page = 1) { return(DynamicJson.Parse(api.FriendsChain(uid, count, page))); }
public void LoadducoinThemTen() { // DataTable t = new DataTable(); t.Columns.Add(new DataColumn("#", typeof(int))); t.Columns.Add(new DataColumn("KH", typeof(Bitmap))); t.Columns.Add(new DataColumn("NAME", typeof(string))); t.Columns.Add(new DataColumn("SYMBOL", typeof(string))); t.Columns.Add(new DataColumn("GIATRIVONHOA", typeof(string))); t.Columns.Add(new DataColumn("GIA", typeof(string))); t.Columns.Add(new DataColumn("CHANGE1h", typeof(string))); t.Columns.Add(new DataColumn("CHANGE24h", typeof(string))); t.Columns.Add("uri"); Bitmap b = new Bitmap(50, 15); using (Graphics g = Graphics.FromImage(b)) { g.DrawString("Loading...", this.Font, new SolidBrush(Color.Black), 0f, 0f); } string url = "https://cryws.herokuapp.com/api/coins/tiny"; HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); httpWebRequest.Method = WebRequestMethods.Http.Get; httpWebRequest.Accept = "text/json"; HttpWebResponse response = (HttpWebResponse)httpWebRequest.GetResponse(); var streamReader = new StreamReader(response.GetResponseStream()); var result = streamReader.ReadToEnd(); var statuses = DynamicJson.Parse(result); int count1 = 0; foreach (var status in statuses) { // MessageBox.Show(status1 + ""+ status.sb); foreach (string prime in list) { if (prime.Equals(status.sb.ToString())) { t.Rows.Add(new object[] { count1, b, status.nm, status.sb, status.mc, status.pr, status.c01, status.c24, "https://cryws.herokuapp.com/res/coins_high/16/color/" + status.sb + ".png" }); break; } } count1++; } gvDSUuThich.DataSource = t; ThreadPool.QueueUserWorkItem(delegate { foreach (DataRow row in t.Rows) { HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(row["uri"].ToString()); myRequest.Method = "GET"; HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse(); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(myResponse.GetResponseStream()); myResponse.Close(); row["KH"] = bmp; } }); gvDSUuThich.Columns["uri"].Visible = false; }
/// <summary> /// 获取两个用户之间的详细关注关系情况 /// </summary> /// <param name="sourceID">源用户的UID。</param> /// <param name="sourceScreenName">源用户的微博昵称。 </param> /// <param name="targetID">目标用户的UID。 </param> /// <param name="targetScreenName">目标用户的微博昵称。 </param> /// <returns></returns> public dynamic Show(string sourceID = "", string sourceScreenName = "", string targetID = "", string targetScreenName = "") { return(DynamicJson.Parse(api.Show(sourceID, sourceScreenName, targetID, targetScreenName))); }
public ApiResp Execute(System.Collections.Hashtable params_ht) { ApiResp resp = new ApiResp(); try { string jsonData = params_ht["json"].ToString(); dynamic jsonObj = DynamicJson.Parse(jsonData); string carId = ""; if (jsonObj.IsDefined("carId")) { carId = jsonObj.carId;//车辆ID } string latitude = ""; if (jsonObj.IsDefined("body.latitude")) { latitude = jsonObj.body.latitude;//纬度 } string longitude = ""; if (jsonObj.IsDefined("body.longitude")) { longitude = jsonObj.body.longitude;//经度 } string elevation = ""; if (jsonObj.IsDefined("body.elevation")) { elevation = jsonObj.body.elevation;//海拔 } string speed = ""; if (jsonObj.IsDefined("body.speed")) { speed = jsonObj.body.speed;//车速 } string direction = ""; if (jsonObj.IsDefined("body.direction")) { direction = jsonObj.body.direction;//方向 } string time = ""; if (jsonObj.IsDefined("body.time")) { time = jsonObj.body.time;//时间 } string surplusPercent = ""; if (jsonObj.IsDefined("body.surplusPercent")) { surplusPercent = jsonObj.body.surplusPercent;//剩余电量百分比 } string surplusDistance = ""; if (jsonObj.IsDefined("body.surplusDistance")) { surplusDistance = jsonObj.body.surplusDistance;//剩余续航里程 } string distance = ""; if (jsonObj.IsDefined("body.distance")) { distance = jsonObj.body.distance;//总行驶里程 } VehicleManager vm = new VehicleManager(); Hashtable vehicle_ht = vm.GetVehicleInfoByGPSNum(carId); if (vehicle_ht != null && vehicle_ht.Keys.Count > 0) { string vid = vehicle_ht["ID"].ToString(); Hashtable ht = new Hashtable(); if (!string.IsNullOrEmpty(longitude)) { ht["Longitude"] = longitude; } if (!string.IsNullOrEmpty(latitude)) { ht["Latitude"] = latitude; } if (!string.IsNullOrEmpty(speed)) { ht["CurrentSpeed"] = speed; } if (!string.IsNullOrEmpty(time)) { ht["GPSTime"] = DateTime.Now; } if (!string.IsNullOrEmpty(surplusPercent)) { ht["Electricity"] = surplusPercent; } if (!string.IsNullOrEmpty(surplusDistance)) { ht["ExpectRange"] = surplusDistance; } if (!string.IsNullOrEmpty(distance)) { ht["Mileage"] = distance; } bool result = false; if (ht.Keys.Count > 0) { result = vm.AddOrEditVehicleInfo(ht, vid); } resp.Code = result ? "0" : "1"; } return(resp); } catch { resp.Code = "1"; return(resp); } }
/// <summary> /// 关注一个用户 /// </summary> /// <param name="uid">需要关注的用户ID。</param> /// <param name="screenName">需要关注的用户昵称。 </param> /// <returns></returns> public dynamic Create(string uid = "", string screenName = "") { return(DynamicJson.Parse(api.Create(uid, screenName))); }
private void HandleBookMetadata(ApiRequest request) { switch (request.HttpMethod) { case HttpMethods.Get: // The spec is here: https://docs.google.com/document/d/e/2PACX-1vREQ7fUXgSE7lGMl9OJkneddkWffO4sDnMG5Vn-IleK35fJSFqnC-6ulK1Ss3eoETCHeLn0wPvcxJOf/pub // See also https://www.w3.org/Submission/2017/SUBM-epub-a11y-20170125/#sec-conf-reporting. var licenseUrl = _bookSelection.CurrentSelection.GetLicenseMetadata().License.Url; if (string.IsNullOrEmpty(licenseUrl)) { licenseUrl = null; // allows us to use ?? below. } var metadata = new { metapicture = new { type = "image", value = "/bloom/" + _bookSelection.CurrentSelection.GetCoverImagePath(), translatedLabel = LocalizationManager.GetString("BookMetadata.metapicture", "Picture") }, name = new { type = "readOnlyText", value = _bookSelection.CurrentSelection.TitleBestForUserDisplay, translatedLabel = LocalizationManager.GetString("BookMetadata.name", "Name") }, numberOfPages = new { type = "readOnlyText", value = _bookSelection.CurrentSelection.GetLastNumberedPageNumber().ToString(), translatedLabel = LocalizationManager.GetString("BookMetadata.numberOfPages", "Number of pages") }, inLanguage = new { type = "readOnlyText", value = _bookSelection.CurrentSelection.BookData.Language1.Iso639Code, translatedLabel = LocalizationManager.GetString("BookMetadata.inLanguage", "Language") }, // "All rights reserved" is purposely not localized, so it remains an accurate representation of // the English information that will be put in the file in place of a License URL. License = new { type = "readOnlyText", value = licenseUrl ?? @"All rights reserved", translatedLabel = LocalizationManager.GetString("BookMetadata.License", "License") }, author = new { type = "editableText", value = "" + _bookSelection.CurrentSelection.BookInfo.MetaData.Author, translatedLabel = LocalizationManager.GetString("BookMetadata.author", "Author") }, summary = new { type = "bigEditableText", value = "" + _bookSelection.CurrentSelection.BookInfo.MetaData.Summary, translatedLabel = LocalizationManager.GetString("PublishTab.Upload.Summary", "Summary") }, typicalAgeRange = new { type = "editableText", value = "" + _bookSelection.CurrentSelection.BookInfo.MetaData.TypicalAgeRange, translatedLabel = LocalizationManager.GetString("BookMetadata.typicalAgeRange", "Typical age range") }, level = new { type = "editableText", value = "" + _bookSelection.CurrentSelection.BookInfo.MetaData.ReadingLevelDescription, translatedLabel = LocalizationManager.GetString("BookMetadata.level", "Reading level") }, subjects = new { type = "subjects", value = _bookSelection.CurrentSelection.BookInfo.MetaData.Subjects, translatedLabel = LocalizationManager.GetString("BookMetadata.subjects", "Subjects") }, a11yLevel = new { type = "a11yLevel", value = "" + _bookSelection.CurrentSelection.BookInfo.MetaData.A11yLevel, translatedLabel = LocalizationManager.GetString("BookMetadata.a11yLevel", "Accessibility level"), helpurl = "http://www.idpf.org/epub/a11y/accessibility.html#sec-acc-pub-wcag" }, a11yCertifier = new { type = "editableText", value = "" + _bookSelection.CurrentSelection.BookInfo.MetaData.A11yCertifier, translatedLabel = LocalizationManager.GetString("BookMetadata.a11yCertifier", "Level certified by") }, hazards = new { type = "hazards", value = "" + _bookSelection.CurrentSelection.BookInfo.MetaData.Hazards, translatedLabel = LocalizationManager.GetString("BookMetadata.hazards", "Hazards"), helpurl = "http://www.idpf.org/epub/a11y/techniques/techniques.html#meta-004" }, a11yFeatures = new { type = "a11yFeatures", value = "" + _bookSelection.CurrentSelection.BookInfo.MetaData.A11yFeatures, translatedLabel = LocalizationManager.GetString("BookMetadata.a11yFeatures", "Accessibility features"), helpurl = "http://www.idpf.org/epub/a11y/techniques/techniques.html#meta-003" } }; var translatedStringPairs = new { flashingHazard = LocalizationManager.GetString("BookMetadata.flashingHazard", "Flashing Hazard"), motionSimulationHazard = LocalizationManager.GetString("BookMetadata.motionSimulationHazard", "Motion Simulation Hazard"), alternativeText = LocalizationManager.GetString("BookMetadata.alternativeText", "Has Image Descriptions"), signLanguage = LocalizationManager.GetString("BookMetadata.signLanguage", "Sign Language"), }; var blob = new { metadata, translatedStringPairs, }; request.ReplyWithJson(blob); break; case HttpMethods.Post: var json = request.RequiredPostJson(); var settings = DynamicJson.Parse(json); _bookSelection.CurrentSelection.BookInfo.MetaData.Author = settings["author"].value.Trim(); _bookSelection.CurrentSelection.BookInfo.MetaData.Summary = settings["summary"].value.Trim(); _bookSelection.CurrentSelection.BookInfo.MetaData.TypicalAgeRange = settings["typicalAgeRange"].value.Trim(); _bookSelection.CurrentSelection.BookInfo.MetaData.ReadingLevelDescription = settings["level"].value.Trim(); _bookSelection.CurrentSelection.BookInfo.MetaData.Subjects = settings["subjects"].value; _bookSelection.CurrentSelection.BookInfo.MetaData.A11yLevel = settings["a11yLevel"].value.Trim(); _bookSelection.CurrentSelection.BookInfo.MetaData.A11yCertifier = settings["a11yCertifier"].value.Trim(); _bookSelection.CurrentSelection.BookInfo.MetaData.Hazards = settings["hazards"].value.Trim(); _bookSelection.CurrentSelection.BookInfo.MetaData.A11yFeatures = settings["a11yFeatures"].value.Trim(); _bookSelection.CurrentSelection.Save(); request.PostSucceeded(); break; default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// 取消关注一个用户 /// </summary> /// <param name="uid">需要取消关注的用户ID。</param> /// <param name="screenName">需要取消关注的用户昵称。 </param> /// <returns></returns> public dynamic Destroy(string uid = "", string screenName = "") { return(DynamicJson.Parse(api.Destroy(uid, screenName))); }
/// <summary> /// 获取用户发布的微博的ID /// </summary> /// <param name="uid">需要查询的用户ID。 </param> /// <param name="screenName">需要查询的用户昵称。</param> /// <param name="sinceID">若指定此参数,则返回ID比since_id大的微博(即比since_id时间晚的微博),默认为0。</param> /// <param name="maxID">若指定此参数,则返回ID小于或等于max_id的微博,默认为0。 </param> /// <param name="count">单页返回的记录条数,默认为50。 </param> /// <param name="page">返回结果的页码,默认为1。</param> /// <param name="baseApp">是否只获取当前应用的数据。0为否(所有数据),1为是(仅当前应用),默认为0。</param> /// <param name="feature">过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。 </param> /// <returns></returns> public dynamic UserTimelineIDs(string uid = "", string screenName = "", string sinceID = "", string maxID = "", int count = 50, int page = 1, bool baseApp = false, int feature = 0) { return(DynamicJson.Parse(api.UserTimelineIDs(uid, screenName, sinceID, maxID, count, page, baseApp, feature))); }
/// <summary> /// 更新当前登录用户所关注的某个好友的备注信息 /// </summary> /// <param name="uid">需要修改备注信息的用户UID。 </param> /// <param name="remark">备注信息</param> /// <returns></returns> public dynamic UpdateRemark(string uid, string remark) { return(DynamicJson.Parse(api.UpdateRemark(uid, remark))); }
/// <summary> /// 获取当前用户最新转发的微博列表 /// </summary> /// <param name="sinceID">若指定此参数,则返回ID比since_id大的微博(即比since_id时间晚的微博),默认为0。 </param> /// <param name="maxID">若指定此参数,则返回ID小于或等于max_id的微博,默认为0。 </param> /// <param name="count">单页返回的记录条数,默认为50。 </param> /// <param name="page">返回结果的页码,默认为1。 </param> /// <returns></returns> public dynamic RepostByMe(string sinceID = "", string maxID = "", int count = 50, int page = 1) { return(DynamicJson.Parse(api.RepostByMe(sinceID, maxID, count, page))); }
/// <summary> /// 根据评论ID批量返回评论信息 /// </summary> /// <param name="cids">需要查询的批量评论ID,最大50。</param> /// <returns></returns> public dynamic ShowBatch(params string[] cids) { return(DynamicJson.Parse(api.ShowBatch(cids))); }