Esempio n. 1
0
 public MicroResource GetMicroCourseByKey(string key)
 {
     using (var dbres = new MODResourceEntities())
     {
         MicroResource microresource = new MicroResource();
         microresource.FileUrl           = AppSetting.FileUrl;
         microresource.microResourceList = new List <Resource>();
         List <tb_Code_Knowledge> CataAllids = CacheHelper.Get("CataIds") as List <tb_Code_Knowledge>;
         int[] konwledges = CataAllids.Select(s => s.ID).ToArray();
         IQueryable <tb_Resource> qresource = dbres.tb_Resource.Where(w => w.tb_ResourceKnowledge.Where(wrk => konwledges.Contains(wrk.KnowledgeID)).Select(s1 => s1.ResourceID).Contains(w.ID) && w.IsDelete == 0);
         if (!string.IsNullOrEmpty(key))
         {
             qresource = qresource.Where(w => w.Title.Contains(key));
         }
         microresource.microResourceList = qresource.OrderBy(o => o.UploadDate).Select(s => new Resource
         {
             ID          = s.ID.ToString(),
             FileID      = s.FileID.ToString(),
             Title       = s.Title,
             Description = s.Description,
             FileType    = s.FileType,
             KeyWords    = s.KeyWords,
             UploadDate  = s.UploadDate
         }).ToList();
         microresource.resourceCount = qresource.Count();
         return(microresource);
     }
 }
Esempio n. 2
0
 public MicroResource GetMicroCourseByKnowledgeID(string ids, string key)
 {
     using (var dbres = new MODResourceEntities())
     {
         MicroResource microresource = new MicroResource();
         microresource.FileUrl           = AppSetting.FileUrl;
         microresource.microResourceList = new List <Resource>();
         string[] cataids = ids.Split(',');
         IQueryable <tb_Resource> qresource = dbres.tb_Resource.Where(w => w.tb_ResourceKnowledge.Where(wrk => cataids.Contains(wrk.KnowledgeID.ToString())).Select(s1 => s1.ResourceID).Contains(w.ID) && w.IsDelete == 0);
         if (!string.IsNullOrEmpty(key))
         {
             qresource = qresource.Where(w => w.Title.Contains(key));
         }
         microresource.microResourceList = qresource.OrderBy(o => o.UploadDate).Select(s => new Resource
         {
             ID          = s.ID.ToString(),
             FileID      = s.FileID.ToString(),
             Title       = s.Title,
             Description = s.Description,
             FileType    = s.FileType,
             KeyWords    = s.KeyWords,
             UploadDate  = s.UploadDate
         }).ToList();
         microresource.resourceCount = microresource.microResourceList.Count;
         return(microresource);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 获取资源列表
 /// </summary>
 /// <param name="cataIDs"></param>
 /// <param name="resourceType"></param>
 /// <returns></returns>
 public List <Resource> GetResourceList(string cataIDs, int resourceType, int resourceStyle)
 {
     using (var db = new MODResourceEntities())
     {
         List <Resource>          resourceList = new List <Resource>();
         string[]                 cataArr      = cataIDs.Split(',');
         IQueryable <tb_Resource> queryres     = db.tb_Resource.Where(m => cataArr.Contains(m.Catalog.ToString()));
         if (resourceType != 0 || resourceStyle != 0)
         {
             queryres = queryres.Where(m => m.ResourceType == resourceType && m.ResourceStyle == resourceStyle);
         }
         resourceList = queryres.Select(s => new Resource
         {
             ID            = s.ID.ToString(),
             Title         = s.Title,
             Catalog       = s.Catalog,
             ResourceType  = s.ResourceType,
             ResourceStyle = s.ResourceStyle,
             KeyWords      = s.KeyWords,
             FileID        = s.FileID.ToString(),
             Description   = s.Description,
             UploadDate    = s.UploadDate,
             FileType      = s.FileType
         }).ToList();
         return(resourceList);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 获取学段
 /// </summary>
 /// <returns></returns>
 public static List <StageModel> GetStage()
 {
     using (var db = new ModMetaEntities())
     {
         using (var dbres = new MODResourceEntities())
         {
             int[]             stage     = dbres.tb_Course.Select(s => s.SchoolStage != null?(int)s.SchoolStage:2).Distinct().ToArray();
             List <StageModel> stageList = db.tb_Code_SchoolStage.Where(w => w.Deleted == 0 && stage.Contains(w.ID)).Select(s => new StageModel
             {
                 stageID   = s.ID,
                 stageName = s.CodeName,
                 IsCurrent = false
             }).ToList();
             if (string.IsNullOrEmpty(CookieHelper.GetCookieValue("StageID")))
             {
                 CookieHelper.SetCookie("StageID", "2");
             }
             int stageID = int.Parse(CookieHelper.GetCookieValue("StageID"));
             foreach (StageModel smodel in stageList)
             {
                 if (smodel.stageID == stageID)
                 {
                     smodel.IsCurrent = true;
                 }
             }
             return(stageList);
         }
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 获取教材通过版本
 /// </summary>
 /// <param name="ediID"></param>
 /// <param name="subjectId"></param>
 /// <param name="stageId"></param>
 /// <returns></returns>
 public List <CourseModel> GetBookListByEditionID(int ediID, int subjectId, int stageId)
 {
     using (var db = new ModMetaEntities())
     {
         using (var dbres = new MODResourceEntities())
         {
             List <CourseModel>     courseModelList = new List <CourseModel>();
             IQueryable <tb_Course> tempCourse      = dbres.tb_Course.Where(w => w.Subject == subjectId.ToString() && w.SchoolStage == stageId);
             courseModelList = tempCourse.Where(w => w.EditionID == ediID && w.Coursetype != "movie").OrderBy(o => o.CoursePath).Select(s => new CourseModel
             {
                 CourseName = s.CourseName,
                 EditionID  = s.EditionID,
                 GradeID    = s.Grade,
                 ID         = s.ID,
                 ImageUrl   = AppSetting.ReslibUrl + "/DigitalClass/" + s.CoursePath + "/Course.gif",
                 IsOwnApply = ((s.Coursetype != "course") ? false : true)
             }).ToList();
             foreach (CourseModel course in courseModelList)
             {
                 if (!course.IsOwnApply)
                 {
                     tb_Course       tempcourse = dbres.tb_Course.Find(course.ID);
                     int             grade      = int.Parse(tempcourse.Grade);
                     int             subject    = int.Parse(tempcourse.Subject);
                     tb_StandardBook book       = db.tb_StandardBook.Where(w => w.Edition == course.EditionID && w.Subject == subject && w.Grade == grade && w.Booklet == tempcourse.BookReel).FirstOrDefault();
                     course.ID = book.ID;
                 }
             }
             return(courseModelList);
         }
     }
 }
Esempio n. 6
0
 /// <summary>
 /// 云课堂电影课
 /// </summary>
 /// <param name="subjectID"></param>
 /// <param name="stageID"></param>
 /// <returns></returns>
 public ApplyModel GetCourseAndMovice(string subjectID, int stageID)
 {
     using (var db = new ModMetaEntities())
     {
         using (var dbres = new MODResourceEntities())
         {
             ApplyModel appModel = new ApplyModel();
             appModel.CourseAllList = new CourseAllModel();
             // string[] grades = db.tb_Code_ListTable1_Relationship.Where(w => w.End_ID == stageID).Select(s => s.Start_ID.ToString()).ToArray();
             IQueryable <tb_Course> tempCourse = dbres.tb_Course.Where(w => w.Subject == subjectID && w.SchoolStage == stageID);
             int[] edi = tempCourse.Where(w => w.Coursetype != "movie").Select(s => s.EditionID).Distinct().ToArray();
             appModel.CourseAllList.EditionList = db.tb_Code_ListTable3.Where(w => edi.Contains(w.ID)).OrderBy(o => o.Seq).Select(s => new Edition
             {
                 EditionID   = s.ID,
                 EditionName = s.CodeName
             }).ToList();
             if (appModel.CourseAllList.EditionList != null && appModel.CourseAllList.EditionList.Count > 0)
             {
                 int ediID = appModel.CourseAllList.EditionList[0].EditionID;
                 appModel.CourseAllList.CourseList = tempCourse.Where(w => w.EditionID == ediID && w.Coursetype != "movie").OrderBy(o => o.CoursePath).Select(s => new CourseModel
                 {
                     CourseName = s.CourseName,
                     EditionID  = s.EditionID,
                     GradeID    = s.Grade,
                     ID         = s.ID,
                     ImageUrl   = AppSetting.ReslibUrl + "/DigitalClass/" + s.CoursePath + "/Course.gif",
                     IsOwnApply = ((s.Coursetype != "course") ?false:true)
                 }).ToList();
                 foreach (CourseModel course in appModel.CourseAllList.CourseList)
                 {
                     if (!course.IsOwnApply)
                     {
                         tb_Course       tempcourse = dbres.tb_Course.Find(course.ID);
                         int             grade      = int.Parse(tempcourse.Grade);
                         int             subject    = int.Parse(tempcourse.Subject);
                         tb_StandardBook book       = db.tb_StandardBook.Where(w => w.Edition == course.EditionID && w.Subject == subject && w.Grade == grade && w.Booklet == tempcourse.BookReel && w.Deleted == 0).FirstOrDefault();
                         course.ID = book.ID;
                     }
                 }
             }
             appModel.MoviceList = tempCourse.Where(w => w.Coursetype == "movie").OrderBy(o => o.Grade).Select(s => new MovieModel
             {
                 MoviceName = s.CourseName,
                 ID         = s.ID,
                 Url        = AppSetting.ReslibUrl + "/MovieListen/" + s.CoursePath + "/Start.htm",
                 ImageUrl   = AppSetting.ReslibUrl + "/MovieListen/" + s.CoursePath + "/Course.gif",
                 SubjectID  = s.Subject
             }).ToList();
             CacheHelper.Remove("CataIds");
             return(appModel);
         }
     }
 }
Esempio n. 7
0
 /// <summary>
 /// 根据学段id取出已有教材从而动态获取到学段所有学科
 /// </summary>
 /// <param name="stageid">学段id</param>
 /// <returns></returns>
 public List <SubjectModel> GetSubjectByStage(int stageid)
 {
     using (var db = new ModMetaEntities())
     {
         using (var dbres = new MODResourceEntities())
         {
             string[]            subIdlist = dbres.tb_Course.Where(w => w.SchoolStage == stageid).Select(s => s.Subject).Distinct().ToArray();
             List <SubjectModel> subModel  = db.tb_Code_ListTable2.Where(w => subIdlist.Contains(w.ID.ToString())).OrderBy(o => o.Seq).Select(s => new SubjectModel
             {
                 SubjectID   = s.ID,
                 SubjectName = s.CodeName
             }).ToList();
             return(subModel);
         }
     }
 }
Esempio n. 8
0
        /// <summary>
        /// 关键字查询资源列表
        /// </summary>
        /// <param name="bookID"></param>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public List <Resource> GetResourceListByKey(string cataIDs, string keyword)
        {
            using (var db = new MODResourceEntities())
            {
                var             catalist     = cataIDs.Split(',');
                List <Resource> resourceList = new List <Resource>();
                resourceList = db.tb_Resource.Where(m => catalist.Contains(m.Catalog.ToString()) && m.Title.Contains(keyword)).Select(s => new Resource {
                    ID            = s.ID.ToString(),
                    Title         = s.Title,
                    Catalog       = s.Catalog,
                    ResourceType  = s.ResourceType,
                    ResourceStyle = s.ResourceStyle,
                    KeyWords      = s.KeyWords,
                    FileID        = s.FileID.ToString(),
                    Description   = s.Description,
                    UploadDate    = s.UploadDate,
                    FileType      = s.FileType
                }).ToList();

                return(resourceList);
            }
        }
Esempio n. 9
0
 private void UploadDataBase_Click(object sender, EventArgs e)
 {
     using (var db = new ModMetaEntities())
     {
         using (var dbres = new MODResourceEntities())
         {
             using (var dbfile = new MODkingfilesEntities())
             {
                 /////////////先增加文件信息//////////////
                 foreach (tb_Files file in filelist)
                 {
                     tb_Files tempfile = dbfile.tb_Files.Find(file.ID);
                     if (tempfile == null)
                     {
                         dbfile.tb_Files.Add(file);
                     }
                 }
                 dbfile.SaveChanges();
                 /////////////再增加资源信息//////////////
                 foreach (tb_Resource resource in resourcelist)
                 {
                     tb_Resource tempresource = dbres.tb_Resource.Find(resource.ID);
                     if (tempresource == null)
                     {
                         if (resource.Edition == 66 && resource.Grade == 3 && resource.BookReel == 2 && resource.Subject == 1)
                         {
                             ViewMod_Trunt_Branch tbmodel = db.ViewMod_Trunt_Branch.Where(w => w.tID == resource.Catalog).FirstOrDefault();
                             resource.Catalog = tbmodel.bID;
                         }
                         resource.ResourceClass = 1;
                         dbres.tb_Resource.Add(resource);
                     }
                 }
                 dbres.SaveChanges();
                 MessageBox.Show("操作成功");
             }
         }
     }
 }
Esempio n. 10
0
        /// <summary>
        /// 获取云课堂子应用
        /// </summary>
        /// <param name="subjectID"></param>
        /// <param name="ediID"></param>
        /// <param name="gradeID"></param>
        /// <param name="BookletID"></param>
        /// <returns></returns>
        public ApplyPartModel GetCourseAppList(int CourseID)
        {
            using (var db = new ModMetaEntities())
            {
                using (var dbres = new MODResourceEntities())
                {
                    ApplyPartModel applyModel = new ApplyPartModel();
                    applyModel.appList = new List <AppPartModel>();
                    tb_Course       course = dbres.tb_Course.Find(CourseID);
                    tb_StandardBook book   = db.tb_StandardBook.Where(w => w.Edition == course.EditionID && w.Subject.ToString() == course.Subject && w.Grade.ToString() == course.Grade && w.Booklet == course.BookReel && w.Deleted == 0).FirstOrDefault();
                    applyModel.ImageUrl = AppSetting.ReslibUrl + "/DigitalClass/" + course.CoursePath + "/Course.gif";
                    applyModel.BookUrl  = AppSetting.ReslibUrl + "/DigitalClass/" + course.CoursePath + "/Start.htm";
                    applyModel.appList  = dbres.tb_CourseApp.Where(w => w.CourseID == CourseID).Select(apps => new AppPartModel
                    {
                        AppName = apps.AppName,
                        AppType = apps.AppType,
                        Url     = apps.AppType == 0? (apps.Folder + "?BookID=" + book.ID): (AppSetting.ReslibUrl + "/DigitalClass/" + course.CoursePath + "/" + apps.Folder + "/Start.htm")
                    }).ToList();

                    return(applyModel);
                }
            }
        }
Esempio n. 11
0
 /// <summary>
 /// 统计资源
 /// </summary>
 public void TotalResource()
 {
     using (var db = new MODResourceEntities())
     {
         IQueryable <tb_Resource> query = db.tb_Resource.Where(w => w.IsDelete == 0);
         if (comboSubject.SelectedValue != null)
         {
             query = query.Where(w => w.Subject == (int)comboSubject.SelectedValue);
         }
         if (comboStage.SelectedValue != null)
         {
             query = query.Where(w => w.SchoolStage == (int)comboStage.SelectedValue);
         }
         if (comboGrade.SelectedValue != null && (int)comboGrade.SelectedValue != 0)
         {
             query = query.Where(w => w.Grade == (int)comboGrade.SelectedValue);
         }
         if (comboEdition.SelectedValue != null)
         {
             query = query.Where(w => w.Edition == (int)comboEdition.SelectedValue);
         }
         if (comboBrlee.SelectedValue != null && (int)comboBrlee.SelectedValue != 0)
         {
             query = query.Where(w => w.BookReel == (int)comboBrlee.SelectedValue);
         }
         resCount.Text    = query.Count().ToString();
         tempresourceList = query.Select(s => new Resource
         {
             Applicable      = s.Applicable,
             AppraisedCounts = s.AppraisedCounts,
             BookReel        = s.BookReel,
             BreviaryImgUrl  = s.BreviaryImgUrl,
             Catalog         = s.Catalog,
             CollectCounts   = s.CollectCounts,
             ComeFrom        = s.ComeFrom,
             Copyright       = s.Copyright,
             CopyrightName   = s.CopyrightName,
             Description     = s.Description,
             DownCounts      = s.DownCounts,
             Edition         = s.Edition,
             ScanCounts      = s.ScanCounts,
             FileID          = s.FileID,
             FileType        = s.FileType,
             Grade           = s.Grade,
             ID              = s.ID,
             IsDelete        = s.IsDelete,
             IsRecommend     = s.IsRecommend,
             IsVerify        = s.IsVerify,
             KeyWords        = s.KeyWords,
             MaterialID      = s.MaterialID,
             ModifyDate      = s.ModifyDate,
             Number          = s.Number,
             Purview         = s.Purview,
             ResourceClass   = s.ResourceClass,
             ResourceLevel   = s.ResourceLevel,
             ResourceSize    = s.ResourceSize,
             ResourceStyle   = s.ResourceStyle,
             ResourceType    = s.ResourceType,
             SchoolStage     = s.SchoolStage,
             Sort            = s.Sort,
             Subject         = s.Subject,
             TeachingModules = s.TeachingModules,
             TeachingStep    = s.TeachingStep,
             TeachingStyle   = s.TeachingStyle,
             TimeSpan        = s.TimeSpan,
             Title           = s.Title,
             UploadDate      = s.UploadDate,
             UploadUser      = s.UploadUser
         }).ToList();
     }
 }