BlueDot.MsBuild.Tasks.DeployApplication.Execute C# (CSharp) Метод

Execute() публичный Метод

public Execute ( ) : bool
Результат bool
        public override bool Execute()
        {
            try
            {
                using (var appClient = GetApplicationManagementService())
                {
                    using (var groupClient = GetDeviceGroupManagementService())
                    {
                        // Create the application install
                        var app = FindOrCreateApplication(appClient);
                        var install = CreateInstall(appClient, app);

                        // assign to a group
                        int? groupId = GetGroupId(groupClient, null);
                        if (groupId.HasValue)
                        {
                            var assignedApps = groupClient.GetApplicationsAssociatedToGroup(groupId.Value);
                            if (assignedApps.SingleOrDefault(p => p.ApplicationId == app.ApplicationId) == null)
                            {
                                groupClient.AssociateApplications(
                                    new[] {app.ApplicationId},
                                    Environment.UserName,
                                    groupId.Value);

                                LogMessage(MessageImportance.Low,
                                           String.Format(
                                               "Associated application to group '{0}' for first time", DeviceGroup));
                            }

                            // Make this install active
                            groupClient.UpdateInstallForGroupApplication(
                                new DeviceGroupInstallUpdate
                                    {
                                        ApplicationId = app.ApplicationId,
                                        DeployToDeviceDate = DateTime.UtcNow,
                                        DeviceGroupId = groupId.Value,
                                        InstallId = install.InstallId,
                                        InstallOnDeviceDate = DateTime.UtcNow,
                                        IsActiveInstall = true,
                                        LastUpdatedByUserName = Environment.UserName
                                    });

                            LogMessage(MessageImportance.Low,
                                       "Install has been set as active install with immediate download and install scheduled");
                        }
                        else
                        {
                            LogMessage(MessageImportance.Normal,
                                       String.Format("Unable to find group named '{0}'. App was not assigned to group",
                                                     DeviceGroup));
                        }
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {
                LogMessage(MessageImportance.High, "Failed");
                LogMessage(MessageImportance.High, ex.ToString());
                return false;
            }
        }