Beispiel #1
0
        public void UpdateResourceIndex(string name, int grade, int resourceType, int resourceCategory, int resourceId, List <string> words, int creator)
        {
            var resourceIndexs = ResourceIndexRepository.GetResourceIndices(resourceId, resourceCategory);

            if (resourceIndexs != null && resourceIndexs.Count > 0)
            {
                var keywords   = resourceIndexs.Select(s => s.Yrx_Keyword);
                var enumerable = keywords as string[] ?? keywords.ToArray();

                //删除数据库中存在的部分数据
                var resourceDel = enumerable.Except(words).ToList();
                var ids         = new List <int>();
                foreach (var delWord in resourceDel)
                {
                    ids = resourceIndexs.Where(x => x.Yrx_Keyword == delWord).Select(s => s.Yrx_Id).ToList();
                }
                if (ids.Count > 0)
                {
                    ResourceIndexRepository.Delete(ids.ToArray());
                }

                //添加新的部分数据
                var resourceAdd = words.Except(enumerable).ToList();
                foreach (var addWord in resourceAdd)
                {
                    Yw_ResourceIndex resourceIndex = new Yw_ResourceIndex()
                    {
                        Yrx_Keyword          = addWord,
                        Yrx_Grade            = grade,
                        Yrx_ResourceType     = resourceType,
                        Yrx_ResourceId       = resourceId,
                        Yrx_ResourceCategory = resourceCategory,
                        Yrx_CreateTime       = DateTime.Now,
                        Yrx_Creator          = creator
                    };
                    ResourceIndexRepository.Add(resourceIndex);
                }

                ResourceIndexRepository.UpdateByIds(resourceIndexs.Select(s => s.Yrx_Id).ToList(), resourceType, grade);
            }
            else
            {
                foreach (var word in words)
                {
                    Yw_ResourceIndex resourceIndex = new Yw_ResourceIndex()
                    {
                        Yrx_Keyword          = word,
                        Yrx_Grade            = grade,
                        Yrx_ResourceType     = (int)resourceType,
                        Yrx_ResourceId       = resourceId,
                        Yrx_ResourceCategory = resourceCategory,
                        Yrx_CreateTime       = DateTime.Now,
                        Yrx_Creator          = creator
                    };
                    ResourceIndexRepository.Add(resourceIndex);
                }
            }
        }
Beispiel #2
0
        public void AddResourceIndex(string name, int grade, int resourceType, int resourceId, int category, List <string> words, int creator)
        {
            List <Yw_ResourceIndex> resourceIndices = new List <Yw_ResourceIndex>();

            foreach (var word in words)
            {
                Yw_ResourceIndex resourceIndex = new Yw_ResourceIndex()
                {
                    Yrx_Keyword          = word,
                    Yrx_Grade            = grade,
                    Yrx_ResourceType     = resourceType,
                    Yrx_ResourceId       = resourceId,
                    Yrx_ResourceCategory = category,
                    Yrx_CreateTime       = DateTime.Now,
                    Yrx_Creator          = creator
                };
                ResourceIndexRepository.Add(resourceIndex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 资源组关联文本列表
        /// </summary>
        /// <param name="paging"></param>
        /// <param name="grade"></param>
        /// <param name="mediaType"></param>
        /// <param name="nameOrKey"></param>
        /// <returns></returns>
        public List <Yw_TextResource> GetTextList(PagingObject paging, int grade, int textType, string nameOrKey)
        {
            List <Yw_TextResource> textList = new List <Yw_TextResource>();

            if (!string.IsNullOrEmpty(nameOrKey))
            {
                if (nameOrKey.IsNumberic() && nameOrKey.Length >= 5)
                {
                    textList = TextResourceRepository.GetPagingTextList(paging, nameOrKey._ToInt32(), grade, textType, false, 1);
                }
                else
                {
                    var resourceIds = ResourceIndexRepository.GetResourceIndexIds(paging, grade, 0, textType, nameOrKey, ResourceTypeEnum.文本资源);
                    Dictionary <int, int> orderDic = resourceIds.ToOrderDic();
                    textList = TextResourceRepository.GetTextListByIds(resourceIds).ToList();
                    textList = textList.OrderBy(x => orderDic[x.Ytr_Id]).ToList();
                }
            }
            else
            {
                textList = TextResourceRepository.GetPagingTextList(paging, nameOrKey._ToInt32(), grade, textType, false, 1);
            }
            return(textList);
        }
Beispiel #4
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);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public List <Yw_TextResource> GetPagingTextResource(PagingObject paging, int id, string nameOrkey, int grade, int textType)
        {
            List <Yw_TextResource> textList = new List <Yw_TextResource>();

            if (id > 0)
            {
                textList = TextResourceRepository.GetPagingTextList(paging, id, grade, textType, true, 0);
            }
            else
            {
                if (!string.IsNullOrEmpty(nameOrkey))
                {
                    var textIds = ResourceIndexRepository.GetResourceIndexIds(paging, grade, 0, textType, nameOrkey, ResourceTypeEnum.文本资源);
                    Dictionary <int, int> orderDic = textIds.ToOrderDic();
                    textList = TextResourceRepository.GetTextListByIds(textIds);
                    textList = textList.OrderBy(x => orderDic[x.Ytr_Id]).ToList();
                }
                else
                {
                    textList = TextResourceRepository.GetPagingTextList(paging, id, grade, textType, false, 0);
                }
            }
            return(textList);
        }