public SetPropertiesUpdate CreateFromWorkpacket(CreditOne.P360FormService.Models.Responses.Workpacket workpacket)
        {
            if (workpacket == null)
            {
                return(null);
            }

            var wrokpacketProperties = workpacket.Folder.Attributes.Properties
                                       .Select(p => _mapper.Map <Property>(p))
                                       .ToArray();
            SetPropertiesUpdate result = new SetPropertiesUpdate
            {
                Properties = wrokpacketProperties,
                Target     = PropertyUpdateTarget.FolderAttributes
            };

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Creates a new workpacket using request and existing workpacket
        /// by updating existing workpacket with request into new workpacket
        /// </summary>
        /// <param name="sessionTokenHeader">p360 login session</param>
        /// <param name="workpacket">model workpacket retrieved from p360</param>
        /// <param name="request">request with updates to apply to workpacket</param>
        /// <returns></returns>
        public async Task <Workpacket> CreateFromWorkpacketAsync(SessionTokenHeader sessionTokenHeader, string workpacketId, Workpacket workpacket, UpdateRequest request)
        {
            // Create merged request from workpacket and request
            var fileUpdates = _workpacketUpdateDomainService.CreateFromFiles(new Files(workpacket?.Folder?.FolderItems).Add(request.GetFiles()));
            var dataUpdates = _workpacketUpdateDomainService.CreateFromDataAndWorkpacket(workpacketId, request, workpacket);

            // create p360 request
            WorkpacketUpdate[] workpacketUpdates = new WorkpacketUpdate[fileUpdates.Length + 1];
            fileUpdates.CopyTo(workpacketUpdates, 0);
            workpacketUpdates[workpacketUpdates.Length - 1] = dataUpdates;

            // execute request
            var result = await Service.CreateWorkpacketAsync(
                sessionTokenHeader,
                _p360ServiceData.CurrentValue.ProcessName,
                _p360ServiceData.CurrentValue.NodeName,
                workpacketUpdates
                );

            await Service.ForwardWorkpacketAsync(sessionTokenHeader, result.CreateWorkpacketResult.Id);

            // map
            var response = _mapper.Map <Workpacket>(result.CreateWorkpacketResult);

            return(response);
        }