Beispiel #1
0
        protected override void Execute(CodeActivityContext executionContext)
        {
            //Create the tracing service
            ITracingService tracingService = executionContext.GetExtension <ITracingService>();

            //Create the context
            IWorkflowContext            context        = executionContext.GetExtension <IWorkflowContext>();
            IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>();
            IOrganizationService        service        = serviceFactory.CreateOrganizationService(context.UserId);

            tracingService.Trace("Resolving Account from Context");

            Account entity = new Account();

            entity.Id = ((EntityReference)AccountReference.Get <EntityReference>(executionContext)).Id;

            tracingService.Trace("Account resolved with Id {0}", entity.Id.ToString());

            tracingService.Trace("Create a note for the account");
            Annotation newNote = new Annotation();

            newNote.Subject  = NoteSubject.Get <string>(executionContext);
            newNote.NoteText = NoteBody.Get <string>(executionContext);
            newNote.ObjectId = entity.ToEntityReference();

            Guid noteId = service.Create(newNote);

            tracingService.Trace("Note has been created");

            NoteReference.Set(executionContext, new EntityReference(Annotation.EntityLogicalName, noteId));
        }
Beispiel #2
0
 public IList <IViewerAspect> LoadByNote(NoteReference note)
 {
     return(_viewerRepository
            .FindByNote(note.Code)
            .Select(_viewerAspectMapper.Map)
            .ToList());
 }
Beispiel #3
0
 public NoteReferenceDTO GetItemById(int id)
 {
     if (id > 0)
     {
         try
         {
             NoteReference noteReference = _db.NoteReferences.GetItemById(id);
             if (noteReference != null)
             {
                 IMapper          mapper           = new MapperConfiguration(c => c.CreateMap <NoteReference, NoteReferenceDTO>()).CreateMapper();
                 NoteReferenceDTO noteReferenceDto = mapper.Map <NoteReference, NoteReferenceDTO>(noteReference);
                 noteReferenceDto.Reference = _db.Notes.GetItemById(noteReference.ReferenceId)?.Title;
                 return(noteReferenceDto);
             }
             else
             {
                 throw new NoteNotFoundException("Ссылка заметки не найдена");
             }
         }
         catch (NoteCustomException)
         {
             throw;
         }
         catch (Exception e)
         {
             throw new NoteCustomException(e.Message);
         }
     }
     else
     {
         throw new NoteArgumentException();
     }
 }
Beispiel #4
0
 public IList <ICommentAspect> LoadByNote(NoteReference note)
 {
     return(_commentRepository
            .FindByNote(note.Code)
            .Select(_commentAspectMapper.Map)
            .ToList());
 }
Beispiel #5
0
        public INote Load(string noteId)
        {
            var noteReference = new NoteReference(noteId);
            var noteAspect    = _noteAspectLoader.Load(noteReference);

            return(new NoteDomain(noteAspect)
            {
                Tags = _tagAspectLoader.LoadByNote(noteReference),
                Comments = _commentAspectLoader.LoadByNote(noteReference),
                Viewers = _viewerAspectLoader.LoadByNote(noteReference)
            });
        }
Beispiel #6
0
        public void Create(string loginToken, NoteModel model)
        {
            var login = _loginTokenGateway.Get(loginToken);

            var note = new NoteAspect
            {
                Content   = model.Content,
                Title     = model.Title,
                CreatedBy = login.OpenId,
                CreatedOn = DateTimeUtil.GetNow(),
                Reference = NoteReference.Create()
            };

            _notePersistor.Persist(new NoteDomain(note));
        }
Beispiel #7
0
 public void Create(NoteReferenceDTO noteReference)
 {
     if (noteReference != null)
     {
         try
         {
             IMapper       mapper = new MapperConfiguration(c => c.CreateMap <NoteReferenceDTO, NoteReference>()).CreateMapper();
             NoteReference noteReferenceEntity = mapper.Map <NoteReferenceDTO, NoteReference>(noteReference);
             _db.NoteReferences.Save(noteReferenceEntity);
         }
         catch (NoteCustomException)
         {
             throw;
         }
         catch (Exception e)
         {
             throw new NoteCustomException(e.Message);
         }
     }
     else
     {
         throw new NoteArgumentException();
     }
 }