public MessageViewModel(OutboundMessageViewModel outboundMessage) { this._outboundMessage = outboundMessage; Message message = new Message(); message.@out = 1; if (outboundMessage.IsChat) { message.chat_id = (int)outboundMessage.UserOrChatId; } else { message.uid = (int)outboundMessage.UserOrChatId; } message.date = Extensions.DateTimeToUnixTimestamp(DateTime.UtcNow, true); message.sticker_id = outboundMessage.StickerItem == null ? 0 : outboundMessage.StickerItem.StickerId; message.body = message.sticker_id != 0 || outboundMessage.GraffitiAttachmentItem != null ? "" : outboundMessage.MessageText; message.attachments = new List <Attachment>(); if (message.sticker_id == 0) { foreach (IOutboundAttachment outboundAttachment in outboundMessage.Attachments.Where <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => !a.IsGeo))) { Attachment attachment = outboundAttachment.GetAttachment(); if (attachment != null) { message.attachments.Add(attachment); } } } if (outboundMessage.StickerItem != null) { message.attachments.Add(outboundMessage.StickerItem.CreateAttachment()); } if (outboundMessage.GraffitiAttachmentItem != null) { message.attachments.Add(outboundMessage.GraffitiAttachmentItem.CreateAttachment()); } if (message.sticker_id == 0) { OutboundGeoAttachment outboundGeoAttachment = outboundMessage.Attachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a.IsGeo)) as OutboundGeoAttachment; if (outboundGeoAttachment != null) { message.geo = new Geo() { coordinates = string.Format("{0} {1}", (object)outboundGeoAttachment.Latitude.ToString((IFormatProvider)CultureInfo.InvariantCulture), (object)outboundGeoAttachment.Longitude.ToString((IFormatProvider)CultureInfo.InvariantCulture)) } } ; OutboundForwardedMessages forwardedMessages = outboundMessage.Attachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a is OutboundForwardedMessages)) as OutboundForwardedMessages; message.fwd_messages = forwardedMessages != null ? new List <Message>((IEnumerable <Message>)forwardedMessages.Messages) : new List <Message>(); } else { message.fwd_messages = new List <Message>(); } this.InitializeWithMessage(message); }
private bool HandleInputParams(NavigationEventArgs e = null) { if (ParametersRepository.GetParameterForIdAndReset("GoPickImage") != null) { this.ShowPhotoChooser(true); return(true); } string text = ParametersRepository.GetParameterForIdAndReset("NewMessageContents") as string; if (!string.IsNullOrEmpty(text)) { this.WallPostVM.Text = text; } GeoCoordinate geoCoordinate = ParametersRepository.GetParameterForIdAndReset("NewPositionToBeAttached") as GeoCoordinate; if (geoCoordinate != null) { OutboundGeoAttachment attachment = new OutboundGeoAttachment(geoCoordinate.Latitude, geoCoordinate.Longitude); this.WallPostVM.AddAttachment(attachment); } Poll poll = ParametersRepository.GetParameterForIdAndReset("UpdatedPoll") as Poll; if (poll != null) { IEnumerable <IOutboundAttachment> arg_B2_0 = this.WallPostVM.Attachments; Func <IOutboundAttachment, bool> arg_B2_1 = new Func <IOutboundAttachment, bool>((a) => { return(a is OutboundPollAttachment); }); OutboundPollAttachment outboundPollAttachment = Enumerable.FirstOrDefault <IOutboundAttachment>(arg_B2_0, arg_B2_1) as OutboundPollAttachment; if (outboundPollAttachment != null) { outboundPollAttachment.Poll = poll; } else { OutboundPollAttachment attachment2 = new OutboundPollAttachment(poll); this.WallPostVM.AddAttachment(attachment2); } } Stream stream = ParametersRepository.GetParameterForIdAndReset("ChoosenPhoto") as Stream; List <Stream> list = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotos") as List <Stream>; List <Stream> list2 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotosPreviews") as List <Stream>; if (stream != null) { if (!this._fromPhotoPicker || this._isForwardNav) { OutboundPhotoAttachment attachment3 = OutboundPhotoAttachment.CreateForUploadNewPhoto(stream, this.WallPostVM.UserOrGroupId, this.WallPostVM.IsGroup, null, PostType.WallPost); this.WallPostVM.AddAttachment(attachment3); this.WallPostVM.UploadAttachments(); } } else if (list != null) { if (!this._fromPhotoPicker || this._isForwardNav) { for (int i = 0; i < list.Count; i++) { Stream arg_1C4_0 = list[i]; Stream previewStream = null; if (list2 != null && list2.Count > i) { previewStream = list2[i]; } OutboundPhotoAttachment attachment4 = OutboundPhotoAttachment.CreateForUploadNewPhoto(arg_1C4_0, this.WallPostVM.UserOrGroupId, this.WallPostVM.IsGroup, previewStream, PostType.WallPost); this.WallPostVM.AddAttachment(attachment4); } this.WallPostVM.UploadAttachments(); } } else if (this.WallPostVM.GoDirectlyToPhotoChooser && e != null && e.IsNavigationInitiator) { Navigator.Current.GoBack(); } Photo photo = ParametersRepository.GetParameterForIdAndReset("PickedPhoto") as Photo; if (photo != null) { OutboundPhotoAttachment attachment5 = OutboundPhotoAttachment.CreateForChoosingExistingPhoto(photo, this.WallPostVM.UserOrGroupId, this.WallPostVM.IsGroup, PostType.WallPost); this.WallPostVM.AddAttachment(attachment5); } VKClient.Common.Backend.DataObjects.Video video = ParametersRepository.GetParameterForIdAndReset("PickedVideo") as VKClient.Common.Backend.DataObjects.Video; if (video != null) { OutboundVideoAttachment attachment6 = new OutboundVideoAttachment(video); this.WallPostVM.AddAttachment(attachment6); } AudioObj audioObj = ParametersRepository.GetParameterForIdAndReset("PickedAudio") as AudioObj; if (audioObj != null) { OutboundAudioAttachment attachment7 = new OutboundAudioAttachment(audioObj); this.WallPostVM.AddAttachment(attachment7); } Doc doc = ParametersRepository.GetParameterForIdAndReset("PickedDocument") as Doc; if (doc != null) { OutboundDocumentAttachment attachment8 = new OutboundDocumentAttachment(doc); this.WallPostVM.AddAttachment(attachment8); } TimerAttachment timerAttachment = ParametersRepository.GetParameterForIdAndReset("PickedTimer") as TimerAttachment; if (timerAttachment != null) { OutboundTimerAttachment attachment9 = new OutboundTimerAttachment(timerAttachment); IEnumerable <IOutboundAttachment> arg_326_0 = this.WallPostVM.Attachments; Func <IOutboundAttachment, bool> arg_326_1 = new Func <IOutboundAttachment, bool>((a) => { return(a.AttachmentId == "timestamp"); }); IOutboundAttachment outboundAttachment = Enumerable.FirstOrDefault <IOutboundAttachment>(arg_326_0, arg_326_1); if (outboundAttachment != null) { int index = this.WallPostVM.Attachments.IndexOf(outboundAttachment); this.WallPostVM.RemoveAttachment(outboundAttachment); this.WallPostVM.InsertAttachment(index, attachment9); } else { this.WallPostVM.AddAttachment(attachment9); } this.WallPostVM.FromGroup = true; } FileOpenPickerContinuationEventArgs fileOpenPickerContinuationEventArgs = ParametersRepository.GetParameterForIdAndReset("FilePicked") as FileOpenPickerContinuationEventArgs; if ((fileOpenPickerContinuationEventArgs != null && Enumerable.Any <StorageFile>(fileOpenPickerContinuationEventArgs.Files)) || ParametersRepository.Contains("PickedPhotoDocuments")) { object parameterForIdAndReset = ParametersRepository.GetParameterForIdAndReset("FilePickedType"); IReadOnlyList <StorageFile> arg_3DA_0; if (fileOpenPickerContinuationEventArgs == null) { IReadOnlyList <StorageFile> readOnlyList = (List <StorageFile>)ParametersRepository.GetParameterForIdAndReset("PickedPhotoDocuments"); arg_3DA_0 = readOnlyList; } else { arg_3DA_0 = fileOpenPickerContinuationEventArgs.Files; } IReadOnlyList <StorageFile> readOnlyList2 = arg_3DA_0; AttachmentType attachmentType; if (parameterForIdAndReset != null && Enum.TryParse <AttachmentType>(parameterForIdAndReset.ToString(), out attachmentType)) { using (IEnumerator <StorageFile> enumerator = readOnlyList2.GetEnumerator()) { while (enumerator.MoveNext()) { StorageFile current = enumerator.Current; if (attachmentType != AttachmentType.VideoFromPhone) { if (attachmentType == AttachmentType.DocumentFromPhone || attachmentType == AttachmentType.DocumentPhoto) { OutboundUploadDocumentAttachment attachment10 = new OutboundUploadDocumentAttachment(current); this.WallPostVM.AddAttachment(attachment10); this.WallPostVM.UploadAttachments(); } } else { long groupId = this.WallPostVM.FromGroup ? this.WallPostVM.UserOrGroupId : 0L; OutboundUploadVideoAttachment attachment11 = new OutboundUploadVideoAttachment(current, true, groupId); this.WallPostVM.AddAttachment(attachment11); this.WallPostVM.UploadAttachments(); } } } } } List <StorageFile> list3 = ParametersRepository.GetParameterForIdAndReset("ChosenDocuments") as List <StorageFile>; if (list3 != null) { IEnumerable <StorageFile> arg_4D4_0 = list3; Func <StorageFile, OutboundUploadDocumentAttachment> arg_4D4_1 = new Func <StorageFile, OutboundUploadDocumentAttachment>((chosenDocument) => new OutboundUploadDocumentAttachment(chosenDocument)); using (IEnumerator <OutboundUploadDocumentAttachment> enumerator2 = Enumerable.Select <StorageFile, OutboundUploadDocumentAttachment>(arg_4D4_0, arg_4D4_1).GetEnumerator()) { while (enumerator2.MoveNext()) { OutboundUploadDocumentAttachment current2 = enumerator2.Current; this.WallPostVM.AddAttachment(current2); } } this.WallPostVM.UploadAttachments(); } List <StorageFile> list4 = ParametersRepository.GetParameterForIdAndReset("ChosenVideos") as List <StorageFile>; if (list4 != null) { IEnumerable <StorageFile> arg_550_0 = list4; Func <StorageFile, OutboundUploadVideoAttachment> arg_550_1 = new Func <StorageFile, OutboundUploadVideoAttachment>((chosenDocument) => new OutboundUploadVideoAttachment(chosenDocument, true, 0L)); using (IEnumerator <OutboundUploadVideoAttachment> enumerator3 = Enumerable.Select <StorageFile, OutboundUploadVideoAttachment>(arg_550_0, arg_550_1).GetEnumerator()) { while (enumerator3.MoveNext()) { OutboundUploadVideoAttachment current3 = enumerator3.Current; this.WallPostVM.AddAttachment(current3); } } this.WallPostVM.UploadAttachments(); } return(false); }
public static void HandleInputParams(WallPostViewModel wallPostVM) { GeoCoordinate parameterForIdAndReset1 = ParametersRepository.GetParameterForIdAndReset("NewPositionToBeAttached") as GeoCoordinate; if (parameterForIdAndReset1 != null) { OutboundGeoAttachment outboundGeoAttachment = new OutboundGeoAttachment(parameterForIdAndReset1.Latitude, parameterForIdAndReset1.Longitude); wallPostVM.AddAttachment((IOutboundAttachment)outboundGeoAttachment); } List <Stream> parameterForIdAndReset2 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotos") as List <Stream>; List <Stream> parameterForIdAndReset3 = ParametersRepository.GetParameterForIdAndReset("ChoosenPhotosPreviews") as List <Stream>; if (parameterForIdAndReset2 != null) { for (int index = 0; index < parameterForIdAndReset2.Count; ++index) { Stream stream1 = parameterForIdAndReset2[index]; Stream stream2 = parameterForIdAndReset3[index]; long userOrGroupId = wallPostVM.UserOrGroupId; int num1 = wallPostVM.IsGroup ? 1 : 0; Stream previewStream = stream2; int num2 = 0; OutboundPhotoAttachment forUploadNewPhoto = OutboundPhotoAttachment.CreateForUploadNewPhoto(stream1, userOrGroupId, num1 != 0, previewStream, (PostType)num2); wallPostVM.AddAttachment((IOutboundAttachment)forUploadNewPhoto); } wallPostVM.UploadAttachments(); } Photo parameterForIdAndReset4 = ParametersRepository.GetParameterForIdAndReset("PickedPhoto") as Photo; if (parameterForIdAndReset4 != null) { OutboundPhotoAttachment choosingExistingPhoto = OutboundPhotoAttachment.CreateForChoosingExistingPhoto(parameterForIdAndReset4, wallPostVM.UserOrGroupId, wallPostVM.IsGroup, PostType.WallPost); wallPostVM.AddAttachment((IOutboundAttachment)choosingExistingPhoto); } VKClient.Common.Backend.DataObjects.Video parameterForIdAndReset5 = ParametersRepository.GetParameterForIdAndReset("PickedVideo") as VKClient.Common.Backend.DataObjects.Video; if (parameterForIdAndReset5 != null) { OutboundVideoAttachment outboundVideoAttachment = new OutboundVideoAttachment(parameterForIdAndReset5); wallPostVM.AddAttachment((IOutboundAttachment)outboundVideoAttachment); } AudioObj parameterForIdAndReset6 = ParametersRepository.GetParameterForIdAndReset("PickedAudio") as AudioObj; if (parameterForIdAndReset6 != null) { OutboundAudioAttachment outboundAudioAttachment = new OutboundAudioAttachment(parameterForIdAndReset6); wallPostVM.AddAttachment((IOutboundAttachment)outboundAudioAttachment); } Doc parameterForIdAndReset7 = ParametersRepository.GetParameterForIdAndReset("PickedDocument") as Doc; if (parameterForIdAndReset7 != null) { OutboundDocumentAttachment documentAttachment = new OutboundDocumentAttachment(parameterForIdAndReset7); wallPostVM.AddAttachment((IOutboundAttachment)documentAttachment); } FileOpenPickerContinuationEventArgs parameterForIdAndReset8 = ParametersRepository.GetParameterForIdAndReset("FilePicked") as FileOpenPickerContinuationEventArgs; if ((parameterForIdAndReset8 == null || !Enumerable.Any <StorageFile>(parameterForIdAndReset8.Files)) && !ParametersRepository.Contains("PickedPhotoDocuments")) { return; } object parameterForIdAndReset9 = ParametersRepository.GetParameterForIdAndReset("FilePickedType"); IReadOnlyList <StorageFile> storageFileList = parameterForIdAndReset8 != null ? parameterForIdAndReset8.Files : (IReadOnlyList <StorageFile>)ParametersRepository.GetParameterForIdAndReset("PickedPhotoDocuments"); AttachmentType attachmentType; // ISSUE: explicit reference operation // ISSUE: cast to a reference type if (parameterForIdAndReset9 == null || !Enum.TryParse <AttachmentType>((parameterForIdAndReset9).ToString(), out attachmentType)) { return; } IEnumerator <StorageFile> enumerator = ((IEnumerable <StorageFile>)storageFileList).GetEnumerator(); try { while (enumerator.MoveNext()) { StorageFile current = enumerator.Current; if (attachmentType != AttachmentType.VideoFromPhone) { if (attachmentType == AttachmentType.DocumentFromPhone || attachmentType == AttachmentType.DocumentPhoto) { OutboundUploadDocumentAttachment documentAttachment = new OutboundUploadDocumentAttachment(current); wallPostVM.AddAttachment((IOutboundAttachment)documentAttachment); wallPostVM.UploadAttachments(); } } else { OutboundUploadVideoAttachment uploadVideoAttachment = new OutboundUploadVideoAttachment(current, true, 0L); wallPostVM.AddAttachment((IOutboundAttachment)uploadVideoAttachment); wallPostVM.UploadAttachments(); } } } finally { if (enumerator != null) { enumerator.Dispose(); } } }
private void DoSend() { SendMessageRequest sendMessageRequest = new SendMessageRequest(); int num1 = this._isChat ? 1 : 0; sendMessageRequest.IsChat = num1 != 0; long userOrChatId = this._userOrChatId; sendMessageRequest.UserOrCharId = userOrChatId; string messageText = this._messageText; sendMessageRequest.MessageBody = messageText; StickerItemData stickerItem = this.StickerItem; int num2 = stickerItem != null ? stickerItem.StickerId : 0; sendMessageRequest.StickerId = num2; string stickerReferrer = this.StickerReferrer; sendMessageRequest.StickerReferrer = stickerReferrer; SendMessageRequest request = sendMessageRequest; if (this.GraffitiAttachmentItem != null && this.GraffitiAttachmentItem.IsUploaded) { request.AttachmentIds = new List <string>() { this.GraffitiAttachmentItem.AttachmentId } } ; else if (this.Attachments.Count > 0) { request.AttachmentIds = new List <string>(); foreach (IOutboundAttachment outboundAttachment in this.Attachments.Where <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => !a.IsGeo))) { request.AttachmentIds.Add(outboundAttachment.AttachmentId); } } OutboundGeoAttachment outboundGeoAttachment = this.Attachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a.IsGeo)) as OutboundGeoAttachment; if (outboundGeoAttachment != null) { request.Latitude = outboundGeoAttachment.Latitude; request.Longitude = outboundGeoAttachment.Longitude; request.IsGeoAttached = true; } OutboundForwardedMessages forwardedMessages = this.Attachments.FirstOrDefault <IOutboundAttachment>((Func <IOutboundAttachment, bool>)(a => a is OutboundForwardedMessages)) as OutboundForwardedMessages; if (forwardedMessages != null) { request.ForwardedMessagesIds = new List <int>(forwardedMessages.Messages.Select <Message, int>((Func <Message, int>)(m => m.mid))); } // ISSUE: reference to a compiler-generated field if (this.UploadFinished != null) { // ISSUE: reference to a compiler-generated field this.UploadFinished((object)this, EventArgs.Empty); } MessagesService.Instance.SendMessage(request, (Action <BackendResult <VKClient.Audio.Base.ResponseWithId, ResultCode> >)(res => { if (res.ResultCode == ResultCode.Succeeded) { this._deliveredMessageId = res.ResultData.response; this._deliveryDateTime = DateTime.UtcNow; Logger.Instance.Info("OutboundMessageViewModel deliveryId = " + (object)this._deliveredMessageId); this.OutboundMessageStatus = OutboundMessageStatus.Delivered; } else { this.OutboundMessageStatus = OutboundMessageStatus.Failed; } // ISSUE: reference to a compiler-generated field if (this.MessageSent == null) { return; } // ISSUE: reference to a compiler-generated field this.MessageSent((object)this, EventArgs.Empty); })); }