예제 #1
0
        public async Task <OperationSetup[]> Execute(Operation op)
        {
            string name  = op.OperationContext[OperationMeta.Linker.RequestedName];
            var    match = _matcher.GetMatch(name);

            if (match.Success)
            {
                name = _matcher.EditJobName(match.Value);
                await _unitOfWork.FileRepository.AddFile(new FileEntity
                {
                    Age  = DateTime.Now,
                    Name = name,
                    Path = op.OperationContext[OperationMeta.Linker.FilePath],
                    User = op.OperationContext[OperationMeta.Linker.UserName]
                });

                await _filesHub.SendLinkingCompled(op.OperationId, true, string.Empty);

                await _unitOfWork.SaveChanges();

                return(Array.Empty <OperationSetup>());
            }

            await _filesHub.SendLinkingCompled(op.OperationId, false, BLRes.LinkingFileOperation_Incompatible_JobName);

            return(Array.Empty <OperationSetup>());
        }
예제 #2
0
        public async Task <OperationSetup[]> Execute(Operation op)
        {
            List <OperationSetup> newOperations = new List <OperationSetup>();
            string user = op.OperationContext[OperationMeta.MultiFile.UserName];

            foreach (var file in op.OperationContext)
            {
                if (file.Key == "UserName")
                {
                    continue;
                }

                var result = _jobNameMatcher.GetMatch(file.Key);
                if (result.Success)
                {
                    string name = result.Value;
                    name = _jobNameMatcher.EditJobName(name);

                    await _unitOfWork.FileRepository.AddFile(new FileEntity
                    {
                        Age  = DateTime.Now,
                        Name = name,
                        Path = file.Value,
                        User = user
                    });
                }
                else
                {
                    newOperations.Add(new OperationSetup(
                                          OperationNames.LinkingFileOperation,
                                          OperationNames.FileOperationType,
                                          new Dictionary <string, string>
                    {
                        { OperationMeta.Linker.FilePath, file.Value },
                        { OperationMeta.Linker.FileName, file.Key },
                        { OperationMeta.Linker.UserName, user },
                        { OperationMeta.Linker.StartId, op.OperationId }
                    },
                                          DateTime.Now + TimeSpan.FromDays(3)));
                }
            }

            await _unitOfWork.SaveChanges();

            return(await newOperations.ToAsyncEnumerable().ToArray());
        }