public StatusUpdateEventArgs(UserStatus status, string statusText, long channelId, StatusUpdateAction action)
 {
     Status = status;
     StatusText = statusText;
     ChannelId = channelId;
     Action = action;
 }
        public UserStatus ParseStatusUpdate(ChannelStatusUpdate statusupdate, int statusType)
        {
            var status = new UserStatus
            {
                From = statusupdate.From,
                To = statusupdate.To,
                Status = statusupdate.Status,
                StatusType = statusType,
                SortDate = statusupdate.DatePosted,
                SourceChannelId = IsInSearchMode ? 0 : config.ChannelId,
                ChannelStatusKey = statusupdate.ChannelStatusKey,
                SearchKeyword = searchKeyword,
                IsRead = IsRead,
                IsNew = true,
                DateCreated = DateTime.Now,
            };

            foreach (var statusattachment in statusupdate.Attachments)
            {
                var attachment = new UserStatusAttachment
                    {
                        StatusKey = status.StatusKey,
                        PreviewAltText = statusattachment.PreviewAltText,
                        PreviewImageUrl = statusattachment.PreviewImageUrl,
                        TargetUrl = statusattachment.TargetUrl,
                        MediaType = statusattachment.MediaType,
                        DateCreated = DateTime.Now
                    };

                status.Attachments.Add(attachment);
            }

            return status;
        }
Example #3
0
        internal static void Send(IEnumerable<ChannelInstance> channels, string inreplyTo, ExecutedRoutedEventArgs e)
        {
            var mailbox = VirtualMailBox.Current;
            var tb = (TextBox)e.Parameter;
            var channelsArray = channels
                .Where(s => s != null)
                .Select(s => s.Configuration.ChannelId.ToString());

            var status = new UserStatus
            {
                Status = tb.Text.Trim(),
                StatusType = StatusTypes.MyUpdate,
                SortDate = DateTime.Now,
                InReplyTo = inreplyTo,
                DateCreated = DateTime.Now,
                TargetChannelId = String.Join(";", channelsArray.ToArray())
            };

            mailbox.StatusUpdates.Add(status);

            ClientState.Current.DataService.Save(status);

            // Save command
            CommandQueue.Enqueue(AppCommands.SendStatusUpdate, status);

            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                ClientState.Current.ShowMessage(
                    new AppMessage(Strings.StatusWillBeUpdatedLater)
                    {
                        EntityId = status.StatusId,
                        EntityType = EntityType.UserStatus
                    }, MessageType.Success);
            }

            tb.Text = String.Empty;
        }
        void ProcessChild(UserStatus status, ChannelStatusUpdate child, int statusType)
        {
            var childStatus = ParseStatusUpdate(child, statusType);

            childStatus.ParentKey = status.StatusKey;
            childStatus.Attachments.ForEach(ClientState.Current.DataService.Save);

            ClientState.Current.DataService.Save(childStatus);

            status.Add(childStatus);

            EventBroker.Publish(AppEvents.StatusUpdateReceived, status);
        }
        void ProcessChild(UserStatus status, ChannelStatusUpdate child, int statusType)
        {
            var childStatus = ParseStatusUpdate(child, statusType);

            childStatus.ParentKey = status.StatusKey;
            childStatus.Attachments.ForEach(ClientState.Current.DataService.Save);

            ClientState.Current.DataService.Save(childStatus);

            ClientState.Current.Search.Store(status);
        }
 public SendStatusUpdateCommand(UserStatus status)
 {
     this.status = status;
 }
 public void SetReplyTo(UserStatus replyTo)
 {
     StatusUpdateControl.ReplyTo = replyTo;
 }
Example #8
0
        void LoadStatusUpdates()
        {
            using (new CodeTimer("VirtualMailBox/Load/StatusUpdates"))
            {
                const string query1 = "select StatusId, StatusKey, ParentKey, ProfileId, SourceChannelId, TargetChannelId, ChannelStatusKey, [From], [To], [Status], InReplyTo, StatusType, SearchKeyword, IsRead, SortDate, DateRead, DateCreated from UserStatus";
                const string query2 = "select AttachmentId, UserId, StatusKey, PreviewImageUrl, PreviewAltText, TargetUrl, MediaType, DateCreated from UserStatusAttachments";

                var temp = new List<UserStatus>();

                using (var reader = ClientState.Current.DataService.ExecuteReader(query1))
                {
                    while (reader.Read())
                    {
                        var statusUpdate = new UserStatus(reader);

                        temp.Add(statusUpdate);
                        keyedStatusUpdates.Add(statusUpdate.StatusKey, statusUpdate);
                    }
                }

                using (var reader = ClientState.Current.DataService.ExecuteReader(query2))
                    while (reader.Read())
                        statusUpdateAttachments.Add(new UserStatusAttachment(reader));

                var dbStatusUpdateAttachments = ClientState.Current.DataService.SelectAll<UserStatusAttachment>().ToList();

                #region Add child statusses to parents

                foreach (var status in temp)
                {
                    if (!String.IsNullOrEmpty(status.ParentKey))
                    {
                        if (keyedStatusUpdates.ContainsKey(status.ParentKey))
                            keyedStatusUpdates[status.ParentKey].Add(status);
                    }
                }

                #endregion

                #region Add status update attachments

                foreach (var statusUpdateAttachment in dbStatusUpdateAttachments)
                {
                    if (keyedStatusUpdates.ContainsKey(statusUpdateAttachment.StatusKey))
                        keyedStatusUpdates[statusUpdateAttachment.StatusKey].Attachments.Add(statusUpdateAttachment);
                }

                #endregion

                statusUpdates.AddRange(temp.OrderByDescending(s => s.ParentSortDate));
            }
        }
 void OnStatusUpdated(UserStatus status, string statusText, long channelId, StatusUpdateAction action)
 {
     if (StatusUpdated != null)
     {
         StatusUpdated(this, new StatusUpdateEventArgs(status, statusText, channelId, action));
     }
 }
Example #10
0
        public void Add(UserStatus status)
        {
            status.Parent = this;

            Children.Add(status);
        }
        void UpdateStatus_Execute(object sender, ExecutedRoutedEventArgs e)
        {
            var status = new UserStatus
                {
                    Status = StatusTextBox.Text.Trim(),
                    StatusType = StatusTypes.MyUpdate,
                    SortDate = DateTime.Now,
                    DateCreated = DateTime.Now,
                    TargetChannelId = String.Join(";", SelectedChannels.Select(i => i.ToString()).ToArray())
                };

            mailbox.StatusUpdates.Add(status);

            ClientState.Current.DataService.Save(status);

            // Save command
            CommandQueue.Enqueue(AppCommands.SendStatusUpdate, status);

            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                ClientState.Current.ShowMessage(
                    new AppMessage(Strings.StatusWillBeUpdatedLater)
                        {
                            EntityId = status.StatusId,
                            EntityType = EntityType.UserStatus
                        }, MessageType.Success);
            }

            StatusTextBox.Text = String.Empty;
        }
 public static void StatusUpdateReceived(UserStatus status)
 {
     // Add to search index
     ClientState.Current.Search.Store(status);
 }
        /// <summary>
        /// Called when [validation finished handler].
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        void OnValidationFinishedHandler(object sender, EventArgs e)
        {
            ChannelSetupControl control = sender as ChannelSetupControl;

            if (control.IsValidated)
            {
                if (control.InviteFriends)
                {
                    // Send out viral
                    var message = Messages.Next();
                    var config = control.ChannelConfiguration;

                    var status = new UserStatus
                    {
                        Status = message,
                        StatusType = StatusTypes.MyUpdate,
                        SortDate = DateTime.Now,
                        DateCreated = DateTime.Now,
                        TargetChannelId = config.ChannelId.ToString()
                    };

                    new BackgroundActionTask(delegate
                        {
                            var channel = ChannelsManager.GetChannelObject(config.ChannelId);

                            ChannelContext.Current.ClientContext =
                                new ChannelClientContext(ClientState.Current.Context, config);

                            channel.StatusUpdatesChannel.UpdateMyStatus(status.DuckCopy<ChannelStatusUpdate>());

                        }).ExecuteAsync();
                }

                var firstItem = (FrameworkElement)transitionContainer.Items[0];
                var secondItem = (FrameworkElement)transitionContainer.Items[1];

                TimeSpan duration = new TimeSpan(0, 0, 0);
                transitionContainer.RestDuration = new Duration(duration);
                transitionContainer.ApplyTransition(firstItem, secondItem);
            }

            OnPropertyChanged("HasConfiguredChannels");
        }