private static AssetIdCollection GetAssetIds(AssetSelectionData selectionData)
        {
            AssetIdCollection result = new AssetIdCollection();

            using (AssetInventoryContext context = DbConnect.AssetInventoryContext())
            {
                foreach (string assetId in selectionData.SelectedAssets)
                {
                    result.Add(assetId);

                    //Check to see if the asset has badge boxes
                    BadgeBox badgeBox = context.BadgeBoxes.FirstOrDefault(n => n.PrinterId == assetId);
                    if (badgeBox != null)
                    {
                        TraceFactory.Logger.Debug($"Asset: {assetId} has associated BadgeBox: {badgeBox.BadgeBoxId}");
                        result.Add(badgeBox.BadgeBoxId);
                    }

                    //Check to see if the asset has cameras
                    Core.AssetInventory.Camera camera = context.Assets.OfType <Core.AssetInventory.Camera>().FirstOrDefault(c => c.PrinterId == assetId);
                    if (camera != null)
                    {
                        TraceFactory.Logger.Debug($"Asset: {assetId} has associated Camera: {camera.AssetId}");
                        result.Add(camera.AssetId);
                    }
                }
            }
            return(result);
        }
Beispiel #2
0
 /// <summary>
 /// Initializes this configuration control with the specified <see cref="PluginConfigurationData" />.
 /// </summary>
 /// <param name="configuration">The configuration data.</param>
 /// <param name="environment">Information about the plugin environment.</param>
 public void Initialize(PluginConfigurationData configuration, PluginEnvironment environment)
 {
     _activityData       = configuration.GetMetadata <HpacServerConfigurationActivityData>();
     _assetSelectionData = configuration.Assets;
     hpac_ServerComboBox.Initialize(configuration.Servers.SelectedServers.FirstOrDefault(), "HPAC");
     hpacTileCombobox.DataSource   = EnumUtil.GetValues <HpacTile>().ToList();
     hpacTileCombobox.SelectedItem = _activityData.HpacConfigTile.ToString();
     LoadConfiguration();
 }
            private static string GetAssetDisplayString(PluginConfigurationData configurationData)
            {
                AssetSelectionData assets = configurationData.Assets;

                if (assets?.SelectedAssets?.Count + assets?.InactiveAssets?.Count > 0)
                {
                    return($"Assets: {assets.SelectedAssets.Count} selected, {assets.InactiveAssets.Count} inactive");
                }
                else
                {
                    return(null);
                }
            }
Beispiel #4
0
        /// <summary>
        /// Transforms <see cref="AssetSelectionData" /> from a <see cref="PluginConfigurationData" /> object into a
        /// corresponding <see cref="AssetInfoCollection" /> using data from the specified <see cref="IAssetInventory" />.
        /// </summary>
        /// <param name="configurationData">The <see cref="PluginConfigurationData" />.</param>
        /// <param name="assetInventory">The <see cref="IAssetInventory" />.</param>
        /// <returns>An <see cref="AssetInfoCollection" /> object.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="configurationData" /> is null.
        /// <para>or</para>
        /// <paramref name="assetInventory" /> is null.
        /// </exception>
        public static AssetInfoCollection GetExecutionAssets(PluginConfigurationData configurationData, IAssetInventory assetInventory)
        {
            if (configurationData == null)
            {
                throw new ArgumentNullException(nameof(configurationData));
            }

            if (assetInventory == null)
            {
                throw new ArgumentNullException(nameof(assetInventory));
            }

            AssetSelectionData assetSelectionData = configurationData.Assets ?? new AssetSelectionData();

            return(assetInventory.GetAssets(assetSelectionData.SelectedAssets));
        }
        /// <summary>
        /// Initializes the asset selection control for selecting assets with the specified attributes
        /// and adds the specified assets to the grid.
        /// </summary>
        /// <param name="data">The asset selection data.</param>
        /// <param name="attributes">The attributes of assets that can be selected.</param>
        /// <exception cref="ArgumentNullException"><paramref name="data" /> is null.</exception>
        public void Initialize(AssetSelectionData data, AssetAttributes attributes)
        {
            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            _assetAttributes = attributes;
            _assetRows.Clear();

            var allAssetIds            = data.SelectedAssets.Union(data.InactiveAssets);
            AssetInfoCollection assets = ConfigurationServices.AssetInventory.GetAssets(allAssetIds);

            foreach (AssetInfo asset in assets)
            {
                _assetRows.Add(new AssetSelectionRow(asset, data.SelectedAssets.Contains(asset.AssetId)));
            }

            asset_GridView.Refresh();
            OnDisplayedAssetsChanged();
        }
        /// <summary>
        /// Creates a new instance of ManifestAssetAgent.
        /// </summary>
        /// <param name="scenarioId"></param>
        public ManifestAssetAgent(Guid scenarioId)
        {
            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                // Retrieve asset usage data for all enabled activities in the specified session
                var activities = (from assetUsage in context.VirtualResourceMetadataAssetUsages
                                  let data = assetUsage.AssetSelectionData
                                             let metadata = assetUsage.VirtualResourceMetadata
                                                            let resource = metadata.VirtualResource
                                                                           where resource.EnterpriseScenarioId == scenarioId &&
                                                                           resource.Enabled == true &&
                                                                           metadata.Enabled == true &&
                                                                           data != null
                                                                           select new { Id = metadata.VirtualResourceMetadataId, Assets = data }).ToList();

                foreach (var activity in activities)
                {
                    AssetSelectionData assetSelectionData = GetSelectionData(activity.Assets);
                    _activityAssets.Add(activity.Id, GetAssetIds(assetSelectionData));
                }
            }
        }
        /// <summary>
        /// Updates the virtual resource metadata asset usage.
        /// </summary>
        /// <param name="oldAsset">The old asset.</param>
        /// <param name="newAsset">The new asset.</param>
        private void UpdateVirtualResourceMetadataAssetUsage(string oldAsset, string newAsset)
        {
            foreach (VirtualResourceMetadataAssetUsage vrmau in _assetMetadataUsages)
            {
                XElement           asd = XElement.Parse(vrmau.AssetSelectionData);
                AssetSelectionData assetSelectionData = Serializer.Deserialize <AssetSelectionData>(asd);

                if (assetSelectionData.SelectedAssets.Contains(oldAsset))
                {
                    var changes = assetSelectionData.SelectedAssets.Select(str => str.Replace(oldAsset, newAsset)).ToList();
                    assetSelectionData.SelectedAssets.Clear();
                    foreach (var asset in changes)
                    {
                        assetSelectionData.SelectedAssets.Add(asset);
                    }

                    XElement newAsd = Serializer.Serialize(assetSelectionData);
                    vrmau.AssetSelectionData = newAsd.ToString();
                }
            }
            int result = _context.SaveChanges();
        }
        /// <summary>
        /// Creates and returns a <see cref="PluginConfigurationData" /> instance containing the
        /// configuration data from this control.
        /// </summary>
        /// <returns>The configuration data.</returns>
        public PluginConfigurationData GetConfiguration()
        {
            _activityData.LockTimeouts = lockTimeoutControl.Value;
            _activityData.DeviceMemoryProfilerConfig = deviceMemoryProfilerControl.SelectedData;
            _activityData.HPRoamAuthentication       = radioButton_RoamApp.Checked;
            _activityData.AuthProvider          = (AuthenticationProvider)comboBox_AuthProvider.SelectedValue;
            _activityData.DocumentProcessAction = GetPullPrintAction();
            _activityData.DelayBeforePullPrint  = (int)numericUpDown_PullPrintDelay.Value;

            _activityData.ShuffleDocuments       = shuffle_CheckBox.Checked;
            _activityData.PhoneDocumentPush      = radioButton_PullPrintPhone.Checked;
            _activityData.PhoneDocument          = textBox_PhoneDocument.Text;
            _activityData.RoamDocumentSendAction = GetDocumentSendAction();

            AssetSelectionData assetSelectionData = assetSelectionControl.AssetSelectionData;

            if (radioButton_PullPrintPhone.Checked)
            {
                assetSelectionData.SelectedAssets.Add(_mobileAsset.AssetId);
                _activityData.MobileEquipmentId = _mobileAsset.MobileEquipmentId;
            }
            _activityData.AndroidDocumentAction = GetAndroidDocAction();

            LocalPrintQueueInfo info = new LocalPrintQueueInfo("HP Roam");

            _printQueues.Add(info);
            _activityData.DelayAfterPrint            = GetDelayAfterPrint();
            _activityData.UsePrintServerNotification = printServerNotificationcheckBox.Checked;

            int count = documentSelectionControl.DocumentSelectionData.SelectedDocuments.Count();

            return(new PluginConfigurationData(_activityData, Version)
            {
                Assets = assetSelectionData,
                Documents = documentSelectionControl.DocumentSelectionData,
                PrintQueues = new PrintQueueSelectionData(_printQueues)
            });
        }
        private void SetBulkDevice()
        {
            _bulkDeviceList = new BulkDeviceList();
            foreach (VirtualResourceMetadataAssetUsage vrmau in _assetMetadataUsages)
            {
                XElement           asd = XElement.Parse(vrmau.AssetSelectionData);
                AssetSelectionData assetSelectionData = Serializer.Deserialize <AssetSelectionData>(asd);

                foreach (string assetId in assetSelectionData.SelectedAssets)
                {
                    if (AssetNotInList(assetId))
                    {
                        BulkDeviceEnt bulkDevice = new BulkDeviceEnt();

                        bulkDevice.CurrentDevice             = assetId;
                        bulkDevice.Active                    = IsActiveAsset(assetId, assetSelectionData.InactiveAssets);
                        bulkDevice.VirtualResourceMetadataId = vrmau.VirtualResourceMetadataId;

                        _bulkDeviceList.Add(bulkDevice);
                    }
                }
            }
        }