示例#1
0
        public void Execute(IExecutionContext context, Command command)
        {
            var data = command.Data;

            if (!string.IsNullOrEmpty(data))
            {
                var uploadFileProperties = new Dictionary <string, string>();
                uploadFileProperties.Add(TaskAddAttachmentEventProperties.Type, CoreAttachmentType.FileAttachment);
                var fileName = Path.GetFileName(data);
                uploadFileProperties.Add(TaskAddAttachmentEventProperties.Name, fileName);

                TaskAddAttachmentCommand.AddAttachment(context, uploadFileProperties, data);
            }
            else
            {
                throw new Exception(StringUtil.Loc("CannotUploadFile"));
            }
        }
        public void Execute(IExecutionContext context, Command command)
        {
            ArgUtil.NotNull(context, nameof(context));
            ArgUtil.NotNull(command, nameof(command));

            var data = command.Data;

            if (!string.IsNullOrEmpty(data))
            {
                var uploadSummaryProperties = new Dictionary <string, string>();
                uploadSummaryProperties.Add(TaskAddAttachmentEventProperties.Type, CoreAttachmentType.Summary);
                var fileName = Path.GetFileName(data);
                uploadSummaryProperties.Add(TaskAddAttachmentEventProperties.Name, fileName);

                TaskAddAttachmentCommand.AddAttachment(context, uploadSummaryProperties, data);
            }
            else
            {
                throw new InvalidOperationException(StringUtil.Loc("CannotUploadSummary"));
            }
        }