public void CanNotSendCommandToASessionOnNonExistingCollection() { using (var undoContext = UndoContext.Current) { undoContext.Start(); RemoteAppManagementClient client = GetRemoteAppManagementClient(); SessionCommandParameter parameter = new SessionCommandParameter { UserUpn = "*****@*****.**" }; // testing the web fault OperationResultWithTrackingId response = null; Assert.Throws <CloudException>(() => response = client.Collections.LogoffSession("mycoll", parameter)); Assert.Throws <CloudException>(() => response = client.Collections.DisconnectSession("mycoll", parameter)); SessionSendMessageCommandParameter messageParameter = new SessionSendMessageCommandParameter() { Message = "Hey there!", UserUpn = "*****@*****.**" }; Assert.Throws <CloudException>(() => response = client.Collections.SendMessageToSession("mycoll", messageParameter)); } }
public override void ExecuteCmdlet() { SessionCommandParameter parameter = new SessionCommandParameter { UserUpn = UserUpn }; var response = CallClient(() => Client.Collections.DisconnectSession(CollectionName, parameter), Client.Collections); WriteTrackingId(response); }
public void CanDisconnectASessionInACollection() { using (var undoContext = UndoContext.Current) { undoContext.Start(); RemoteAppManagementClient client = GetRemoteAppManagementClient(); SessionCommandParameter parameter = new SessionCommandParameter { UserUpn = "*****@*****.**" }; // testing the web fault OperationResultWithTrackingId response = null; response = client.Collections.DisconnectSession("simple", parameter); Assert.NotNull(response); Assert.NotNull(response.TrackingId); Assert.Equal(HttpStatusCode.Accepted, response.StatusCode); AssertLongrunningOperation(client, RemoteAppOperationStatus.Success, response.TrackingId); TestUtilities.Wait(20000); CollectionSessionListResult sessionList = client.Collections.ListSessions("simple"); Assert.NotNull(sessionList); Assert.NotNull(sessionList.Sessions); Assert.True(sessionList.StatusCode == HttpStatusCode.OK); Assert.NotEmpty(sessionList.Sessions); RemoteAppSession session = null; foreach (var s in sessionList.Sessions) { if (s.UserUpn == parameter.UserUpn) { session = s; break; } } Assert.NotNull(session); Assert.Equal(SessionState.Disconnected, session.State); } }
public override void ExecuteCmdlet() { SessionCommandParameter parameter = new SessionCommandParameter { UserUpn = UserUpn }; OperationResultWithTrackingId response = null; string caption = Commands_RemoteApp.SessionLogOffCaptionMessage; string warning = String.Format(System.Globalization.CultureInfo.CurrentCulture, Commands_RemoteApp.SessionLogOffWarningQuestionFormat, UserUpn); if (ShouldProcess(caption, warning, caption)) { response = CallClient(() => Client.Collections.LogoffSession(CollectionName, parameter), Client.Collections); } if (response != null) { WriteTrackingId(response); } }
/// <summary> /// Logs off the session associated with the user UPN /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.RemoteApp.ICollectionOperations. /// </param> /// <param name='collectionName'> /// Required. The RemoteApp collection name where the session exists. /// </param> /// <param name='sessionParameter'> /// Required. The session command parameter to logoff a session. /// </param> /// <returns> /// The response containing the operation tracking id. /// </returns> public static Task <OperationResultWithTrackingId> LogoffSessionAsync(this ICollectionOperations operations, string collectionName, SessionCommandParameter sessionParameter) { return(operations.LogoffSessionAsync(collectionName, sessionParameter, CancellationToken.None)); }
/// <summary> /// Logs off the session associated with the user UPN /// </summary> /// <param name='operations'> /// Reference to the /// Microsoft.WindowsAzure.Management.RemoteApp.ICollectionOperations. /// </param> /// <param name='collectionName'> /// Required. The RemoteApp collection name where the session exists. /// </param> /// <param name='sessionParameter'> /// Required. The session command parameter to logoff a session. /// </param> /// <returns> /// The response containing the operation tracking id. /// </returns> public static OperationResultWithTrackingId LogoffSession(this ICollectionOperations operations, string collectionName, SessionCommandParameter sessionParameter) { return(Task.Factory.StartNew((object s) => { return ((ICollectionOperations)s).LogoffSessionAsync(collectionName, sessionParameter); } , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult()); }