コード例 #1
0
        public int GetObjectCount(JToken token, int rowNr)
        {
            string select      = "";
            string query       = "";
            int    objectCount = 0;
            string parentName  = (string)token["DataName"];

            _currentItem = _idxData.Find(x => x.DataName == parentName);
            if (string.IsNullOrEmpty(_currentItem.ParentKey))
            {
                select = _currentItem.Select;
                if (!String.IsNullOrEmpty(select))
                {
                    _currentItem.DataTable = _dbConn.GetDataTable(select, query);
                }
                objectCount = _currentItem.DataTable.Rows.Count;
            }
            else
            {
                //DataRow pr = _parentItem.DataTable.Rows[rowNr];
                //string query = GetParentKey(pr, _currentItem.ParentKey);
                //DataRow[] childRows = _currentItem.DataTable.Select(query);
                //objectCount = childRows.Length;
            }
            return(objectCount);
        }
コード例 #2
0
        private IndexFileData GetIndexData(JToken token)
        {
            string        dataName    = (string)token["DataName"];
            IndexFileData indexObject = _idxData.Find(x => x.DataName == dataName);

            return(indexObject);
        }
コード例 #3
0
 private void PopulateChildIndex(JToken level, int parentId, int parentNodeId)
 {
     if (level["DataObjects"] != null)
     {
         foreach (JToken subLevel in level["DataObjects"])
         {
             _parentItem  = GetIndexData(level);
             _currentItem = GetIndexData(subLevel);
             int nodeId = CreateChildNodeIndex(subLevel, parentId, parentNodeId);
             if (nodeId > 0)
             {
                 int     childCount = _currentItem.DataTable.Rows.Count;
                 DataRow pr         = _parentItem.DataTable.Rows[parentId];
                 //string query = GetParentKey(pr, _currentItem.ParentKey);
                 //    DataRow[] childRows = _currentItem.DataTable.Select(query);
                 for (int i = 0; i < childCount; i++)
                 {
                     _parentItem  = GetIndexData(level);
                     _currentItem = GetIndexData(subLevel);
                     _location    = GetIndexLocation(pr);
                     int levelId = PopulateIndexItem(_currentItem.DataTable.Rows[i], nodeId);
                     PopulateChildIndex(subLevel, i, levelId);
                 }
             }
         }
     }
 }
コード例 #4
0
        private async Task <bool> CreateChildNodeIndex(JToken token, int parentId, string parentNodeId)
        {
            bool          childNode = false;
            DataRow       pr        = _parentItem.DataTable.Rows[parentId];
            string        dataName  = (string)token["DataName"];
            IndexFileData childItem = _idxData.Find(x => x.DataName == dataName);
            string        nodeName  = dataName + "s";

            if (string.IsNullOrEmpty(childItem.ParentKey))
            {
            }
            else
            {
                string query = GetParentKey(pr, childItem.ParentKey);
                query = " where " + query;
                string select = dataAccessDefs.GetSelectString(childItem.DataName);
                await GetDataForIndexing(select, query, childItem.DataName);

                if (_currentItem.DataTable.Rows.Count > 0)
                {
                    childNode = true;
                    myIndex.Add(new IndexData {
                        DataName = nodeName, DataType = nodeName, IndexNode = parentNodeId, QcLocation = null
                    });
                }
            }
            return(childNode);
        }
コード例 #5
0
    public static void ExportFile(UnityEditor.BuildTarget target, string copyto)
    {
        string platform   = AssetBundleCtrl_Windows.GetPlatformName(target);
        string file       = System.IO.Path.Combine(Application.dataPath, "AssetBundle/" + platform);
        var    updatalist = file + "/VersionNum/VersionUpdateList.bytes";

        if (File.Exists(updatalist) == false)
        {
            EditorUtility.DisplayDialog("", updatalist + " 不存在,\n请生成 增量包文件!(第二个按钮)", "OK");
            return;
        }

        var data = IndexFileData.Create(File.ReadAllBytes(updatalist));

        copyto += ("/" + platform);

        if (Directory.Exists(copyto))
        {
            Directory.Delete(copyto, true);
        }
        Directory.CreateDirectory(copyto);

        //拷贝版本描述文件
        File.Copy(Path.Combine(file, "VersionNum/VersionHash.xml"), Path.Combine(copyto, "VersionHash.xml"), true);
        File.Copy(Path.Combine(file, "VersionNum/VersionUpdateList.bytes"), Path.Combine(copyto, "VersionUpdateList.bytes"), true);

        foreach (var d in data.dataMap)
        {
            File.Copy(Path.Combine(file, d.Value.path), Path.Combine(copyto, d.Value.path), true);
        }
    }
コード例 #6
0
 private async Task PopulateChildIndex(JToken level, int parentId, string parentNodeId)
 {
     if (level["DataObjects"] != null)
     {
         int nodeId = 1;
         foreach (JToken subLevel in level["DataObjects"])
         {
             _parentItem  = GetIndexData(level);
             _currentItem = GetIndexData(subLevel);
             string childNodeId = parentNodeId + $"{nodeId}/";
             if (await CreateChildNodeIndex(subLevel, parentId, childNodeId))
             {
                 nodeId++;
                 int     childCount = _currentItem.DataTable.Rows.Count;
                 DataRow pr         = _parentItem.DataTable.Rows[parentId];
                 for (int i = 0; i < childCount; i++)
                 {
                     _parentItem  = GetIndexData(level);
                     _currentItem = GetIndexData(subLevel);
                     _location    = GetIndexLocation(pr);
                     string indexNode = childNodeId + $"{i + 1}/";
                     PopulateIndexItem(_currentItem.DataTable.Rows[i], indexNode);
                     await PopulateChildIndex(subLevel, i, indexNode);
                 }
             }
         }
     }
 }
コード例 #7
0
    public static void Execute(UnityEditor.BuildTarget target)
    {
        string platform       = AssetBundleCtrl_Windows.GetPlatformName(target);
        string newVersionHash = System.IO.Path.Combine(Application.dataPath, "AssetBundle/" + platform + "/VersionNum/VersionHash.xml");
        string oldVersionHash = System.IO.Path.Combine(Application.dataPath, "AssetBundle/" + platform + "/VersionNum/VersionHash-old.xml");


        SortedList <string, AssetInfo> dicNewHashInfo = CreateHashList.ReadHashFile(newVersionHash);
        SortedList <string, AssetInfo> dicOldHashInfo = new SortedList <string, AssetInfo>();

        if (File.Exists(oldVersionHash))
        {
            dicOldHashInfo = CreateHashList.ReadHashFile(oldVersionHash);
        }


        string versionUpdateFile = System.IO.Path.Combine(Application.dataPath, "AssetBundle/" + platform + "/VersionNum/VersionUpdateList.bytes");

        IndexFileData data = new IndexFileData();

        data.mVersion = "0.01";
        foreach (KeyValuePair <string, AssetInfo> newPair in dicNewHashInfo)
        {
            if (string.Compare(newPair.Key, "AllResources") == 0)
            {
                continue;
            }

            if (dicOldHashInfo.ContainsKey(newPair.Key))
            {
                if (newPair.Value.hash128 != dicOldHashInfo[newPair.Key].hash128)
                {
                    data.dataMap[newPair.Value.fileName] = new IndexData()
                    {
                        path = newPair.Value.fileName, hash = newPair.Value.hash128
                    };
                }
            }
            else
            {
                data.dataMap[newPair.Value.fileName] = new IndexData()
                {
                    path = newPair.Value.fileName, hash = newPair.Value.hash128
                };
            }
        }

        //增加AssetbundleManifest
        data.dataMap["AllResources"] = new IndexData()
        {
            path = "AllResources", hash = "nohash"
        };
        File.WriteAllText(versionUpdateFile, data.ToString());

        AssetDatabase.Refresh();
    }
コード例 #8
0
        private IndexFileData GetIndexFileData(string dataType)
        {
            IndexFileData        indexdata = new IndexFileData();
            IndexRootJson        rootJson  = GetIndexRootData();
            string               taxonomy  = rootJson.Taxonomy;
            List <IndexFileData> idxData   = GetIndexArray(taxonomy);

            indexdata = idxData.FirstOrDefault(s => s.DataName == dataType);
            return(indexdata);
        }
コード例 #9
0
        public void PopulateIndex(int topId, int parentId, int parentNodeId)
        {
            JToken level = JsonIndexArray[topId];

            _currentItem = GetIndexData(level);
            GetDataForIndexing(_currentItem.Select, "");
            DataRow dataRow = _currentItem.DataTable.Rows[parentId];

            _location = GetIndexLocation(dataRow);
            int levelId = PopulateIndexItem(dataRow, parentNodeId);

            PopulateChildIndex(level, parentId, levelId);
        }
コード例 #10
0
    /// <summary>
    /// 根据服务端列表创建资源下载队列
    /// </summary>
    /// <param name="httppath"></param>
    /// <param name="indexdata"></param>
    /// <param name="processCallback"></param>
    private void CreateCurVersionResTaskQue(string httppath, byte[] indexdata, Action <float, string, bool> processCallback)
    {
        var data = IndexFileData.Create(indexdata);

        foreach (var d in data.dataMap.Values)
        {
            resDownloadTaskQue.Enqueue(HttpMgr.Task.Create(httppath + "/" + GetPlatformName() + "/" + d.path, null, (HttpMgr.Task task, WWW w) =>
            {
                Debug.Log("下载资源:" + task.url);
                if (w.error != null)    //判断是不是发生异常
                {
                    //写入
                    if (Directory.Exists(mLocalHotUpdateResPath) == false)
                    {
                        Directory.CreateDirectory(mLocalHotUpdateResPath);
                    }
                    //
                    string path = Path.Combine(mLocalHotUpdateResPath, Path.GetFileName(task.url));
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }

                    File.WriteAllBytes(path, w.bytes);

                    //继续当前版本下载任务
                    if (resDownloadTaskQue.Count > 0)
                    {
                        var _task = resDownloadTaskQue.Dequeue();
                        HttpMgr.Instance.GetLayer((uint)HttpLayer.HotUpdate).QueueTask(_task);
                    }

                    else     //当前任务全部下载完
                    {
                        //开始下一个版本
                        DoNextVersionTask(processCallback);
                    }
                }
                else
                {
                    processCallback(-1, "网络出错:" + w.error, false);
                    Debug.LogError(w.error);
                    return;
                }
            }));
        }
    }
コード例 #11
0
        private static IndexFileData ProcessJTokens(JToken token)
        {
            IndexFileData idxDataObject = new IndexFileData();

            idxDataObject.DataName           = (string)token["DataName"];
            idxDataObject.NameAttribute      = token["NameAttribute"]?.ToString();
            idxDataObject.Select             = token["Select"]?.ToString();
            idxDataObject.LatitudeAttribute  = token["LatitudeAttribute"]?.ToString();
            idxDataObject.LongitudeAttribute = token["LongitudeAttribute"]?.ToString();
            idxDataObject.Keys      = token["Keys"]?.ToString();
            idxDataObject.ParentKey = token["ParentKey"]?.ToString();
            if (token["UseParentLocation"] != null)
            {
                idxDataObject.UseParentLocation = (Boolean)token["UseParentLocation"];
            }
            return(idxDataObject);
        }
コード例 #12
0
        public async Task PopulateIndex(int topId, int parentId, string parentNodeId)
        {
            try
            {
                JToken level = JsonIndexArray[topId];
                _currentItem = GetIndexData(level);
                string select = dataAccessDefs.GetSelectString(_currentItem.DataName);
                await GetDataForIndexing(select, "", _currentItem.DataName);

                DataRow dataRow = _currentItem.DataTable.Rows[parentId];
                _location    = GetIndexLocation(dataRow);
                parentNodeId = parentNodeId + $"{parentId + 1}/";
                PopulateIndexItem(dataRow, parentNodeId);
                await PopulateChildIndex(level, parentId, parentNodeId);
            }
            catch (Exception ex)
            {
                throw new System.Exception($"Error in PopulateIndex: {ex.ToString()}");
            }
        }
コード例 #13
0
        private void InsertMissingObjectToIndex(PredictionResult result)
        {
            IndexFileData indexdata = GetIndexFileData(result.DataType);

            if (indexdata.DataName != null)
            {
                JObject       dataObject    = JObject.Parse(result.DataObject);
                string        dataName      = dataObject[indexdata.NameAttribute].ToString();
                string        dataType      = result.DataType;
                DataAccessDef dataAccessDef = _accessDefs.First(x => x.DataType == dataType);
                string        dataKey       = GetDataKey(dataObject, dataAccessDef.Keys);
                int           parentId      = result.IndexId;
                string        jsonData      = result.DataObject;
                double        latitude      = -99999.0;
                double        longitude     = -99999.0;
                int           nodeId        = GeIndextNode(dataType, parentId);
                if (nodeId > 0)
                {
                    _dbConn.InsertIndex(nodeId, dataName, dataType, dataKey, jsonData, latitude, longitude);
                }
            }
        }
コード例 #14
0
        private int CreateChildNodeIndex(JToken token, int parentId, int parentNodeId)
        {
            int           childNodeId = 0;
            DataRow       pr          = _parentItem.DataTable.Rows[parentId];
            string        dataName    = (string)token["DataName"];
            IndexFileData childItem   = _idxData.Find(x => x.DataName == dataName);
            string        nodeName    = dataName + "s";

            if (string.IsNullOrEmpty(childItem.ParentKey))
            {
            }
            else
            {
                string query = GetParentKey(pr, childItem.ParentKey);
                query = " where " + query;
                GetDataForIndexing(childItem.Select, query);
                if (_currentItem.DataTable.Rows.Count > 0)
                {
                    childNodeId = _dbConn.InsertIndex(parentNodeId, nodeName, nodeName, "", "", 0.0, 0.0);
                }
            }
            return(childNodeId);
        }
コード例 #15
0
        public async Task <int> GetObjectCount(JToken token, int rowNr, string filter)
        {
            string select = "";
            string query  = "";

            if (!string.IsNullOrEmpty(filter))
            {
                query = " " + filter;
            }
            int    objectCount = 0;
            string parentName  = (string)token["DataName"];

            _currentItem = _idxData.Find(x => x.DataName == parentName);
            if (string.IsNullOrEmpty(_currentItem.ParentKey))
            {
                select = dataAccessDefs.GetSelectString(_currentItem.DataName);
                if (!String.IsNullOrEmpty(select))
                {
                    _currentItem.DataTable = await sourceAccess.GetDataTable(select, query, _currentItem.DataName);
                }
                objectCount = _currentItem.DataTable.Rows.Count;
            }
            return(objectCount);
        }