Exemple #1
0
        /// <summary>
        /// 加载文件到内存,返回文件信息
        /// </summary>
        /// <param name="_strFilePath">文件路径</param>
        /// <param name="_cb">回调</param>
        public void OnLoadLocalRes(string _strFilePath, Action <IResourceNode> _cb)
        {
            IResourceNode rNode = null;

            rNode = new LocalResourceNode(_strFilePath);
            rNode.LoadResource(resp =>
            {
                _cb(resp);
            }, (er, resp) =>
            {
                Debug.LogError(resp);
            });
        }
Exemple #2
0
        /// <summary>
        /// 排队上传
        /// </summary>
        private void UpdateToServer(Action _cb, Action <string> _eCb)
        {
            if (m_qUpdate.Count > 0)
            {
                LocalResourceNode fileNode = m_qUpdate.Dequeue() as LocalResourceNode;
                string            fileName = fileNode.GetName();
                string            fileCrc  = fileNode.GetCrc();

                string strName = fileName;
                int    nIndex  = strName.LastIndexOf('.');
                if (nIndex > 0 && nIndex < strName.Length - 1)
                {
                    strName = strName.Substring(strName.LastIndexOf('.') + 1);
                }
                else
                {
                    strName = "ErrorType";
                }

                HttpService.UploadFile(fileName, fileCrc, null, fileNode.GetResource() as byte[], strName, () =>
                {
                    PopWaiting();
                    UpdateToServer(_cb, _eCb);
                }, (errorType, errorInfo) =>
                {
                    PopWaiting();

                    string strEr = string.Format("资源:{0},上传错误:{1}", fileName, errorInfo);

                    string strKey = fileNode.GetCrc() + fileNode.GetName();
                    if (key_rNode.ContainsKey(strKey))
                    {
                        IResourceNode rNode = key_rNode[strKey];
                        if (!m_pErrorNode.Contains(rNode))
                        {
                            m_pErrorNode.Add(rNode);
                        }
                    }

                    _eCb(strEr);

                    UpdateToServer(_cb, _eCb);
                }); // End Http

                Debug.Log(string.Format("余下:{0}", m_qUpdate.Count));
            }
            else
            {
                // 弹框提示上传失败,点击重新上传
                if (m_pErrorNode.Count > 0)
                {
                    string strTips = string.Format("资源上传失败个数:{0} /n点击【确定】按钮,失败重传!", m_pErrorNode.Count);
                    LogicUtils.Instance.OnAlert(strTips, () => {
                        m_qUpdate = new Queue <IResourceNode>(m_pErrorNode);
                        UpdateToServer(_cb, _eCb);
                    });
                }
                else
                {
                    LogicUtils.Instance.OnAlert("资源上传完成!");
                    _cb();
                }
            }
        }