public async Task <ICommandResult> Start(string group = "tea") { var context = await GetContextAsync().ConfigureAwait(false); var roomItemGroup = await _mediator.Send(new GetRoomItemGroupByNameQuery(roomId : context.Room.Id, userId : context.User.Id, name : group)).ConfigureAwait(false); if (roomItemGroup == null) { return(Response(ErrorStrings.StartRun_GroupInvalidName(group), ResponseType.User)); } if (!roomItemGroup.Options.Any()) { return(Response(ErrorStrings.StartRun_GroupNoOptions(roomItemGroup.Name), ResponseType.User)); } var command = new StartRunCommand( id: await _idGenerator.GenerateAsync().ConfigureAwait(false), userId: context.User.Id, roomId: context.Room.Id, roomGroupId: roomItemGroup.Id, startTime: _clock.UtcNow()); await _mediator.Send(command).ConfigureAwait(false); return(Response(new SlashCommandResponse { Text = ResponseStrings.RunStarted(context.Command.UserId, roomItemGroup.Name), Type = ResponseType.Channel, Attachments = AttachmentBuilder.BuildOptions(roomItemGroup.Options) })); }
// Token: 0x060019CD RID: 6605 RVA: 0x0005C2F0 File Offset: 0x0005A4F0 internal static CreateAttachmentResponse AttachReferenceAttachment(AttachmentDataProvider attachmentDataProvider, UserContext userContext, string location, string dataProviderItemId, string parentItemId, IdConverter idConverter, string dataProviderParentItemId = null, string providerEndpointUrl = null) { CreateAttachmentResponse result = null; if (!userContext.IsDisposed) { if (string.IsNullOrEmpty(providerEndpointUrl)) { providerEndpointUrl = attachmentDataProvider.GetEndpointUrlFromItemLocation(location); } string linkingUrl = attachmentDataProvider.GetLinkingUrl(userContext, location, providerEndpointUrl, dataProviderItemId, dataProviderParentItemId); string text = Path.GetFileName(HttpUtility.UrlDecode(linkingUrl)); if (OneDriveProUtilities.IsDurableUrlFormat(text)) { text = text.Substring(0, text.LastIndexOf("?", StringComparison.InvariantCulture)); } try { userContext.LockAndReconnectMailboxSession(); IdAndSession idAndSession = new IdAndSession(StoreId.EwsIdToStoreObjectId(parentItemId), userContext.MailboxSession); ReferenceAttachmentType referenceAttachmentType = new ReferenceAttachmentType { Name = text, AttachLongPathName = linkingUrl, ProviderEndpointUrl = providerEndpointUrl, ProviderType = attachmentDataProvider.Type.ToString() }; if (!userContext.IsGroupUserContext) { referenceAttachmentType.ContentId = Guid.NewGuid().ToString(); referenceAttachmentType.ContentType = "image/png"; } AttachmentHierarchy attachmentHierarchy = new AttachmentHierarchy(idAndSession, true, true); using (AttachmentBuilder attachmentBuilder = new AttachmentBuilder(attachmentHierarchy, new AttachmentType[] { referenceAttachmentType }, idConverter, true)) { ServiceError serviceError; Attachment attachment = attachmentBuilder.CreateAttachment(referenceAttachmentType, out serviceError); if (serviceError == null) { attachmentHierarchy.SaveAll(); } result = CreateAttachmentHelper.CreateAttachmentResponse(attachmentHierarchy, attachment, referenceAttachmentType, idAndSession, serviceError); } } finally { userContext.UnlockAndDisconnectMailboxSession(); } } return(result); }
// Token: 0x0600199D RID: 6557 RVA: 0x0005A534 File Offset: 0x00058734 internal static AttachmentIdType CreateAttachmentAndSendPendingGetNotification(UserContext userContext, string itemId, byte[] bytes, string name, CreateAttachmentNotificationPayload result, IdConverter idConverter, string channelId) { AttachmentIdType result2 = null; if (!userContext.IsDisposed) { AttachmentBuilder attachmentBuilder = null; try { userContext.LockAndReconnectMailboxSession(); if (result.ResultCode == AttachmentResultCode.Success) { IdAndSession idAndSession = new IdAndSession(StoreId.EwsIdToStoreObjectId(itemId), userContext.MailboxSession); FileAttachmentType fileAttachmentType = new FileAttachmentType { Content = bytes, IsInline = false, Name = name, Size = bytes.Length }; AttachmentHierarchy attachmentHierarchy = new AttachmentHierarchy(idAndSession, true, true); attachmentBuilder = new AttachmentBuilder(attachmentHierarchy, new AttachmentType[] { fileAttachmentType }, idConverter, true); ServiceError serviceError; using (Attachment attachment = attachmentBuilder.CreateAttachment(fileAttachmentType, out serviceError)) { if (serviceError == null) { attachmentHierarchy.SaveAll(); } result.Response = CreateAttachmentHelper.CreateAttachmentResponse(attachmentHierarchy, attachment, fileAttachmentType, idAndSession, serviceError); } if (result.Response.ResponseMessages.Items != null && result.Response.ResponseMessages.Items.Length > 0 && result.Response.ResponseMessages.Items[0].ResponseCode == ResponseCodeType.NoError) { ((AttachmentInfoResponseMessage)result.Response.ResponseMessages.Items[0]).Attachments[0].Size = fileAttachmentType.Size; result2 = CreateAttachmentHelper.GetAttachmentIdFromCreateAttachmentResponse(result.Response); } } CreateAttachmentHelper.SendPendingGetNotification(userContext, result, channelId); } finally { userContext.UnlockAndDisconnectMailboxSession(); if (attachmentBuilder != null) { attachmentBuilder.Dispose(); } } } return(result2); }
public static Ad Build(Action <Ad> modifier = null) { var ad = new Ad { Attachment = AttachmentBuilder.Build(), Location = AdLocationBuilder.Build() }; modifier?.Invoke(ad); return(ad); }
public void BuildOptions_SixOptions_TwoAttachments() { var options = new List <Option> { new Option { Id = 1, Name = "test1" }, new Option { Id = 2, Name = "test2" }, new Option { Id = 3, Name = "test3" }, new Option { Id = 4, Name = "test4" }, new Option { Id = 5, Name = "test5" }, new Option { Id = 6, Name = "test6" }, }; var attachments = AttachmentBuilder.BuildOptions(options).ToList(); Assert.Equal(2, attachments.Count); var attachment1 = attachments[0]; var attachment2 = attachments[1]; Assert.Equal(5, attachment1.Actions.Count); Assert.Single(attachment2.Actions); Assert.Equal(options[5].Id.ToString(), attachment2.Actions[0].Value); }