コード例 #1
0
        public bool Equals(AmountViewModel other)
        {
            if (!HasValue)
            {
                return(!other.HasValue);
            }

            return(Amount == other.Amount && AssetType.Equals(other.AssetType));
        }
コード例 #2
0
        /// <summary>
        /// Filters only the folder or files from the selected folder.
        /// </summary>
        public static Dictionary<string, Asset> GetSubList(Asset _asset, AssetType _assetType)
        {
            Dictionary<string, Asset> dtAssets = new Dictionary<string, Asset>();
            List<Asset> lasAssets;

            if (_assetType.Equals(AssetType.Folder))
                lasAssets = _asset.GetFolderList();
            else
                lasAssets = _asset.GetFileList();

            foreach (Asset asAsset in lasAssets)
            {
                if (!dtAssets.Keys.Contains(asAsset.BranchId.ToString()))
                    dtAssets.Add(asAsset.BranchId.ToString(), asAsset);
            }
            return dtAssets;
        }
コード例 #3
0
        /// <summary>
        /// Filters everything even subfolders from the selected folder. Key = AssetID, Value = Asset.
        /// <para>If AssetType.Unspecified is selected, it will return all folders and files.</para>
        /// </summary>
        public static List<Asset> GetFilterList(Asset _assetFolder, AssetType _assetType = AssetType.Unspecified, string _path = "", bool excludeProjectTypes = false, List<string> excludeFolders = null, IhSiteBuilderLog siteLog = null)
        {
            FilterParams fpFilter = new FilterParams();
            fpFilter.ExcludeProjectTypes = excludeProjectTypes;

            if (!_assetType.Equals(AssetType.Unspecified))
                fpFilter.Add(Comparison.Equals, _assetType);

            Dictionary<string, Asset> dtAssets = new Dictionary<string, Asset>();
            if (!string.IsNullOrWhiteSpace(_path))
            {
                if (Asset.Load(_path).IsLoaded)
                    _assetFolder = Asset.Load(_path);
            }

            List<Asset> laAssets = _assetFolder.GetFilterList(fpFilter);

            if (excludeFolders != null)
            {
                laAssets = ExcludeFolderList(laAssets, excludeFolders);
            }
            foreach (Asset asAsset in laAssets)
            {
                if (!dtAssets.Keys.Contains(asAsset.BranchId.ToString()))
                {
                    if (asAsset.Type.Equals(AssetType.Folder))
                    {
                        dtAssets.Add(asAsset.BranchId.ToString(), asAsset);
                    }
                    else if (asAsset.Type.Equals(AssetType.File))
                    {
                        if (asAsset.WorkflowStatus.Name.Equals("Live") || asAsset.WorkflowStatus.Name.Equals("Stage") || asAsset.WorkflowStatus.Name.Equals("Draft") || asAsset.WorkflowStatus.Name.Equals(""))
                        {
                            dtAssets.Add(asAsset.BranchId.ToString(), asAsset);
                        }
                    }
                }
                else
                {
                    if (asAsset.WorkflowStatus.Name.Equals("Live"))
                    {
                        dtAssets[asAsset.BranchId.ToString()] = asAsset;
                    }
                    else if (asAsset.WorkflowStatus.Name.Equals("Stage"))
                    {
                        if (!dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Live") && !dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Stage"))
                        {
                            dtAssets[asAsset.BranchId.ToString()] = asAsset;
                        }
                    }
                    else if (asAsset.WorkflowStatus.Name.Equals("Draft"))
                    {
                        if (!dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Live") && !dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Stage") && !dtAssets[asAsset.BranchId.ToString()].WorkflowStatus.Name.Equals("Draft"))
                        {
                            dtAssets[asAsset.BranchId.ToString()] = asAsset;
                        }
                    }
                }
            }
            return dtAssets.Values.ToList<Asset>();
        }
コード例 #4
0
        /// <summary>
        /// Create a file or a folder based on the path (provide full path including with file name like "/FirstFolder/SecondFolder/FileName.jpg".
        /// <para>If the folders in the middle don't exist, it will create them.</para>
        /// </summary>
        public static Asset CreateNewAsset(string _path, AssetType _assetType)
        {
            Asset asAsset = Asset.Load(_path);
            if (!asAsset.IsLoaded)
            {
                List<string> lsPath = ParsePath(_path);
                string szPath = "/";
                for (int i = 0; i < lsPath.Count; i++)
                {
                    asAsset = Asset.Load(szPath + lsPath[i]);

                    if (i + 1 == lsPath.Count && !asAsset.IsLoaded)
                    {
                        Asset asModel;
                        if (_assetType.Equals(AssetType.Folder))
                            asModel = IhSiteBuilderHelper.BaseFolderModel;
                        else
                            asModel = IhSiteBuilderHelper.BaseFileModel;

                        asAsset = Asset.CreateNewAsset(lsPath[i], Asset.Load(szPath), asModel, new Dictionary<string, string>());
                    }
                    else if (!asAsset.IsLoaded)
                        asAsset = Asset.CreateNewAsset(lsPath[i], Asset.Load(szPath), IhSiteBuilderHelper.BaseFolderModel, new Dictionary<string, string>());

                    szPath += lsPath[i] + "/";
                }
            }
            return asAsset;
        }
コード例 #5
0
        /// <summary>
        /// Creates all assets including sub-folders based on the selected asset folder. It will retrieve either all folders or files depending on the asset type selected.
        /// </summary>
        /// <param name="_asset">Root Asset Folder</param>
        /// <param name="_assetType">Choose either file or folder</param>
        private string CreateContent(Asset _asset, AssetType _assetType, string _TagName = "asset", bool includeContent = true, List<string> excludeFolders = null, bool excludeProjectTypes = false)
        {
            StringBuilder sbOutput = new StringBuilder();
            //If asset type is a folder include the root folder in XML
            if (_assetType.Equals(AssetType.Folder))
            {
                sbOutput.AppendLine(GetAssetAttributes(_asset, _TagName));

                if (includeContent)
                {
                    sbOutput.AppendLine(GetAssetContent(_asset));
                }

                sbOutput.AppendLine(string.Format("</{0}>", _TagName));
            }

            foreach (Asset asAsset in IhSiteBuilderHelper.GetFilterList(_asset, _assetType, excludeProjectTypes: excludeProjectTypes, excludeFolders: excludeFolders))
            {
                IhSiteBuilderHelper.SaveLog(dicLog, "File Name: " + asAsset.AssetPath);
                //If Asset is a binary file, it will skip
                if (_assetType.Equals(AssetType.File) && asAsset.TemplateId.Equals(0))
                {
                    BuildAsset(asAsset, sbBinary);

                    if (!liBinaryFiles.Contains(asAsset.Id))
                        liBinaryFiles.Add(asAsset.Id);
                }
                else
                {
                    BuildAsset(asAsset, sbOutput);
                    if (_assetType.Equals(AssetType.File))
                    {
                        if (IhSiteBuilderHelper.IsBinaryAttached(asAsset))
                        {
                            if (!liBinaryWrapped.Contains(asAsset.Id))
                                liBinaryWrapped.Add(asAsset.Id);
                        }
                    }
                }

                if (!liTemplates.Contains(asAsset.TemplateId) && asAsset.TemplateId > 0)
                {
                    if (!Asset.Load(asAsset.TemplateId).AssetPath.ToString().Contains("/Basis/"))
                    {
                        liTemplates.Add(asAsset.TemplateId);
                    }
                }

                if (!liModels.Contains(asAsset.ModelId) && asAsset.ModelId > 0)
                {
                    if (!Asset.Load(asAsset.ModelId).AssetPath.ToString().Contains("/Basis/"))
                    {
                        liModels.Add(asAsset.ModelId);
                    }
                }
            }
            return sbOutput.ToString();
        }