Ejemplo n.º 1
0
        /// <summary>
        /// 学案xml序列化(不用)
        /// </summary>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public static bool SerialiazeCourse(int Cid)
        {
            LearnSite.Model.Courses course = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses   bll    = new LearnSite.BLL.Courses();
            course = bll.GetModel(Cid);
            string xmlCoursePath = CourseCidPath(Cid);

            if (!Directory.Exists(xmlCoursePath)) //如果不存在该目录,则创建
            {
                Directory.CreateDirectory(xmlCoursePath);
            }
            string xmlCourseName = xmlCoursePath + @"\" + Cid + ".xml";

            if (File.Exists(xmlCourseName))
            {
                File.Delete(xmlCourseName);
            }
            XmlSerializer xs     = new XmlSerializer(typeof(LearnSite.Model.Courses));
            Stream        stream = new FileStream(xmlCourseName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);

            xs.Serialize(stream, course);
            stream.Close();

            if (File.Exists(xmlCourseName))
            {
                return(true);
            }
            {
                return(false);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 新建学案,返回学案编号
        /// </summary>
        /// <param name="dtCourse"></param>
        /// <returns></returns>
        private static int CreateCourse(DataTable dtCourse, int cobj, int Hid)
        {
            int newCid = 0;

            LearnSite.Model.Courses cs  = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses   bll = new LearnSite.BLL.Courses();
            cs = bll.GetTableModel(dtCourse);//获得学案的model
            int    thisCid      = cs.Cid;
            string thisCcontent = cs.Ccontent;

            cs.Cterm     = Int32.Parse(LearnSite.Common.XmlHelp.GetTerm());     //替换成当前学期
            cs.Cdate     = DateTime.Now;
            cs.Cobj      = cobj;                                                //替换成当前年级
            cs.Cks       = bll.CksMaxValue(cs.Cterm.Value, cs.Cobj.Value, Hid); //替换成当前年级的最新课节
            cs.Chid      = Hid;
            cs.Cfiletype = "txt";
            newCid       = bll.Add(cs);//获得新增学案的Cid

            string oldstr      = "Store/" + thisCid.ToString();
            string newstr      = "Store/" + newCid.ToString();
            string newCcontent = thisCcontent.Replace(oldstr, newstr); //替换链接地址

            bll.UpdateCcontent(newCid, newCcontent);                   //更新内容

            return(newCid);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 将指定Cid从xml内容读到model中
        /// </summary>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public static LearnSite.Model.Courses course(int Cid)
        {
            LearnSite.Model.Courses cs = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses bll = new LearnSite.BLL.Courses();
            string xmlFile = XmlFilename(Cid);
            DataSet ds = new DataSet();
            DataTable dt = new DataTable();

            if (xmlFile != "")
            {
                ds.ReadXml(xmlFile);//读取xml文件到ds
                dt = ds.Tables["Course"];
                cs = bll.GetTableModel(dt);
                ds.Dispose();
                return cs;
            }
            else
            {
                ds.Dispose();
                return null;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 将指定Cid从xml内容读到model中
        /// </summary>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public static LearnSite.Model.Courses course(int Cid)
        {
            LearnSite.Model.Courses cs  = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses   bll = new LearnSite.BLL.Courses();
            string    xmlFile           = XmlFilename(Cid);
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            if (xmlFile != "")
            {
                ds.ReadXml(xmlFile);//读取xml文件到ds
                dt = ds.Tables["Course"];
                cs = bll.GetTableModel(dt);
                ds.Dispose();
                return(cs);
            }
            else
            {
                ds.Dispose();
                return(null);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 新建课程,返回课程编号
 /// </summary>
 /// <param name="dtCourse"></param>
 /// <returns></returns>
 private static int CreateCourse(DataTable dtCourse)
 {
     LearnSite.Model.Courses cs = new LearnSite.Model.Courses();
     LearnSite.BLL.Courses bll = new LearnSite.BLL.Courses();
     cs = bll.GetTableModel(dtCourse);//获得课程的model
     int thisCid = cs.Cid;
     string thisCcontent = cs.Ccontent;
     int maxCid = bll.GetMaxId();
     string oldstr = "Store/"+thisCid.ToString();
     string newstr = "Store/" + maxCid.ToString();
     cs.Ccontent = thisCcontent.Replace(oldstr, newstr);//替换链接地址
     cs.Cterm =Int32.Parse( LearnSite.Common.XmlHelp.GetTerm());//替换成当前学期
     cs.Cdate = DateTime.Now;
     if (HttpContext.Current.Session["importgrade"] != null)
     {
         cs.Cobj = int.Parse(HttpContext.Current.Session["importgrade"].ToString());//替换成当前年级
         cs.Cks = bll.CksMaxValue(cs.Cterm.Value, cs.Cobj.Value);//替换成当前年级的最新课时
     }
     if (HttpContext.Current.Request.Cookies["TeacherCookies"] != null)
     {
         cs.Chid = Int32.Parse(HttpContext.Current.Request.Cookies["TeacherCookies"].Values["Hid"].ToString());
     }
     int newCid = bll.Add(cs);//获得新增课程的Cid
     return newCid;
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 课程xml序列化(不用)
        /// </summary>
        /// <param name="Cid"></param>
        /// <returns></returns>
        public static bool SerialiazeCourse(int Cid)
        {
            LearnSite.Model.Courses course = new LearnSite.Model.Courses();
            LearnSite.BLL.Courses bll = new LearnSite.BLL.Courses();
            course = bll.GetModel(Cid);
            string xmlCoursePath = CourseCidPath(Cid);
            if (!Directory.Exists(xmlCoursePath)) //如果不存在该目录,则创建
                Directory.CreateDirectory(xmlCoursePath);
            string xmlCourseName = xmlCoursePath + @"\" + Cid + ".xml";
            if (File.Exists(xmlCourseName))
                File.Delete(xmlCourseName);
            XmlSerializer xs = new XmlSerializer(typeof(LearnSite.Model.Courses));
            Stream stream = new FileStream(xmlCourseName, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
            xs.Serialize(stream, course);
            stream.Close();

            if (File.Exists(xmlCourseName))
            {
                return true;
            }
            {
                return false;
            }
        }