void TestDiffMatchPatch() { var s1 = @"//. using Au; using Au.Types; using System; using System.Collections.Generic; class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;; var s=""one""; "; var s2 = @"/*/ role exeProgram; outputPath %AFolders.Workspace%\bin; console true; /*/ //. using Au; using Au.Types; using System; using System.Collections.Generic; using My.NS1; //ąčę îôû using My.NS2; class Script : AScript { [STAThread] static void Main(string[] a) => new Script(a); Script(string[] args) { //;;; var i=2; "; var dmp = new diff_match_patch(); List <Diff> diff = dmp.diff_main(s1, s2, true); dmp.diff_cleanupSemantic(diff); var delta = dmp.diff_toDelta(diff); AOutput.Write(delta); AOutput.Write("----"); var d2 = dmp.diff_fromDelta(s1, delta); //AOutput.Write(d2); AOutput.Write(dmp.diff_text2(d2)); }
protected void Application_BeginRequest(object sender, EventArgs e) { string hPath = Request.Url.LocalPath.ToString().ToLower(); if (!hPath.Contains(".asmx")) { foreach (var p in ConfigurationManager.AppSettings.AllKeys) { if (!p.StartsWith("/")) { continue; } if (!hPath.Contains(p)) { continue; } Context.RewritePath(hPath.Replace(p, ConfigurationManager.AppSettings[p])); break; } //Context.RewritePath(hPath.Replace("/validate", "/Enter.asmx/validate")); } AOutput.Log(""); AOutput.Log("URL:" + Request.RawUrl); AOutput.Log("FORM:" + Request.Form.ToString()); AOutput.Log("IP:" + Request.UserHostAddress); AOutput.Log("USER:"******""); }
private void InitRemoteConfig() { SetJindu("正在检查本地资源版本,请稍候"); AOutput.Log("InitRemoteConfig"); ConfigDownloader.Instance.StartToDownload(ConfigURL, () => { ParseConfigs(); if (UConfigManager.bUsingAb) { SetJindu("正在加载脚本资源......"); StartCoroutine(OnDownloadDll(ConfigDownloader.Instance.OnGetValue("dll"))); } else { SetJindu("正在加载脚本资源..."); LoadDll(File.ReadAllBytes("Assets/RemoteResources/Dll/ahotgames.bytes") , File.ReadAllBytes("Assets/RemoteResources/Dll/ahotgames.pdb")); } }, () => { SetJindu("正在加载本地资源,请稍候"); Debug.Log("下载远端配置文件失败,加载本地文件"); UConfigManager.bUsingAb = false; StartCoroutine(OnDownloadDll(UStaticFuncs.GetStreamAssetPath() + UStaticFuncs.GetPlatformFolder(Application.platform) + "/dll/ahotgames.ab")); }); }
private async Task BeginRead() { if (!IsConnected) { return; } try { byte[] buffer = new byte[readbuffsize]; var iBytesAvailable = await m_ClientStream.ReadAsync(buffer, 0, readbuffsize); if (0 >= iBytesAvailable) { AddDisconectPacket(); return; } else { SocketData data = new SocketData(buffer, iBytesAvailable); m_vSocketData.Enqueue(data); EngineControler.Instance.QueForTick(this); } lastReceiveDataTime = ApiDateTime.Now; await BeginRead(); } catch (System.Exception ex) { AOutput.Log($"ReadComplete {ex.Message}"); AddDisconectPacket(); } }
/// <summary> /// Compiles C# file or project if need. /// Returns false if fails (C# errors etc). /// </summary> /// <param name="reason">Whether to recompile if compiled, etc. See also Remarks.</param> /// <param name="r">Results.</param> /// <param name="f">C# file. If projFolder used, must be the main file of the project.</param> /// <param name="projFolder">null or project folder.</param> /// <remarks> /// Must be always called in the main UI thread (Thread.CurrentThread.ManagedThreadId == 1). /// /// Adds <see cref="MetaReferences.DefaultReferences"/>. /// /// If f role is classFile: /// If CompReason.Run, does not compile (just parses meta), sets r.role=classFile and returns false. /// Else compiles but does not create output files. /// </remarks> public static bool Compile(ECompReason reason, out CompResults r, FileNode f, FileNode projFolder = null) { Debug.Assert(Thread.CurrentThread.ManagedThreadId == 1); r = null; var cache = XCompiled.OfCollection(f.Model); bool isCompiled = reason != ECompReason.CompileAlways && cache.IsCompiled(f, out r, projFolder); //AOutput.Write("isCompiled=" + isCompiled); if (!isCompiled) { bool ok = false; try { ok = _Compile(reason == ECompReason.Run, f, out r, projFolder); } catch (Exception ex) { //AOutput.Write($"Failed to compile '{f.Name}'. {ex.ToStringWithoutStack()}"); AOutput.Write($"Failed to compile '{f.Name}'. {ex}"); } if (!ok) { cache.Remove(f, false); return(false); } } return(true); }
IEnumerator OnDownloadDll(string dllPath) { AOutput.Log($"dllPath {dllPath}"); www = new WWW(dllPath); yield return(www); if (string.IsNullOrEmpty(www.error)) { if (dllPath.EndsWith(".ab")) { LoadDll(www.assetBundle.LoadAsset <TextAsset>("ahotgames").bytes, null); } else { var dllBytes = www.bytes; #if UNITY_EDITOR www = new WWW(dllPath.Replace(".bytes", ".pdb")); AOutput.Log($"www {www.url}"); yield return(www); LoadDll(dllBytes, www.bytes); #else LoadDll(dllBytes, null); #endif } } else { AOutput.Log($"www {www.url} error {www.error}"); } www = null; }
static void Upload(string docDir) { if (!ARegistry.GetString(out var user, "kas", @"\Help") || !ARegistry.GetString(out var pass, "kaip", @"\Help") || !ARegistry.GetString(out var pass2, "kaip2", @"\Help") ) { throw new FileNotFoundException("user or password not found in registry"); } //upload pass = Encoding.UTF8.GetString(Convert.FromBase64String(pass)); var name = @"\_site.tar.bz2"; var path = docDir + name; using (var client = new WebClient()) { client.Credentials = new NetworkCredential(user, pass); client.UploadFile("ftp://ftp.quickmacros.com/public_html/au" + name, WebRequestMethods.Ftp.UploadFile, path); } AFile.Delete(path); AOutput.Write("Uploaded"); //extract using (var client = new WebClient()) { string r1 = client.DownloadString($"https://www.quickmacros.com/au/extract_help.php?kaip={pass2}"); if (r1 != "done") { AOutput.Write(r1); return; } } AOutput.Write("<>Extracted to <link>https://www.quickmacros.com/au/help/</link>"); }
/// <summary> /// Prints all errors and warnings. /// Calls <see cref="Clear"/>. /// Does nothing if no errors and warnings. /// </summary> public void PrintAll() { if (_b == null) { return; } var s = ToString(); _b.Clear(); //header line _b.AppendFormat("<><Z #{0}>Compilation: ", ErrorCount != 0 ? "F0E080" : "A0E0A0"); if (ErrorCount != 0) { _b.Append(ErrorCount).Append(" errors").Append(WarningCount != 0 ? ", " : ""); } if (WarningCount != 0) { _b.Append(WarningCount).Append( @" warnings <fold> Warnings can be disabled in Properties -> noWarnings or warningLevel. Warnings for part of code can be disabled with <google>C# #pragma warning<>.</fold>" ); } _b.AppendLine("<>"); //errors and warnings _b.Append(s); AOutput.Write(_b.ToString()); Clear(); }
public HttpResponseMessage ordercallback() { var callback = OnReadPostData(); var xe = XElement.Parse(callback); var cash_feev = xe.Element("cash_fee"); var out_trade_nov = xe.Element("out_trade_no"); var total_feev = xe.Element("total_fee"); var trade_typev = xe.Element("trade_type"); var signv = xe.Element("sign"); if (cash_feev != null && out_trade_nov != null && total_feev != null && trade_typev != null && signv != null) { var out_trade_no = out_trade_nov.Value; var cash_fee = cash_feev.Value; var total_fee = total_feev.Value; var trade_type = trade_typev.Value; if (cash_fee == total_fee) { //var res = DoOrderPayed(out_trade_no, typeParser.intParse(cash_fee), trade_type, callback); { AOutput.LogError("order " + out_trade_no + " update failed\r\n" + callback); } } else { AOutput.LogError("order " + out_trade_no + " fee not equal!\r\n" + callback); } } var res = (@"<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg><sign><![CDATA[" + signv.Value + "]]></sign></xml>"); return(ResultToJson.ToNormalResponse(res)); }
public void DownloadConfig(Action downloadConfigComplete) { var ks = dExcelLoaders.Keys.ToArray(); var l = new List <string>(); foreach (var k in ks) { l.Add($"txt/{k}"); } UHotAssetBundleLoader.Instance.OnDownloadResources(() => { foreach (var k in dExcelLoaders.Keys) { var tb = "txt/" + k; var ta = UHotAssetBundleLoader.Instance.OnLoadAsset <TextAsset>(tb); if (ta != null) { dExcelLoaders[k].Invoke(ta.text); } else { AOutput.Log($"Load config invalid {tb}"); } } downloadConfigComplete(); }, l.ToArray()); }
public void OnDownloadResources(List <string> lResources, Action downloaded, Action <float> progress = null) { AOutput.Log($"OnDownloadResources Environment.UseAB {Environment.UseAB} {Utils.GetPlatformFolder(Application.platform)} {string.Join(",", lResources)}"); if (!Environment.UseAB) { downloaded?.Invoke(); return; } if (dRemoteVersions.Count == 0) { OnDownloadText(Utils.GetPlatformFolder(Application.platform) + "/versions", (content) => { var acontent = content.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var c in acontent) { var ac = c.Split('|'); if (ac.Length < 2) { continue; } if (!dRemoteVersions.ContainsKey(ac[0])) { dRemoteVersions.Add(ac[0], ac[1]); } } DoCheckVersions(lResources, downloaded, progress); }); } else { DoCheckVersions(lResources, downloaded, progress); } }
/// <summary> /// Skips current statement. /// _i can be at any place in the statement except in parts enclosed in (), [] or {}. /// Finally _i will be at the ending ';' or '}' (if '}' is not followed by ';'). /// </summary> /// <param name="debugShow"></param> void _SkipStatement(bool debugShow = false) { #if DEBUG int i0 = _i; #endif gk1: while (!_TokIsChar(_i, "({;[")) { _i++; } if (!_TokIsChar(_i, ';')) { _SkipEnclosed(); if (!_TokIsChar(_i, '}')) { goto gk1; //skip any number of (enclosed) or [enclosed] parts, else skip single {enclosed} part } if (_TokIsChar(_i + 1, ';')) { _i++; } } #if DEBUG if (debugShow) { string s = new string(T(i0), 0, (int)(T(_i + 1) - T(i0))); AOutput.Write($"<><c 0xff>skipped:</c>\r\n{s}"); } #endif }
private void CreatePacket() { eMessageType eOpCode = (eMessageType)m_bOpCode; ResetPacketHeader(); m_PacketDataStream.Position = 0; // reset position so it is ready for reading Packet packet = ClientConnectionUtil.ProcessClientPacket(eOpCode, m_PacketDataStream, this); if (packet != null) { m_vPacketsToProcess.Enqueue(new SinglePacketProcessor(packet)); EngineControler.Instance.QueForProcessing(this); } else { AOutput.Log("Create packet failed!"); } if (m_vSocketData.Count > 0) { EngineControler.Instance.QueForTick(this); } }
private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var ex = (e.ExceptionObject as Exception); AOutput.LogError("UnhandledException " + ex.Message); AOutput.LogError("UnhandledException " + ex.StackTrace); }
private void ProcessStreamData() { if (TryPraseProcessSecurityRequest()) { return; } while (0 < m_SocketData.BytesUnread) { if (!m_bValidPacketHeader) { if (!ReadPacketHeader()) { if (showInvalidSocketData) { AOutput.Log("Invalid socket data from " + ConnectionDesc + " count:" + m_SocketData.BytesUnread); } break; } } else { ReadPacketData(); } } }
public void ServerTick() { DateTime nowTime = DateTime.Now; TimeSpan span = nowTime - m_OldTime; foreach (ITickableSystem subSystem in m_vSubSystems) { m_OldTime = nowTime; DateTime ot = DateTime.Now; try { subSystem.Tick(span.TotalSeconds); } catch (Exception ex) { AOutput.Log("Tick exception " + ex.Message); AOutput.Log(ex.StackTrace); } DateTime nt = DateTime.Now; double t = (nt - ot).TotalMilliseconds; if (t > 300) { AOutput.Log(subSystem.GetType().FullName + " spans (ms)" + t); } } Thread.Sleep(1); }
private void GameHandler_CreateOrderRequest(IResponer responer, PktCreateOrderRequest vo) { var player = APlayerManager.Instance.OnGetPlayerByConn(responer.playerConnDesc); if (player == null) { return; } var data = PaymentLoader.Instance.OnGetData(vo.productID); var result = new PktCreateOrderResult(); if (data == null) { return; } result.eResult = PktCreateOrderResult.EResult.Success; var orders = new CakeServer("order", player.psid); var order = orders.GetSingleItem(LibUtils.StringUtils.GetGUIDString()); order.SetValue(ParamNameDefs.ProductID, vo.productID); order.SetValue(ParamNameDefs.Price, data.Price); result.orderID = order.iid; result.extraInfo = APIWechatPay.Pay(data.Price, order.iid, $"描述:{data.Desc}"); AOutput.Log($"result.extraInfo {result.extraInfo}"); responer.Response(result); }
public void FactoryInit(ByteStream buffer, ClientConnection client) { m_Client = client; if (null == buffer) { return; } try { int iPacketSize = buffer.Length; Initialize(buffer); if (buffer.BytesRead != iPacketSize) { string error = string.Format(@"Packet size mismatch of type {0}", this.GetType().ToString()); AOutput.Log(error); throw new System.Exception(error); } } catch { AOutput.Log(string.Format(@"Failed Initializing Packet of type {0}", this.GetType().ToString())); m_bValid = false; } }
public void Start(int port, Action <IPEndPoint, byte[]> bytesReceiveHandler) { if (udpClient != null) { return; } udpClient = new UdpClient(port); receiveHandler = bytesReceiveHandler; ipendpoint = new IPEndPoint(IPAddress.Any, port); ipendpointv6 = new IPEndPoint(IPAddress.IPv6Any, port); var addresses = Dns.GetHostAddresses(Dns.GetHostName()); AOutput.Log("Listening UDP " + addresses.Length + " addresses"); foreach (var adr in addresses) { AOutput.Log("\t" + adr.ToString()); } if (receiveHandler != null) { new Thread(new ThreadStart(ReceiveHand)).Start(); new Thread(new ThreadStart(ReceiveHandV6)).Start(); } }
private void Start() { #if UNITY_ANDROID MonoInstancePool.getInstance <SDK_Orientation>(true).ShowBar(); #endif Screen.fullScreen = true; MonoInstancePool.getInstance <AntiScriptSplit>(true); MonoInstancePool.getInstance <SDK_WeChat>(true); trUIAlert = UStaticFuncs.FindChildComponent <Transform>(transform, "UIAlert"); fprocessing = 0.1f; #if UNITY_IOS MonoInstancePool.getInstance <SDK_AppleInApp>(true); #endif gameObject.AddComponent <UConsoleDebug>(); #if !UNITY_WEBGL var fa = "fa" + Utils_Plugins.Util_GetBundleVersion(); if (!PlayerPrefs.HasKey(fa)) { AOutput.Log($"start copy files {fa}"); MonoInstancePool.getInstance <UCopyFilesFromStreamingAssets>().OnCopy("versions.txt", UStaticFuncs.ConfigSaveDir, () => { InitRemoteConfig(); PlayerPrefs.SetInt("fa" + Utils_Plugins.Util_GetBundleVersion(), 1); }); } else { #endif InitRemoteConfig(); #if !UNITY_WEBGL } #endif }
/// <summary> /// Processes an incoming packet to an ClientConnection interface /// </summary> /// <param name="messageType">Packet message identifier</param> /// <param name="packetStream">Packet stream data</param> /// <param name="client">Client interface to handle the packet</param> /// <param name="bThrowOnError">True to throw an exception instead of logging</param> /// <returns>Packet to process or NULL if a control packet dispatched to the client</returns> public static Packet ProcessClientPacket(eMessageType messageType, Stream packetStream, ClientConnection client, bool bThrowOnError) { // string userName = ( client.ConnectionUser != null ) ? client.ConnectionUser.Login : "******"; Packet packet = PacketFactory.Instance.ParseData(messageType, packetStream, client); // if( packet is LogoutPacket ) // { // client.SignalLogout(); // return null; // } //else if (packet.IsValid) { return(packet); } if (bThrowOnError) { throw new InvalidOperationException(string.Format(@"Invalid Packet Data Received For Type '{0}'. {1}", messageType, "userName")); } else { AOutput.Log(string.Format(@"Invalid Packet Data Received For Type '{0}'. {1}", messageType, "userName")); } return(null); }
public bool UpdateOneData(string collectionName , FilterDefinition <BsonDocument> filter , UpdateDefinition <BsonDocument> update , bool upsert = false) { bool bSuccess = true; string serror = ""; try { var collection = db.GetCollection <BsonDocument>(collectionName); UpdateOptions uo = new UpdateOptions(); uo.IsUpsert = upsert; if (filter == null) { filter = FilterDefinition <BsonDocument> .Empty; } var result = collection.UpdateOne(filter, update, uo); } catch (Exception ex) { bSuccess = false; serror = ex.Message; AOutput.LogError($"UpdateOneData {ex.Message}"); } return(bSuccess); }
public static string CreateZip(string zipPath, string dirPath) { ZipFile czip = ZipFile.Create(zipPath); czip.Password = Pd; DiskArchiveStorage myDisk = new DiskArchiveStorage(czip); czip.BeginUpdate(myDisk); var files = Directory.EnumerateFiles(dirPath); foreach (string file in files) { if (!file.EndsWith(".txt")) { continue; } if (!File.Exists(file)) { AOutput.Log("File not found!"); } czip.Add(file, Path.GetFileName(file)); } czip.CommitUpdate(); czip.Close(); return(zipPath); }
public void OnRead(BsonDocument document) { foreach (var p in dParams) { if (!dParams.ContainsKey(p.Key)) { AOutput.LogError("Cannot find param " + p.Key); return; } if (document.Contains(p.Key)) { var aparam = dParams[p.Key]; switch (aparam.eParamType) { case EParamType.String: OnSetParamValue(p.Key, document[p.Key].AsString, true); break; case EParamType.Int: OnSetParamValue(p.Key, document[p.Key].AsInt32, true); break; case EParamType.Double: OnSetParamValue(p.Key, document[p.Key].AsDouble, true); break; case EParamType.Long: OnSetParamValue(p.Key, document[p.Key].AsInt64, true); break; } } } }
public void OnEnter(AAvatar avatar, string roomType) { if (!avatar.bAI) { if (dRooms.ContainsKey(avatar.username)) { if (dRooms[avatar.username].roomType != roomType) { AOutput.Log($"avatar.username enter different room {roomType}"); dRooms[avatar.username].OnExit(avatar.username); dRooms.Remove(avatar.username); } } ARoomBase room = null; if (!dRooms.ContainsKey(avatar.username)) { room = OnCreate(roomType); dRooms.Add(avatar.username, room); } else { room = dRooms[avatar.username]; } room.OnEnter(avatar); } }
static void Main(string[] args) { var sport = args.Length > 0 ? args[0] : "999"; InitValueDefs.dbconnect = args.Length > 1 ? args[1] : "mongodb://127.0.0.1:27018"; InitValueDefs.dbname = args.Length > 2 ? args[2] : "common"; AOutput.bIsConsole = true; AOutput.Instance.RegistOutputDel(doLog); AOutput.LogTag = EngineServer.eServerType.ToString(); EngineServer.Instance.EngineInit(); EngineServer.Instance.ServerStartUp(typeParser.intParse(sport), EngineServer.EServerType.GatewayServer); GameHandlers_Enter.Instance.Init(); EngineServer.Instance.RegistSubSystem(GameHandlers_Enter.Instance); StartConsoleServer(); try { ConfigManager.Instance.Init(); AOutput.Log($"Config loaded."); } catch (Exception ex) { AOutput.LogError($"Load config error:{ex.Message}"); } }
protected override void InitComponents() { UICommonWait.Show(); Task.Run(async() => { if (!LibClient.AClientApp.bConnected) { await LibClient.AClientApp.StartClient(); } UEventListener.Instance.AddProducingAction(() => { UICommonWait.Hide(); }); }); inputUsername = FindWidget <InputField>("inputUsername"); if (!string.IsNullOrEmpty(CachedUsername)) { inputUsername.text = CachedUsername; } inputPassword = FindWidget <InputField>("inputPassword"); btnLogin = FindWidget <Button>("btnLogin"); btnLogin.onClick.AddListener(() => { Task.Run(async() => { if (!LibClient.AClientApp.bConnected) { await LibClient.AClientApp.StartClient(); } if (!LibClient.AClientApp.bConnected) { UEventListener.Instance.AddProducingAction(() => { btnLogin.enabled = true; UICommonWait.Hide(); }); AOutput.Log($"连接失败!"); return; } UEventListener.Instance.AddProducingAction(OnLogin); }); btnLogin.enabled = false; }); var btnRegister = FindWidget <Button>("btnRegister"); btnRegister.onClick.AddListener((UnityEngine.Events.UnityAction)(() => { base.OnUnloadThis(); AHotBase.LoadUI <UIRegister>(); })); RegisterEvent(UEvents.Login, OnLoginCb); }
public override void rcvEnterGameCb(AvatarInfo info) { AOutput.Log($"rcvEnterGameCb"); UEventListener.Instance.OnDispatchEvent(UEvents.EnterGame, new EventEnterGame() { info = info }); }
void _FunctionsFinally() { if (_funcUnknownDll.Count > 50) { AOutput.Write("Warning: too many unknown dll:"); AOutput.Write(_funcUnknownDll); } }
public void ListAll() { foreach (var a in dUIDIndexedAvatars) { AOutput.Log($"[{a.Key}]{a.Value.AvatarName} Lv:{a.Value.AvatarLevel}"); } AOutput.Log($"Total:{dUIDIndexedAvatars.Count}"); }