private void ReplaceLocalRes(string fileName, byte[] data) { string filePath = LOCAL_RES_PATH + fileName; FileStream stream = new FileStream(filePath, FileMode.Create); stream.Write(data, 0, data.Length); stream.Flush(); stream.Close(); //如果是更新包 if (fileName == LGameConfig.UPDATE_FILE_ZIP) { LUtil.UnpackFiles(filePath, LOCAL_RES_PATH); File.Delete(filePath); } }
static void CreateZipFile() { string srcPath = Application.streamingAssetsPath + Path.DirectorySeparatorChar; string outPath = ExportConfigWindow.EXPORT_OUT_PATH + Path.DirectorySeparatorChar; forEachHandle(srcPath, "meta", (string filename) => { File.Delete(@filename); }); if (!Directory.Exists(srcPath)) { Directory.CreateDirectory(srcPath); } LUtil.PackFiles(outPath + LGameConfig.UPDATE_FILE_ZIP, srcPath); Debug.Log(" 热更zip包: " + outPath + LGameConfig.UPDATE_FILE_ZIP); }
static public int AESDecrypt_s(IntPtr l) { try { System.Byte[] a1; checkArray(l, 1, out a1); System.String a2; checkType(l, 2, out a2); System.String a3; checkType(l, 3, out a3); var ret = LUtil.AESDecrypt(a1, a2, a3); pushValue(l, true); pushValue(l, ret); return(2); } catch (Exception e) { return(error(l, e)); } }
/** * Call a lua method. * * @param ref LuaFunction cResFunc - The result of the function, if the lua function calls ok, if it is not null, will call it instead of look up from table by strFunc. * @param string strFunc - The function name. * @param object cParam1 - The first param. * @param object cParam2 - The second param. * @param object cParam3 - The third param. * @return object - The number of result. */ public object CallMethod(ref LuaFunction cResFunc, string strFunc, object cParam1, object cParam2, object cParam3) { // Check function first. if (null == cResFunc) { // Check params. if (string.IsNullOrEmpty(strFunc)) { return(null); } // Check table. if (!Valid) { return(null); } // Check function. object cFuncObj = m_cLuaTable[strFunc]; if ((null == cFuncObj) || !(cFuncObj is LuaFunction)) { return(null); } // Get function. cResFunc = (LuaFunction)cFuncObj; if (null == cResFunc) { return(null); } } // Try to call this method. try { return(cResFunc.call(cParam1, cParam2, cParam3)); } catch (Exception e) { Debug.LogError(LUtil.FormatException(e)); cResFunc = null; return(null); } }
public void parseRichDefaultString(string content, UnityAction <string, Dictionary <string, string> > specHandleFunc = null) { parseRichElemString(content, (flag, param) => { if (flag == "lab") { this.insertElement( param.ContainsKey("txt") ? param["txt"] : "", LUtil.StringToColor(param.ContainsKey("color") ? param["color"] : defaultLabColor), param.ContainsKey("size") ? System.Convert.ToInt32(param["size"]) : defaultLabSize, param.ContainsKey("isUnderLine") ? System.Convert.ToBoolean(param["isUnderLine"]) : false, param.ContainsKey("isOutLine") ? System.Convert.ToBoolean(param["isOutLine"]) : false, LUtil.StringToColor(param.ContainsKey("outLineColor") ? param["outLineColor"] : "#000000"), param.ContainsKey("data") ? param["data"] : "" ); } else if (flag == "img") { this.insertElement( param.ContainsKey("path") ? param["path"] : "", param.ContainsKey("data") ? param["data"] : ""); } else if (flag == "anim") { this.insertElement(param["path"], param.ContainsKey("fps") ? System.Convert.ToSingle(param["fps"]) : 15f, param.ContainsKey("data") ? param["data"] : ""); } else if (flag == "newline") { this.insertElement(1); } else { if (specHandleFunc != null) { specHandleFunc.Invoke(flag, param); } } }); this.reloadData(); }
/** * Create a lua class instance for monobehavior instead of do a file. * * @param string strFile - The lua class name. * @return bool - true if success, otherwise false. */ public bool CreateClassInstance(string strClassName) { if (string.IsNullOrEmpty(strClassName)) { return(false); } // Try to get global lua class. try { // Get class first. LuaTable cClsTable = (LuaTable)Game.GetLuaSvr().luaState[strClassName]; if (null == cClsTable) { return(false); } // Get "new" method of the lua class to create instance. LuaFunction cNew = (LuaFunction)cClsTable["new"]; if (null == cNew) { return(false); } // We choose no default init parameter for constructor. object cInsChunk = cNew.call(); if (null == cInsChunk) { return(false); } // If we create instance ok, use it as table. m_cLuaTableOpt = new LLuaTable((LuaTable)cInsChunk); return(true); } catch (System.Exception e) { Debug.LogError(LUtil.FormatException(e)); } return(false); }
/// <summary> /// Logins the specified signature. /// </summary> /// <param name="Signature">The signature.</param> /// <param name="ToController">To controller.</param> /// <param name="ToAction">To action.</param> /// <param name="id">The identifier.</param> /// <returns>ActionResult.</returns> public ActionResult Login(string Signature, string ToController, string ToAction, string id) { try { OAuth oauth = new OAuth(CivetHelper.AppID); OAuth.UserInfo uInfo = oauth.FastGetUserInfo(Request); //判斷用戶權限並給UserInfo賦值(存入Session) if (uInfo == null) { return(Redirect(Url.Action("AlertInfo", "Home", new { ErrMsg = LUtil.Lang(HttpContext, "无账号信息") }))); } #region 添加管理员信息 if (uInfo != null) { if (!string.IsNullOrEmpty(uInfo.civetno)) { MongoCollection <ModUApiManager> uapimanager = mongoh.GetDb().GetCollection <ModUApiManager>("uapi_managers"); ModUApiManager modeuap = uapimanager.Find(Query.And( Query.EQ("_id", new BsonString(uInfo.civetno.ToUpper())), Query.EQ("is_disabled", new BsonBoolean(false)) )).FirstOrDefault(); if (modeuap != null) { if (modeuap.last_login_time < DateTime.Now.AddMinutes(-2)) { uapimanager.Update((Query.EQ("_id", new BsonString(uInfo.civetno.ToUpper()))), Update.Set("last_login_time", DateTime.Now)); } UtilComm.UApi_Manager = modeuap; //if (!modeuap.is_disabled) //{ // return Redirect(Url.Action("AlertInfo", "Home", new { ErrMsg = LUtil.Lang(HttpContext, "无权限") })); //} } else { return(Redirect(Url.Action("AlertInfo", "Home", new { ErrMsg = LUtil.Lang(HttpContext, "无账号信息") }))); } Managelog(uInfo.civetno.ToUpper()); } } #endregion base.UserInfo = new ModUserInfo { BaseInfo = uInfo }; string url = string.IsNullOrEmpty(id) ? Url.Action(ToAction, ToController) : Url.Action(ToAction, ToController, new { id = id }); string QueryString = HtmlUtil.DealQuery(Request.QueryString.ToString(), "code", "id"); if (QueryString != "") { url += "?" + QueryString; } //完善登錄操作 return(Redirect(url)); } catch (Exception) { return(Redirect(Url.Action("AlertInfo", "Home", new { ErrMsg = LUtil.Lang(HttpContext, "数据读取异常") }))); } }