Exemplo n.º 1
0
        private ApplicationDetailsListParameter VerifyPreconditions()
        {
            ApplicationDetailsListParameter appDetails = new ApplicationDetailsListParameter()
            {
                DetailsList = new System.Collections.Generic.List <PublishedApplicationDetails>()
                {
                    new PublishedApplicationDetails()
                }
            };

            string          appName     = null;
            string          appPath     = null;
            string          iconURI     = null;
            IconPngUrisType iconPngUris = new IconPngUrisType();

            switch (ParameterSetName)
            {
            case AppPath:
            {
                appName = Path.GetFileNameWithoutExtension(FileVirtualPath);
                appPath = FileVirtualPath;

                break;
            }

            case AppId:
            {
                GetStartMenuApplicationResult startMenu = Client.Publishing.StartMenuApplication(CollectionName, StartMenuAppId);
                appName     = startMenu.Result.Name;
                appPath     = startMenu.Result.VirtualPath;
                iconURI     = startMenu.Result.IconUri;
                iconPngUris = new IconPngUrisType()
                {
                    IconPngUris = startMenu.Result.IconPngUris,
                };
                break;
            }
            }

            appDetails.DetailsList[0].Name        = String.IsNullOrWhiteSpace(DisplayName) ? appName : DisplayName;
            appDetails.DetailsList[0].VirtualPath = appPath;

            appDetails.DetailsList[0].IconUri     = iconURI;
            appDetails.DetailsList[0].IconPngUris = iconPngUris;

            appDetails.DetailsList[0].Alias = "";

            appDetails.DetailsList[0].CommandLineArguments = CommandLine;

            appDetails.DetailsList[0].AvailableToUsers = true;

            return(appDetails);
        }
        private ApplicationDetailsListParameter VerifyPreconditions()
        {
            ApplicationDetailsListParameter appDetails = new ApplicationDetailsListParameter()
            {
                DetailsList = new System.Collections.Generic.List<PublishedApplicationDetails>()
                {
                    new PublishedApplicationDetails()
                }
            };

            string appName = null;
            string appPath = null;
            string iconURI = null;
            IconPngUrisType iconPngUris = new IconPngUrisType();

            switch (ParameterSetName)
            {
                case AppPath:
                {
                    appName = Path.GetFileNameWithoutExtension(FileVirtualPath);
                    appPath = FileVirtualPath;
                    
                    break;
                }
                case AppId:
                {
                    GetStartMenuApplicationResult startMenu = Client.Publishing.StartMenuApplication(CollectionName, StartMenuAppId);
                    appName = startMenu.Result.Name;
                    appPath = startMenu.Result.VirtualPath;
                    iconURI = startMenu.Result.IconUri;
                    iconPngUris = new IconPngUrisType()
                    {
                        IconPngUris = startMenu.Result.IconPngUris,
                    };
                    break;
                }
            }

            appDetails.DetailsList[0].Name = String.IsNullOrWhiteSpace(DisplayName) ? appName : DisplayName;
            appDetails.DetailsList[0].VirtualPath = appPath;

            appDetails.DetailsList[0].IconUri = iconURI;
            appDetails.DetailsList[0].IconPngUris = iconPngUris;

            appDetails.DetailsList[0].Alias = "";

            appDetails.DetailsList[0].CommandLineArguments = CommandLine;

            appDetails.DetailsList[0].AvailableToUsers = true; 

            return appDetails;
        }
        private void StartApplicationPublishing(ApplicationDetailsListParameter appDetails)
        {
            PublishApplicationsResult response = CallClient(() => Client.Publishing.PublishApplications(CollectionName, appDetails), Client.Publishing);

            WriteObject(response.ResultList, true);
        }
 /// <summary>
 /// Publishes remote applications with given application details in the
 /// collection.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.RemoteApp.IPublishingOperations.
 /// </param>
 /// <param name='collectionName'>
 /// Required. Collection Name
 /// </param>
 /// <param name='applicationDetailsList'>
 /// Required. List of publishing details
 /// </param>
 /// <returns>
 /// Definition for result of PublishApplications operation.
 /// </returns>
 public static Task <PublishApplicationsResult> PublishApplicationsAsync(this IPublishingOperations operations, string collectionName, ApplicationDetailsListParameter applicationDetailsList)
 {
     return(operations.PublishApplicationsAsync(collectionName, applicationDetailsList, CancellationToken.None));
 }
 /// <summary>
 /// Publishes remote applications with given application details in the
 /// collection.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.RemoteApp.IPublishingOperations.
 /// </param>
 /// <param name='collectionName'>
 /// Required. Collection Name
 /// </param>
 /// <param name='applicationDetailsList'>
 /// Required. List of publishing details
 /// </param>
 /// <returns>
 /// Definition for result of PublishApplications operation.
 /// </returns>
 public static PublishApplicationsResult PublishApplications(this IPublishingOperations operations, string collectionName, ApplicationDetailsListParameter applicationDetailsList)
 {
     return(Task.Factory.StartNew((object s) =>
     {
         return ((IPublishingOperations)s).PublishApplicationsAsync(collectionName, applicationDetailsList);
     }
                                  , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }
Exemplo n.º 6
0
        private void PublishAction()
        {
            ApplicationDetailsListParameter appDetails = VerifyPreconditions();

            StartApplicationPublishing(appDetails);
        }
Exemplo n.º 7
0
        private void StartApplicationPublishing(ApplicationDetailsListParameter appDetails)
        {
            PublishApplicationsResult response = CallClient(() => Client.Publishing.PublishApplications(CollectionName, appDetails), Client.Publishing);

            WriteObject(response.ResultList, true);
        }
        public void CanPublishModifyUnpublishApps()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                RemoteAppManagementClient client = GetRemoteAppManagementClient();

                CollectionListResult serviceList = null;
                Assert.DoesNotThrow(() =>
                {
                    serviceList = client.Collections.List();
                });

                Assert.NotNull(serviceList);
                Assert.NotEmpty(serviceList.Collections);

                Collection activeCollection = null;
                ApplicationDetailsListParameter appDetailsList = new ApplicationDetailsListParameter();
                PublishedApplicationDetails publishApp = new PublishedApplicationDetails();
                string publishingAppName = TestUtilities.GenerateName("TestApp");
                string publishingAppAlias = null;
                GetPublishedApplicationResult publishedAppResult = null;

                // Find collection in "Active" state so that publishing operations can be performed
                foreach (Collection ser in serviceList.Collections)
                {
                    if (ser.Status == "Active")
                    {
                        activeCollection = ser;
                        break;
                    }
                }

                Assert.NotNull(activeCollection);

                // Publish an App
                {
                    appDetailsList.DetailsList = new List<PublishedApplicationDetails>();
                    publishApp.AvailableToUsers = true;
                    publishApp.Name = publishingAppName;
                    publishApp.VirtualPath = "%systemroot%\\system32\\notepad.exe";
                    publishApp.IconPngUris = new IconPngUrisType();     // backend throws exception if this is null

                    appDetailsList.DetailsList.Add(publishApp);

                    PublishApplicationsResult publishResult = client.Publishing.PublishApplications(activeCollection.Name, appDetailsList);

                    // Verify for publish operation
                    Assert.NotNull(publishResult);
                    Assert.NotEmpty(publishResult.ResultList);
                    foreach (PublishingOperationResult oneResult in publishResult.ResultList)
                    {
                        Assert.True(oneResult.Success);
                        publishingAppAlias = oneResult.ApplicationAlias;
                        break;
                    }
                }

                // Wait for app status to change to Published
                publishedAppResult = WaitForAppStatus(client, activeCollection.Name, publishingAppAlias, AppPublishingStatus.Published);

                // Modify Published application
                {
                    PublishedApplicationDetails newAppDetails = publishedAppResult.Result;
                    ApplicationDetailsParameter newAppDetailsParam = new ApplicationDetailsParameter();

                    newAppDetails.Name = TestUtilities.GenerateName("ModTestApp");
                    newAppDetailsParam.Details = newAppDetails;

                    ModifyApplicationResult modifiedAppResult = client.Publishing.ModifyApplication(activeCollection.Name, publishingAppAlias, newAppDetailsParam);

                    // Verify Modify app result
                    Assert.NotNull(modifiedAppResult);
                    Assert.NotNull(modifiedAppResult.Result);
                    Assert.True(modifiedAppResult.StatusCode == HttpStatusCode.OK);
                }

                // Wait for app status to change to Published
                publishedAppResult = WaitForAppStatus(client, activeCollection.Name, publishingAppAlias, AppPublishingStatus.Published);

                // Unpublish the application
                {
                    UnpublishApplicationsResult unpublishAppResult = client.Publishing.Unpublish(activeCollection.Name, new AliasesListParameter { AliasesList = { publishingAppAlias } });

                    // Verify unpublish app result
                    Assert.NotNull(unpublishAppResult);
                    Assert.NotEmpty(unpublishAppResult.ResultList);
                    foreach (PublishingOperationResult oneResult in unpublishAppResult.ResultList)
                    {
                        Assert.True(oneResult.Success);
                    }
                }
            }
        }
Exemplo n.º 9
0
        public void CanPublishModifyUnpublishApps()
        {
            using (var undoContext = UndoContext.Current)
            {
                undoContext.Start();

                RemoteAppManagementClient client = GetRemoteAppManagementClient();

                CollectionListResult serviceList = null;
                Assert.DoesNotThrow(() =>
                {
                    serviceList = client.Collections.List();
                });

                Assert.NotNull(serviceList);
                Assert.NotEmpty(serviceList.Collections);

                Collection activeCollection = null;
                ApplicationDetailsListParameter appDetailsList = new ApplicationDetailsListParameter();
                PublishedApplicationDetails     publishApp     = new PublishedApplicationDetails();
                string publishingAppName  = TestUtilities.GenerateName("TestApp");
                string publishingAppAlias = null;
                GetPublishedApplicationResult publishedAppResult = null;

                // Find collection in "Active" state so that publishing operations can be performed
                foreach (Collection ser in serviceList.Collections)
                {
                    if (ser.Status == "Active")
                    {
                        activeCollection = ser;
                        break;
                    }
                }

                Assert.NotNull(activeCollection);

                // Publish an App
                {
                    appDetailsList.DetailsList  = new List <PublishedApplicationDetails>();
                    publishApp.AvailableToUsers = true;
                    publishApp.Name             = publishingAppName;
                    publishApp.VirtualPath      = "%systemroot%\\system32\\notepad.exe";
                    publishApp.IconPngUris      = new IconPngUrisType(); // backend throws exception if this is null

                    appDetailsList.DetailsList.Add(publishApp);

                    PublishApplicationsResult publishResult = client.Publishing.PublishApplications(activeCollection.Name, appDetailsList);

                    // Verify for publish operation
                    Assert.NotNull(publishResult);
                    Assert.NotEmpty(publishResult.ResultList);
                    foreach (PublishingOperationResult oneResult in publishResult.ResultList)
                    {
                        Assert.True(oneResult.Success);
                        publishingAppAlias = oneResult.ApplicationAlias;
                        break;
                    }
                }

                // Wait for app status to change to Published
                publishedAppResult = WaitForAppStatus(client, activeCollection.Name, publishingAppAlias, AppPublishingStatus.Published);

                // Modify Published application
                {
                    PublishedApplicationDetails newAppDetails      = publishedAppResult.Result;
                    ApplicationDetailsParameter newAppDetailsParam = new ApplicationDetailsParameter();

                    newAppDetails.Name         = TestUtilities.GenerateName("ModTestApp");
                    newAppDetailsParam.Details = newAppDetails;

                    ModifyApplicationResult modifiedAppResult = client.Publishing.ModifyApplication(activeCollection.Name, publishingAppAlias, newAppDetailsParam);

                    // Verify Modify app result
                    Assert.NotNull(modifiedAppResult);
                    Assert.NotNull(modifiedAppResult.Result);
                    Assert.True(modifiedAppResult.StatusCode == HttpStatusCode.OK);
                }

                // Wait for app status to change to Published
                publishedAppResult = WaitForAppStatus(client, activeCollection.Name, publishingAppAlias, AppPublishingStatus.Published);

                // Unpublish the application
                {
                    UnpublishApplicationsResult unpublishAppResult = client.Publishing.Unpublish(activeCollection.Name, new AliasesListParameter {
                        AliasesList = { publishingAppAlias }
                    });

                    // Verify unpublish app result
                    Assert.NotNull(unpublishAppResult);
                    Assert.NotEmpty(unpublishAppResult.ResultList);
                    foreach (PublishingOperationResult oneResult in unpublishAppResult.ResultList)
                    {
                        Assert.True(oneResult.Success);
                    }
                }
            }
        }
 /// <summary>
 /// Publishes remote applications with given application details in the
 /// collection.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.RemoteApp.IPublishingOperations.
 /// </param>
 /// <param name='collectionName'>
 /// Required. Collection Name
 /// </param>
 /// <param name='applicationDetailsList'>
 /// Required. List of publishing details
 /// </param>
 /// <returns>
 /// Definition for result of PublishApplications operation.
 /// </returns>
 public static Task<PublishApplicationsResult> PublishApplicationsAsync(this IPublishingOperations operations, string collectionName, ApplicationDetailsListParameter applicationDetailsList)
 {
     return operations.PublishApplicationsAsync(collectionName, applicationDetailsList, CancellationToken.None);
 }
 /// <summary>
 /// Publishes remote applications with given application details in the
 /// collection.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.RemoteApp.IPublishingOperations.
 /// </param>
 /// <param name='collectionName'>
 /// Required. Collection Name
 /// </param>
 /// <param name='applicationDetailsList'>
 /// Required. List of publishing details
 /// </param>
 /// <returns>
 /// Definition for result of PublishApplications operation.
 /// </returns>
 public static PublishApplicationsResult PublishApplications(this IPublishingOperations operations, string collectionName, ApplicationDetailsListParameter applicationDetailsList)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IPublishingOperations)s).PublishApplicationsAsync(collectionName, applicationDetailsList);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }