/// <summary> /// 更新视频状态 /// </summary> /// <param name="request"></param> /// <returns></returns> public dynamic UpdateStatus(W_CourseWare model, int System_Station_ID) { W_CourseWare CourseWareModel = Orm.Single <W_CourseWare>(x => x.ID == model.ID && x.System_Station_ID == System_Station_ID); if (CourseWareModel == null) { throw new ApiException("操作失败,未找到操作数据,请刷新重试"); } if (model.Status == 7) { PolyvInfoMapper bll = new PolyvInfoMapper(); PolyvInfoModel PolyvModel = bll.GetPolyvSetByWhere(System_Station_ID); if (PolyvModel == null) { throw new ApiException("资源上传目录未设置,请先设置!"); } else { if (PolyvModel.Valid == 0) { throw new ApiException("资源上传设置未开启,请先开启!"); } } try { //string readtoken = "88cb627e-0bf2-4b64-833f-3e8e60a9f8e8"; //string secretkey = "UfmKG8jJ82"; string readtoken = PolyvModel.readtoken; string secretkey = PolyvModel.secretkey; string signn = string.Format("readtoken={0}&vid={1}{2}", readtoken, CourseWareModel.PolyvVID, secretkey); string Sign = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(signn, "sha1"); string postData = string.Format("readtoken={0}&vid={1}&sign={2}", readtoken, CourseWareModel.PolyvVID, Sign); string Url = "http://v.polyv.net/uc/services/rest?method=getById&readtoken=" + readtoken + "&vid=" + CourseWareModel.PolyvVID + "&sign=" + Sign; string result = bll.doGet(Url); JavaScriptSerializer jss = new JavaScriptSerializer(); PlayModelData Json = jss.Deserialize <PlayModelData>(result); DateTime dt = DateTime.Parse(Json.data[0].duration); model.Duration = dt.Hour * 60 * 60 + dt.Minute * 60 + dt.Second; //if (Json.data[0].filesize.Length > 0) // CourseSize = Json.data[0].filesize[Json.data[0].filesize.Length - 1].ToInt(0); model.CourseSize = Convert.ToInt64(Json.data[0].source_filesize); } catch (Exception) { } } return(SqlMapper.Update("UpdateStatus", new { PolyvVID = model.PolyvVID, Status = model.Status, Duration = model.Duration, CourseSize = model.CourseSize, ID = model.ID })); }
/// <summary> /// 更新播放次数 /// </summary> /// <param name="request"></param> /// <returns></returns> public dynamic GetUpdatePlayCount(int ID, int System_Station_ID) { W_CourseWare model = Orm.Single <W_CourseWare>(x => x.ID == ID && x.System_Station_ID == System_Station_ID); if (model == null) { throw new ApiException("未找到对应数据"); } model.PlayCount = model.PlayCount + 1; if (Orm.Update(model) <= 0) { throw new ApiException("修改失败"); } return(true); }
/// <summary> /// 添加修改课件 /// </summary> /// <param name="Model"></param> /// <param name="System_Station_ID"></param> /// <param name="AccountID"></param> /// <returns></returns> public dynamic SaveCourseWare(W_CourseWare Model, int System_Station_ID, int AccountID) { if (Model.ID > 0) { W_CourseWare model = Orm.Single <W_CourseWare>(x => x.ID == Model.ID && x.System_Station_ID == System_Station_ID); if (model == null) { throw new ApiException("您要修改的数据不存在"); } Model.AddPerson = model.AddPerson; Model.AddTime = model.AddTime; if (Orm.Update(Model) <= 0) { throw new ApiException("修改失败"); } } else { Model.System_Station_ID = System_Station_ID; Model.AddTime = DateTime.Now; Model.Valid = 1; Model.Status = 0; Model.Duration = 0; Model.PlayCount = 0; Model.AddPerson = AccountID; //去掉后缀 if (Model.Name != null && Model.Name.Contains(".")) { Model.Name = Model.Name.Split('.')[0]; } int count = SqlMapper.QueryForObject <int>("GetW_CourseWareCount", new { PolyvVID = Model.PolyvVID }); if (count > 0) { return(true); } else { if (Orm.Insert(Model) <= 0) { throw new ApiException("添加失败"); } return(true); } } return(true); }
/// <summary> /// 启用禁用课件 /// </summary> /// <param name="request"></param> /// <returns></returns> public dynamic UpdateValid(CourseWareModel model, int System_Station_ID) { W_CourseWare CourseWareModel = Orm.Single <W_CourseWare>(x => x.ID == model.ID && x.System_Station_ID == System_Station_ID); if (CourseWareModel == null) { throw new ApiException("操作失败,未找到操作数据,请刷新重试"); } CourseWareModel.Valid = model.Valid; if (Orm.Update(CourseWareModel) <= 0) { throw new ApiException("操作失败,请重新操作"); } return(true); }
/// <summary> /// 删除课件 /// </summary> /// <param name="request"></param> /// <returns></returns> public dynamic DeleteCourseWare(CourseWareModel model, int System_Station_ID) { W_CourseWare CourseWareModel = Orm.Single <W_CourseWare>(x => x.ID == model.ID && x.System_Station_ID == System_Station_ID); if (CourseWareModel == null) { throw new ApiException("操作失败,未找到操作数据,请刷新重试"); } W_Course_Chapters chaptersmodel = Orm.Single <W_Course_Chapters>(x => x.CourseWare_ID == model.ID && x.System_Station_ID == System_Station_ID); if (chaptersmodel != null) { throw new ApiException("章节应用了该课件,请先删除课件"); } return(Orm.Delete(CourseWareModel)); }
/// <summary> ///删除学科及对应的关系表 DeleteDiscipline /// </summary> public bool RemoveDiscipline(int ID, int System_Station_ID) { if (ID <= 0) { throw new ApiException("无效参数!"); } //判断是不是该机构添加的学科 W_Discipline model = Orm.Single <W_Discipline>(x => x.ID == ID && x.System_Station_ID == System_Station_ID); if (model == null) { throw new ApiException("操作失败,未找到对应的数据!"); } ///判断学科启用状态 if (model.Valid == 1) { throw new ApiException("学科启用状态,不能删除!"); } W_Discipline modelCid = Orm.Single <W_Discipline>(x => x.CID == ID && x.System_Station_ID == System_Station_ID); ///判断学科子集是否存在课程 if (modelCid != null) { throw new ApiException("该学科下面存在课程,不能删除!"); } W_QuestionStore modelstore = Orm.Single <W_QuestionStore>(x => x.Discipline_ID == ID && x.System_Station_ID == System_Station_ID && x.IsDelete == 0); ///判断题库是否应用该学科 if (modelstore != null) { throw new ApiException("题库应用了该学科,不能删除!"); } W_CourseWare modelware = Orm.Single <W_CourseWare>(x => x.Discipline_ID == ID && x.System_Station_ID == System_Station_ID); ///判断资源库是否应用该学科 if (modelware != null) { throw new ApiException("资源库应用了该学科,不能删除!"); } //删除数据 if (Orm.Delete <W_Discipline>(x => x.ID == ID && x.System_Station_ID == System_Station_ID) > 0) { return(true); } return(false); }
public dynamic SaveCourseWare(W_CourseWare Model) { return(Success(mapper.SaveCourseWare(Model, this.System_Station_ID, this.AccountID))); }
public dynamic UpdateStatus(W_CourseWare model) { return(Success(mapper.UpdateStatus(model, this.System_Station_ID))); }