コード例 #1
0
 public void Show()
 {
     if (!isTitleSet)
     {
         CommonLog.Error("Not Set Title");
         return;
     }
     else if (!isMessageSet)
     {
         CommonLog.Error("Not Set Message");
         return;
     }
     else if (!isPositiveButtonSet)
     {
         CommonLog.Error("Not Set PositiveButton");
         return;
     }
     else if (!isNegativeButtonSet)
     {
         CommonLog.Error("Not Set NegativeButton");
         return;
     }
     else if (!isCreated)
     {
         CommonLog.Error("Create AlertDialog Failure");
         return;
     }
     builder.Call("show");
 }
コード例 #2
0
        public IActionResult Delete(int orderID, int page = 1, string sort = "")
        {
            Order delRec;

            try
            {
                delRec = repository.Delete(orderID);
            }
            catch (Exception e)
            {
                TempData["message"] = $"Ошибка удаления: {e.Message} {e.InnerException.Message}";
                return(RedirectToAction("Index", new { page, sort }));
            }

            if (delRec != null)
            {
                TempData["message"] = $"Запись № \"{delRec.Number}\" успешно удалена!";
                CommonLog log = new CommonLog()
                {
                    Action     = "Orders",
                    ActionID   = orderID,
                    ActionDate = DateTime.Now,
                    UserDesc   = User.Identity.Name,
                    TxtMsg     = "Удаление",
                    _UID       = Guid.NewGuid()
                };
                logRepository.Save(log);
            }


            return(RedirectToAction("Index", new { page, sort }));
        }
コード例 #3
0
        /// <summary>
        /// 释放未使用的Bundle
        /// </summary>
        public void SafeDisposeAll()
        {
            _StrListHelper.Clear();
            CommonLog.Log(MAuthor.HSQ, $"共有bundle{_abCache.Count}个");
            //先统一清理依赖, 避免出现
            foreach (var abikv in _abCache)
            {
                abikv.Value.ClearDependentsIfUnused();
            }

            foreach (var abikv in _abCache)
            {
                //Log.E("销毁:{0},Asset:{1}",abikv.Key,abikv.Value.data.assetsInfo[0].assetFullName);
                var success = abikv.Value.SafeDispose();
                //被移除的加入
                if (success)
                {
                    _StrListHelper.Add(abikv.Key);
                }
            }

            foreach (var str in _StrListHelper)
            {
                RemoveBundleCache(str);
            }

            CommonLog.Log(MAuthor.HSQ, $"本次一共销毁了{_StrListHelper.Count}个,目前剩余{_abCache.Count}个bundle");
            // foreach (var abikv in _abCache)
            // {
            //     CommonLog.Log(MAuthor.HSQ, $"剩余:{abikv.Key},Asset:{abikv.Value.data.assetsInfo[0].assetFullName}");
            // }
        }
コード例 #4
0
        private IEnumerator DownloadSingleFile(SingleFileDownloadRequest sr)
        {
            FileUtils.DeleteFile(sr.targetPath);

            var request = UnityWebRequest.Get(sr.url);

            request.downloadHandler = new DownloadHandlerFile(sr.targetPath);
            yield return(request.SendWebRequest());

            var(errorType, errorMsg) = CheckWebRequestError(sr, request);
            request.Dispose();

            if (errorType != WebRequestError.None)
            {
                CommonLog.Error(MAuthor.WY, errorMsg);
                var displayError = errorType == WebRequestError.Raw ? errorMsg : $"错误码:10{(int) errorType}";
                var mb           = MessageBox.Show("提示", $"获取服务器文件{Path.GetFileName(sr.url)} 失败 {displayError}", "重试", "退出");
                yield return(mb);

                if (mb.isOk)
                {
                    StartUpdate();
                }
                else
                {
                    Quit();
                }

                sr.success = false;
                yield break;
            }

            sr.success = true;
        }
コード例 #5
0
        private void ShowAndroidUpdateDialog(string appUpdateUrl)
        {
            CommonLog.Log(MAuthor.ZX, "Open Android Update Dialog");
            AndroidJavaClass  unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
            AndroidJavaObject activity    = unityPlayer.GetStatic <AndroidJavaObject>("currentActivity");

            AndroidAlertDialog alertDialog = new AndroidAlertDialog(activity);

            alertDialog.SetTitle("游戏版本检测");
            alertDialog.SetMessage("检测到有新的游戏版本,是否更新?");
            alertDialog.SetPositiveButton("是", new AlertDialogClickListener((dialog, which) =>
            {
                //跳转App更新界面
                Application.OpenURL(appUpdateUrl);
                //强制退出
                Application.Quit();
            }));
            alertDialog.SetNegativeButton("否", new AlertDialogClickListener((dialog, which) =>
            {
                //强制退出
                Application.Quit();
            }));
            alertDialog.Create();
            alertDialog.Show();
        }
コード例 #6
0
 public static void SaveToPersistAssetFile(string SavedDir, string fileName, byte[] rawData)
 {
     if (rawData == null)
     {
         return;
     }
     //保存结果为文件
     try
     {
         {
             string tempName = new Guid().ToString() + ".download";
             var    pathRoot = GetPersistAssetFilePath(SavedDir, "");
             //删了旧文件
             FileUtils.DeleteFile(pathRoot + fileName);
             //写到临时文件
             FileUtils.WriteAllBytes(pathRoot + tempName, rawData);
             //写完改名字
             FileUtils.RenameFile(pathRoot, tempName, fileName);
         }
     }
     catch (Exception e)
     {
         CommonLog.Error("Save File Dir:{0} Name:{1} failure .Reason:{2}", SavedDir, fileName, e);
     }
 }
コード例 #7
0
    private void RespCallback(IAsyncResult result)
    {
        var myRequestState = result.AsyncState as RequestState;

        try
        {
            var myHttpWebRequest = myRequestState.request;
            myRequestState.response = (HttpWebResponse)myHttpWebRequest.EndGetResponse(result);

            if (myRequestState.response.StatusCode != HttpStatusCode.OK &&
                myRequestState.response.StatusCode != HttpStatusCode.PartialContent)
            {
                CommonLog.Error(
                    $"{myRequestState.fileInfo.FileName} StatusCode : {myRequestState.response.StatusCode}");
            }

            var responseStream = myRequestState.response.GetResponseStream();
            myRequestState.streamResponse = responseStream;
            responseStream.BeginRead(myRequestState.BufferRead, 0, BUFFER_SIZE, ReadCallBack, myRequestState);
        }
        catch (Exception ex)
        {
            myRequestState.m_file_stream?.Close();
            CommonLog.Error(MAuthor.WY, $"download {myRequestState.fileInfo.FileName} resp exception {ex.Message}");
            myRequestState.progress.SetException(ex, WWWFileDownloader.eWWWErrorType.WriteFileError);
            myRequestState.allDone.Set();
        }
    }
コード例 #8
0
        /**
         * 读取两个字节的整形
         **/
        public short ReadShort()
        {
            if (!IsReadable)
            {
#if UNITY_EDITOR
                CommonLog.Error("这个是不可读的对象");
#endif
            }
            else
            {
                if (readerIndex + 1 < writerIndex)
                {
                    int h   = data[readerIndex++];
                    int l   = data[readerIndex++] & 0x000000ff;
                    int len = ((h << 8) & 0x0000ff00) | (l);
                    return((short)len);
                }
                else
                {
#if UNITY_EDITOR
                    CommonLog.Error("这个是不合法的数据");
#endif
                }
            }
            return(0);
        }
コード例 #9
0
        /**
         *  读取4个字节的float
         **/
        public float ReadFloat()
        {
            if (!IsReadable)
            {
#if UNITY_EDITOR
                CommonLog.Error("这个是不可读的对象");
#endif
            }
            else
            {
                if (readerIndex + 3 < writerIndex)
                {
                    int intbs = ReadInt();
                    var res   = Int32BitsToSingle(intbs);
                    return(res);
                }
                else
                {
#if UNITY_EDITOR
                    CommonLog.Error("这个是不合法的数据");
#endif
                }
            }
            return(0f);
        }
コード例 #10
0
        /**
         * 读取八字节整形
         **/
        public long ReadLong()
        {
            if (!IsReadable)
            {
#if UNITY_EDITOR
                CommonLog.Error("这个是不可读的对象");
#endif
            }
            else
            {
                if (readerIndex + 7 < writerIndex)
                {
                    unchecked
                    {
                        ulong ret = ((((ulong)data[readerIndex++]) << 56) & 0xff00000000000000);
                        ret |= (((ulong)(data[readerIndex++]) << 48) & 0x00ff000000000000);
                        ret |= (((ulong)(data[readerIndex++]) << 40) & 0x0000ff0000000000);
                        ret |= (((ulong)(data[readerIndex++]) << 32) & 0x000000ff00000000);
                        ret |= (((ulong)(data[readerIndex++]) << 24) & 0x00000000ff000000);
                        ret |= (((ulong)(data[readerIndex++]) << 16) & 0x0000000000ff0000);
                        ret |= (((ulong)(data[readerIndex++]) << 8) & 0x000000000000ff00);
                        ret |= (((ulong)(data[readerIndex++])) & 0x00000000000000ff);
                        return((long)ret);
                    }
                }
                else
                {
#if UNITY_EDITOR
                    CommonLog.Error("这个是不合法的数据");
#endif
                }
            }
            return(0);
        }
コード例 #11
0
        /**
         * 读取四字节整形
         **/
        public uint ReadUInt()
        {
            if (!IsReadable)
            {
#if UNITY_EDITOR
                CommonLog.Error("这个是不可读的对象");
#endif
            }
            else
            {
                if (readerIndex + 3 < writerIndex)
                {
                    unchecked
                    {
                        uint ret = (uint)(((data[readerIndex++]) << 24) & 0xff000000);
                        ret |= (uint)(((data[readerIndex++]) << 16) & 0x00ff0000);
                        ret |= (uint)(((data[readerIndex++]) << 8) & 0x0000ff00);
                        ret |= (uint)(((data[readerIndex++])) & 0x000000ff);
                        return(ret);
                    }
                }
                else
                {
#if UNITY_EDITOR
                    CommonLog.Error("这个是不合法的数据");
#endif
                }
            }
            return(0u);
        }
コード例 #12
0
        /**
         * 读取N个字节
         **/
        public byte[] ReadBytes(int len)
        {
            if (!IsReadable)
            {
#if UNITY_EDITOR
                CommonLog.Error("这个是不可读的对象");
#endif
            }
            else
            {
                if (len > 0 && readerIndex + len - 1 < writerIndex)
                {
                    byte[] data = new byte[len];
                    for (int i = 0; i < len; i++)
                    {
                        data[i] = ReadByte();
                    }
                    return(data);
                }
                else
                {
#if UNITY_EDITOR
                    CommonLog.Error("这个是不合法的数据");
#endif
                }
            }
            return(new byte[0]);
        }
コード例 #13
0
        /**
         * 写入一部分字节
         **/
        public ByteBuf WriteBytes(ByteBuf src)
        {
            if (!IsWriteable)
            {
#if UNITY_EDITOR
                CommonLog.Error("这个是不可写的对象");
#endif
                return(this);
            }
            short sum = (short)(src.writerIndex - src.readerIndex);
            if (sum >= 0)
            {
                Capacity(writerIndex + sum + 2);

                WriteShort(sum);
                if (sum > 0)
                {
                    Array.Copy(src.data, src.readerIndex, data, writerIndex, sum);
                    writerIndex     += sum;
                    src.readerIndex += sum;
                }
            }
            else
            {
#if UNITY_EDITOR
                CommonLog.Error("写入对象过长");
#endif
            }
            return(this);
        }
コード例 #14
0
    //[MenuItem("Tools/SetDefineTest", false, 10)]
    //public static void SetDefineTest()
    //{
    //    SetDefineSymbols(BuildTargetGroup.Standalone, "");
    //}

    public static void SetDefineSymbols(BuildTargetGroup target, string defines)
    {
        //OS.System参数中含有分号;会被截断成多条指令
        defines = defines.Replace("#", ";");
        CommonLog.Log($"SetDeinfeSymbols={defines}");
        PlayerSettings.SetScriptingDefineSymbolsForGroup(target, defines);
    }
コード例 #15
0
ファイル: AutoPacker.cs プロジェクト: wuyin1985/TestAB
    private static string GetBuildSettingArgStr(string argName, string searchSource)
    {
        var strArray = searchSource.Split(',');

        for (int i = 0; i < strArray.Length; i++)
        {
            if (strArray[i].Contains(argName))
            {
                int shBgn = strArray[i].IndexOf("=") + 1;
                int shEnd = strArray[i].IndexOf("]");
                if (shBgn > -1 && shEnd > -1 && shEnd > shBgn)
                {
                    var rtn = strArray[i].Substring(shBgn, shEnd - shBgn);
                    CommonLog.Log($"get build setting argument {argName} = {rtn}");
                    return(rtn);
                }
                else
                {
                    CommonLog.Error($"get build setting argument {argName} failed!");
                }
            }
        }

        return(string.Empty);
    }
コード例 #16
0
        public void DoStop()
        {
            if (Stop)
            {
                return;
            }
            Stop    = true;
            Running = false;
            if (addedUpdateListener)
            {
                TimerTaskManager.Instance.RemoveUpdateTimer(this);
            }
            addedUpdateListener = false;
            //调用下一个
            if (NextFun != null)
            {
                try
                {
#if DEBUG_PERFORMANCE_TRACE
                    Profiler.BeginSample(stackInfoNextFun);
#endif
                    NextFun();
#if DEBUG_PERFORMANCE_TRACE
                    Profiler.EndSample();
#endif
                }
                catch (Exception e)
                {
                    //TimerLogger.Error(e.ToString());
                    CommonLog.Error(e.ToString());
                }
            }
        }
コード例 #17
0
ファイル: AutoPacker.cs プロジェクト: wuyin1985/TestAB
    public static void ExportXcode()
    {
        //拷贝资源
        //-EditorToolUtils.InstallGameAssets();
        //生成版本配置文件
        //-GameAssetManager.GenerateVersionCfg(buildParameter.AppVersion, buildParameter.VersionCfg);

        SetIOSSettings();

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

        foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
        {
            if (!scene.enabled)
            {
                continue;
            }
            levels.Add(scene.path);
        }

        //string subDirName = string.Format($"{DateTime.Now.Year}-{DateTime.Now.Month}-{DateTime.Now.Day}-{DateTime.Now.Hour}-{DateTime.Now.Minute}");
        var exportPath = string.Format($"{Application.dataPath}{ExportPath}");

        if (!Directory.Exists(exportPath))
        {
            Directory.CreateDirectory(exportPath);
        }

        var exportFile   = exportPath + ExportName;
        var buildOptions = GenBuildOptions();

        CommonLog.Log($"ExportPath={exportFile}");
        BuildPipeline.BuildPlayer(levels.ToArray(), exportFile, BuildTarget.iOS, buildOptions);
    }
コード例 #18
0
ファイル: AutoPacker.cs プロジェクト: wuyin1985/TestAB
    public static void ExportAndroid()
    {
        //拷贝资源
        //-EditorToolUtils.InstallGameAssets();
        //生成版本配置文件
        //-GameAssetManager.GenerateVersionCfg(buildParameter.AppVersion, buildParameter.VersionCfg);

        SetAndroidSettings();

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

        foreach (EditorBuildSettingsScene scene in EditorBuildSettings.scenes)
        {
            if (!scene.enabled)
            {
                continue;
            }
            levels.Add(scene.path);
        }
        //var exportPath = string.Format($"{Application.dataPath}{ExportPath}");

        //if (!Directory.Exists(exportPath))
        //    Directory.CreateDirectory(exportPath);
        var exportApk = ExportPath + ExportName;

        var buildOptions = GenBuildOptions();

        CommonLog.Log($"ExportPath={exportApk}");
        BuildPipeline.BuildPlayer(levels.ToArray(), exportApk, BuildTarget.Android, buildOptions);
    }
コード例 #19
0
        //根据打包后的Manifest刷新XML
        public void RefreshXMLTableByManifest(AssetBundleManifest manifest)
        {
            HashSet <string> bundleHash = new HashSet <string>();

            foreach (var t in XMLTable.BundleInfos)
            {
                var defaultBundleName = t.GetBundleNameWithLangExtension(eAssetLanguageVarType.Default);
                var dependences       = manifest.GetAllDependencies(defaultBundleName);
                t.dependenceBundleName = new string[dependences.Length];
                for (int i = 0; i < dependences.Length; i++)
                {
                    t.dependenceBundleName[i] = AssetI8NHelper.GetBundleNameWithOutLangStr(dependences[i]);
                }
                var hash = manifest.GetAssetBundleHash(defaultBundleName);
                if (bundleHash.Contains(hash.ToString()))
                {
                    //fileHash重名的,打印出来,并且使用bundleName来合并,避免冲突
                    t.bundleFileName = defaultBundleName + "_" + hash.ToString();
                    CommonLog.Error(string.Format("卧槽,有bundleFileHash冲突,bundle信息为,bundleName:{0},bundleHash:{1},asset:{2}"
                                                  , defaultBundleName, hash.ToString(), t.assets[0].resPath));
                }
                else
                {
                    bundleHash.Add(defaultBundleName);
                    t.bundleFileName = defaultBundleName;
                }
            }
        }
コード例 #20
0
        private T ParseAcsResponse <T>(AcsRequest <T> request, HttpResponse httpResponse) where T : AcsResponse
        {
            CommonLog.LogInfo(request, httpResponse, CommonLog.ExecuteTime);
            var format = httpResponse.ContentType;

            if (httpResponse.isSuccess())
            {
                return(ReadResponse(request, httpResponse, format));
            }

            try
            {
                var error = ReadError(request, httpResponse, format);
                if (null != error.ErrorCode)
                {
                    if (500 <= httpResponse.Status)
                    {
                        throw new ServerException(error.ErrorCode,
                                                  string.Format("{0}, the request url is {1}, the RequestId is {2}.", error.ErrorMessage,
                                                                httpResponse.Url ?? "empty", error.RequestId));
                    }

                    if (400 == httpResponse.Status && (error.ErrorCode.Equals("SignatureDoesNotMatch") ||
                                                       error.ErrorCode.Equals("IncompleteSignature")))
                    {
                        var errorMessage = error.ErrorMessage;
                        var re           = new Regex(@"string to sign is:", RegexOptions.Compiled | RegexOptions.IgnoreCase);
                        var matches      = re.Match(errorMessage);

                        if (matches.Success)
                        {
                            var errorStringToSign = errorMessage.Substring(matches.Index + matches.Length);

                            if (request.StringToSign.Equals(errorStringToSign))
                            {
                                throw new ClientException("SDK.InvalidAccessKeySecret",
                                                          "Specified Access Key Secret is not valid.", error.RequestId);
                            }
                        }
                    }

                    throw new ClientException(error.ErrorCode, error.ErrorMessage, error.RequestId);
                }
            }
            catch (ServerException ex)
            {
                CommonLog.LogException(ex, ex.ErrorCode, ex.ErrorMessage);
                throw new ServerException(ex.ErrorCode, ex.ErrorMessage, ex.RequestId);
            }
            catch (ClientException ex)
            {
                CommonLog.LogException(ex, ex.ErrorCode, ex.ErrorMessage);
                throw new ClientException(ex.ErrorCode, ex.ErrorMessage, ex.RequestId);
            }

            var t = Activator.CreateInstance <T>();

            t.HttpResponse = httpResponse;
            return(t);
        }
コード例 #21
0
        protected virtual void RunCallBack()
        {
            if (_runner != null)
            {
#if DEBUG_PERFORMANCE_TRACE
                Profiler.BeginSample(stackInfo);
#endif
                _runner.Run();
#if DEBUG_PERFORMANCE_TRACE
                Profiler.EndSample();
#endif
            }
            else if (_fun != null)
            {
                try
                {
#if DEBUG_PERFORMANCE_TRACE
                    Profiler.BeginSample(stackInfo);
#endif
                    _fun();
#if DEBUG_PERFORMANCE_TRACE
                    Profiler.EndSample();
#endif
                }
                catch (Exception e)
                {
                    //TimerLogger.Error(e.ToString());
                    CommonLog.Error(e.ToString());
                }
            }
            else
            {
                DoStop();
            }
        }
コード例 #22
0
        /// <summary>
        /// 设置调用CallBack后的回调,可以更容易实现调用链,Loop的话每次都会调用,如果Timer已经结束了,会立刻调用
        /// </summary>
        public void DoAfterTimer(System.Action f
#if DEBUG_PERFORMANCE_TRACE
                                 , string memberName    = null
                                 , string path          = null
                                 , int sourceLineNumber = default(int)
#endif
                                 )
        {
#if DEBUG_PERFORMANCE_TRACE
            stackInfoNextFun = $"DoAffterTimer {path} : {memberName}:Line({sourceLineNumber})";
#endif
            NextFun = f;
            if (Stop)
            {
                try
                {
#if DEBUG_PERFORMANCE_TRACE
                    Profiler.BeginSample(stackInfoNextFun);
#endif
                    NextFun();
#if DEBUG_PERFORMANCE_TRACE
                    Profiler.EndSample();
#endif
                }
                catch (Exception e)
                {
                    //TimerLogger.Error(e.ToString());
                    CommonLog.Error(e.ToString());
                }
            }
        }
コード例 #23
0
 public void SetError(Exception ex, string sInfo = "")
 {
     this.Code    = Enumeration.HttpStatusCode.ServerError;
     this.Error   = ex.Message;
     this.Success = false;
     CommonLog.CommonErrorLog(ex, sInfo);
 }
コード例 #24
0
ファイル: FileMapSystem.cs プロジェクト: wuyin1985/TestAB
        /// <summary>
        /// 删除非当前版本使用的资源
        /// </summary>
        public void DeleteAllOldFile()
        {
            try
            {
                var allDirFiles = UnityPersistFileHelper.GetPersistAssetFileList(Dir, "*" + FileMapInfo.FileExtension);
                var needFiles   = new List <string>(FileInfo.AllFileMapInfo.Length);
                for (int i = 0; i < FileInfo.AllFileMapInfo.Length; i++)
                {
                    needFiles.Add(FileInfo.AllFileMapInfo[i].GetMappedFileName());
                }

                var allNeedDelFiles = new List <string>();
                foreach (var file in allDirFiles)
                {
                    if (!needFiles.Contains(file))
                    {
                        allNeedDelFiles.Add(file);
                    }
                }

                if (allNeedDelFiles.Count > 0)
                {
                    UnityPersistFileHelper.DeletePersistAssetFileList(Dir, allNeedDelFiles);
                }
            }
            catch (Exception e)
            {
                CommonLog.Error(e);
            }
        }
コード例 #25
0
        /// <summary>
        /// 初始化加载配置
        /// </summary>
        public void LoadAssetBundleConfig()
        {
            try
            {
                if (GameAssetManager.USED_AB_MODE)
                {
                    if (FileMapperMode)
                    {
                        ////初始化FileMaper
                        FileMapper.InitFromLocalFile();
                        LoadFileMapperConfig();
                        CommonLog.Log("初始化AB系统配置结束:FileMode");
                    }
                    else
                    {
                        //默认先加载下载的bundle信息文件
                        LoadStreamingConfig();
                        CommonLog.Warning("初始化AB系统配置结束:ABMode");
                    }
                }
            }
            catch (Exception e)
            {
                CommonLog.Error(e);
            }

            //Log.W("当前配置文件版本为{0}", version);
        }
コード例 #26
0
        /// <summary>
        /// 无论啥错误都会返回一个默认的
        /// </summary>
        /// <param name="cfgBytes"></param>
        /// <returns></returns>
        public static FileMapGroupInfo ReadFromByteBuf(byte[] cfgBytes)
        {
            var group   = new FileMapGroupInfo();
            var byteBuf = ByteBuf.CreateFromBytes(cfgBytes);

            group.MD51 = byteBuf.ReadLong();
            group.MD52 = byteBuf.ReadLong();
            group.Ver  = new Version()
            {
                Version_Major = byteBuf.ReadInt(),
                Version_Minor = byteBuf.ReadInt(),
                Version_Build = byteBuf.ReadInt(),
            };
            var readedMd5 = MD5Creater.MD5Struct.CreateFromLong(group.MD51, group.MD52);
            var fileMD5   = MD5Creater.GenerateMd5Code(cfgBytes, 16);

            if (!readedMd5.Equals(fileMD5))
            {
                CommonLog.Error("MD5校验不通过!");
                return(null);
            }

            int FileNum = byteBuf.ReadInt();

            group.AllFileMapInfo = new FileMapInfo[FileNum];
            for (int i = 0; i < group.AllFileMapInfo.Length; i++)
            {
                group.AllFileMapInfo[i] = FileMapInfo.ReadFromByteBuf(byteBuf);
            }

            return(group);
        }
コード例 #27
0
    private bool InitConfig(string config)
    {
        /// norm log
        RegisterNormModuleLogByName("login", "rolebuild", "rolelogin", "logout",
                                    "PVEfight", "gettask", "finishtask", "acquire",
                                    "customacquire", "moneycost", "customcost",
                                    "getitem", "removeitem", "heart", "levelup",
                                    "newstages", "activity", "partner", "pvp",
                                    "arena", "serverevent", "recharge", "shoptrade",
                                    "equiprefit", "corps", "roundtrip", "skilllevelup",
                                    "bladesoul", "talent", "talentstat", "artifact",
                                    "formation", "consignment");
        /// logic log
        RegisterLogicModuleLogByName("gm");
        /// common log
        m_DicLogs.Clear();
        XmlDocument xmldoc = new XmlDocument();

        xmldoc.Load(config);
        XmlNodeList list = xmldoc.SelectNodes("LOGS");

        foreach (XmlNode nd in list)
        {
            XmlNodeList ls = nd.SelectNodes("item");
            foreach (XmlNode node in ls)
            {
                XmlNode    id      = node.SelectSingleNode("id");
                XmlElement element = (XmlElement)id;
                int        logid   = Convert.ToInt32(element.InnerText);
                XmlNode    name    = node.SelectSingleNode("name");
                element = (XmlElement)name;
                string  logname = element.InnerText;
                XmlNode type    = node.SelectSingleNode("type");
                element = (XmlElement)type;
                int     ntype     = Convert.ToInt32(element.InnerText);
                XmlNode cache     = node.SelectSingleNode("cache");
                int     cachesize = 4 * 1024 * 1024;
                if (cache != null)
                {
                    element   = (XmlElement)cache;
                    cachesize = Convert.ToInt32(element.InnerText);
                }
                CommonLog log = new CommonLog(logid, logname, cachesize);
                log.m_Type = ntype;
                m_DicLogs.Add(logid, log);
            }
        }
        if (m_DicLogs.Count <= 0)
        {
            return(false);
        }
        m_IsRun  = true;
        m_Thread = new Thread(new ThreadStart(FlushAll));
        if (m_Thread != null)
        {
            m_Thread.Start();
        }
        return(true);
    }
コード例 #28
0
ファイル: GameAssetManager.cs プロジェクト: wuyin1985/TestAB
    /// <summary>
    /// PS,即便不存在,也能返回Asset,只是内容为空
    /// </summary>
    /// <param name="pathAndassetName">路径大小写敏感</param>
    /// <param name="assetType"></param>
    /// <param name="warning">如果不存在,是否Log</param>
    /// <returns></returns>
    public Asset LoadAsset(string pathAndassetName, eAssetType assetType, bool warning = true)
    {
        pathAndassetName = CheckAssetPath(pathAndassetName);

#if UNITY_EDITOR
        if (!Application.isPlaying)
        {
            CommonLog.Error("非运行模式下,请勿调用AssetManager");
            return(null);
        }

        if (pathAndassetName.Contains(@"\"))
        {
            CommonLog.Error("路径{0}格式错误,请使用/替换\\", pathAndassetName);
            return(null);
        }
#endif

        string bundlePath = this.GetBundlePath(pathAndassetName, assetType);
        Asset  asset      = this.CheckAssetInDicCache(assetType, bundlePath);
        if (asset != null)
        {
            if (asset.IsDone)
            {
                //asset.OnAssetLoaded_CallbackOnce = null;
                //if (asset.IsFromBundle)
                //{
                //    //if (asset.checkAssetIn(pathAndassetName) == false)
                //    {
                //        var loader = AssetBundleManager.Instance.GetBundleInfoByResName(asset.AssetName);
                //        var val = loader.LoadByName(AssetBundleManager.Instance.GetAssetInBundleName(asset.AssetName),
                //            asset.getValueType(assetType));
                //        this.SetLoadAssetValue(asset, val, warning);
                //        //asset.addAssetIn(pathAndassetName, val);
                //    }
                //else
                //{
                //    var val1 = asset.allAssets[pathAndassetName];
                //    this.SetLoadAssetValue(asset, val1, warning);
                //}
                //}
                return(asset);
            }
            this.LoadAssetFromResources(asset, warning, assetType);
            return(asset);
        }
        else
        {
            string bundlename   = null;
            bool   isFromBundle = AssetBundleManager.Instance.CheckIsInBundle(pathAndassetName, out bundlename);
            asset = new Asset(pathAndassetName, assetType, bundlePath, isFromBundle);
            this.LoadAssetFromResources(asset, warning, assetType);
            this.AddAssetData(bundlePath, assetType, asset);
            return(asset);
        }
    }
コード例 #29
0
        /// <summary>
        /// 添加日志消息
        /// </summary>
        /// <param name="message">消息内容</param>
        /// <param name="exp">异常</param>
        public void Write(string message, Exception exp)
        {
            var log = new CommonLog {
                Exp = exp, Message = message ?? exp.Message.Replace("\r\n", "")
            };

            log.RecordExecuteMethod();
            //写入日志
            Add(log);
        }
コード例 #30
0
        //解析配表
        private bool ParseBundleConfig(string cfgStr)
        {
            try
            {
                var table = cfgStr.FromXML <AssetBundleTable>();
                if (table != null)
                {
                    _table = table;
                    _abNameToData.Clear();
                    _resPathTofullAssetPathData.Clear();
                    _resNameToBundleName.Clear();

                    //将XML配置转换到系统内置信息
                    foreach (var x in table.BundleInfos)
                    {
                        var xbundleMD5Name = x.bundleNameMD5Struct.GetMD5Str(!x.isComplexName);
                        if (!_abNameToData.TryGetValue(xbundleMD5Name, out var abd))
                        {
                            abd = new AssetBundleData
                            {
                                bundleName      = xbundleMD5Name,
                                bundleFileName  = x.bundleFileName,
                                bundleHashName  = x.bundleNameMD5Struct,
                                dependency      = x.dependenceBundleName ?? new string[0],
                                assetsInfo      = new AssetBundleAssetData[x.assets.Length],
                                bundleLanguages = x.bundleLanguages
                            };


                            for (var i = 0; i < x.assets.Length; i++)
                            {
                                var ass = new AssetBundleAssetData
                                {
                                    resPath       = x.assets[i].resPath,
                                    assetFullName = x.assets[i].assetFullName
                                };
                                abd.assetsInfo[i] = ass;

                                _resPathTofullAssetPathData[ass.resPath] = ass.assetFullName;
                                _resNameToBundleName[ass.resPath]        = xbundleMD5Name;
                            }

                            _abNameToData[abd.bundleName] = abd;
                        }
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                CommonLog.Error(e);
                return(false);
            }
        }
コード例 #31
0
 private bool InitConfig(string config)
 {
     /// norm log
     RegisterNormModuleLogByName("login", "rolebuild", "rolelogin", "logout",
                             "PVEfight", "gettask", "finishtask", "acquire",
                             "customacquire", "moneycost", "customcost",
                             "getitem", "removeitem", "heart", "levelup",
                             "newstages", "activity", "partner", "pvp",
                             "arena", "serverevent", "recharge", "shoptrade",
                             "equiprefit", "corps", "roundtrip", "skilllevelup",
                             "bladesoul", "talent", "talentstat", "artifact",
                             "formation", "consignment");
     /// logic log
     RegisterLogicModuleLogByName("gm");
     /// common log
     m_DicLogs.Clear();
     XmlDocument xmldoc = new XmlDocument();
     xmldoc.Load(config);
     XmlNodeList list = xmldoc.SelectNodes("LOGS");
     foreach (XmlNode nd in list) {
       XmlNodeList ls = nd.SelectNodes("item");
       foreach (XmlNode node in ls) {
     XmlNode id = node.SelectSingleNode("id");
     XmlElement element = (XmlElement)id;
     int logid = Convert.ToInt32(element.InnerText);
     XmlNode name = node.SelectSingleNode("name");
     element = (XmlElement)name;
     string logname = element.InnerText;
     XmlNode type = node.SelectSingleNode("type");
     element = (XmlElement)type;
     int ntype = Convert.ToInt32(element.InnerText);
     XmlNode cache = node.SelectSingleNode("cache");
     int cachesize = 4 * 1024 * 1024;
     if (cache != null) {
       element = (XmlElement)cache;
       cachesize = Convert.ToInt32(element.InnerText);
     }
     CommonLog log = new CommonLog(logid, logname, cachesize);
     log.m_Type = ntype;
     m_DicLogs.Add(logid, log);
       }
     }
     if (m_DicLogs.Count <= 0)
       return false;
     m_IsRun = true;
     m_Thread = new Thread(new ThreadStart(FlushAll));
     if (m_Thread != null) {
       m_Thread.Start();
     }
     return true;
 }