Exemple #1
0
        private int?GetGroupId(DeviceGroupManagementClient service, int?groupId)
        {
            int?foundGroupId = null;

            try
            {
                DeviceGroup[] groups = service.GetChildGroups(groupId);

                for (int i = 0; i < groups.Length; i++)
                {
                    if (groups[i].Name == "Authorized Devices")
                    {
                        foundGroupId = GetGroupId(service, groups[i].Id);
                        break;
                    }
                    if (groups[i].Name == DeviceGroup)
                    {
                        foundGroupId = groups[i].Id;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                LogMessage(MessageImportance.High, "Error Retrieving Groups.");
                LogMessage(MessageImportance.High, ex.ToString());
            }
            return(foundGroupId);
        }
Exemple #2
0
        private DeviceGroupManagementClient GetDeviceGroupManagementService()
        {
            var proxy = new DeviceGroupManagementClient(
                CreateDefaultBinding(),
                new EndpointAddress(DeviceGroupManagementUrl));

            return(proxy);
        }
        private DeviceGroupManagementClient GetDeviceGroupManagementService()
        {
            DeviceGroupManagementClient service = new DeviceGroupManagementClient(
                CreateDefaultBinding(),
                new EndpointAddress(this.DeviceGroupManagementUrl));

            return(service);
        }
        public void AddPackageToGroup(int newPackageId)
        {
            if (!string.IsNullOrEmpty(this.DeviceGroup))
            {
                using (DeviceGroupManagementClient service = this.GetDeviceGroupManagementService())
                {
                    int?groupId = GetGroupId(service, null);

                    if (groupId.HasValue)
                    {
                        DeviceGroupAssociationAddition[] addList = new DeviceGroupAssociationAddition[1] {
                            new DeviceGroupAssociationAddition()
                            {
                                DeploymentPackageId = newPackageId,
                                DeviceGroupId       = groupId.Value,
                                DeploymentDate      = DateTime.Now,
                                CreatedByUserName   = "******",
                                CreatedWhen         = DateTime.Now,
                                InstallationDate    = DateTime.Now,
                                RemovalDate         = DateTime.Now.AddYears(100)
                            }
                        };
                        try
                        {
                            service.AssociateDeploymentPackages(addList);
                            LogMessage(MessageImportance.Normal,
                                       string.Format("Associated Package {0} to device group {1}", newPackageId, this.DeviceGroup));
                        }
                        catch (Exception ex)
                        {
                            LogMessage(MessageImportance.High, "Error Associating Package {0} to Group {1}.");
                            LogMessage(MessageImportance.High, ex.ToString());
                        }
                    }
                }
            }
        }
        private int? GetGroupId(DeviceGroupManagementClient service, int? groupId)
        {
            int? foundGroupId = null;
            try
            {
                DeviceGroup[] groups = service.GetChildGroups(groupId);

                for (int i = 0; i < groups.Length; i++)
                {
                    if (groups[i].Name == "Authorized Devices")
                    {
                        foundGroupId = GetGroupId(service, groups[i].Id);
                        break;
                    }
                    if (groups[i].Name == this.DeviceGroup)
                    {
                        foundGroupId = groups[i].Id;
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                LogMessage(MessageImportance.High, "Error Retrieving Groups.");
                LogMessage(MessageImportance.High, ex.ToString());

            }
            return foundGroupId;
        }
 private DeviceGroupManagementClient GetDeviceGroupManagementService()
 {
     DeviceGroupManagementClient service = new DeviceGroupManagementClient(
         CreateDefaultBinding(),
         new EndpointAddress(this.DeviceGroupManagementUrl));
     return service;
 }
 private DeviceGroupManagementClient GetDeviceGroupManagementService()
 {
     var proxy = new DeviceGroupManagementClient(
         CreateDefaultBinding(),
         new EndpointAddress(DeviceGroupManagementUrl));
     return proxy;
 }