/// <summary> /// タイムフリー /// </summary> /// <param name="program"></param> /// <returns></returns> public async Task TimeFree(Entities.Program program) { try { Status = RecorderStatus.Working; _duration = (int)(program.End - program.Start).TotalSeconds; await Radiko.Login(Config.RadikoEmail, Config.RadikoPassword); _program = program; Directory.CreateDirectory(Path.Combine("wwwroot", "records")); _filename = Path.GetFullPath(Path.Combine("wwwroot", "records", $"{Guid.NewGuid().ToString()}.m4a")); StartTime = DateTime.Now; var m3U8 = await Radiko.GetTimeFreeM3U8(program); var arg = Define.Radiko.TimeFreeFfmpegArgs.Replace("[M3U8]", m3U8).Replace("[FILE]", _filename); arg = Replace(arg, _program); CreateProcess(arg); _ffmpeg.Start(); _ffmpeg.BeginOutputReadLine(); _ffmpeg.BeginErrorReadLine(); } catch (Exception ex) { Global.Logger.Error($"{ex.Message}¥n{ex.StackTrace}"); } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = 0; if (validateData()) { Entities.Program oProgram = new Entities.Program(); oProgram.code = Convert.ToInt32(txtCode.Text); oProgram.name = txtName.Text.ToString(); oProgram.unit = Convert.ToInt64(txtUnit.Text); oProgram.state = Convert.ToInt16(cboState.SelectedValue); if (ProgramBLL.getInstance().exists(oProgram.code)) //If the program exists in the database { records = ProgramBLL.getInstance().modify(oProgram); //To modify the program } else { records = ProgramBLL.getInstance().insert(oProgram);//To insert a program } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente."; } } }
protected void btnSave_Click(object sender, ImageClickEventArgs e) { Int32 records = -1; if (validateData()) { Entities.UserSystem oUser = new Entities.UserSystem(); Entities.Program oProgram = new Entities.Program(); Entities.Role oRole = new Entities.Role(); oUser.code = Convert.ToInt32(txtCode.Text); oUser.id = txtId.Text; oUser.name = txtName.Text; oUser.lastName = txtLastName.Text; oUser.homePhone = txtHomePhone.Text; oUser.cellPhone = txtCellPhone.Text; oUser.email = txtEmail.Text; oProgram.code = Convert.ToInt16(cboProgram.SelectedValue); if(oProgram.code == 0) { oProgram.code = 1; } oUser.Password = txtId.Text; oRole.Role_Id = Convert.ToInt16(cboRole.SelectedValue); oUser.oProgram = oProgram; oUser.oRole = oRole; oUser.state = Convert.ToInt16(cboState.SelectedValue); if (BLL.UserSystemBLL.getInstance().exists(oUser.code)) { records = BLL.UserSystemBLL.getInstance().modify(oUser); } else { records = BLL.UserSystemBLL.getInstance().insert(oUser); if (records > 0) { Entities.Email oEmail = new Entities.Email(); String body = messageDesign(oUser.email); oEmail.correoContacto(oUser.email, body, "Bienvenido a Siscape"); } } blockControls(); loadData(); if (records > 0) { lblMessage.Text = "Datos almacenados correctamente."; } //no c para que es esto else { ScriptManager.RegisterStartupScript(Page, Page.GetType(), "comboBox", "comboBox();", true); } } }
private Program CopyMPToP(ModelProgram MP) { Entities.Program P = new Entities.Program { ProgramId = MP.ProgramId, FkShiftId = MP.FkShiftId, ProgramTitle = MP.ProgramTitle, DateCreated = MP.DateCreated, DateUpdated = MP.DateUpdated, }; return(P); }
/// <summary> /// 文字列置換 /// </summary> /// <param name="src"></param> /// <param name="program"></param> /// <returns></returns> protected string Replace(string src, Entities.Program program) { var res = src; res = res.Replace("[TAG_TITLE]", Config.TagTitle); res = res.Replace("[TAG_ARTIST]", Config.TagArtist); res = res.Replace("[TAG_COMMENT]", Config.TagComment); res = res.Replace("[TAG_GENRE]", Config.TagGenre); res = res.Replace("[TAG_ALBUM]", Config.TagAlbum); res = res.Replace("[BITRATE]", Config.BitRate); res = res.Replace("[SAMPLINGRATE]", Config.SamplingRate); res = res.Replace("[VOLUME]", Config.Volume); res = res.Replace("[CH_NAME]", program.Station.Name); res = res.Replace("[CH]", program.Station.Code); if (!string.IsNullOrWhiteSpace(program.Id)) { res = res.Replace("[TITLE]", program.Title); res = res.Replace("[CAST]", program.Cast); res = res.Replace("[INFO]", program.Description); // 28時表記 var date = program.Start.Hour < 5 ? program.Start.AddDays(-1) : program.Start; res = res.Replace("[SYEAR]", Convert.ToString(date.Year)); res = res.Replace("[SMONTH]", date.Month.ToString("d2")); res = res.Replace("[SDAY]", date.Day.ToString("d2")); res = res.Replace("[SHOUR]", date.Hour < 5 ? (date.Hour + 24).ToString("d2") : date.Hour.ToString("d2")); res = res.Replace("[SMIN]", date.Minute.ToString("d2")); res = res.Replace("[SYOBI]", GetYobi(date.DayOfWeek)); // 28時表記 date = program.End.Hour < 5 ? program.End.AddDays(-1) : program.End; res = res.Replace("[EYEAR]", Convert.ToString(date.Year)); res = res.Replace("[EMONTH]", date.Month.ToString("d2")); res = res.Replace("[EDAY]", date.Day.ToString("d2")); res = res.Replace("[EHOUR]", date.Hour < 5 ? (date.Hour + 24).ToString("d2") : date.Hour.ToString("d2")); res = res.Replace("[EMIN]", date.Minute.ToString("d2")); res = res.Replace("[EYOBI]", GetYobi(date.DayOfWeek)); } return(res); }
/// <summary> /// 録音開始 /// </summary> /// <returns></returns> public async Task Start() { try { Status = RecorderStatus.Working; using (var con = new SqliteConnection($"Data Source={Define.File.DbFile}")) { var pModel = new ProgramModel(con); _program = pModel.Search(new ProgramSearchCondition() { StationId = Task.Station.Id, From = Task.Reserve.Start, To = Task.Reserve.End }).FirstOrDefault(); _program.Station = Task.Station; } if (Task.Reserve.IsTimeFree) { // 番組情報取得 using (var con = new SqliteConnection($"Data Source={Define.File.DbFile}")) { _ = TimeFree(_program); } } else { await Radiko.Login(Config.RadikoEmail, Config.RadikoPassword); Directory.CreateDirectory(Path.Combine("wwwroot", "records")); _filename = Path.GetFullPath(Path.Combine("wwwroot", "records", $"{Guid.NewGuid().ToString()}.m4a")); StartTime = DateTime.Now; _token = await Radio.Radiko.GetAuthToken(); var arg = Define.Radiko.RealTimeFfmpegArgs.Replace("[TOKEN]", _token) .Replace("[TIME]", (Task.End.AddSeconds(Define.Radiko.EndSec) - DateTime.Now).ToString(@"hh\:mm\:ss")) .Replace("[FILE]", _filename); arg = Replace(arg, _program); CreateProcess(arg); _ffmpeg.Start(); _ffmpeg.BeginOutputReadLine(); _ffmpeg.BeginErrorReadLine(); } } catch (Exception ex) { var a = ex.Message; } }
public IActionResult UpdateProgram(int id) { if (id < 1) { return(NotFound()); } Entities.Program P = OurdbContext.Program.Find(id); if (P.ProgramId < 1) { return(NotFound()); } IList <Shift> ILS = OurdbContext.Shift.ToList(); ViewBag.vb = ILS; return(View("AddUpdateProgram", CopyPToMP(P))); }
protected void gvProgram_RowEditing(object sender, GridViewEditEventArgs e) { unlockControls(); Int32 code = Convert.ToInt32(gvProgram.Rows[e.NewEditIndex].Cells[0].Text); Entities.Program oProgram = ProgramBLL.getInstance().getProgram(code); txtCode.Text = oProgram.code.ToString(); txtName.Text = oProgram.name.ToString(); txtUnit.Text = oProgram.unit.ToString(); try { cboState.SelectedValue = oProgram.state.ToString(); } catch (Exception) { cboState.SelectedValue = "1"; } ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", "$('html, body').animate({ scrollTop: $('body').offset().top });", true); }
/// <summary> /// タイムフリーのM3U8取得 /// </summary> /// <param name="program"></param> /// <returns></returns> public static async Task <string> GetTimeFreeM3U8(Entities.Program program) { var m3U8 = ""; var token = await GetAuthToken(); var url = Define.Radiko.TimeFreeM3U8.Replace("[CH]", program.Station.Code) .Replace("[FT]", program.Start.ToString("yyyyMMddHHmmss")) .Replace("[TO]", program.End.ToString("yyyyMMddHHmmss")); using (var handler = new HttpClientHandler() { UseCookies = true }) { using (var client = new HttpClient(handler)) { if (_cookieContainer != null) { handler.CookieContainer = _cookieContainer; } var request = new HttpRequestMessage(HttpMethod.Post, url); request.Headers.Add("pragma", "no-cache"); request.Headers.Add("X-Radiko-AuthToken", token); var res = await client.SendAsync(request); var text = await res.Content.ReadAsStringAsync(); foreach (var line in text.Split("\n")) { if (!line.Contains("http")) { continue; } m3U8 = line; break; } } } return(m3U8); }
public IActionResult ProgramDetail(int ProgramID) { Entities.Program P = OurdbContext.Program.Where(abc => abc.ProgramId == ProgramID).FirstOrDefault(); return(View(P)); }