Exemplo n.º 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;
                }
            }
        }
Exemplo n.º 2
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;
                }
            }
        }