Ejemplo n.º 1
0
 public List <Yw_MediaResource> GetAudioAndVideo(PagingObject paging, string nameOrKey)
 {
     if (string.IsNullOrEmpty(nameOrKey))
     {
         return(new List <Yw_MediaResource>());
     }
     return(MediaResourceRepository.GetAudioAndVideo(paging, nameOrKey));
 }
Ejemplo n.º 2
0
        public ManageResourcesControl(
            Window owner,
            MediaResourceType mediaResourceType)
        {
            _owner = owner;
            _mediaResourceRepository = new MediaResourceRepository();
            _mediaResourceType       = mediaResourceType;

            InitializeComponent();

            var mediaResources = _mediaResourceRepository.GetByResourceType(_mediaResourceType).ToList();

            _mediaResources = new ObservableCollection <MediaResource>(mediaResources);

            resourcesList.ItemsSource = _mediaResources;

            addResourceButton.Content = $"Add {mediaResourceType}";
        }
Ejemplo n.º 3
0
        public void AddMediaResource(DtoResourceRequest resource)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    int textObjectId = 0;
                    if (!string.IsNullOrEmpty(resource.AudioContent))
                    {
                        textObjectId = AddTextObject(resource.AudioContent, resource.Status, resource.Creator);
                    }

                    var mediaObjectId = AddMediaObject((int)resource.MediaObjectType, resource.Url, resource.ImgId, textObjectId, resource.Description, resource.Creator);

                    Yw_MediaResource mediaResource = new Yw_MediaResource()
                    {
                        Ymr_Name          = resource.Name,
                        Ymr_MediaType     = (int)resource.MediaType,
                        Ymr_CreateTime    = DateTime.Now,
                        Ymr_Grade         = resource.Grade,
                        Ymr_Status        = resource.Status,
                        Ymr_MediaObjectId = mediaObjectId,
                        Ymr_Keywords      = resource.Keyword,
                        Ymr_UpdateTime    = DateTime.Now,
                        Ymr_Creator       = resource.Creator,
                        Ymr_Editor        = resource.Editor
                    };
                    MediaResourceRepository.Add(mediaResource);

                    if (resource.MediaType != MediaResourceTypeEnum.小艾变 && resource.MediaType != MediaResourceTypeEnum.开场语)
                    {
                        var words = GetWords(resource.Name, resource.Keyword, resource.Grade);
                        AddResourceIndex(resource.Name, resource.Grade, (int)resource.ResourceType, mediaResource.Ymr_Id, (int)ResourceTypeEnum.多媒体资源, words, resource.Creator);
                    }

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    RollbackTran();
                    throw ex;
                }
            }
        }
Ejemplo n.º 4
0
        public List <DtoResourceGroupItem> GetResourceGroupItem(PagingObject paging, int groupid, int resouceType)
        {
            List <DtoResourceGroupItem> groupItems = new List <DtoResourceGroupItem>();
            var resourceIds = ResourceGroupItemRepository.GetResourceIdByTypeAndGroupId(groupid, resouceType).Select(s => s.Ygi_ResourceId).ToList();

            if (resouceType == (int)ResourceTypeEnum.多媒体资源)
            {
                groupItems = MediaResourceRepository.GetMediaForGroupItem(paging, resourceIds);
            }
            else if (resouceType == (int)ResourceTypeEnum.文本资源)
            {
                groupItems = TextResourceRepository.GetTextForGroupItem(paging, resourceIds);
            }
            else if (resouceType == (int)ResourceTypeEnum.题目)
            {
                SubjectBll subjectBll = new SubjectBll();
                groupItems = subjectBll.SubjectService.GetSubjectForGroupItem(paging, resourceIds);
            }
            return(groupItems);
        }
Ejemplo n.º 5
0
        public List <DtoMediaResourceToCourse> GetMediaToCourse(PagingObject paging, int courseId, int mediaType, string nameOrKey)
        {
            var mediaList = new List <DtoMediaResourceToCourse>();

            if (mediaType == (int)MediaResourceTypeEnum.小艾说 || mediaType == (int)MediaResourceTypeEnum.小艾变)
            {
                if (mediaType == (int)MediaResourceTypeEnum.小艾变)
                {
                    return(MediaResourceRepository.GetXiaoAiToCourse(paging, nameOrKey, (int)MediaResourceTypeEnum.小艾变));
                }
                if (mediaType == (int)MediaResourceTypeEnum.小艾说)
                {
                    return(MediaResourceRepository.GetXiaoAiToCourse(paging, nameOrKey, (int)MediaResourceTypeEnum.小艾说));
                }
            }
            else
            {
                //list = ResourceGroupItemRepository.GetGroupIdAndResourceType(courseId);
                if (!string.IsNullOrEmpty(nameOrKey))
                {
                    if (nameOrKey.IsNumberic() && nameOrKey.Length >= 5)
                    {
                        mediaList = MediaResourceRepository.GetMediaToCourseById(paging, mediaType, courseId, nameOrKey._ToInt32());
                    }
                    else
                    {
                        mediaList = MediaResourceRepository.GetMediaToCourse(paging, courseId, mediaType, nameOrKey);
                    }
                }
                else
                {
                    mediaList = MediaResourceRepository.GetMediaToCourseById(paging, mediaType, courseId, nameOrKey._ToInt32());
                }
            }
            return(mediaList);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 资源组关联多媒体列表
        /// </summary>
        /// <param name="paging"></param>
        /// <param name="grade"></param>
        /// <param name="mediaType"></param>
        /// <param name="nameOrKey"></param>
        /// <returns></returns>
        public List <Yw_MediaResource> GetMediaList(PagingObject paging, int grade, int mediaType, string nameOrKey)
        {
            List <Yw_MediaResource> mediaList = new List <Yw_MediaResource>();

            if (!string.IsNullOrEmpty(nameOrKey))
            {
                if (nameOrKey.IsNumberic() && nameOrKey.Length >= 5)
                {
                    mediaList = MediaResourceRepository.GetMediaListForGroup(paging, nameOrKey._ToInt32(), grade, mediaType);
                }
                else
                {
                    var resourceIds = ResourceIndexRepository.GetMediaIndexIds(paging, grade, mediaType, nameOrKey);
                    Dictionary <int, int> orderDic = resourceIds.ToOrderDic();
                    mediaList = MediaResourceRepository.GetMediaListByIds(resourceIds).ToList();
                    mediaList = mediaList.OrderBy(x => orderDic[x.Ymr_Id]).ToList();
                }
            }
            else
            {
                mediaList = MediaResourceRepository.GetMediaListForGroup(paging, nameOrKey._ToInt32(), grade, mediaType);
            }
            return(mediaList);
        }
Ejemplo n.º 7
0
        public List <Yw_MediaResource> GetPagingMediaResource(PagingObject paging, int id, string nameOrkey, int grade, int mediaType)
        {
            List <Yw_MediaResource> mediaList = new List <Yw_MediaResource>();

            if (id > 0)
            {
                mediaList = MediaResourceRepository.GetPagingMediaList(paging, id, grade, mediaType, true, 0);
            }
            else
            {
                if (!string.IsNullOrEmpty(nameOrkey))
                {
                    var mediaIds = ResourceIndexRepository.GetResourceIndexIds(paging, grade, mediaType, 0, nameOrkey, ResourceTypeEnum.多媒体资源);
                    Dictionary <int, int> orderDic = mediaIds.ToOrderDic();
                    mediaList = MediaResourceRepository.GetMediaListByIds(mediaIds);
                    mediaList = mediaList.OrderBy(x => orderDic[x.Ymr_Id]).ToList();
                }
                else
                {
                    mediaList = MediaResourceRepository.GetPagingMediaList(paging, id, grade, mediaType, false, 0);
                }
            }
            return(mediaList);
        }
Ejemplo n.º 8
0
 public DtoMediaResourceToCourse GetPrologueById(int prologueId)
 {
     return(MediaResourceRepository.GetPrologueById(prologueId));
 }
Ejemplo n.º 9
0
 public List <DtoMediaResourceToCourse> GetPrologues(string description)
 {
     return(MediaResourceRepository.GetPrologues(description));
 }
Ejemplo n.º 10
0
 public List <DtoMediaResourceAndObject> GetXiaoAiBianOrPrologue(PagingObject paging, int mediaType)
 {
     return(MediaResourceRepository.GetXiaoAiBianOrPrologue(paging, mediaType));
 }
Ejemplo n.º 11
0
 public DtoAudioResource GetAudioMedia(int id)
 {
     return(MediaResourceRepository.GetAudioMedia(id));
 }
Ejemplo n.º 12
0
        public void UpdateMediaResource(DtoResourceRequest resource)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    var words = GetWords(resource.Name, resource.Keyword, resource.Grade);
                    Yw_MediaResource mediaResource = MediaResourceRepository.GetMediaResource(resource.Id);
                    if (mediaResource != null)
                    {
                        mediaResource.Ymr_Name       = resource.Name;
                        mediaResource.Ymr_Grade      = resource.Grade;
                        mediaResource.Ymr_Status     = resource.Status;
                        mediaResource.Ymr_Keywords   = resource.Keyword;
                        mediaResource.Ymr_UpdateTime = DateTime.Now;
                        mediaResource.Ymr_Editor     = resource.Editor;
                        MediaResourceRepository.Update(mediaResource);
                    }

                    Yw_MediaObject mediaObject = MediaObjectRepository.GetMediaObject(mediaResource.Ymr_MediaObjectId);
                    if (mediaObject != null)
                    {
                        mediaObject.Yme_Url          = resource.Url;
                        mediaObject.Yme_ImageCoverId = resource.ImgId;
                        mediaObject.Yme_Description  = resource.Description;
                        mediaObject.Yme_Editor       = resource.Editor;
                        mediaObject.Yme_UpdateTime   = DateTime.Now;
                        if (!string.IsNullOrEmpty(resource.AudioContent))
                        {
                            if (mediaObject.Yme_TextObjectId > 0)
                            {
                                Yw_TextObject textObject = TextObjectRepository.GeTextObject(mediaObject.Yme_TextObjectId);
                                textObject.Yxo_Content    = resource.AudioContent;
                                textObject.Yxo_Editor     = resource.Editor;
                                textObject.Yxo_UpdateTime = DateTime.Now;
                                TextObjectRepository.Update(textObject);
                            }
                            else
                            {
                                Yw_TextObject textObject = new Yw_TextObject()
                                {
                                    Yxo_Content    = resource.AudioContent,
                                    Yxo_Status     = 1,
                                    Yxo_CreateTime = DateTime.Now,
                                    Yxo_Creator    = resource.Creator,
                                    Yxo_Editor     = resource.Editor,
                                    Yxo_UpdateTime = DateTime.Now
                                };
                                int textObjectId = TextObjectRepository.Add(textObject);
                                mediaObject.Yme_TextObjectId = textObjectId;
                            }
                        }
                        MediaObjectRepository.Update(mediaObject);
                    }


                    UpdateResourceIndex(resource.Name, resource.Grade, (int)resource.MediaType, (int)ResourceTypeEnum.多媒体资源, mediaResource.Ymr_Id, words, resource.Creator);

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    RollbackTran();
                    throw ex;
                }
            }
        }