示例#1
0
        public JsonResult DeleteWare(int id)
        {
            ResCourseWare ware = _courseManager.GetCourseWareById(id);

            if (ware == null || ware.TenantId != CurrentTenant.TenantId)
            {
                return(Json(new { result = 0, msg = RetechWing.LanguageResources.CourseLanguage.DontFindDeleteCourseware }, JsonRequestBehavior.AllowGet));
            }
            ware.IsDelete = 1;
            _courseManager.UpdateCourseWare(ware);
            return(Json(new { result = 1, msg = LanguageResources.Common.DeleteSuccess }, JsonRequestBehavior.AllowGet));
        }
示例#2
0
        public JsonResult SaveCourseware1(int wareId, string wareName, string wareTags, string desc)
        {
            ResCourseWare ware = _courseManager.GetCourseWareById(wareId);

            if (ware == null || ware.TenantId != CurrentTenant.TenantId)
            {
                return(Json(new { result = 0, msg = RetechWing.LanguageResources.CourseLanguage.DontFindUpdateCoruseWare }, JsonRequestBehavior.DenyGet));
            }
            ware.WareName = wareName;
            ware.Tags     = wareTags;
            ware.WareDesc = desc;
            _courseManager.UpdateCourseWare(ware);
            return(Json(new { result = 1, msg = LanguageResources.Common.SaveSuccess }, JsonRequestBehavior.DenyGet));
        }
示例#3
0
 public ContentResult SaveCourseWare(
     HttpPostedFileBase frontImg,
     string packId,
     string resultPath,
     int wareType,
     string wareName,
     string courseWareTags,
     string desc,
     string filename,
     int filesize)
 {
     try
     {
         var model = new ResCourseWare();
         model.FileName       = filename;
         model.TenantId       = CurrentTenant.TenantId;
         model.IsDelete       = 0;
         model.LastUpdateTime = DateTime.Now;
         model.LookCount      = 0;
         model.LoveCount      = 0;
         model.PackId         = packId;
         model.Path           = resultPath;
         model.PicUrl         = SaveFile(frontImg, "~/UploadFiles/Wares/");
         model.Score          = 0;
         model.Tags           = courseWareTags;
         model.Type           = wareType;
         model.UserId         = CurrentUser.UserId;
         model.WareDesc       = desc;
         model.FileSize       = filesize;
         model.WareName       = wareName;
         _courseManager.AddCourseWare(model);
         return(Content("1"));
     }
     catch (Exception ex)
     {
         return(Content(ex.Message));
     }
 }
示例#4
0
        /// <summary>
        /// 获取内部课件但课件存在外地的那些课件
        /// 【用于移动端播放】
        /// </summary>
        /// <param name="wareIds"></param>
        /// <returns></returns>
        public List <ResCourseWare> GetInternalWareExternal(IEnumerable <int> wareIds)
        {
            try
            {
                if (!wareIds.Any())
                {
                    return(new List <ResCourseWare>());
                }

                var param = new Dictionary <string, string>();
                param["Ids"] = wareIds.GetString();
                var response = ExternalWareHelper.CreatePostHttpResponse(ExternalWareHelper.tenantwareServerBaseUrl + "FS/FileListGet", param, null);
                var wares    = new List <ResCourseWare>();
                if (response == null)
                {
                    return(wares);
                }
                var str = ExternalWareHelper.GetResponseString(response);

                var data = Newtonsoft.Json.JsonConvert.DeserializeObject <ResultData>(str);
                if (data.RecordCount == 0 || data.DataList.Count == 0)
                {
                    return(wares);
                }

                foreach (var item in data.DataList)
                {
                    if (item["IsConvert"] != "1")
                    {
                        continue;
                    }

                    var ware = new ResCourseWare();

                    int type = int.Parse(item["FileType"]);
                    ware.WareId = int.Parse(item["Id"]);
                    var hasUrl = false;
                    if (item.ContainsKey("Url"))
                    {
                        var str1 = Newtonsoft.Json.JsonConvert.SerializeObject(item["Url"] as object);
                        var urls = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(str1);
                        if (urls.Any())
                        {
                            hasUrl = true;
                        }
                    }
                    if (hasUrl)
                    {
                        var random = new Random();
                        var str1   = Newtonsoft.Json.JsonConvert.SerializeObject(item["Url"] as object);
                        var urls   = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(str1);
                        //var urls = item["Url"] as List<Dictionary<string, string>>;

                        var curls = urls.FindAll(p => !string.IsNullOrEmpty(p["ConvertFileUrl"]));
                        if (curls.Count > 0)
                        {
                            ware.Path = curls[random.Next(0, curls.Count - 1)]["ConvertFileUrl"];
                            if (type == 0)
                            {
                                ware.Path = ware.Path.Substring(0, ware.Path.IndexOf("data"));
                            }
                            if (type == 1)
                            {
                                //ware.Path = ExternalWareHelper.tenantwareServerBaseUrl + item["FilePath"].Replace("\\", "/");
                                ware.Path = urls[0]["FileUrl"];
                            }
                        }
                        var packids = urls.FindAll(p => !string.IsNullOrEmpty(p["PackId"]) && p["PackId"] != "0");
                        if (packids.Count > 0)
                        {
                            ware.PackId = packids[random.Next(0, packids.Count - 1)]["PackId"];
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(ware.Path))
                        {
                            ware.Path = ExternalWareHelper.tenantwareServerBaseUrl + item["ConvertFilePath"].Replace("\\", "/");
                            if (type == 0)
                            {
                                ware.Path = ware.Path.Substring(0, ware.Path.IndexOf("data"));
                            }
                        }
                        if (string.IsNullOrEmpty(ware.PackId) && type == 0)
                        {
                            string PakcId = "0";
                            if (!string.IsNullOrEmpty(item["OtherInformation"]))
                            {
                                var OtherInformation = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(item["OtherInformation"]);
                                PakcId = OtherInformation.packID;
                            }
                            ware.PackId = PakcId;
                        }
                    }

                    wares.Add(ware);
                }

                return(wares);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#5
0
        /// <summary>
        /// Parses the ware.
        /// </summary>
        /// <returns>The ware.</returns>
        /// <param name="item">Item.</param>
        private ResCourseWare parseWare(Dictionary <string, dynamic> item)
        {
            var ware = new ResCourseWare();
            int type = int.Parse(item["FileType"]);

            ware.WareType = 1;
            ware.WareId   = int.Parse(item["Id"]);
            ware.Type     = type;
            ware.WareName = item["Filename"];
            if (item.ContainsKey("Url"))
            {
                var random = new Random();
                var str    = Newtonsoft.Json.JsonConvert.SerializeObject(item["Url"] as object);
                var urls   = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(str);
                //var urls = item["Url"] as List<Dictionary<string, string>>;

                var curls = urls.FindAll(p => !string.IsNullOrEmpty(p["ConvertFileUrl"]));
                if (curls.Count > 0)
                {
                    ware.Path = curls[random.Next(0, curls.Count - 1)]["ConvertFileUrl"];
                    if (type == 0)
                    {
                        ware.Path = ware.Path.Substring(0, ware.Path.IndexOf("data"));
                    }
                }
                var furls = urls.FindAll(p => !string.IsNullOrEmpty(p["FileUrl"]));
                if (furls.Count > 0)
                {
                    ware.FileName = furls[random.Next(0, furls.Count - 1)]["FileUrl"];
                }

                var purls = urls.FindAll(p => !string.IsNullOrEmpty(p["PicUrl"]));
                if (purls.Count > 0)
                {
                    ware.PicUrl = purls[random.Next(0, purls.Count - 1)]["PicUrl"];
                }

                var packids = urls.FindAll(p => !string.IsNullOrEmpty(p["PackId"]) && p["PackId"] != "0");
                if (packids.Count > 0)
                {
                    ware.PackId = packids[random.Next(0, packids.Count - 1)]["PackId"];
                }
            }
            if (string.IsNullOrEmpty(ware.FileName))
            {
                ware.FileName = ExternalWareHelper.wareServerBaseUrl + item["FilePath"].Replace("\\", "/");
                ware.Path     = ware.FileName;
                if (type == 0)
                {
                    ware.Path = ware.Path.Substring(0, ware.Path.IndexOf("data"));
                }
                if (type == 1)
                {
                    ware.Path = ExternalWareHelper.tenantwareServerBaseUrl + item["FilePath"].Replace("\\", "/");
                }
            }
            if (string.IsNullOrEmpty(ware.Path))
            {
                ware.Path = ExternalWareHelper.wareServerBaseUrl + item["ConvertFilePath"].Replace("\\", "/");
            }
            if (string.IsNullOrEmpty(ware.PackId))
            {
                string PakcId = "0";
                if (!string.IsNullOrEmpty(item["OtherInformation"]))
                {
                    var OtherInformation = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(item["OtherInformation"]);
                    PakcId = OtherInformation.packID;
                }
                ware.PackId = PakcId;
            }
            if (string.IsNullOrEmpty(ware.PicUrl))
            {
                ware.PicUrl = ExternalWareHelper.wareServerBaseUrl + item["PicPath"].Replace("\\", "/");
            }
            ware.WareDesc = item["Introduction"];
            ware.Tags     = item["KeyPoint"];
            ware.Duration = item["LearnDuration"];

            //ware.FileSize = Convert.ToInt32(item["FileSize"]);

            return(ware);
        }
示例#6
0
 /// <summary>
 /// 更新课件信息
 /// </summary>
 /// <param name="ware"></param>
 /// <returns></returns>
 public bool UpdateCourseWare(ResCourseWare ware)
 {
     return(_dataAccess.UpdateEntity(ware) > 0);
 }
示例#7
0
 /// <summary>
 /// 添加一个课件
 /// </summary>
 /// <param name="ware"></param>
 /// <returns></returns>
 public int AddCourseWare(ResCourseWare ware)
 {
     return(_dataAccess.AddEntity(ware));
 }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="wareId"></param>
        /// <returns></returns>
        public ActionResult EditCourseware(int wareId)
        {
            ResCourseWare ware = _courseManager.GetCourseWareById(wareId);

            return(View(ware));
        }
示例#9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult CourseWarePreview(int id)
        {
            ResCourseWare ware = _courseManager.GetCourseWareById(id, false);

            return(View(ware));
        }