Exemple #1
0
    private static XmlElement GetElement(XmlDocument xmlDoc, SaasAir serverFileInfo)
    {
        string      id          = serverFileInfo.Id;
        string      name        = serverFileInfo.Name;
        string      remark      = serverFileInfo.Remark;
        string      versionName = serverFileInfo.VersionNum;
        SaasAirType airType     = serverFileInfo.AirType;
        string      filePath    = serverFileInfo.FilePath;
        string      bundle      = serverFileInfo.Bundle;
        string      manifest    = serverFileInfo.Manifest;
        XmlElement  record      = xmlDoc.CreateElement("record");

        record.SetAttribute("id", id.ToString());
        record.SetAttribute("name", name);
        record.SetAttribute("remark", remark);
        record.SetAttribute("versionName", versionName);
        record.SetAttribute("filePath", filePath);
        record.SetAttribute("bundle", bundle);
        record.SetAttribute("manifest", manifest);
        XmlElement element = xmlDoc.CreateElement("airType");

        element.SetAttribute("id", airType.Id.ToString());
        element.SetAttribute("name", airType.Name);
        record.AppendChild(element);
        return(record);
    }
Exemple #2
0
    private string getUUID(string name)
    {
        SaasAir air = null;

        if (saasAir != null)
        {
            air = saasAir.Find(p => p.Name.Equals(name));
        }
        return(air == null ? null : air.Manifest);
    }
Exemple #3
0
    private void saveFile(string file, Action <string> callBack)
    {
        //Debug.Log("aaa===  " + file);
        string serverPath = serverFileMap[file].Bundle;

        //Debug.Log("bbb===  " + serverPath);

        ServerAssetManager.Instace.getFile(Tips.SERVER_FILE_PATH + serverPath, file, (string pathId, byte[] bytes) =>
        {
            if (bytes == null)
            {
                Debug.LogError("读取文件失败  :  " + pathId);
                return;
            }
            SaasAir serverInfo = serverFileMap[file];

            string localPath = Tips.LOCAL_FILE_PATH + serverInfo.FilePath;
            //Debug.Log(localPath);
            //Debug.Log(bytes.Length);
            LocalAssetManager.Instace.saveFile(localPath, bytes);


            if (localFileMap.ContainsKey(pathId))
            {
                //Debug.Log("c111cc===  " + pathId);
                //AssetFileInfo localInfo = localFileMap[pathId];
                ////localInfo.nameId = updateFile;
                //localInfo.version = serverInfo.version;
                ////localInfo.path = serverInfo.path;
                //localInfo.fileType = serverInfo.fileType;
                //localInfo.isLoad = serverInfo.isLoad;
            }
            else
            {
                //Debug.Log("c222cc===  " + pathId);
                //AssetFileInfo localInfo = new AssetFileInfo();
                //localInfo.nameId = pathId;
                //localInfo.version = serverInfo.version;
                //localInfo.path = localPath;
                //localInfo.fileType = serverInfo.fileType;
                //localInfo.isLoad = serverInfo.isLoad;

                //localFileMap.Add(pathId, localInfo);
            }

            if (callBack != null)
            {
                callBack(pathId);
            }
        });
    }
Exemple #4
0
    private Dictionary <string, SaasAir> analyzeFileInfo(SecurityElement xml)
    {
        Dictionary <string, SaasAir> map = new Dictionary <string, SaasAir>();

        foreach (SecurityElement item in xml.Children)
        {
            SaasAir info = new SaasAir(item.Attribute("id"), item.Attribute("name"), item.Attribute("remark"), item.Attribute("versionName"), item.Attribute("filePath"),
                                       item.Attribute("bundle"), item.Attribute("manifest"), new SaasAirType(item));

            map.Add(info.Name, info);
        }

        return(null);
    }
    private void initLocalResInfoFile()
    {
        int loadedCount = 0;

        getServerFileList(() =>
        {
            foreach (var key in serverFileMap.Keys)
            {
                if (!serverFileMap.ContainsKey(key))
                {
                    loadedCount += 1;
                    continue;
                }

                SaasAir serverFileInfo = serverFileMap[key];
            }
        });
    }
Exemple #6
0
    private Dictionary <string, SaasAir> analyzeFileInfo(string text)
    {
        Dictionary <string, SaasAir> map = new Dictionary <string, SaasAir>();

        JsonData data = JsonConvert.DeserializeObject <JsonData>(text);

        foreach (var item in data.data)
        {
            //去掉配置文件的存储
            if (item.Name.Equals(Tips.BOOTSTRAP_NAME))
            {
                continue;
            }
            SaasAir info = item;
            map.Add(info.Name, info);
        }

        return(map);
    }
Exemple #7
0
    private void getServerFileList(Action callBack)
    {
        //获取ResInfo内容
        foreach (var item in saasAir)
        {
            //去掉配置文件的存储
            if (item.Name.Equals(Tips.BOOTSTRAP_NAME))
            {
                continue;
            }
            SaasAir info = item;
            serverFileMap.Add(info.Name, info);
        }

        callBack();
        //ServerAssetManager.Instace.getFile(Tips.SERVER_FILE_PATH, (string text) =>
        //{
        //    serverFileMap = analyzeFileInfo(text);

        //    callBack();

        //}, onError);
    }
Exemple #8
0
    //本地没有此文件,则认为此文件包含的所有文件均不存在
    //复制文件到本地
    private void initLocalBootstrapFile()
    {
        int loadedCount = 0;

        getServerFileList(() =>
        {
            //StringBuilder fileListBuffer = new StringBuilder();
            XmlDocument xmlDoc = new XmlDocument();
            XmlElement root    = xmlDoc.CreateElement("root");
            xmlDoc.AppendChild(root);
            foreach (var file in serverFileMap)
            {
                SaasAir serverFileInfo = file.Value;
                //Debug.Log(serverFileInfo.path);
                ServerAssetManager.Instace.getFile(Tips.SERVER_FILE_PATH + serverFileInfo.FilePath + serverFileInfo.Bundle, serverFileInfo.Name, (string fileName, byte[] bytes) =>
                {
                    loadedCount += 1;
                    //Debug.LogError(fileName);
                    SaasAir localFileInfo = serverFileMap[fileName];
                    //将下载的资源文件保存在本地
                    LocalAssetManager.Instace.saveFile(Tips.LOCAL_FILE_PATH + localFileInfo.FilePath, bytes);
                    localFileInfo.FilePath = Tips.LOCAL_FILE_PATH + localFileInfo.FilePath;

                    //fileListBuffer.AppendLine(localFileInfo.getCsvText());
                    XmlElement record = GetElement(xmlDoc, serverFileInfo);
                    root.AppendChild(record);
                });
            }
            saveBootstrap();
            xmlDoc.Save(Tips.LOCAL_RESINFO_PATH);
            if (_completeFunc != null)
            {
                _completeFunc();
            }
        });
    }