/// <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"); }
protected override void ExecuteCore() { var group = new ProgressGroup { Status = Strings.UpdatingStatus }; ProgressManager.Current.Register(group); try { foreach (var config in status.TargetChannels) { var channel = ChannelsManager.GetChannelObject(config.ChannelId); try { group.SourceChannelId = config.ChannelId; ChannelContext.Current.ClientContext = new ChannelClientContext(ClientState.Current.Context, config); Logger.Debug("Updating status. Channel = {0}", LogSource.BackgroundTask, config.DisplayName); if (config.IsConnected) { var data = String.Format("wrap_access_token={0}&channels={1}&inreplyto={2}&body={3}", CloudApi.AccessToken, config.ChannelKey, status.InReplyTo, HttpUtility.UrlEncode(status.Status)); HttpServiceRequest.Post(String.Concat(CloudApi.ApiBaseUrl, "send/statusupdate"), data, true); } else { channel.StatusUpdatesChannel.UpdateMyStatus(status.DuckCopy <ChannelStatusUpdate>()); } } catch (Exception ex) { ClientState.Current.ShowMessage( new AppMessage( String.Concat( String.Format(Strings.ErrorOccuredDuringStatusUpdate, channel.Configuration.DisplayName), String.Format(Strings.ServerSaid, ex.Message))) { SourceChannelId = config.ChannelId }, MessageType.Error); throw; } } Thread.CurrentThread.ExecuteOnUIThread(() => ClientState.Current.ShowMessage( new AppMessage(Strings.StatusUpdatedSuccessfully) { EntityId = status.StatusId, EntityType = EntityType.UserStatus }, MessageType.Success)); } finally { group.IsCompleted = true; } }