Exemplo n.º 1
0
        public void TransferPackageFile(StitchGroupName groupName, string toNodeId, string filePath, string fileName, InstanceAdaptorDetails adaptor, string jobId, string taskId)
        {
            // TODO: More validation and error handling
            // TODO: We need to get more sophisticated about this, such as doing the transfer in chunks and allowing restarts
            if (!groupName.IsValid() || !groupName.IsVersionGroup())
            {
                throw new Exception("Must use a valid version name for a package upload file");
            }
            if (adaptor == null)
            {
                throw new Exception("Adaptor details must be provided");
            }

            var bytes    = File.ReadAllBytes(filePath);
            var envelope = new FileTransferEnvelope
            {
                Contents             = bytes,
                GroupName            = groupName.VersionString,
                JobId                = jobId,
                TaskId               = taskId,
                PacketNumber         = 1,
                TotalNumberOfPackets = 1,
                FileName             = fileName,
                Adaptor              = adaptor
            };
            var message = new ClusterMessageBuilder()
                          .ToNode(toNodeId)
                          .FromNode()
                          .WithInternalObjectPayload(envelope)
                          .Build();

            Send(message);
        }
Exemplo n.º 2
0
        public void IsValid_Test()
        {
            var target = new StitchGroupName()
            {
                VersionString = null
            };

            target.IsValid().Should().BeFalse();
        }