Пример #1
0
        public void UpdateTextResource(DtoResourceRequest resource)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    var             words        = GetWords(resource.Name, resource.Keyword, resource.Grade);
                    Yw_TextResource textResource = TextResourceRepository.GetTextResource(resource.Id);
                    if (textResource != null)
                    {
                        textResource.Ytr_Name       = resource.Name;
                        textResource.Ytr_TextType   = (int)resource.TextType;
                        textResource.Ytr_Grade      = resource.Grade;
                        textResource.Ytr_Status     = resource.Status;
                        textResource.Ytr_Keywords   = resource.Keyword;
                        textResource.Ytr_UpdateTime = DateTime.Now;
                        textResource.Ytr_Editor     = resource.Editor;
                        TextResourceRepository.Update(textResource);


                        UpdateTextObject(textResource.Ytr_TextObjectId, resource.Content, resource.Status, resource.Editor);

                        UpdateResourceIndex(resource.Name, resource.Grade, (int)resource.TextType, (int)ResourceTypeEnum.文本资源, textResource.Ytr_Id, words, resource.Creator);
                    }

                    scope.Complete();
                }
                catch (Exception ex)
                {
                    RollbackTran();
                    throw ex;
                }
            }
        }
Пример #2
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);
        }
Пример #3
0
        public List <DtoMediaResourceToCourse> GetTextToCourse(PagingObject paging, int courseId, int textType, string nameOrKey)
        {
            List <DtoMediaResourceToCourse> textList = new List <DtoMediaResourceToCourse>();

            if (!string.IsNullOrEmpty(nameOrKey))
            {
                if (nameOrKey.IsNumberic() && nameOrKey.Length >= 5)
                {
                    textList = TextResourceRepository.GetTextToCourseById(paging, textType, courseId, nameOrKey._ToInt32());
                }
                else
                {
                    textList = TextResourceRepository.GetTextToCourse(paging, courseId, textType, nameOrKey);
                }
            }
            else
            {
                textList = TextResourceRepository.GetTextToCourseById(paging, textType, courseId, 0);
            }
            return(textList);
        }
Пример #4
0
        public void AddTextResource(DtoResourceRequest resource)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                try
                {
                    var words = GetWords(resource.Name, resource.Keyword, resource.Grade);

                    var textObjectId = AddTextObject(resource.Content, resource.Status, resource.Creator);
                    if (textObjectId > 0)
                    {
                        Yw_TextResource textResource = new Yw_TextResource()
                        {
                            Ytr_Name         = resource.Name,
                            Ytr_TextType     = (int)resource.TextType,
                            Ytr_CreateTime   = DateTime.Now,
                            Ytr_Grade        = resource.Grade,
                            Ytr_Status       = resource.Status,
                            Ytr_TextObjectId = textObjectId,
                            Ytr_Keywords     = resource.Keyword,
                            Ytr_UpdateTime   = DateTime.Now,
                            Ytr_Creator      = resource.Creator,
                            Ytr_Editor       = resource.Editor
                        };
                        TextResourceRepository.Add(textResource);

                        AddResourceIndex(resource.Name, resource.Grade, (int)resource.TextType, textResource.Ytr_Id, (int)ResourceTypeEnum.文本资源, words, resource.Creator);
                    }
                    scope.Complete();
                }
                catch (Exception ex)
                {
                    RollbackTran();
                    throw ex;
                }
            }
        }
Пример #5
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);
        }
Пример #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);
        }
Пример #7
0
 public DtoTextResource GetDtoTextResource(int id)
 {
     return(TextResourceRepository.GetDtoTextResource(id));
 }