Ejemplo n.º 1
0
        private async Task CreateRetentionSchedule(string nodeId, uint period)
        {
            try
            {
                var node = await _alfrescoHttpClient.GetRecordCategory(nodeId, ImmutableList <Parameter> .Empty
                                                                       .Add(new Parameter(AlfrescoNames.Headers.Include, AlfrescoNames.Includes.HasRetentionSchedule, ParameterType.QueryString)));

                if (node.Entry?.HasRetentionSchedule != true)
                {
                    await _alfrescoHttpClient.ExecutionQueue(new ExecutionQueue
                    {
                        Name    = "createDispositionSchedule",
                        NodeRef = $"workspace://SpacesStore/{nodeId}"
                    });
                }

                var nodeChildren = await _alfrescoHttpClient.GetNodeChildren(nodeId, ImmutableList <Parameter> .Empty
                                                                             .Add(new Parameter(AlfrescoNames.Headers.Where, "(nodeType='rma:dispositionSchedule')", ParameterType.QueryString))
                                                                             .Add(new Parameter(AlfrescoNames.Headers.MaxItems, 1, ParameterType.QueryString)));

                var children = nodeChildren?.List?.Entries?.ToList() ?? new List <NodeChildAssociationEntry>();

                if (children.Count == 0)
                {
                    Log.Error("Retention schedule not found", $"CreateRetentionSchedule for '{nodeId}' failed");
                }

                var retentionScheduleId = children[0].Entry.Id;

                await _alfrescoHttpClient.FormProcessor(retentionScheduleId, new FormProcessor
                {
                    Prop_rma_dispositionAuthority    = "Authority",
                    Prop_rma_dispositionInstructions = "Instructions",
                    Prop_rma_recordLevelDisposition  = "true"
                });

                await _alfrescoHttpClient.DispositionActionDefinitions(retentionScheduleId, new DispositionActionDefinitions
                {
                    CombineDispositionStepConditions = "false",
                    Description = "DispositionActionDefinitions",
                    EligibleOnFirstCompleteEvent = "true",
                    GhostOnDestroy = "on",
                    Name           = "cutoff",
                    Period         = $"year|{period}",
                    PeriodProperty = "rma:dateFiled"
                });
            }
            catch (Exception ex)
            {
                Log.Error(ex, $"CreateRetentionSchedule for '{nodeId}' failed");
            }
        }
Ejemplo n.º 2
0
 public async Task <NodeChildAssociationPaging> GetChildren([FromRoute] string nodeId, [FromQuery] BasicNodeQueryParamsWithRelativePath queryParams)
 {
     return(await _alfrescoHttpClient.GetNodeChildren(nodeId, ImmutableList <Parameter> .Empty.AddQueryParams(queryParams)));
 }
Ejemplo n.º 3
0
        public async Task <TransactionHistoryPdf> ToPdfModel(DateTime currentDate)
        {
            var mainGroup = await _alfrescoHttpClient.GetGroupMembers(JobsNames.MainGroup,
                                                                      ImmutableList <Parameter> .Empty.Add(new Parameter(AlfrescoNames.Headers.Where, AlfrescoNames.MemberType.Group, ParameterType.QueryString)));

            var pdfCount = await _alfrescoHttpClient.GetNodeChildren(AlfrescoNames.Aliases.Root, ImmutableList <Parameter> .Empty
                                                                     .Add(new Parameter(AlfrescoNames.Headers.MaxItems, 1, ParameterType.QueryString))
                                                                     .Add(new Parameter(AlfrescoNames.Headers.RelativePath, JobsNames.DailyFingerPrintPath, ParameterType.QueryString))
                                                                     .Add(new Parameter(AlfrescoNames.Headers.Where, $"(nodeType='{AlfrescoNames.ContentModel.Content}')", ParameterType.QueryString)));

            var transactionHistory = await _transactionHistoryRepository.GetTransactionHistoryByDate(currentDate.Date, currentDate.Date);

            var pdfCounter = pdfCount?.List?.Pagination?.TotalItems.HasValue == true ? pdfCount.List.Pagination.TotalItems.Value : 1;

            TransactionHistoryPdf transactionHistoryObj = new TransactionHistoryPdf
            {
                Header        = string.Format(PdfTranslations.PageHeader, _transactionHistoryConfiguration?.Originator, currentDate.ToString("dd.MM.yyyy")),
                Name          = string.Format(PdfTranslations.FirstPage.Name, currentDate.ToString("dd.MM.yyyy")),
                Originator    = string.Format(PdfTranslations.FirstPage.Originator, _transactionHistoryConfiguration?.Originator),
                Address       = string.Format(PdfTranslations.FirstPage.Address, _transactionHistoryConfiguration?.Address),
                SerialNumber  = string.Format(PdfTranslations.FirstPage.SerialNumber, ++pdfCounter),
                NumberOfPages = PdfTranslations.FirstPage.NumberOfPages,
                Rows          = new TableRows
                {
                    Pid           = PdfTranslations.Cells.Pid,
                    TypeOfObject  = PdfTranslations.Cells.TypeOfObject,
                    TypeOfChanges = PdfTranslations.Cells.TypeOfChanges,
                    Descriptions  = PdfTranslations.Cells.Descriptions,
                    Author        = PdfTranslations.Cells.Author,
                    Date          = PdfTranslations.Cells.Date
                },
                Columns = new List <TableColumns>()
            };

            foreach (var item in transactionHistory)
            {
                TransactionHistoryParameters eventParams = null;

                if (item.EventParameters != null)
                {
                    eventParams = JsonConvert.DeserializeObject <TransactionHistoryParameters>(item.EventParameters);
                }

                string requestGroup = mainGroup?.List?.Entries?.FirstOrDefault(u => u.Entry.Id == item.UserGroupId)?.Entry?.DisplayName ?? item.UserGroupId;

                if (eventParams != null)
                {
                    transactionHistoryObj.Columns.Add(new TableColumns
                    {
                        Pid           = item.Pid,
                        TypeOfObject  = item.FkNodeTypeCodeNavigation.Code,
                        TypeOfChanges = item.FkEventTypeCodeNavigation.Code,
                        Descriptions  = eventParams.Message,
                        Author        = string.Join("; ", item.UserId, requestGroup),
                        Date          = item.OccuredAt.ToString("dd.MM.yyyy hh:mm:ss")
                    });
                }
                else
                {
                    transactionHistoryObj.Columns.Add(new TableColumns
                    {
                        Pid           = item.Pid,
                        TypeOfObject  = item.FkNodeTypeCodeNavigation.Code,
                        TypeOfChanges = "",
                        Descriptions  = item.FkEventTypeCodeNavigation.Code,
                        Author        = string.Join(";", item.UserId, requestGroup),
                        Date          = item.OccuredAt.ToString("dd.MM.yyyy hh:mm:ss")
                    });
                }
            }

            return(transactionHistoryObj);
        }
Ejemplo n.º 4
0
        private async Task <NodeEntry> CreateArhiveAndMoveAllFiles(NodeUpdate body, string archiveFolder, string nodeType)
        {
            var copiedNodes  = new List <NodeEntry>();
            var updatedNodes = new List <NodeEntry>();
            var connections  = new List <Tuple <string, string> >();

            var alfrescoBody = _mapper.Map <NodeBodyUpdate>(body);
            var documentInfo = await _alfrescoHttpClient.UpdateNode(body.NodeId, alfrescoBody, ImmutableList <Parameter> .Empty
                                                                    .Add(new Parameter(AlfrescoNames.Headers.Include, AlfrescoNames.Includes.Path, ParameterType.QueryString)));

            var parentFolderInfo = await _alfrescoHttpClient.GetNodeInfo(documentInfo.Entry.ParentId);

            // create folder in archive because copy folder violation
            var copyFolderInfo = await _nodesService.CreateFolder(archiveFolder);

            AlfrescoPagingRequest <NodeChildAssociationPagingFixed, List19Fixed, NodeChildAssociationEntry> request;

            // copy and remove all associations - Copies .eml/.zfo and all it's children to the archive folder
            var entries = (await _alfrescoHttpClient.GetNodeChildren(body.NodeId, ImmutableList <Parameter> .Empty
                                                                     .Add(new Parameter(AlfrescoNames.Headers.MaxItems, 1, ParameterType.QueryString))
                                                                     .Add(new Parameter(AlfrescoNames.Headers.Where, $"(nodeType='{nodeType}')", ParameterType.QueryString))))
                          ?.List?.Entries?.ToList();

            if (entries?.Count > 0)
            {
                var nodeId = entries[0]?.Entry?.Id;

                request = new AlfrescoPagingRequest <NodeChildAssociationPagingFixed, List19Fixed, NodeChildAssociationEntry>(
                    parameters => _alfrescoHttpClient.GetNodeSecondaryChildren(nodeId, parameters)
                    );

                while (await request.Next())
                {
                    var response = request.Response();
                    if (!(response?.List?.Entries?.Count > 0))
                    {
                        break;
                    }

                    foreach (var item in response.List.Entries.ToList())
                    {
                        await _alfrescoHttpClient.DeleteSecondaryChildren(nodeId, item.Entry.Id);

                        var copyInfo = await _alfrescoHttpClient.NodeCopy(item.Entry.Id, new NodeBodyCopy
                        {
                            TargetParentId = copyFolderInfo.Entry.Id
                        });

                        var properties = copyInfo.Entry.Properties.As <JObject>().ToDictionary();
                        var pid        = properties.GetNestedValueOrDefault(SpisumNames.Properties.Pid)?.ToString();
                        await _alfrescoHttpClient.UpdateNode(copyInfo.Entry.Id, new NodeBodyUpdate()
                                                             .AddProperty(SpisumNames.Properties.Pid, null)
                                                             .AddProperty(SpisumNames.Properties.PidRef, pid)
                                                             .AddProperty(SpisumNames.Properties.Ref, item.Entry.Id));

                        copiedNodes.Add(copyInfo);
                    }
                }

                // Copy .eml / .zfo
                var copyEmlZfo = await _alfrescoHttpClient.NodeCopy(nodeId, new NodeBodyCopy
                {
                    TargetParentId = copyFolderInfo.Entry.Id
                });

                var propertiesEmlZfo = copyEmlZfo.Entry.Properties.As <JObject>().ToDictionary();
                var pidEmlZfo        = propertiesEmlZfo.GetNestedValueOrDefault(SpisumNames.Properties.Pid)?.ToString();

                await _alfrescoHttpClient.UpdateNode(copyEmlZfo?.Entry?.Id, new NodeBodyUpdate()
                                                     .AddProperty(SpisumNames.Properties.Pid, null)
                                                     .AddProperty(SpisumNames.Properties.PidRef, pidEmlZfo)
                                                     .AddProperty(SpisumNames.Properties.Ref, nodeId));

                copiedNodes.Add(copyEmlZfo);
            }

            // Take all files and move them to the new location
            // find all children and rename + change node type
            request = new AlfrescoPagingRequest <NodeChildAssociationPagingFixed, List19Fixed, NodeChildAssociationEntry>(
                parameters => _alfrescoHttpClient.GetNodeSecondaryChildren(body.NodeId, parameters)
                );

            while (await request.Next())
            {
                var response = request.Response();
                if (!(response?.List?.Entries?.Count > 0))
                {
                    break;
                }

                foreach (var item in response.List.Entries.ToList())
                {
                    if (item.Entry.NodeType == SpisumNames.NodeTypes.Component)
                    {
                        continue;
                    }

                    connections.Add(new Tuple <string, string>(item.Entry.Id, copiedNodes.FirstOrDefault(x => x.Entry.Name == item.Entry.Name)?.Entry?.Id));

                    var updateBody = new NodeBodyUpdate();

                    if (item.Entry.NodeType == AlfrescoNames.ContentModel.Content)
                    {
                        updateBody.NodeType = SpisumNames.NodeTypes.Component;
                    }
                    if (item.Entry.NodeType == SpisumNames.NodeTypes.Email)
                    {
                        updateBody.NodeType = SpisumNames.NodeTypes.EmailComponent;
                    }
                    if (item.Entry.NodeType == SpisumNames.NodeTypes.DataBox)
                    {
                        updateBody.NodeType = SpisumNames.NodeTypes.DataBoxComponent;
                    }

                    var personGroup = await GetCreateUserGroup();

                    updateBody.Permissions = _nodesService.SetPermissions(personGroup.GroupPrefix, _identityUser.Id).Permissions;

                    updateBody.Properties = new Dictionary <string, object>
                    {
                        { AlfrescoNames.ContentModel.Owner, _identityUser.Id },
                        { SpisumNames.Properties.Group, _identityUser.RequestGroup }
                    };

                    updatedNodes.Add(await _alfrescoHttpClient.UpdateNode(item.Entry.Id, updateBody));

                    if (item.Entry.NodeType == AlfrescoNames.ContentModel.Content)
                    {
                    }
                }
            }

            // Set PID to archive
            List <NodeEntry> movedNodes = new List <NodeEntry>();

            movedNodes.Add(await _nodesService.MoveByPath(body.NodeId, SpisumNames.Paths.EvidenceDocumentsForProcessing(_identityUser.RequestGroup)));
            movedNodes.AddRange(await _nodesService.MoveAllComponets(body.NodeId));

            foreach (var copy in copiedNodes)
            {
                var id = connections.First(x => x.Item2 == copy.Entry.Id);

                var node = movedNodes.FirstOrDefault(x => x.Entry.Id == id.Item1);

                if (node == null)
                {
                    continue;
                }

                var properties = node.Entry.Properties.As <JObject>().ToDictionary();
                var pid        = properties.GetNestedValueOrDefault(SpisumNames.Properties.Pid)?.ToString();

                if (string.IsNullOrWhiteSpace(pid))
                {
                    continue;
                }

                await _alfrescoHttpClient.UpdateNode(copy.Entry.Id, new NodeBodyUpdate
                {
                    Properties = new Dictionary <string, object>
                    {
                        { SpisumNames.Properties.PidArchive, pid }
                    }
                });
            }

            return(await _alfrescoHttpClient.GetNodeInfo(body.NodeId));
        }