private bool Form_LoadData(object sender, object data)
        {
            _dataSource.Clear();

            var result = _accountBLL.QueryAssetUnit();

            if (result != Model.ConnectionCode.Success)
            {
                return(false);
            }

            var accounts = LoginManager.Instance.Assets;

            foreach (var account in accounts)
            {
                AssetUnit asset = new AssetUnit
                {
                    FundCode       = account.AccountCode,
                    CapitalAccount = account.CapitalAccount,
                    AssetNo        = account.AssetNo,
                    AssetName      = account.AssetName,
                };

                var fund = LoginManager.Instance.Accounts.Find(o => o.AccountCode.Equals(asset.FundCode));
                if (fund != null)
                {
                    asset.FundName     = fund.AccountName;
                    asset.EAccountType = fund.AccountType;
                }

                _dataSource.Add(asset);
            }

            return(true);
        }
Exemple #2
0
 public void InitResourceData(AssetUnit unit, Dictionary <string, AssetUnit> allunit)
 {
     if (!this.mDicResourceData.ContainsKey(unit.mName))
     {
         ResourceData data = ResourceData.Create(unit.mName, unit.mPath, unit.mAssetSize, unit.mType);
         data.mRefCount    = unit.mRefCount;
         data.mHasCheckRef = false;
         this.mDicResourceData.Add(unit.mName, data);
         List <string> deps = unit.mAllDependencies;
         foreach (var dep in deps)
         {
             //string name = BuildCommon.GetLevelABPathName(dep);
             if (allunit.ContainsKey(dep))
             {
                 AssetUnit    unit1 = allunit[dep];
                 ResourceData data1 = ResourceData.Create(unit1.mName, unit1.mPath, unit1.mAssetSize, unit1.mType);
                 data1.mRefCount    = unit1.mRefCount;
                 data1.mHasCheckRef = false;
                 if (!this.mDicResourceData.ContainsKey(unit1.mName))
                 {
                     this.mDicResourceData.Add(unit1.mName, data1);
                 }
             }
             else
             {
                 continue;
             }
         }
     }
 }
Exemple #3
0
        public async Task <IActionResult> Edit(int id, [Bind("AssetUnitId,Code,Name,CreateBy,CreateDate,UpdateBy,UpdateDate,IsActive,IsDelete")] AssetUnit assetUnit)
        {
            if (id != assetUnit.AssetUnitId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(assetUnit);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AssetUnitExists(assetUnit.AssetUnitId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(assetUnit));
        }
    public static void GetAllAssets()
    {
        //清空操作
        allLevelAssets.Clear();

        List <string> allAssetPath = new List <string>();

        //1添加场景路径

        foreach (string scene in mScenes)
        {
            allAssetPath.Add(scene);
        }

        //2添加Resource资源路径
        foreach (string resrPath in mResources)
        {
            allAssetPath.Add(resrPath);
        }

        //获取场景以及预制件中所有的资源信息
        string[] allExportAssets = AssetDatabase.GetDependencies(allAssetPath.ToArray());


        Dictionary <string, AssetUnit> allFiles = new Dictionary <string, AssetUnit>();

        foreach (string p in allExportAssets)
        {
            //if (p.Contains(".dll") || p.Contains(".cs"))
            if (p.Contains(".dll"))
            {
                continue;
            }

            AssetUnit unit = new AssetUnit(p);

            //Asset等级
            int level = unit.mLevel;

            //存在
            if (allLevelAssets.ContainsKey(level))
            {
                allLevelAssets[level].Add(p, unit);
            }
            else
            {
                //添加等级
                Dictionary <string, AssetUnit> levelAsset = new Dictionary <string, AssetUnit>();
                allLevelAssets.Add(level, levelAsset);
                //添加asset信息
                allLevelAssets[level].Add(p, unit);
            }
        }

        //创建Asset索引
        BuildAssetUnitIndex();
    }
Exemple #5
0
        public async Task <IActionResult> Create([Bind("AssetUnitId,Code,Name,CreateBy,CreateDate,UpdateBy,UpdateDate,IsActive,IsDelete")] AssetUnit assetUnit)
        {
            if (ModelState.IsValid)
            {
                _context.Add(assetUnit);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(assetUnit));
        }
    //对AssetUnit进行排序
    private static int SortAssetUnit(AssetUnit unit1, AssetUnit unit2)
    {
        int res = 0;

        if (unit1.mLevel > unit2.mLevel)
        {
            res = 1;
        }
        else if (unit1.mLevel < unit2.mLevel)
        {
            res = -1;
        }
        return(res);
    }
Exemple #7
0
 public void InitCollectDepData(AssetUnit unit)
 {
     if (!this.mDicCollectDepResourceData.ContainsKey(unit.mName))
     {
         List <string> deps = unit.mAllDependencies;
         List <string> temp = new List <string>();
         foreach (var dep in deps)
         {
             string name = BuildCommon.GetLevelABPathName(dep);
             temp.Add(name);
         }
         this.mDicCollectDepResourceData.Add(unit.mName, new CollectDepResourceData(unit.mName, temp));
     }
 }
Exemple #8
0
 public static bool isSingleDependenced(AssetUnit asset)
 {
     if (asset.mDirectUpperDependences.Count > 1)
     {
         return(false);
     }
     else if (asset.mDirectUpperDependences.Count == 1)
     {
         return(isSingleDependenced(asset.mDirectUpperDependences[0]));
     }
     else
     {
         return(true);
     }
 }
    public static void DumpVersionFile()
    {
        List <string> allFiles = new List <string>();

        BuildCommon.GetFiles(ResourceCommon.assetbundleFilePath, allFiles, true);

        XmlDocument doc  = new XmlDocument();
        XmlElement  root = doc.CreateElement("Version");

        root.SetAttribute("Number", "1.0.0");
        root.SetAttribute("Big", "false");

        foreach (string element in allFiles)
        {
            int        size         = 0;
            string     md5          = GetFileMD5(element, ref size);
            XmlElement ele          = doc.CreateElement("file");
            string     relativePath = element.Replace(Application.dataPath + "/assetbundles/", "");

            ele.SetAttribute("fpath", relativePath);
            ele.SetAttribute("size", size.ToString());
            ele.SetAttribute("md5", md5);
            root.AppendChild(ele);

            //保存大小信息到AssetUnit中
            string assetName = "Assets/" + relativePath;
            assetName = assetName.Substring(0, assetName.Length - 6);
            AssetUnit assetUnit = GetAssetUnit(assetName);
            if (assetUnit != null)
            {
                assetUnit.mAssetSize = size;
            }
        }

        doc.AppendChild(root);
        string assetBundleVersionPath = ResourceCommon.assetbundleFilePath + "Version.bytes";

        doc.Save(assetBundleVersionPath);

        //拷贝到对应的Resource目录
        string resourceVersionPath = Application.dataPath + "/Resources/" + "Version.bytes";

        File.Copy(assetBundleVersionPath, resourceVersionPath, true);

        Debug.Log("Dump Version Success!!!");
    }
    /// <summary>
    /// 初始化allLevelAssets,全部打包资源
    /// </summary>
    private static void GetAllAssets()
    {
        allLevelAssets.Clear();
        //所有资源路径
        List <string> allAssetPath = new List <string>();

        //添加场景资源路径
        foreach (var scene in mScenes)
        {
            allAssetPath.Add(scene);
        }
        //添加Resources资源路径
        foreach (var resPath in mResource)
        {
            allAssetPath.Add(resPath);
        }
        //所有需要打包的资源路径+引用路径
        string[] allExportAssets = AssetDatabase.GetDependencies(allAssetPath.ToArray());

        foreach (var asset in allExportAssets)
        {
            if (asset.Contains(".cs") || asset.Contains("dll"))
            {
                continue;
            }
            AssetUnit unit = new AssetUnit(asset);
            if (!allFiles.ContainsKey(asset))
            {
                allFiles.Add(asset, unit);
            }
            //所在层级
            int level = unit.mLevel;
            if (allLevelAssets.ContainsKey(level))
            {
                allLevelAssets[level].Add(asset, unit);
            }
            else
            {
                Dictionary <string, AssetUnit> levelAsset = new Dictionary <string, AssetUnit>();
                allLevelAssets.Add(level, levelAsset);
                allLevelAssets[level].Add(asset, unit);
            }
        }
        BuildAssetUnitIndex();
    }
    /// <summary>
    /// 根据层级创建AssetUnit的索引信息
    /// </summary>
    private static void BuildAssetUnitIndex()
    {
        if (allLevelAssets.Count == 0)
        {
            return;
        }
        int index = 0;

        for (int level = 1; level <= allLevelAssets.Count; level++)
        {
            Dictionary <string, AssetUnit> levelAssets = allLevelAssets[level];
            foreach (var pair in levelAssets)
            {
                AssetUnit unit = pair.Value;
                unit.mIndex = index;
                index++;
            }
        }
    }
    //添加asset信息
    private static void AddAssetSizeToAssetInfoFile()
    {
        //添加asset信息
        XmlDocument xmlDoc = new XmlDocument();

        xmlDoc.Load(ResourceCommon.assetbundleFilePath + "AssetInfo.bytes");

        XmlNodeList xnl = xmlDoc.SelectSingleNode("AllAssets").ChildNodes;

        for (int i = 0; i < xnl.Count; i++)
        {
            XmlElement xe        = (XmlElement)xnl.Item(i);
            string     assetName = xe.GetAttribute("name");

            //获取对应的AssetUnit
            AssetUnit unit = GetAssetUnit("Assets/" + assetName);

            xe.SetAttribute("bundlesize", unit.mAssetSize.ToString());
        }
        xmlDoc.Save(ResourceCommon.assetbundleFilePath + "AssetInfo.bytes");
    }
    //创建Asset资源信息
    public static void DumpAssetInfoFile()
    {
        if (allLevelAssets.Count == 0)
        {
            return;
        }

        ////创建所有资源Asset列表
        XmlDocument doc  = new XmlDocument();
        XmlElement  root = doc.CreateElement("AllAssets");

        //遍历所有Asset数据
        for (int level = 1; level <= allLevelAssets.Count; level++)
        {
            Dictionary <string, AssetUnit> levelAssets = allLevelAssets[level];
            foreach (KeyValuePair <string, AssetUnit> asset in levelAssets)
            {
                string    assetName = asset.Key;
                AssetUnit assetUnit = asset.Value;

                XmlElement ele = doc.CreateElement("Asset");

                //设置路径名称
                assetName = assetName.Replace("Assets/", "");
                ele.SetAttribute("name", assetName);

                //设置asset索引
                ele.SetAttribute("index", assetUnit.mIndex.ToString());

                //设置等级
                ele.SetAttribute("level", level.ToString());

                List <AssetUnit> sortDepencys = new List <AssetUnit>();
                //获取AssetUnit所有依赖,并排序
                List <string> depencys = assetUnit.mAllDependencies;
                foreach (string depency in depencys)
                {
                    AssetUnit depencyUnit = GetAssetUnit(depency);
                    sortDepencys.Add(depencyUnit);
                }

                //排序
                sortDepencys.Sort(SortAssetUnit);
                //保存依赖索引
                string depencystr = "";
                for (int i = 0; i < sortDepencys.Count; i++)
                {
                    AssetUnit unit = sortDepencys[i];

                    if (i != sortDepencys.Count - 1)
                    {
                        depencystr += unit.mIndex + ",";
                    }
                    else
                    {
                        depencystr += unit.mIndex;
                    }
                }
                ele.SetAttribute("depency", depencystr.ToString());

                root.AppendChild(ele);
            }
        }

        doc.AppendChild(root);
        BuildCommon.CheckFolder(BuildCommon.getPath(ResourceCommon.assetbundleFilePath));
        doc.Save(ResourceCommon.assetbundleFilePath + "AssetInfo.bytes");

        Debug.Log("CreateAssetInfo success!!!");
    }