Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 private List <BadgeBoxInfo> GetBadgeBoxes(IEnumerable <AssetInfo> assets)
 {
     using (AssetInventoryContext context = new AssetInventoryContext())
     {
         var badgeBoxes = BadgeBox.SelectByAsset(context, assets.Select(n => n.AssetId)).ToList();
         return(badgeBoxes.Select(n => BadgeBox.GetInfo(n)).ToList());
     }
 }
Exemplo n.º 3
0
 private static BadgeBoxDetail CreateBadgeBoxDetail(BadgeBox badgeBox)
 {
     return(new BadgeBoxDetail(badgeBox.BadgeBoxId, DateTime.MaxValue)
     {
         BadgeBoxId = badgeBox.BadgeBoxId,
         IPAddress = badgeBox.IPAddress,
         Availability = AssetAvailability.Available,
         PrinterId = badgeBox.PrinterId,
         Description = badgeBox.Description
     });
 }
Exemplo n.º 4
0
        private void button_DeleteBadgeBox_Click(object sender, EventArgs e)
        {
            BadgeBox selected = SelectedBadgeBox;

            if (selected != null && MessageBox.Show($"Delete '{selected.BadgeBoxId}'?", "Delete Badge Box", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                _badgeBoxes.Remove(selected);
                _context.BadgeBoxes.Remove(selected);
                _context.SaveChanges();
                badgeListControl.Refresh();
            }
        }
Exemplo n.º 5
0
        private void button_AddBadgeBox_Click(object sender, EventArgs e)
        {
            BadgeBox newBadgeBox = new BadgeBox();

            using (BadgeBoxEditForm dialog = new BadgeBoxEditForm())
            {
                dialog.Initialize(newBadgeBox, _context);
                if (dialog.ShowDialog(this) == DialogResult.OK)
                {
                    _badgeBoxes.Add(newBadgeBox);
                    badgeListControl.Refresh();
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes the <see cref="BadgeBoxEditForm"/>.
        /// </summary>
        /// <param name="badgeBox">The badge box.</param>
        /// <param name="context">The context.</param>
        public void Initialize(BadgeBox badgeBox, AssetInventoryContext context)
        {
            _context  = context;
            _badgeBox = badgeBox;

            textBox_BadgeBoxId.Text    = _badgeBox.BadgeBoxId;
            textBox_BadgeBoxId.Enabled = string.IsNullOrEmpty(_badgeBox.BadgeBoxId);
            textBox_Descr.Text         = _badgeBox.Description;
            textBox_Address.Text       = _badgeBox.IPAddress;
            textBox_PrinterId.Text     = _badgeBox.PrinterId;

            badgeListControl.BadgeBox = _badgeBox;
            badgeListControl.Initialize(_badgeBox.Badges, _context);
        }
Exemplo n.º 7
0
        private void button_EditBadgeBox_Click(object sender, EventArgs e)
        {
            BadgeBox selected = SelectedBadgeBox;

            if (selected != null)
            {
                using (BadgeBoxEditForm dialog = new BadgeBoxEditForm())
                {
                    dialog.Initialize(selected, _context);
                    if (dialog.ShowDialog(this) == DialogResult.OK)
                    {
                        badgeListControl.Refresh();
                    }
                }
            }
        }