
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CEFSharpWpf;
using Com.FirmLib.Bll;
using Com.FirmLib.Entity;
using Com.FirmLib.UI.Common;
using Com.FirmLib.UI.Common.Model;
using FWindSoft.DataFramework;

namespace Com.FirmLib.UI.BllCommon
{
    public static class AssetShowItemUtils
    {
        /// <summary>
        /// 获取漏掉的类型信息
        /// </summary>
        /// <param name="assetItems"></param>
        /// <param name="containsTypeIds"></param>
        /// <returns></returns>
        public static List<ProductTypeShowItem> GetLossTypes(List<AssetShowItem> assetItems,List<string> containsTypeIds)
        {
            List<ProductTypeShowItem> items = new List<ProductTypeShowItem>();
            var containItems = containsTypeIds;
            var assets =assetItems ?? new List<AssetShowItem>();
            foreach (var asset in assets)
            {
                if (string.IsNullOrEmpty(asset.TypeId))
                {
                    continue;
                }

                if (containItems.Any(c => c == asset.TypeId))
                {
                    continue;
                }
                if (items.Any(c => c.ProductTypeId == asset.TypeId))
                {
                    continue;
                }
                items.Add(asset.ConverterTypeShowItemByAsset());
            }
            return items;
        }

        /// <summary>
        /// 显示资产详情
        /// </summary>
        /// <param name="item"></param>
        public static void ShowAssetDetail(AssetShowItem item)
        {
            AssetItem parItem = new AssetItem();
            parItem.Id = item.Id;
            parItem.ProjectId = item.ProjectId;
            parItem.FamilyCode = item.FamilyCode;
            string url = BllFactory<AssetBll>.Instance.GetAssetUrl(parItem);
            WinBrowser.Instance.Show(url, "资产信息");
        }
    }
}
