Example #1
0
        public List <AssetModel> ZipEntriesToAssetList(List <string> entries,
                                                       ProviderProductModel providerProduct)
        {
            List <AssetModel> assets = new List <AssetModel>();

            foreach (var entry in entries)
            {
                assets.Add(new AssetModel()
                {
                    ProviderProduct = providerProduct,
                    BluePrintPath   = entry.ConvertToForwardSlashes().RemoveFileType()
                });
            }
            return(assets);
        }
        internal ProviderProductModel ToProviderProduct(String fullName, Int32 prefixLength)
        {
            String[] parts = fullName.Substring(prefixLength).Split('\\');
            if (parts.Length != 3)
            {
                throw new ArgumentOutOfRangeException($"Filename format not correct {fullName}");
            }
            var output = new ProviderProductModel()
            {
                Provider = parts[0],
                Product  = parts[1]
            };

            output.Pack = Path.GetFileNameWithoutExtension(parts[2]);
            return(output);
        }
 public static List<RouteAssetsModel> GetBluePrintsFromXML(RouteModel route, XDocument Doc)
   {
   List<RouteAssetsModel> output = new List<RouteAssetsModel>();
   try
     {
     var ElementList =
       (IEnumerable) Doc.XPathEvaluate("//iBlueprintLibrary-cAbsoluteBlueprintID");
     foreach (XElement BluePrintNode in ElementList)
       {
       // ReSharper disable once UseDeconstruction
       var result = GetBluePrintDetails(BluePrintNode);
       if (string.IsNullOrEmpty(result.BluePrint)==false)
         {
         var providerProduct = new ProviderProductModel
           {
           Provider = result.Provider,
           Product = result.Product
           };
         var asset = new AssetModel
           {
           ProviderProduct = providerProduct,
           BluePrintPath = result.BluePrint
           };
         var routeAsset = new RouteAssetsModel()
           {
           Route = route,
           Asset = asset
           };
         output.Add(routeAsset);
         }
       }
     return output.DistinctBy(x => x.Asset.AssetPath).ToList();
     }
   catch (Exception e)
     {
     Log.Trace("Failed to obtain blueprint details", e, LogEventType.Error);
     throw;
     }
   }
        /// <summary>
        /// Reads the provider product from directory.
        /// </summary>
        /// <param name="productDirectory">The product directory.</param>
        /// <param name="providerName">Name of the provider.</param>
        /// <returns>ProviderProductModel.</returns>
        public ProviderProductModel ReadProviderProductFromDirectory(DirectoryInfo productDirectory, string providerName)
        {
            ProviderProductModel providerProduct = new ProviderProductModel()
            {
                Provider = providerName,
                Product  = productDirectory.Name
            };
            var packs = productDirectory.GetFiles("*.ap", SearchOption.TopDirectoryOnly);

            if (packs.Length == 0)
            {
                providerProduct.Pack = "";
            }
            else
            {
                providerProduct.Pack = Path.GetFileNameWithoutExtension(packs[0].Name);
            }
            if (packs.Length > 1)
            {
                Log.Trace($"SaveAllProviderProducts warning duplicate .ap file found");
            }
            return(providerProduct);
        }
Example #5
0
        public List <AssetModel> ReadAllAssetsFromDirectory(DirectoryInfo providerProductDir, ProviderProductModel providerProduct, int pathLength)
        {
            try
            {
                FileInfo[] bluePrintFiles =
                    providerProductDir.GetFiles("*.bin", SearchOption.AllDirectories);

                List <AssetModel> assets = new List <AssetModel>();

                foreach (FileInfo bluePrintFile in bluePrintFiles)
                {
                    String bluePrintPath = bluePrintFile.FullName.Substring(pathLength + 1);
                    assets.Add(new AssetModel()
                    {
                        ProviderProduct = providerProduct,
                        BluePrintPath   = bluePrintPath
                    });
                }
                return(assets);
            }
            catch (Exception e)
            {
                Log.Trace($"Failed to read asset files from directory {providerProductDir}", e, LogEventType.Error);
                throw;
            }
        }
Example #6
0
 public Boolean Remove(ProviderProductModel providerProduct)
 {
     throw new NotImplementedException();
     return(false);
 }