Пример #1
0
        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());
                        }
                    }
                }
            }
        }
Пример #2
0
        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());
                        }
                    }
                }
            }
        }