public static AssetAttributesModel ToApiModel(this AssetAttributes src)
 {
     return(new AssetAttributesModel
     {
         Attrbuttes = src?.Attributes?.Select(ToApiModel).OrderBy(x => x.Key).ToArray() ?? new KeyValue[0]
     });
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetSelectionForm" /> class.
 /// </summary>
 /// <param name="assetAttributes">The attributes of the assets to be displayed.</param>
 /// <param name="allowMultipleSelection">if set to <c>true</c> allow multiple assets to be selected.</param>
 public AssetSelectionForm(AssetAttributes assetAttributes, bool allowMultipleSelection)
     : this(allowMultipleSelection)
 {
     AssetInfoCollection assetList = ConfigurationServices.AssetInventory.GetAssets(assetAttributes);
     _assetList = new BindingList <AssetInfo>(assetList.ToList());
     assets_GridView.DataSource = _assetList;
 }
Ejemplo n.º 3
0
 public static AssetAttributesModel ConvertToApiModel(this AssetAttributes src)
 {
     return(new AssetAttributesModel
     {
         Attrbuttes = src.Attributes.Select(ConvertToApiModel).ToArray()
     });
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets the <see cref="SemanticCubeUtilities.DataTypes"/> of an asset attribute.
        /// Called by <see cref="QuadrupleManager.ReadAssetAttribute(AssetAttributes)"/>.
        /// </summary>
        /// <param name="attribute"></param>
        /// <returns>A <see cref="SemanticCubeUtilities.DataTypes"/> value.</returns>
        public static SemanticCubeUtilities.DataTypes AttributeToType(AssetAttributes attribute)
        {
            switch (attribute)
            {
            case AssetAttributes.x:
                return(SemanticCubeUtilities.DataTypes.number);

            case AssetAttributes.y:
                return(SemanticCubeUtilities.DataTypes.number);

            case AssetAttributes.width:
                return(SemanticCubeUtilities.DataTypes.number);

            case AssetAttributes.height:
                return(SemanticCubeUtilities.DataTypes.number);

            case AssetAttributes.rotation:
                return(SemanticCubeUtilities.DataTypes.number);

            case AssetAttributes.number:
                return(SemanticCubeUtilities.DataTypes.number);

            case AssetAttributes.label:
                return(SemanticCubeUtilities.DataTypes.text);

            default:     // will never execute as we limit the user's options with a drop-down
                return(SemanticCubeUtilities.DataTypes.invalidDataType);
            }
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BadgeBoxInfo" /> class.
 /// </summary>
 /// <param name="assetId">The unique identifier for the badge box.</param>
 /// <param name="attributes">The <see cref="AssetAttributes" /> of the badge box.</param>
 /// <param name="assetType">The asset type.</param>
 /// <param name="address">The network address of the badge box.</param>
 /// <param name="printerId">The ID of the printer the badge box is connected to.</param>
 /// <param name="badges">The available badges for this badge box.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="assetId" /> is null.
 /// <para>or</para>
 /// <paramref name="address" /> is null.
 /// </exception>
 public BadgeBoxInfo(string assetId, AssetAttributes attributes, string assetType, string address, string printerId, IList <BadgeInfo> badges)
     : base(assetId, attributes, assetType)
 {
     _address   = address ?? throw new ArgumentNullException(nameof(address));
     _printerId = printerId;
     _badges    = new ReadOnlyCollection <BadgeInfo>(badges);
 }
Ejemplo n.º 6
0
		public static void RunEtcTool(Bitmap bitmap, AssetBundle bundle, string path, AssetAttributes attributes, bool mipMaps, bool highQualityCompression, byte[] CookingRulesSHA1)
		{
			var hasAlpha = bitmap.HasAlpha;
			var bledBitmap = hasAlpha ? TextureConverterUtils.BleedAlpha(bitmap) : null;
			var ktxPath = Toolbox.GetTempFilePathWithExtension(".ktx");
			var pngPath = Path.ChangeExtension(ktxPath, ".png");
			try {
				(bledBitmap ?? bitmap).SaveTo(pngPath);
				var etcTool = GetToolPath("EtcTool");
				var args =
					$"{pngPath} -format " + (hasAlpha ? "RGBA8" : "ETC1") +
					" -jobs 8 " +
					" -effort " + (highQualityCompression ? "60" : "40") +
					(mipMaps ? " -mipmaps 4" : "") +
					$" -output {ktxPath}";
				if (Process.Start(etcTool, args) != 0) {
					throw new Lime.Exception($"ETCTool error\nCommand line: {etcTool} {args}\"");
				}
				bundle.ImportFile(ktxPath, path, 0, "", attributes, CookingRulesSHA1);
			} finally {
				bledBitmap?.Dispose();
				DeletePossibleLockedFile(pngPath);
				DeletePossibleLockedFile(ktxPath);
			}
		}
Ejemplo n.º 7
0
 private static void SyncRawAssets(string extension, AssetAttributes attributes = AssetAttributes.None)
 {
     SyncUpdated(extension, extension, (srcPath, dstPath) => {
         AssetBundle.ImportFile(srcPath, dstPath, 0, extension, attributes, cookingRulesMap[srcPath].SHA1);
         return(true);
     });
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VirtualPrinterInfo" /> class.
 /// </summary>
 /// <param name="assetId">The asset identifier.</param>
 /// <param name="attributes">The asset attributes.</param>
 /// <param name="assetType">The asset type.</param>
 /// <param name="address">The virtual printer address.</param>
 /// <param name="printerPort">The virtual printer port.</param>
 /// <param name="snmpEnabled">if set to <c>true</c> SNMP is enabled for the virtual printer.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="assetId" /> is null.
 /// <para>or</para>
 /// <paramref name="address" /> is null.
 /// </exception>
 public VirtualPrinterInfo(string assetId, AssetAttributes attributes, string assetType, string address, int printerPort, bool snmpEnabled)
     : base(assetId, attributes, assetType)
 {
     _address     = address ?? throw new ArgumentNullException(nameof(address));
     _printerPort = printerPort;
     _snmpEnabled = snmpEnabled;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetSelectionForm" /> class
 /// with the specified asset ID selected.
 /// </summary>
 /// <param name="assetAttributes">The attributes of the assets to be displayed.</param>
 /// <param name="assetId">The asset ID of the asset to be initially selected.</param>
 /// <param name="allowMultipleSelection">if set to <c>true</c> allow multiple assets to be selected.</param>
 public AssetSelectionForm(AssetAttributes assetAttributes, string assetId, bool allowMultipleSelection)
     : this(assetAttributes, allowMultipleSelection)
 {
     if (!string.IsNullOrEmpty(assetId))
     {
         _selectedAssetIds.Add(assetId);
     }
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DeviceInfo" /> class.
 /// </summary>
 /// <param name="assetId">The unique identifier for the device.</param>
 /// <param name="attributes">The <see cref="AssetAttributes" /> for the device.</param>
 /// <param name="assetType">The device type.</param>
 /// <param name="address">The device network address.</param>
 /// <param name="address2">Secondary address used by the device.</param>
 /// <param name="adminPassword">The device admin password.</param>
 /// <param name="productName">The device product name.</param>
 /// <exception cref="ArgumentNullException">
 /// <paramref name="assetId" /> is null.
 /// <para>or</para>
 /// <paramref name="address" /> is null.
 /// </exception>
 public DeviceInfo(string assetId, AssetAttributes attributes, string assetType, string address, string address2, string adminPassword, string productName)
     : base(assetId, attributes, assetType)
 {
     _address       = address ?? throw new ArgumentNullException(nameof(address));
     _address2      = address2;
     _adminPassword = adminPassword;
     _productName   = productName;
 }
Ejemplo n.º 11
0
        public override void SetAttributes(string path, AssetAttributes attributes)
        {
            OnModifying?.Invoke();
            var desc = GetDescriptor(path);

            index[AssetPath.CorrectSlashes(path)] = desc;
            wasModified = true;
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PrintDeviceDetail"/> class.
 /// </summary>
 public PrintDeviceDetail(string deviceId, DateTime?availabilityStartTime, DateTime?availabilityEndTime)
     : base(deviceId, availabilityStartTime, availabilityEndTime)
 {
     PortNumber  = 9100;         // Convention for physical printers
     SnmpEnabled = true;
     UseCrc      = true;
     Capability  = 0;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AssetSelectionForm"/> class,
 /// with the specified asset id selected.
 /// </summary>
 /// <param name="capabilities">The capabilities.</param>
 /// <param name="assetId">The asset id.</param>
 public AssetSelectionForm(AssetAttributes capabilities, string assetId)
     : this(capabilities)
 {
     if (!string.IsNullOrEmpty(assetId))
     {
         _selectedAssetIds = new string[] { assetId };
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// Retrieves <see cref="AssetInfo" /> for assets with all of the specified <see cref="AssetAttributes" />.
        /// </summary>
        /// <param name="attributes">The required attributes of the assets to retrieve.</param>
        /// <returns><see cref="AssetInfo" /> for each asset with all of the specified attributes.</returns>
        public AssetInfoCollection GetAssets(AssetAttributes attributes)
        {
            if (attributes == AssetAttributes.None)
            {
                return(GetAssets());
            }

            return(new AssetInfoCollection(_assets.Where(n => n.Attributes.HasFlag(attributes)).ToList()));
        }
Ejemplo n.º 15
0
 public void ImportFile(
     string srcPath, string dstPath, int reserve,
     string sourceExtension, AssetAttributes attributes,
     DateTime time, byte[] cookingRulesSHA1)
 {
     using (var stream = new FileStream(srcPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) {
         ImportFile(dstPath, stream, reserve, sourceExtension, time, attributes, cookingRulesSHA1);
     }
 }
Ejemplo n.º 16
0
 public override void ImportFile(
     string path, Stream stream, int reserve, string sourceExtension,
     DateTime time, AssetAttributes attributes, byte[] cookingRulesSHA1)
 {
     if ((attributes & AssetAttributes.Zipped) != 0)
     {
         stream = CompressAssetStream(stream, attributes);
     }
     ImportFileRaw(path, stream, reserve, sourceExtension, time, attributes, cookingRulesSHA1);
 }
Ejemplo n.º 17
0
 public override void ImportFile(
     string path, Stream stream, int reserve, string sourceExtension, DateTime time,
     AssetAttributes attributes, byte[] cookingRulesSHA1)
 {
     if ((attributes & (AssetAttributes.Zipped | AssetAttributes.ZippedDeflate)) != 0)
     {
         throw new NotSupportedException();
     }
     ImportFileRaw(path, stream, reserve, sourceExtension, time, attributes, cookingRulesSHA1);
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Retrieves <see cref="AssetInfo" /> for assets with all of the specified <see cref="AssetAttributes" />.
        /// </summary>
        /// <param name="attributes">The required attributes of the assets to retrieve.</param>
        /// <returns><see cref="AssetInfo" /> for each asset with all of the specified attributes.</returns>
        public AssetInfoCollection GetAssets(AssetAttributes attributes)
        {
            using (AssetInventoryContext context = new AssetInventoryContext(_connectionString))
            {
                IQueryable <Asset> assets = _configuration?.AssetPools.Any() == true?
                                            context.Assets.Where(n => _configuration.AssetPools.Contains(n.Pool.Name)) :
                                                context.Assets;

                return(assets.Where(n => n.Capability.HasFlag(attributes)).ToAssetInfoCollection());
            }
        }
Ejemplo n.º 19
0
        private static Stream CompressAssetStream(Stream stream, AssetAttributes attributes)
        {
            MemoryStream memStream = new MemoryStream();

            using (var compressionStream = CreateCompressionStream(memStream, attributes)) {
                stream.CopyTo(compressionStream);
            }
            memStream.Seek(0, SeekOrigin.Begin);
            stream = memStream;
            return(stream);
        }
Ejemplo n.º 20
0
 private static Stream CreateCompressionStream(Stream stream, AssetAttributes attributes)
 {
     if ((attributes & AssetAttributes.ZippedDeflate) != 0)
     {
         return(new DeflateStream(stream, CompressionMode.Compress, leaveOpen: true));
     }
     if ((attributes & AssetAttributes.ZippedLZMA) != 0)
     {
         return(new LzmaCompressionStream(stream, leaveOpen: true));
     }
     throw new NotImplementedException();
 }
Ejemplo n.º 21
0
 private static Stream DecompressAssetStream(AssetStream stream, AssetAttributes attributes)
 {
     if ((attributes & AssetAttributes.ZippedDeflate) != 0)
     {
         return(new DeflateStream(stream, CompressionMode.Decompress));
     }
     if ((attributes & AssetAttributes.ZippedLZMA) != 0)
     {
         return(new LzmaDecompressionStream(stream));
     }
     throw new NotImplementedException();
 }
Ejemplo n.º 22
0
        public override void ImportFileRaw(
            string path, Stream stream, int reserve, string sourceExtension, DateTime time,
            AssetAttributes attributes, byte[] cookingRulesSHA1)
        {
            stream.Seek(0, SeekOrigin.Begin);
            var bytes = new byte[stream.Length];

            stream.Read(bytes, 0, bytes.Length);
            var dir = Path.Combine(BaseDirectory, Path.GetDirectoryName(path));

            Directory.CreateDirectory(dir);
            File.WriteAllBytes(Path.Combine(BaseDirectory, path), bytes);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssetSelectionForm" /> class.
        /// </summary>
        /// <param name="assetAttributes">The attributes of the assets to be displayed.</param>
        /// <param name="assetFilter">A function to apply that acts as an additional filter to the displayed assets.</param>
        /// <param name="allowMultipleSelection">if set to <c>true</c> allow multiple assets to be selected.</param>
        /// <exception cref="ArgumentNullException"><paramref name="assetFilter" /> is null.</exception>
        public AssetSelectionForm(AssetAttributes assetAttributes, Func <AssetInfoCollection, AssetInfoCollection> assetFilter, bool allowMultipleSelection)
            : this(allowMultipleSelection)
        {
            if (assetFilter == null)
            {
                throw new ArgumentNullException(nameof(assetFilter));
            }

            AssetInfoCollection assetList         = ConfigurationServices.AssetInventory.GetAssets(assetAttributes);
            AssetInfoCollection filteredAssetList = assetFilter(assetList);
            _assetList = new BindingList <AssetInfo>(filteredAssetList.ToList());
            assets_GridView.DataSource = _assetList;
        }
Ejemplo n.º 24
0
        public override void ImportFileRaw(
            string path, Stream stream, int reserve, string sourceExtension,
            DateTime time, AssetAttributes attributes, byte[] cookingRulesSHA1)
        {
            OnWrite?.Invoke();
            AssetDescriptor d;
            bool            reuseExistingDescriptor = index.TryGetValue(AssetPath.CorrectSlashes(path), out d) &&
                                                      (d.AllocatedSize >= stream.Length) &&
                                                      (d.AllocatedSize <= stream.Length + reserve);

            if (reuseExistingDescriptor)
            {
                d.Length           = (int)stream.Length;
                d.ModificationTime = time;
                d.CookingRulesSHA1 = cookingRulesSHA1;
                d.Attributes       = attributes;
                d.SourceExtension  = sourceExtension;
                index[AssetPath.CorrectSlashes(path)] = d;
                this.stream.Seek(d.Offset, SeekOrigin.Begin);
                stream.CopyTo(this.stream);
                reserve = d.AllocatedSize - (int)stream.Length;
                if (reserve > 0)
                {
                    byte[] zeroBytes = new byte[reserve];
                    this.stream.Write(zeroBytes, 0, zeroBytes.Length);
                }
            }
            else
            {
                if (FileExists(path))
                {
                    DeleteFile(path);
                }
                d = new AssetDescriptor();
                d.ModificationTime = time;
                d.CookingRulesSHA1 = cookingRulesSHA1;
                d.Length           = (int)stream.Length;
                d.Offset           = indexOffset;
                d.AllocatedSize    = d.Length + reserve;
                d.Attributes       = attributes;
                d.SourceExtension  = sourceExtension;
                index[AssetPath.CorrectSlashes(path)] = d;
                indexOffset += d.AllocatedSize;
                this.stream.Seek(d.Offset, SeekOrigin.Begin);
                stream.CopyTo(this.stream);
                byte[] zeroBytes = new byte[reserve];
                this.stream.Write(zeroBytes, 0, zeroBytes.Length);
                this.stream.Flush();
            }
            wasModified = true;
        }
Ejemplo n.º 25
0
        public void StartEws(AssetAttributes deviceAttribute)
        {
            InternetExplorerDriver browser = null;

            try
            {
                CopyDriverFiles();
                try
                {
                    InternetExplorerOptions options = new InternetExplorerOptions();
                    options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                    browser = new InternetExplorerDriver(options);
                    browser.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(10));
                    browser.Manage().Window.Maximize();

                    // Check to see if there are any popups, such as the first run popup, and close them:
                    HandleSetupUpIeDialog();
                }
                catch (Exception ex)
                {
                    throw new EwsAutomationException("There was an error creating a selenium IE driver: " + ex.Message);
                }

                EwsInit(browser);
                EwsWalk(browser);
                ConfigureNetworking(browser);
                if (deviceAttribute.HasFlag(AssetAttributes.Scanner))
                {
                    ConfigureDigitalSend(browser);
                }

                By signoutLinkLocator = By.Id("EwsLogoff");
                if (ElementExists(signoutLinkLocator, browser))
                {
                    browser.FindElement(signoutLinkLocator).Click();
                }
                else
                {
                    throw new EwsAutomationException("Could not find the signout link.");
                }
            }
            finally
            {
                if (browser != null)
                {
                    browser.Quit();
                }
            }
        }
Ejemplo n.º 26
0
 public void ExportModelAnimations(Model3D model, string pathPrefix, AssetAttributes assetAttributes, byte[] cookingRulesSHA1)
 {
     foreach (var animation in model.Animations)
     {
         if (animation.IsLegacy)
         {
             continue;
         }
         var pathWithoutExt = pathPrefix + animation.Id;
         pathWithoutExt = Animation.FixAntPath(pathWithoutExt);
         var path = pathWithoutExt + ".ant";
         var data = animation.GetData();
         animation.ContentsPath = pathWithoutExt;
         InternalPersistence.Instance.WriteObjectToBundle(AssetBundle, path, data, Persistence.Format.Binary, ".ant", File.GetLastWriteTime(path), assetAttributes, cookingRulesSHA1);
         Console.WriteLine("+ " + path);
     }
 }
Ejemplo n.º 27
0
        PluginExecutionData IPluginFrameworkSimulator.CreateExecutionData(PluginConfigurationData configurationData)
        {
            if (configurationData == null)
            {
                throw new ArgumentNullException(nameof(configurationData));
            }

            PluginExecutionContext executionContext = new PluginExecutionContext
            {
                ActivityExecutionId = SequentialGuid.NewGuid(),
                SessionId           = SessionId,
                UserName            = UserName,
                UserPassword        = UserPassword
            };

            // Retrieve all selected assets, then add any badge boxes associated with those assets
            var selectedAssets = PluginConfigurationTransformer.GetExecutionAssets(configurationData, _assetInventory);
            var badgeBoxes     = GetBadgeBoxes(selectedAssets);
            AssetInfoCollection executionAssets = new AssetInfoCollection(selectedAssets.Union(badgeBoxes).ToList());

            foreach (DeviceInfo ai in selectedAssets)
            {
                string          ip = ai.Address;
                AssetAttributes aa = ai.Attributes;

                if (aa.HasFlag(AssetAttributes.Printer))
                {
                    SetPaperlessPrintMode(ai.Address, ai.AdminPassword);
                }
            }

            return(new PluginExecutionData
                   (
                       configurationData.GetMetadata(),
                       configurationData.MetadataVersion,
                       executionAssets,
                       PluginConfigurationTransformer.GetExecutionDocuments(configurationData, _documentLibrary),
                       PluginConfigurationTransformer.GetExecutionServers(configurationData, _assetInventory),
                       PluginConfigurationTransformer.GetExecutionPrintQueues(configurationData, _assetInventory),
                       (this as IPluginFrameworkSimulator).Environment,
                       executionContext,
                       new PluginRetrySettingDictionary(RetrySettings)
                   ));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AssetSelectionForm"/> class.
        /// </summary>
        /// <param name="capabilities">The capabilities.</param>
        public AssetSelectionForm(AssetAttributes capabilities)
            : this()
        {
            // Get the pools from SystemSettings
            string        poolString = GlobalSettings.Items[Setting.AssetInventoryPools];
            List <string> pools      = poolString.Split(',').ToList();

            AssetInventoryConfiguration configuration = new AssetInventoryConfiguration();

            pools.ForEach(n => configuration.AssetPools.Add(n));

            AssetInventoryController controller = new AssetInventoryController(DbConnect.AssetInventoryConnectionString, configuration);

            foreach (AssetInfo asset in controller.GetAssets(capabilities))
            {
                _assetList.Add(asset);
            }
            assets_GridView.DataSource = _assetList;
        }
Ejemplo n.º 29
0
		public static void RunNVCompress(Bitmap bitmap, AssetBundle bundle, string path, AssetAttributes attributes, DDSFormat format, bool mipMaps, byte[] CookingRulesSHA1)
		{
			bool compressed = format == DDSFormat.DXTi;
			Bitmap bledBitmap = null;
			if (bitmap.HasAlpha) {
				bledBitmap = TextureConverterUtils.BleedAlpha(bitmap);
			}
			var ddsPath = Toolbox.GetTempFilePathWithExtension(".dds");
			var tgaPath = Path.ChangeExtension(ddsPath, ".tga");
			try {
				TextureConverterUtils.SaveToTGA(bledBitmap ?? bitmap, tgaPath, swapRedAndBlue: compressed);
				if (bledBitmap != null && bledBitmap != bitmap) {
					bledBitmap.Dispose();
				}
				RunNVCompressHelper(tgaPath, ddsPath, bitmap.HasAlpha, compressed, mipMaps);
				bundle.ImportFile(ddsPath, path, 0, "", attributes, CookingRulesSHA1);
			} finally {
				DeletePossibleLockedFile(ddsPath);
				DeletePossibleLockedFile(tgaPath);
			}
		}
Ejemplo n.º 30
0
        /// <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();
        }