Exemplo n.º 1
0
        public static R Courses(string imsmanifest, Courses course)
        {
            var m = new R();
            try
            {
                var rl = new List<Contents>();
                var xd = new XmlDocument();
                var nsmgr = new XmlNamespaceManager(xd.NameTable);
                nsmgr.AddNamespace("a", "http://www.imsproject.org/xsd/imscp_rootv1p1p2");
                xd.Load(imsmanifest);

                var xtilte = xd.SelectSingleNode("//a:organization//a:title[1]", nsmgr);
                course.Name = xtilte.InnerText;
                if (!string.IsNullOrEmpty(course.Name))
                {
                    course.Name = course.Name.Trim().Trim(' ');
                }


                var xnl = xd.SelectNodes("//a:organization//a:item[@identifierref]", nsmgr);
                for (int i = 0; i < xnl.Count; i++)
                {
                    var xn = xnl.Item(i);
                    var xn2 = xd.SelectSingleNode("//a:resources/a:resource[@identifier='" + xn.Attributes["identifierref"].Value + "']", nsmgr);
                    var c = new Contents();
                    c.CName = course.CName;
                    c.CCID = i + 1;
                    c.CCName = xn.Attributes["identifier"].Value;
                    c.Name = xn.FirstChild.InnerText;
                    c.Url = xn2.Attributes["href"].Value;
                    rl.Add(c);
                }
                m = CoursesSavedb(course, rl);
                log.Info("import:{0},{1},{2}", m.Code, m.Value, m.Message);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                log.Error(ex.StackTrace);
                m.Message = ex.Message;
                m.Code = 300;
            }
            return m;
        }
Exemplo n.º 2
0
        public static R Courses(Courses courses, List<Contents> contents)
        {
            var m = new R();
            try
            {

                string SQL1 = @"INSERT INTO [Courses]([CID],[CName],[Name],[Type],[Year],[Memo],[Cate],[Sort],[Teacher],[Length])
                                VALUES({0},'{1}','{2}',{3},{4},'{5}',{6},{7},'{8}',{9})";
                string SQL2 = @"INSERT INTO [Contents]([CID],[CCID],[CCName],[Name],[Duration],[Url])
                                VALUES({0},{1},'{2}','{3}',{4},'{5}')";
                var SQL = new StringBuilder();
                SQL.Append("BEGIN");
                SQL.AppendLine();
                SQL.AppendFormat("DELETE FROM [Courses] WHERE CID = {0}", courses.CID);
                SQL.AppendLine();
                SQL.AppendFormat("DELETE FROM [Contents] WHERE CID = {0}", courses.CID);
                SQL.AppendLine();
                SQL.AppendFormat(SQL1, courses.CID, courses.CName, courses.Name, courses.Type, courses.Year, courses.Memo
                    , courses.Cate
                    , courses.Sort
                    , courses.Teacher
                    , courses.Length
                    );
                foreach (var c in contents)
                {
                    SQL.AppendLine();
                    SQL.AppendFormat(SQL2, c.CID, c.CCID, c.CCName, c.Name, c.Duration, c.Url);
                }
                SQL.AppendLine();
                SQL.Append("END");
                log.Info(SQL.ToString());
                var r = SqlHelper.ExecuteNonQuery(C.conn, CommandType.Text, SQL.ToString());
                m.Code = 0;
            }
            catch (Exception ex)
            {
                m.Code = 300;
                m.Message = ex.Message;
                log.Error(ex.Message);
            }

            return m;
        }
Exemplo n.º 3
0
        public static R Cs(string excelPath)
        {
            var r = new R();

            var ds = PreviewCs(excelPath);

            var dt = ds.Tables[0];

            //int CurrentCID = BaseGet.Seed(2);

            foreach (DataRow dr in dt.Rows)
            {
                var info = new Courses();
                info.CID = Get.Seed(2);
                info.CName = Convert.ToString(dr["CName"]);
                info.Name = Convert.ToString(dr["Name"]);
                info.Type = Convert.ToInt32(dr["Type"]);
                info.Year = Convert.ToInt32(dr["Year"]);
                info.Cate = Convert.ToInt32(dr["Cate"]);
                info.Sort = Convert.ToInt32(dr["Sort"]);
                info.Teacher = Convert.ToString(dr["Teacher"]);
                info.Length = Convert.ToDecimal(dr["Length"]);
                info.ActMinutes = Convert.ToDecimal(dr["ActMinutes"]);
                info.Tag = Convert.ToString(dr["Tag"]); ;
                info.Memo = Convert.ToString(dr["Memo"]);
                DAL.M.Update.Courses(info);
            }

            return r;
        }
Exemplo n.º 4
0
        public static R Courses(Courses info)
        {
            var m = new R();
            try
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@CID",info.CID),
                    new SqlParameter("@CName",info.CName),
                    new SqlParameter("@Name",info.Name),
                    new SqlParameter("@Type",info.Type),
                    new SqlParameter("@Year",info.Year),
                    new SqlParameter("@Cate",info.Cate),
                    new SqlParameter("@Sort",info.Sort),
                    new SqlParameter("@Teacher",info.Teacher),
                    new SqlParameter("@ActMinutes",info.ActMinutes),
                    new SqlParameter("@Length",info.Length),
                    new SqlParameter("@Tag",info.Tag),
                    new SqlParameter("@Memo",info.Memo)
                };
                //param[0].Direction = ParameterDirection.InputOutput;
                string SQL = @"INSERT INTO [Courses]
                                           (  CID ,
                                              CName ,
                                              Name ,
                                              Type ,
                                              Year ,
                                              Cate ,
                                              Sort ,
                                              Teacher ,
                                              ActMinutes ,
                                              Length ,
                                              Tag ,
                                              Memo)
                                     VALUES
                                           (  @CID,
                                              @CName ,
                                              @Name ,
                                              @Type ,
                                              @Year ,
                                              @Cate ,
                                              @Sort ,
                                              @Teacher ,
                                              @ActMinutes ,
                                              @Length ,
                                              @Tag ,
                                              @Memo)";
                var r = SqlHelper.ExecuteNonQuery(SqlHelper.Local, CommandType.Text, SQL, param);
                m.Code = 0;
                // m.Value = Convert.ToInt32(param[0].Value);
            }
            catch (Exception ex)
            {
                m.Code = 300;
                m.Message = ex.Message;
                log.Fatal(ex.Message);
                log.FatalException(ex.Message, ex);
            }

            return m;
        }
Exemplo n.º 5
0
 public ActionResult ImportCs2(string sCName)
 {
     var rl = new List<R>();
     try
     {
         string FolderPath = ConfigurationManager.AppSettings.Get("ContentRoot");
         var di = new DirectoryInfo(FolderPath);
         var dii = di.GetDirectories(sCName);
         foreach (var d in dii)
         {
             var r = new R();
             string filename = Path.Combine(FolderPath, d.Name + "\\imsmanifest.xlsx");
             if (System.IO.File.Exists(filename))
             {
                 var course = new Courses();
                 course.CName = d.Name;
                 r = Import.Courses(filename, course, true);
             }
             else
             {
                 r.Code = 101;
                 r.Message = string.Format("File Not Found:{0}", filename);
             }
             rl.Add(r);
         }
     }
     catch (Exception ex)
     {
         log.Warn("{0},{1}", ex.Message, ex.StackTrace);
         var r = new R();
         r.Code = 300;
         r.Message = ex.Message;
         rl.Add(r);
     }
     return Json(rl);
 }
Exemplo n.º 6
0
        public static Courses Courses(int CID,int MID,int Year,int Type)
        {
            var m = new Courses();
            try
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@CID",CID),
                    new SqlParameter("@MID",CID),
                    new SqlParameter("@Year",CID),
                    new SqlParameter("@Type",CID)
                    
                };
                var dr = SqlHelper.ExecuteReader(C.conn, CommandType.StoredProcedure, "Get_Courses", param);
                if (dr.Read())
                {
                    m.CID = CID;
                    m.CName = Convert.ToString(dr["CName"]);
                    m.Name = Convert.ToString(dr["Name"]);
                    m.Type = Convert.ToInt32(dr["Type"]);
                    m.Year = Convert.ToInt32(dr["Year"]);
                    m.Cate = Convert.ToInt32(dr["CateX"]);
                    m.Sort = Convert.ToInt32(dr["Sort"]);
                    m.Teacher = Convert.ToString(dr["Teacher"]);
                    m.Length = Convert.ToDecimal(dr["Length"]);
                    m.Memo = Convert.ToString(dr["Memo"]);

                }
                dr.Close();
            }
            catch (Exception ex)
            {
                log.Fatal("{0},{1}", ex.Message, ex.StackTrace);
            }
            return m;
        }
Exemplo n.º 7
0
        public static List<Courses> CoursesList(int Year,int Type)
        {
            var l = new List<Courses>();
            try
            {
                SqlParameter[] param =
                {
                    new SqlParameter("@Year",Year),
                    new SqlParameter("@Type",Type)
                    
                };
                var dr = SqlHelper.ExecuteReader(C.conn, CommandType.StoredProcedure, "Get_CoursesList", param);
                while (dr.Read())
                {
                    var m = new Courses();
                    m.CID = Convert.ToInt32(dr["CID"]);
                    m.Name = Convert.ToString(dr["Name"]);
                    //m.Second = Convert.ToInt32(dr["Second"]);
                    //m.Minutes = Convert.ToInt32(dr["Minutes"]);
                    //m.Status = Convert.ToInt32(dr["Status"]);
                    if (DBNull.Value != dr["Cate"])
                        m.Cate = Convert.ToInt32(dr["Cate"]);
                    if (DBNull.Value != dr["Sort"])
                        m.Sort = Convert.ToInt32(dr["Sort"]);
                    if (DBNull.Value != dr["Teacher"])
                        m.Teacher = Convert.ToString(dr["Teacher"]);
                    if (DBNull.Value != dr["Length"])
                        m.Length = Convert.ToDecimal(dr["Length"]);
                    m.Type = Convert.ToInt32(dr["Type"]);
                    l.Add(m);
                }
                dr.Close();
            }
            catch (Exception ex)
            {

                log.Fatal(ex.Message);
                log.Fatal(ex.StackTrace);
            }
            return l;
        }
Exemplo n.º 8
0
 public static R UpdateC(Courses c)
 {
     var m = new R();
     try
     {
         string SQL = @"UPDATE [Courses]
                         SET 
                              [Type] = @Type
                             ,[Year] = @Year
                             ,[Cate] = @Cate
                             ,[Sort] = @Sort
                             ,[Teacher] = @Teacher
                             ,[ActMinutes] = @ActMinutes
                             ,[Length] = @Length
                             ,[Memo] = @Memo
                         WHERE [CID] = @CID";
         SqlParameter[] param =
         {
             new SqlParameter("@CID",c.CID),
             new SqlParameter("@Type",c.Type),
             new SqlParameter("@Year",c.Year),
             new SqlParameter("@Cate",c.Cate),
             new SqlParameter("@Sort",c.Sort),
             new SqlParameter("@ActMinutes",c.ActMinutes),
             new SqlParameter("@Teacher",c.Teacher),
             new SqlParameter("@Length",c.Length),
             new SqlParameter("@Memo",c.Memo)
         };
         var r = SqlHelper.ExecuteNonQuery(C.conn, CommandType.Text, SQL, param);
         m.Code = 0;
         m.Value = 0;
         m.Message = "sucess";
     }
     catch (Exception ex)
     {
         m.Code = 300;
         m.Message = ex.Message;
         log.Fatal(ex.Message);
         log.FatalException(ex.Message, ex);
     }
     return m;
 }
Exemplo n.º 9
0
        public static R Courses(string excelPath, Courses course, bool isMP4)
        {
            var m = new R();
            try
            {
                var rl = new List<Contents>();


                //rl.Add(c);

                string SQL = "Select * from [sheet1$]";
                var dr = excel.ExcuteReader(excelPath, SQL);
                int i = 0;
                while (dr.Read())
                {
                    i = i + 1;
                    try
                    {
                        if (dr["章节"] != DBNull.Value && dr["文件"] != DBNull.Value)
                        {
                            var c = new Contents();

                            c.CName = course.CName;
                            c.CCID = i;
                            c.CCName = "";
                            c.Name = Convert.ToString(dr["章节"]);
                            c.Url = Convert.ToString(dr["文件"]);
                            c.MIME = "video/mp4";

                            rl.Add(c);
                        }
                    }
                    catch (Exception ex1)
                    {
                        m.Code = 301;
                        m.Message = ex1.Message;
                        log.Error("{0},{1}", ex1.Message, ex1.StackTrace);
                    }

                }
                dr.Close();
                dr.Dispose();

                m = CoursesSavedb(course, rl);
                log.Info("import:{0},{1},{2}", m.Code, m.Value, m.Message);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
                log.Error(ex.StackTrace);
                m.Message = ex.Message;
                m.Code = 300;
            }
            return m;
        }