public IList <Courseware> GetCoursewaresByPostID(int postID, string coursewareName, string keyWord, string authors, int orgID) { IList <Courseware> coursewares = new List <Courseware>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_COURSEWARE_F_PostID"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_post_id", DbType.Int32, postID); db.AddInParameter(dbCommand, "p_courseware_name", DbType.String, coursewareName); db.AddInParameter(dbCommand, "p_keyword", DbType.String, keyWord); db.AddInParameter(dbCommand, "p_authors", DbType.String, authors); db.AddInParameter(dbCommand, "p_org_id", DbType.Int32, orgID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Courseware courseware = CreateModelObject(dataReader); coursewares.Add(courseware); } } return(coursewares); }
public IList <Courseware> GetCourseware(int coursewareID, string coursewareName, int coursewareTypeID, int PrivodeOrg, DateTime publishDate, string authors, string keyWord, string revisers, string url, string description, string memo, int startRowIndex, int maximumRows, string orderBy) { IList <Courseware> coursewares = new List <Courseware>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_COURSEWARE_S"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_start_row_index", DbType.Int32, startRowIndex); db.AddInParameter(dbCommand, "p_page_size", DbType.Int32, maximumRows); db.AddInParameter(dbCommand, "p_order_by", DbType.AnsiString, GetMappingOrderBy(orderBy)); db.AddOutParameter(dbCommand, "p_count", DbType.Int32, 4); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Courseware courseware = CreateModelObject(dataReader); coursewares.Add(courseware); } } return(coursewares); }
public IList <Courseware> GetStudyCoursewareInfoByTrainTypeID(int trainTypeID, int orgID, int postID, int isGroupleader, int techid, int row) { IList <Courseware> coursewareList = new List <Courseware>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_WARE_TRAIN_G"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_coursreware_type_id", DbType.Int32, 0); db.AddInParameter(dbCommand, "p_train_type_id", DbType.Int32, trainTypeID); db.AddInParameter(dbCommand, "p_org_id", DbType.Int32, orgID); db.AddInParameter(dbCommand, "p_post_id", DbType.Int32, postID); db.AddInParameter(dbCommand, "p_is_group_leader", DbType.Int32, isGroupleader); db.AddInParameter(dbCommand, "p_tech_id", DbType.Int32, techid); db.AddInParameter(dbCommand, "p_row_num", DbType.Int32, row); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Courseware courseware = CreateModelObject(dataReader); coursewareList.Add(courseware); } } return(coursewareList); }
public int AddCourseware(Courseware courseware) { int id = dal.AddCourseware(courseware); objLogBll.WriteLog("新增课件《" + courseware.CoursewareName + "》基本信息" ); return(id); }
public IList <Courseware> GetCoursewaresByCoursewareTypeOnline(int orgid, int postid, string idpath, bool isGroupleader, int techniciantypeid) { IList <Courseware> coursewares = new List <Courseware>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_COURSEWARE_Q_Study"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_org_id", DbType.Int32, orgid); db.AddInParameter(dbCommand, "p_post_id", DbType.Int32, postid); db.AddInParameter(dbCommand, "p_id_path", DbType.String, idpath); db.AddInParameter(dbCommand, "p_is_group_leader", DbType.Int32, isGroupleader); db.AddInParameter(dbCommand, "p_tech", DbType.Int32, techniciantypeid); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Courseware courseware = CreateModelObject(dataReader); coursewares.Add(courseware); } } return(coursewares); }
public async Task UpdateCousewareAsync(Courseware courseware) { try { dbContext.Coursewares.Update(courseware); await dbContext.SaveChangesAsync(); } catch (Exception e) { logger.LogError(e.Message); throw new Exception("Action Failed!"); } }
public static Courseware OpenCourseware(string name) { if (name.IsNullOrEmpty()) { Debug.LogError("Open Courseware must be have a name"); return(null); } var path = Path.Combine(ResourceDirectory, name); path = Path.Combine(path, CoursewareFileName); if (File.Exists(path)) { StreamReader sr = new StreamReader(path); var jsonText = sr.ReadToEnd(); sr.Close(); return(Courseware.CreateFromJson(jsonText)); } return(null); }
public IList <Courseware> GetStationCourseware() { IList <Courseware> objList = new List <Courseware>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_Courseware_G_Station"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Courseware obj = CoursewareDAL.CreateModelObject(dataReader); objList.Add(obj); } } return(objList); }
/// <summary> /// 添加课件 /// </summary> public void AddCourseware() { Courseware courseware = new Courseware(); if (GetString("Name") != "") { courseware.Name = GetString("Name"); courseware.Teacher = GetString("Teacher"); courseware.Description = GetString("Description"); courseware.PubDate = DateTime.Now; //保存附件用代码 HttpFileCollection uploadFiles = this.HttpContext.Request.Files; // 设置上传目标文件夹 string savaPath = this.HttpContext.Request.MapPath(@"../Content/uploadfiles/CoursewareFiles/"); // 上传文件,并返回上传的文件名(由于附件表需要文件名称,所以SaveFiles函数返回了文件名 List<string> fileNames = FileUpload.SaveFiles(uploadFiles, savaPath); Attachment attachment = new Attachment(); //暂时将Type设置为0 attachment.TypeID = 0; CQGJ.AddToAttachment(attachment); CQGJ.SaveChanges(); foreach (var f in fileNames) { AttachmentItem item = new AttachmentItem(); item.AddTime = DateTime.Now; item.Attachment = attachment; item.FileName = f.Split(',').First(); //表示激活 item.Status = 1; CQGJ.AddToAttachmentItem(item); courseware.DownloadCount = attachment.AttachmentID; CQGJ.AddToCourseware(courseware); } CQGJ.SaveChanges(); RedirectToAction("coursewarelist", "stuff"); } RenderView("AddCourseware"); }
public static void SaveCourseware(Courseware courseware) { if (courseware.Title.IsNullOrEmpty()) { return; } var path = Path.Combine(ResourceDirectory, courseware.Root); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, CoursewareFileName); StreamWriter sw = File.CreateText(path); string data = courseware.ToJson(); sw.Write(data); sw.Flush(); sw.Close(); }
public async Task <dynamic> OnUpdateCoursewareAsync([FromForm] Courseware courseware, [FromForm] List <int> fileList, [FromForm] string token) { try { var t = await tokenService.GetTokenAsync(token); if (t == null) { throw new Exception("请先登录"); } if (t.Role != UserRole.Admin) { if (t.Role == UserRole.Student) { throw new Exception("权限不足"); } var uc = await courseService.GetUserCourseAsync(t.UserID, courseware.CourseId); if (uc == null) { throw new Exception("权限不足"); } } await courseService.RemoveCoursewareFilesAsync(courseware.Id); foreach (var fileID in fileList) { await courseService.AddFileToCourseware(courseware.Id, fileID); } await courseService.UpdateCousewareAsync(courseware); return(new { Res = true }); } catch (Exception e) { return(new { Res = false, Error = e.Message }); } }
public IList <Courseware> GetCoursewareInfoByDate(int row) { IList <Courseware> coursewareList = new List <Courseware>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_COURSEWARE_S"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_row_num", DbType.Int32, row); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Courseware courseware = CreateModelObject(dataReader); coursewareList.Add(courseware); } } return(coursewareList); }
public IList <Courseware> GetCoursewaresByCoursewareTypeID(int coursewareTypeID, int orgID) { IList <Courseware> coursewares = new List <Courseware>(); Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_COURSEWARE_Q_TYPEID"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_courseware_type_id", DbType.String, coursewareTypeID); db.AddInParameter(dbCommand, "p_org_id", DbType.String, orgID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Courseware courseware = CreateModelObject(dataReader); coursewares.Add(courseware); } } return(coursewares); }
public static Courseware NewCourseware(string name) { Courseware courseware = null; if (name.IsNullOrEmpty()) { Debug.LogError("New Courseware must be have a name"); } else { if (GetAllCoursewares().Contains(name)) { Debug.Log("New Courseware named: {0} exist.".FormatEx(name)); } else { courseware = new Courseware(); courseware.Title = name; } } return(courseware); }
public static void SetCoursewareModel(Courseware CoursewareData) { if (CoursewareData == null || CoursewareData.Title.IsNullOrEmpty()) { WF.MessageBox.Show("没有打开任何课件, 因此不能选择模型"); return; } var targetPath = Path.Combine(CourseLoader.ResourceDirectory, CoursewareData.ModelPathRoot); if (WF.MessageBox.Show("重新选择模型将会清空全部信息, 是否确定?", "选择模型", WF.MessageBoxButtons.OKCancel) == WF.DialogResult.OK) { string assetbundlePath = OpenFileDialog("模型(*.ab)\0*.ab", ""); if (assetbundlePath.IsNotNullAndEmpty()) { if (!Directory.Exists(targetPath)) { Directory.CreateDirectory(targetPath); } string modelPath = Path.Combine(targetPath, Path.GetFileName(assetbundlePath)); if (File.Exists(modelPath)) { if (WF.MessageBox.Show("已存在同名文件是否覆盖?", "是否覆盖", WF.MessageBoxButtons.OKCancel) == WF.DialogResult.OK) { File.Copy(assetbundlePath, modelPath, true); CoursewareData.ResourceFilePath = Path.GetFileName(assetbundlePath); } } else { File.Copy(assetbundlePath, modelPath, true); CoursewareData.ResourceFilePath = Path.GetFileName(assetbundlePath); } } } }
/// <summary> /// There are no comments for Courseware in the schema. /// </summary> public void AddToCourseware(Courseware courseware) { base.AddObject("Courseware", courseware); }
/// <summary> /// Create a new Courseware object. /// </summary> /// <param name="coursewareID">Initial value of CoursewareID.</param> public static Courseware CreateCourseware(int coursewareID) { Courseware courseware = new Courseware(); courseware.CoursewareID = coursewareID; return courseware; }
public void UpdateCourseware(Courseware courseware) { Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_COURSEWARE_U"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, courseware.CoursewareID); db.AddInParameter(dbCommand, "p_courseware_name", DbType.String, courseware.CoursewareName); db.AddInParameter(dbCommand, "p_courseware_type_id", DbType.Int32, courseware.CoursewareTypeID); db.AddInParameter(dbCommand, "p_provide_org", DbType.Int32, courseware.ProvideOrg); db.AddInParameter(dbCommand, "p_publish_date", DbType.DateTime, courseware.PublishDate); db.AddInParameter(dbCommand, "p_authors", DbType.String, courseware.Authors); db.AddInParameter(dbCommand, "p_revisers", DbType.String, courseware.Revisers); db.AddInParameter(dbCommand, "p_keyword", DbType.String, courseware.KeyWord); db.AddInParameter(dbCommand, "p_description", DbType.String, courseware.Description); db.AddInParameter(dbCommand, "p_url", DbType.String, courseware.Url); db.AddInParameter(dbCommand, "p_memo", DbType.String, courseware.Memo); db.AddInParameter(dbCommand, "p_is_group_leader", DbType.Int32, courseware.IsGroupLearder); db.AddInParameter(dbCommand, "p_tech_id", DbType.Int32, courseware.TechnicianTypeID); db.AddInParameter(dbCommand, "p_order_index", DbType.Int32, courseware.OrderIndex); sqlCommand = "USP_COURSEWARE_RANGE_ORG_D"; DbCommand dbCommand2 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand2, "p_courseware_id", DbType.Int32, courseware.CoursewareID); sqlCommand = "USP_COURSEWARE_RANGE_POST_D"; DbCommand dbCommand3 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand3, "p_courseware_id", DbType.Int32, courseware.CoursewareID); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { db.ExecuteNonQuery(dbCommand, transaction); db.ExecuteNonQuery(dbCommand2, transaction); db.ExecuteNonQuery(dbCommand3, transaction); for (int i = 0; i < courseware.OrgIDAL.Count; i++) { sqlCommand = "USP_COURSEWARE_RANGE_ORG_I"; dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, courseware.CoursewareID); db.AddInParameter(dbCommand, "p_org_id", DbType.Int32, int.Parse(courseware.OrgIDAL[i].ToString())); db.ExecuteNonQuery(dbCommand, transaction); } for (int i = 0; i < courseware.PostIDAL.Count; i++) { sqlCommand = "USP_COURSEWARE_RANGE_POST_I"; dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, courseware.CoursewareID); db.AddInParameter(dbCommand, "p_post_id", DbType.Int32, int.Parse(courseware.PostIDAL[i].ToString())); db.ExecuteNonQuery(dbCommand, transaction); } ArrayList objList = new ArrayList(); CoursewareTrainTypeDAL dal = new CoursewareTrainTypeDAL(); IList <CoursewareTrainType> objTrainTypeList = dal.GetCoursewareTrainTypeByCoursewareID(courseware.CoursewareID); foreach (CoursewareTrainType type in objTrainTypeList) { objList.Add(type.TrainTypeID.ToString()); if (courseware.TrainTypeIDAL.IndexOf(type.TrainTypeID.ToString()) == -1) { sqlCommand = "USP_COURSEWARE_TRAIN_TYPE_D"; DbCommand dbCommand1 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand1, "p_courseware_id", DbType.Int32, courseware.CoursewareID); db.AddInParameter(dbCommand1, "p_train_type_id", DbType.String, type.TrainTypeID); db.ExecuteNonQuery(dbCommand1, transaction); } } for (int i = 0; i < courseware.TrainTypeIDAL.Count; i++) { //新增的培训类别 if (objList.IndexOf(courseware.TrainTypeIDAL[i].ToString()) == -1) { sqlCommand = "USP_COURSEWARE_TRAIN_TYPE_I"; DbCommand dbCommand6 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand6, "p_courseware_id", DbType.Int32, courseware.CoursewareID); db.AddInParameter(dbCommand6, "p_train_type_id", DbType.Int32, int.Parse(courseware.TrainTypeIDAL[i].ToString())); db.AddOutParameter(dbCommand6, "p_order_index", DbType.Int32, 4); db.ExecuteNonQuery(dbCommand6, transaction); } } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } connection.Close(); }
public int AddCourseware(Courseware courseware) { int id = 0; Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_COURSEWARE_I"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddOutParameter(dbCommand, "p_courseware_id", DbType.Int32, 4); db.AddInParameter(dbCommand, "p_courseware_name", DbType.String, courseware.CoursewareName); db.AddInParameter(dbCommand, "p_courseware_type_id", DbType.Int32, courseware.CoursewareTypeID); db.AddInParameter(dbCommand, "p_provide_org", DbType.Int32, courseware.ProvideOrg); db.AddInParameter(dbCommand, "p_publish_date", DbType.Date, courseware.PublishDate); db.AddInParameter(dbCommand, "p_authors", DbType.String, courseware.Authors); db.AddInParameter(dbCommand, "p_revisers", DbType.String, courseware.Revisers); db.AddInParameter(dbCommand, "p_keyword", DbType.String, courseware.KeyWord); db.AddInParameter(dbCommand, "p_description", DbType.String, courseware.Description); db.AddInParameter(dbCommand, "p_url", DbType.String, courseware.Url); db.AddInParameter(dbCommand, "p_memo", DbType.String, courseware.Memo); db.AddInParameter(dbCommand, "p_is_group_leader", DbType.Int32, courseware.IsGroupLearder); db.AddInParameter(dbCommand, "p_tech_id", DbType.Int32, courseware.TechnicianTypeID); db.AddOutParameter(dbCommand, "p_order_index", DbType.Int32, 4); DbConnection connection = db.CreateConnection(); connection.Open(); DbTransaction transaction = connection.BeginTransaction(); try { db.ExecuteNonQuery(dbCommand, transaction); id = Convert.ToInt32(db.GetParameterValue(dbCommand, "p_courseware_id")); //sqlCommand = "USP_COURSEWARE_TRAIN_TYPE_D"; //dbCommand = db.GetStoredProcCommand(sqlCommand); //db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, id); //db.ExecuteNonQuery(dbCommand, transaction); //sqlCommand = "USP_COURSEWARE_RANGE_ORG_D"; //dbCommand = db.GetStoredProcCommand(sqlCommand); //db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, id); //db.ExecuteNonQuery(dbCommand, transaction); //sqlCommand = "USP_COURSEWARE_RANGE_POST_D"; //dbCommand = db.GetStoredProcCommand(sqlCommand); //db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, id); //db.ExecuteNonQuery(dbCommand, transaction); for (int i = 0; i < courseware.TrainTypeIDAL.Count; i++) { sqlCommand = "USP_COURSEWARE_TRAIN_TYPE_I"; dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, id); db.AddInParameter(dbCommand, "p_train_type_id", DbType.Int32, int.Parse(courseware.TrainTypeIDAL[i].ToString())); db.AddOutParameter(dbCommand, "p_order_index", DbType.Int32, 4); db.ExecuteNonQuery(dbCommand, transaction); } for (int i = 0; i < courseware.OrgIDAL.Count; i++) { sqlCommand = "USP_COURSEWARE_RANGE_ORG_I"; dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, id); db.AddInParameter(dbCommand, "p_org_id", DbType.Int32, int.Parse(courseware.OrgIDAL[i].ToString())); db.ExecuteNonQuery(dbCommand, transaction); } for (int i = 0; i < courseware.PostIDAL.Count; i++) { sqlCommand = "USP_COURSEWARE_RANGE_POST_I"; dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, id); db.AddInParameter(dbCommand, "p_post_id", DbType.Int32, int.Parse(courseware.PostIDAL[i].ToString())); db.ExecuteNonQuery(dbCommand, transaction); } transaction.Commit(); } catch (Exception ex) { transaction.Rollback(); throw ex; } connection.Close(); return(id); }
public void UpdateCourseware(Courseware courseware) { dal.UpdateCourseware(courseware); objLogBll.WriteLog("修改课件《" + courseware.CoursewareName + "》基本信息"); }
public Courseware GetCourseware(int coursewareID) { Courseware courseware = null; Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "USP_COURSEWARE_G"; DbCommand dbCommand = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand, "p_courseware_id", DbType.Int32, coursewareID); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { if (dataReader.Read()) { courseware = CreateModelObject(dataReader); } } sqlCommand = "USP_COURSEWARE_TRAIN_TYPE_S"; DbCommand dbCommand1 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand1, "p_courseware_id", DbType.Int32, coursewareID); sqlCommand = "USP_COURSEWARE_RANGE_ORG_S"; DbCommand dbCommand2 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand2, "p_courseware_id", DbType.Int32, coursewareID); sqlCommand = "USP_COURSEWARE_RANGE_POST_S"; DbCommand dbCommand3 = db.GetStoredProcCommand(sqlCommand); db.AddInParameter(dbCommand3, "p_courseware_id", DbType.Int32, coursewareID); IDataReader dataReader1 = db.ExecuteReader(dbCommand1); IDataReader dataReader2 = db.ExecuteReader(dbCommand2); IDataReader dataReader3 = db.ExecuteReader(dbCommand3); ArrayList trainTypeIDAL = new ArrayList(); ArrayList orgIDAL = new ArrayList(); ArrayList postIDAL = new ArrayList(); string strTrainTypeNames = string.Empty; CoursewareTypeDAL coursewareTypeDAL = new CoursewareTypeDAL(); CoursewareType coursewareType = coursewareTypeDAL.GetCoursewareType(courseware.CoursewareTypeID); courseware.CoursewareTypeNames = GetCoursewareTypeNames("/" + coursewareType.CoursewareTypeName, coursewareType.ParentId); while (dataReader1.Read()) { if (dataReader1["TRAIN_TYPE_ID"].ToString() != "") { trainTypeIDAL.Add(DataConvert.ToInt(dataReader1["TRAIN_TYPE_ID"].ToString())); strTrainTypeNames += GetTrainTypeNames("/" + dataReader1["TRAIN_TYPE_NAME"].ToString(), int.Parse(dataReader1["PARENT_ID"].ToString())) + ","; } } while (dataReader2.Read()) { if (dataReader2["ORG_ID"].ToString() != "") { orgIDAL.Add(DataConvert.ToInt(dataReader2["ORG_ID"].ToString())); } } while (dataReader3.Read()) { if (dataReader3["POST_ID"].ToString() != "") { postIDAL.Add(DataConvert.ToInt(dataReader3["POST_ID"].ToString())); } } if (strTrainTypeNames.Length > 0) { strTrainTypeNames = strTrainTypeNames.Substring(0, strTrainTypeNames.Length - 1); } courseware.TrainTypeIDAL = trainTypeIDAL; courseware.OrgIDAL = orgIDAL; courseware.PostIDAL = postIDAL; courseware.TrainTypeNames = strTrainTypeNames; return(courseware); }
public CreateCoursewareDomainEvent(Courseware _Courseware) { GetCourseware = _Courseware; }