public void ProcessInputs(ConsoleLog importLog) { log = importLog; log.Log("************** IMPORT *****************"); ClearTables(log); var f = Task.Factory; var extractTables = f.StartNew(() => ReadTables()); var extractTableForeignConstraints = f.StartNew(() => ExtractTableForeignConstraints()); var extractTriggers = f.StartNew(() => ReadTriggers()); var extractPackages = f.StartNew(() => ReadPackages()); Task.WaitAll(extractPackages); PopulateTables(); PopulateTableForeignConstraints(); PopulatePackages(); PopulateTriggers(); //This must be run after Packages have been persisted to model // to ensure Id (link) is taken from model RePopulatePackageList(); ExtractPackageFunctions(); PopulateFunctions(); //Create list of eneities and persist to model CreateEntities(); PopulateEntities(); log.Log("************ IMPORT END ***************"); }
private void DrawGuiBodyHandler(float width, float height, float scale) { GUILayoutOption maxwidthscreen = GUILayout.MaxWidth(width); if (GUILayout.Button("Back", console.style.MenuStyle)) { if (focusedObject != null) { focusedObject = null; } else { focusedLog = null; console.Defocus(); } } scrollPosition = GUILayout.BeginScrollView(scrollPosition, maxwidthscreen); if (focusedObject != null) { DrawObjectInspection(); } else if (focusedLog != null) { DrawLogInspection(maxwidthscreen); } GUILayout.EndScrollView(); }
protected override int RunProgram(string[] args) { try { var builder = new ContainerBuilder(); Configuration configuration = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var serverSettings = configuration.GetSection("settings") as ServerConfiguration; Debug.Assert(serverSettings != null); builder.RegisterType<ServerProgram>(); builder.RegisterModule(new ServerDependenciesModule(serverSettings, configuration)); IContainer container = builder.Build(); return container.Resolve<ServerProgram>().Run(); } catch (DependencyResolutionException ex) { Console.WriteLine(ex.Message); throw; } catch (Exception ex) { var log = new ConsoleLog(); log.Error("Error while running program", ex); throw; } }
public virtual void BeginProcessInput(ConsoleLog importLog) { log = importLog; ClearTables(log); //Create list of eneities and persist to model PopulateEntities(); }
// Use this for initialization void Start () { ConsoleLog.isShowMenu = showMenu; ConsoleLog.pGazeModule = GameObject.FindObjectOfType<GazeInputModule>(); ConsoleLog.Instanst = this; ConsoleLog.console = GameObject.FindGameObjectWithTag("ConsoleLog").GetComponent<Text> (); ConsoleLog.console.text = ""; ConsoleLog.ConsoleCanvas = gameObject; }
public void BuildExternalInterfaces(ConsoleLog log) { log.Log("Building Interfaces - start"); BuildAllInterfaces(); PopulateInterfaces(); log.Log("Building Interfaces - complete"); }
/// <summary> /// Clear all database tables except audit log. /// </summary> public virtual void ClearTables(ConsoleLog log) { Utility bla = new Utility(); bla.ClearTable("SQL.PackageDefinitions"); bla.ClearTable("SQL.TableDefinitions"); bla.ClearTable("SQL.TableForeignConstraints"); bla.ClearTable("SQL.FunctionDefinitions"); bla.ClearTable("Admin.Buckets"); bla.ClearTable("Admin.Entities"); bla.ClearTable("Admin.EntityRelationships"); bla.ClearTable("Admin.Interfaces"); bla.ClearTable("Admin.InternalInterfaces"); }
static void Main() { Console.WriteLine("Sample Rest Server Started"); Console.WriteLine("The server implements /time REST method."); Console.WriteLine("Browse to http://localhost:9999/time to test it.\n"); var log = new ConsoleLog((Log.Level.Off)); var restServer = new SampleRestServer(log, 9999, 127, 0, 0, 1); restServer.StartAsync(); Console.WriteLine("Press ENTER to exit ..."); Console.ReadLine(); restServer.Stop(); }
static void Main() { Console.WriteLine("Sample Rest Server Started"); Console.WriteLine("The server implements /time REST method."); Console.WriteLine("Browse to http://<host>:8080/time or http://<host>:8080/plaintext to test it.\n"); var log = new ConsoleLog((Log.Level.Verbose)); var restServer = new SampleRestServer(log, 8080, 0, 0, 0, 0); restServer.StartAsync(); Console.WriteLine("Press ENTER to exit ..."); Console.ReadLine(); restServer.Stop(); }
private void RunGraphs(ConsoleLog log, string[] input) { List<Task> _tasks = new List<Task>(); bool entities = false; bool interfaces = false; foreach (string s in input) { if (s.Equals("ENTITY")) { entities = true; } if (s.Equals("INTERFACE")) { interfaces = true; } if (s.Equals("ALL")) { interfaces = true; entities = true; } } var f = Task.Factory; if (entities) { //log.Log("Build Entity graph - start"); BuildEntityGraph entityGraph = new BuildEntityGraph(); var buildEntityGraph = f.StartNew(() => entityGraph.StartGraph(log)); _tasks.Add(buildEntityGraph); } if (interfaces) { //log.Log("Build Interface graph - start"); BuildInterfaceGraph interfaceGraph = new BuildInterfaceGraph(); var buildInterfaceGraph = f.StartNew(() => interfaceGraph.StartGraph(log)); _tasks.Add(buildInterfaceGraph); } foreach (Task task in _tasks) { Task.WaitAll(task); } log.Log(string.Format("Graph building complete - {0} graphs built", _tasks.Count)); }
public void StartAnalysis(ConsoleLog log) { log.Log("Analysis"); log.Log("*************** ANALYSE ******************"); ClearTables(); BuildInternalInterfaces(log); PopulateInterfaces(log); BeginReferentialWeighting(log); PopulateEntityResidence(log); BuildInterfaceReporting(log); PopulateInterfaceReporting(log); BuildBucketReporting(log); PopulateBucketReporting(log); BuildBucketConnections(log); PopulateBucketConnections(log); log.Log("************* ANALYSE END ****************"); }
private void BeginReferentialWeighting(ConsoleLog log) { log.Log("Assess entity residence - start"); FAASModel _context = new FAASModel(); _entities = _context.Entities.ToList(); _internalInterfaces = _context.InternalInterfaces.ToList(); _externalInterfaces = _context.Interfaces.ToList(); foreach (Entity entity in _entities) { //write processing output to same line Console.Write("Assessing {0} \r", entity.Name); EntityResidence entStr = new EntityResidence(); entStr.EntityId = entity.Id; entStr.InternalWeight = GetStrength(entity, "internal"); entStr.ExternalWeight = GetStrength(entity, "external"); entStr.ExternalSources = InterfaceSources(entity, "external").Count; _entStr.Add(entStr); } log.Log("Assess entity residence - start"); }
private void btnSetID_Click(object sender, RoutedEventArgs e) { if (isInternetup) { if (_isCodingSvcIPSet) { if (_isStationIDSet) { if (!Properties.Settings.Default.isConnected) { //unset //Enable the combobox to allow user to change station this.comboID.IsEnabled = true; _isStationIDSet = false; this.btnSetID.Content = "Set"; Properties.Settings.Default.CurrentID = ""; Properties.Settings.Default.Save(); //Clear the datagrid //_ConsoleLogList.Clear(); //this.lvConsoleLog.Items.Refresh(); //Had to use this instead of refresh as the columnh header sort overlay on the itemsource this.lvConsoleLog.ItemsSource = null; this.lvConsoleLog.ItemsSource = _ConsoleLogList; } else { MessageBox.Show("Disconnect from Station ID is required before unset Station ID"); } } else { //set //Disable the combobox this.comboID.IsEnabled = false; _isStationIDSet = true; this.btnSetID.Content = "Unset"; //Set the stationID chosen to "currentstation" in the setting Properties.Settings.Default.CurrentID = this.comboID.Text; Properties.Settings.Default.Save(); _ConsoleLogList.Clear(); if (Properties.Settings.Default.ConsoleLogList != null) { foreach (string log in Properties.Settings.Default.ConsoleLogList) { string[] parts = log.Split(','); //Check is it corresponding stationID if (parts[0] == this.comboID.Text) { ConsoleLog consolelog = new ConsoleLog(); consolelog.CodingID = parts[1]; consolelog.AckTimeStamp = parts[2]; consolelog.AckFrom = parts[3]; consolelog.AckStatus = parts[4]; _ConsoleLogList.Add(consolelog); } } } this.lvConsoleLog.ItemsSource = null; this.lvConsoleLog.ItemsSource = _ConsoleLogList; } } else { ShowMessageBox("IP address had not been set..."); } } else { ShowMessageBox("Please check the internet connection to continue"); } }
public void AddCh(ConsoleLevel level, string channel, string message) { var log = new ConsoleLog(); log.message = message; log.level = level; log.channel = channel; log.Time = DateTime.UtcNow; Add(log); }
public void Setup() { _uut = new ConsoleLog(); }
public void ToggleMenu() { ConsoleLog.SToggleMenu(); }
private void ProcessUnitMap(ConsoleLog log) { ClearTables(); log.Log("Assigning entities to buckets - start"); ReadExcel(); CreateManualBuckets(); UpdateMappedEntities(); UpdateUnmappedEntities(); PopulateBuckets(); log.Log("Assigning entities to buckets - complete"); }
private void Log (string _tagName, object _message, eConsoleLogType _logType, UnityEngine.Object _context, int _skipStackFrameCount = 1) { // Do I need to ignore this call if (IgnoreConsoleLog(_tagName)) return; // Add additional skip frame _skipStackFrameCount++; int _tagID = GetIndexOfConsoleTag(_tagName); // When we cant find our tag, add a new entry if (_tagID == -1) { m_consoleTags.Add(new ConsoleTag(_tagName)); // And update tag-ID _tagID = m_consoleTags.Count - 1; } ConsoleTag _consoleLogTag = m_consoleTags[_tagID]; // Marked to ignore this log if (_consoleLogTag.Ignore) return; int _logID = m_consoleLogsList.Count + 1; ConsoleLog _newConsoleLog = new ConsoleLog(_logID, _tagID, _message.ToString(), _logType, _context, _skipStackFrameCount); #if UNITY_EDITOR // Add this new console to list of logs m_consoleLogsList.Add(_newConsoleLog); // Add it to display list bool _addSuccess = AddToDisplayableLogList(_newConsoleLog); if (_addSuccess) { // Pause unity player on error if (_logType != eConsoleLogType.INFO && _logType != eConsoleLogType.WARNING) { if (m_errorPause) { EditorApplication.isPaused = true; } } } // Set as modified EditorUtility.SetDirty(this); #else NativeBinding.Log(_newConsoleLog); #endif }
static async void _GetIllustDetail(int id, Action <object[]> Reply, Action <object[]> SendMessage, bool slient = false) { try { var detail = await Illust.Get(id); if (detail == null) { if (!slient) { Reply?.Invoke(new object[] { $"数据(pid:{id})获取失败,请稍后再试" }); } return; } ArrayList msg = new(); if (detail.IsUgoira) { var ugoira = await detail.GetUgoira(); if (ugoira == null) { if (!slient) { Reply?.Invoke(new object[] { $"动图数据(pid:{id})获取失败" }); } } else { if (!slient) { Reply?.Invoke(new object[] { $"动图数据(pid:{id})获取成功,正在进行压缩..." }); } var img = await ugoira.LimitGifScale(500, 500); var file = await img.SaveGifToTempFile(); msg.Add(CQCode.CQImage(file)); } } else { foreach (var img in detail.Images) { var cache = await DownloadManager.GetCache(img.Medium); if (string.IsNullOrEmpty(cache)) { var url = ImageUrls.ToPixivCat(img.Medium); cache = await DownloadManager.GetCache(url); if (string.IsNullOrEmpty(cache)) { cache = await DownloadManager.Download(url); if (string.IsNullOrEmpty(cache)) { cache = await DownloadManager.Download(img.Medium, detail.Url); if (string.IsNullOrEmpty(cache)) { msg.Add("[图像缓存失败]"); continue; } } } } ImageUtils.LimitImageScale(cache, 1500, 1500); msg.Add(CQCode.CQImage(cache)); } } msg.Add(detail.ToString()); SendMessage?.Invoke(msg.ToArray()); } catch (Exception ex) { ConsoleLog.Debug("QQ Command - Pixiv", ex.GetFormatString(true)); if (!slient) { Reply?.Invoke(new object[] { $"处理作品(pid:{id})时发生异常错误,任务已终止" }); } } }
public static async void Login(SoraMessage e) { await Task.Run(() => Library.Bilibili.Bilibili.QRCodeLoginRequest( async(bitmap) => { if (e.IsGroupMessage) { await e.ReplyToOriginal("登录任务已建立,请前往私聊等待登录二维码的发送"); } else { await e.ReplyToOriginal("登录任务已建立,请等待登录二维码的发送"); } var qr = new MemoryImage(bitmap); var path = qr.ToBase64File(); await e.SendPrivateMessage(CQCode.CQImage(path), "\n请使用Bilibili客户端扫码登录"); }, async() => await e.SendPrivateMessage("检测到扫描事件,请在客户端中确认登录"), async(cookie) => { if (int.TryParse(cookie.Split(";").Where(x => x.StartsWith("DedeUserID=")).First()[11..], out var id)) { await e.SendPrivateMessage("登录成功\n数据储存中……"); var t = Database.Data.Table <UserData>(); var data = await t.Where(x => x.QQ == e.Sender.Id || x.Bilibili == id).FirstOrDefaultAsync(); if (data != null) { data.QQ = e.Sender.Id; data.Bilibili = id; data.BilibiliCookie = cookie; await Database.Data.UpdateAsync(data).ContinueWith(async x => { if (x.Result > 0) { await e.SendPrivateMessage("记录数据已更新"); } else if (x.IsFaulted && x.Exception != null) { await e.SendPrivateMessage(new StringBuilder() .AppendLine("记录数据因异常导致更新失败,错误信息:") .Append(ConsoleLog.ErrorLogBuilder(x.Exception)) .ToString()); } else { await e.SendPrivateMessage("记录数据因未知原因导致更新失败,请稍后重试"); } }); } else { data = new() { QQ = e.Sender.Id, Bilibili = id, BilibiliCookie = cookie }; await Database.Data.InsertAsync(data).ContinueWith(async x => { if (x.Result > 0) { await e.SendPrivateMessage("记录数据已添加"); } else if (x.IsFaulted && x.Exception != null) { await e.SendPrivateMessage(new StringBuilder() .AppendLine("记录数据因异常导致更新失败,错误信息:") .Append(ConsoleLog.ErrorLogBuilder(x.Exception)) .ToString()); } else { await e.SendPrivateMessage("记录数据因未知原因导致更新失败,请稍后重试"); } }); } }
public void TearDown() { ConsoleLog.Flush(); }
/// <summary> /// 启动WS服务端 /// </summary> public async ValueTask StartServer() { if (!serverReady) { return; } //检查是否已有服务器被启动 if (serverExitis) { throw new SoraServerIsRuningException(); } //心跳包超时检查计时器 this.HeartBeatTimer = new Timer(ConnManager.HeartBeatCheck, null, new TimeSpan(0, 0, 0, (int)Config.HeartBeatTimeOut, 0), new TimeSpan(0, 0, 0, (int)Config.HeartBeatTimeOut, 0)); Server.Start(socket => { //接收事件处理 //获取请求头数据 if (!socket.ConnectionInfo.Headers.TryGetValue("X-Self-ID", out string selfId) || //bot UID !socket.ConnectionInfo.Headers.TryGetValue("X-Client-Role", out string role)) //Client Type { return; } //请求路径检查 bool isLost = role switch { "Universal" => !socket.ConnectionInfo.Path.Trim('/').Equals(Config.UniversalPath), _ => true }; if (isLost) { socket.Close(); ConsoleLog.Warning("Sora", $"关闭与未知客户端的连接[{socket.ConnectionInfo.ClientIpAddress}:{socket.ConnectionInfo.ClientPort}],请检查是否设置正确的监听地址"); return; } //打开连接 socket.OnOpen = () => { //获取Token if (socket.ConnectionInfo.Headers.TryGetValue("Authorization", out string token)) { //验证Token if (!token.Equals(this.Config.AccessToken)) { return; } } //向客户端发送Ping socket.SendPing(new byte[] { 1, 2, 5 }); //事件回调 ConnManager.OpenConnection(role, selfId, socket); ConsoleLog.Info("Sora", $"已连接客户端[{socket.ConnectionInfo.ClientIpAddress}:{socket.ConnectionInfo.ClientPort}]"); }; //关闭连接 socket.OnClose = () => { //移除原连接信息 if (ConnManager.ConnectionExitis(socket.ConnectionInfo.Id)) { ConnManager.CloseConnection(role, selfId, socket); } ConsoleLog.Info("Sora", $"客户端连接被关闭[{socket.ConnectionInfo.ClientIpAddress}:{socket.ConnectionInfo.ClientPort}]"); }; //上报接收 socket.OnMessage = (message) => { //处理接收的数据 // ReSharper disable once SimplifyLinqExpressionUseAll if (!ConnManager.ConnectionExitis(socket.ConnectionInfo.Id)) { return; } //进入事件处理和分发 Task.Run(() => { this.Event .Adapter(JObject.Parse(message), socket.ConnectionInfo.Id); }); }; }); ConsoleLog.Info("Sora", $"Sora WebSocket服务器正在运行[{Config.Location}:{Config.Port}]"); ConsoleLog.Info("Sora", $"Sora 服务端框架版本:{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}"); serverExitis = true; ConsoleLog.Debug("好耶", "这是一个奇奇怪怪的开发者交流群:1081190562"); await Task.Delay(-1); }
public RetiredDrone(Drone drone) { _Data = new RetiredDroneData(drone); ConsoleLog.WriteToConsole(new DroneRetired(this)); }
public RetiredDrone(Drone drone, Collider other) { _Data = new RetiredDroneData(drone, other); ConsoleLog.WriteToConsole(new DroneCollision(this)); }
protected string[] Failed(string why_failed) { ConsoleLog.Warn("HTTP: " + CommandName + " [Failed]: " + why_failed); return(new string[] { "Failed", why_failed }); }
public void StartGraph(ConsoleLog log) { //instatiate and populate global variables entityNodeCount = 0; entityLinkCount = 0; FAASModel _context = new FAASModel(); _entities = _context.Entities.ToList(); _entityRels = _context.EntityRelationships.ToList(); _entityBuckets = _context.Buckets.ToList(); //call main methods log.Log("Building entity level graph - start"); AddArtificialNodesLinks(); AddInternalEntityLinks(); //call clean to add all current homeless nodes to their respective buckets - fix bug where they were being allocated to external buckets CleanLinks(log); AddExternalEntityLinks(log); CleanLinks(log); log.Log("Building entity level graph - complete"); PrintGraph(log); }
private void CleanLinks(ConsoleLog log) { List<Link> _homelessLinks = new List<Link>(); List<Node> _homelessNodes = new List<Node>(); //for the looplinks, check all tree link sources have a source foreach (Link checkLink in _linksToCheck) { var x = (from l in _entityTreeLinks where l.Target == checkLink.Source select l); //if tree-link source is never called as a target, it needs a home if (!x.Any()) { Node source = (from n in _entityNodes where n.id == checkLink.Source select n).FirstOrDefault(); AddLink(GetBucketNode(source), source); } //if multiple tree-links exist remove the checking one var r = (from l in _entityTreeLinks where l.Target == checkLink.Target && l.Source != checkLink.Source select l); if (r.Any()) { _entityTreeLinks.Remove(checkLink); } } foreach (Link link in _entityLinks) { GetHomelessLinks(_homelessLinks, link); } //add links to owning buckets for leftover tree-link sources foreach (Link hlink in _homelessLinks) { var source = (from m in _entityNodes where m.id == hlink.Source select m).FirstOrDefault(); AddLink(GetBucketNode(source), source); } log.Log("Building entity level graph - complete"); }
public void Execute(JobExecutionContext context) { ConsoleLog.WriteLog("同步京东价格--------------Begin"); try { JdJobHelper.AutoUpdatePriceByMessage(); } catch (Exception e) { ConsoleLog.WriteLog("Exception:" + e.Message, LogLevel.Error); ConsoleLog.WriteLog("Exception:" + e.StackTrace, LogLevel.Error); } ConsoleLog.WriteLog("同步京东价格--------------End"); ConsoleLog.WriteLog("同步京东上下架--------------Begin"); try { JdJobHelper.AutoUpdateJdSkuStateByMessage(); } catch (Exception e) { ConsoleLog.WriteLog("Exception:" + e.Message, LogLevel.Error); ConsoleLog.WriteLog("Exception:" + e.StackTrace, LogLevel.Error); } ConsoleLog.WriteLog("同步京东上下架--------------End"); ConsoleLog.WriteLog("同步京东库存--------------Begin"); try { JdJobHelper.AutoUpdateJdStockByMessage(); } catch (Exception e) { ConsoleLog.WriteLog("Exception:" + e.Message, LogLevel.Error); ConsoleLog.WriteLog("Exception:" + e.StackTrace, LogLevel.Error); } ConsoleLog.WriteLog("同步京东库存--------------End"); ConsoleLog.WriteLog("京东商品拒收自动退款--------------Begin"); try { JdJobHelper.AutoRefund(); } catch (Exception e) { ConsoleLog.WriteLog("Exception:" + e.Message, LogLevel.Error); ConsoleLog.WriteLog("Exception:" + e.StackTrace, LogLevel.Error); } ConsoleLog.WriteLog("京东商品拒收自动退款--------------End"); try { JdOrderHelper.SynchroJdForJC(); } catch (Exception e) { ConsoleLog.WriteLog("Exception:" + e.Message, LogLevel.Error); ConsoleLog.WriteLog("Exception:" + e.StackTrace, LogLevel.Error); } }
private void RebuildDisplayableLogs () { // Clear existing displayable logs m_displayableConsoleLogsList.Clear(); // Reset selected logs m_selectedConsoleLog = default(ConsoleLog); // Reset counters InfoLogsCounter = 0; WarningLogsCounter = 0; ErrorLogsCounter = 0; // Iterate through all logs and create a new list of logs based on active configuration int _totalLogs = m_consoleLogsList.Count; for (int _iter = 0; _iter < _totalLogs; _iter++) { ConsoleLog _consoleLog = m_consoleLogsList[_iter]; // Adds to display list, if it satisfies console configuration AddToDisplayableLogList(_consoleLog); } }
private bool fixPositionNextFrame = false; // a hack because the up arrow moves the cursor to the first position. private void Start() { consoleRect = new Rect(0, 0, Screen.width, Mathf.Min(300, Screen.height)); consoleLog = ConsoleLog.Instance; consoleCommandsRepository = ConsoleCommandsRepository.Instance; }
public ConsoleLogFactory() { _log = new ConsoleLog(this); }
/// <summary> /// 创建POST方式的HTTP请求 /// </summary> /// <param name="url">URL</param> /// <param name="parameters">PSOT数据</param> /// <param name="userAgent">UA</param> /// <param name="ContentType">内容类型</param> /// <param name="referer">referer</param> /// <param name="timeout">超时</param> /// <param name="cookies">cookies</param> /// <param name="CustomSource">自定义的来源</param> /// <returns>HttpWebResponse</returns> public static HttpWebResponse CreatePostHttpResponse(string url, JObject parameters, ref CookieContainer cookies, string userAgent = "Windows", string ContentType = "application/x-www-form-urlencoded", string referer = null, int timeout = 3000, string CustomSource = null) { Dictionary <String, String> UAList = new Dictionary <String, String> { { "Windows", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36" }, { "IOS", "Mozilla/5.0 (iPhone; CPU iPhone OS 8_3 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) Version/8.0 Mobile/12F70 Safari/600.1.4" }, { "Andorid", "Mozilla/5.0 (Linux; Android 4.2.1; M040 Build/JOP40D) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.59 Mobile Safari/537.36" } }; HttpWebRequest request = null; //如果是发送HTTPS请求 if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase)) { request = WebRequest.Create(url) as HttpWebRequest; } else { request = WebRequest.Create(url) as HttpWebRequest; } request.Method = "POST"; request.ContentType = ContentType; //设置代理UserAgent和超时 request.UserAgent = UAList[userAgent]; request.Timeout = timeout; request.CookieContainer = cookies; request.Referer = referer ?? string.Empty; //镜华查询在不知道什么时候加了一个这个字段否则就403 if (CustomSource != null) { request.Headers.Set("Custom-Source", CustomSource); } //发送POST数据 if (!(parameters == null || parameters.Count == 0)) { string buffer = JsonConvert.SerializeObject(parameters); byte[] data = Encoding.UTF8.GetBytes(buffer); using (Stream stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } } foreach (string requestHeader in request.Headers) { ConsoleLog.Debug("HTTP-Headers", $"{requestHeader}={request.Headers.GetValues(requestHeader)?[0]}"); } return(request.GetResponse() as HttpWebResponse); }
public void ModulariseEntities(ConsoleLog _log) { log = _log; ProcessUnitMap(log); BuildExternalInterfaces(log); }
private void Button_Click(object sender, RoutedEventArgs e) { var time = DateTime.Now.ToString("hh:mm:ss"); var module = ModuleDefMD.Load(LoadBox.Text); if (StringEnc.IsChecked == true) { StringEncPhase.Execute(module); ConsoleLog.Foreground = Brushes.Aqua; ConsoleLog.AppendText($"{time} Processing String Encryption{Environment.NewLine}"); } if (SOD.IsChecked == true) { OnlinePhase.Execute(module); ConsoleLog.AppendText($"{time} Processing Online Decryption{Environment.NewLine}"); } if (Cflow.IsChecked == true) { ControlFlowObfuscation.Execute(module); ConsoleLog.AppendText($"{time} Processing Control Flow{Environment.NewLine}"); } if (IntConf.IsChecked == true) { AddIntPhase.Execute(module); AddIntPhase.Execute2(module); ConsoleLog.AppendText($"{time} Processing Int Confusion{Environment.NewLine}"); } if (SUC.IsChecked == true) { StackUnfConfusion.Execute(module); ConsoleLog.AppendText($"{time} Processing StackUnfConfusion{Environment.NewLine}"); } if (Ahri.IsChecked == true) { Arithmetic.Execute(module); ConsoleLog.AppendText($"{time} Processing Arithmetic{Environment.NewLine}"); } if (LF.IsChecked == true) { L2F.Execute(module); ConsoleLog.AppendText($"{time} Processing Local Field{Environment.NewLine}"); } if (LFV2.IsChecked == true) { L2FV2.Execute(module); ConsoleLog.AppendText($"{time} Processing Local Field V2{Environment.NewLine}"); } if (Calli_.IsChecked == true) { Calli.Execute(module); ConsoleLog.AppendText($"{time} Processing Call To Calli{Environment.NewLine}"); } if (Proxy_String.IsChecked == true) { ProxyString.Execute(module); ConsoleLog.AppendText($"{time} Processing Proxy Strings{Environment.NewLine}"); } if (ProxyConstants.IsChecked == true) { ProxyINT.Execute(module); ConsoleLog.AppendText($"{time} Processing Proxy Constants{Environment.NewLine}"); } if (Proxy_Meth.IsChecked == true) { ProxyMeth.Execute(module); ConsoleLog.AppendText($"{time} Processing Proxy Methods{Environment.NewLine}"); } if (Renamer.IsChecked == true) { RenamerPhase.Execute(module); ConsoleLog.AppendText($"{time} Processing Renaming{Environment.NewLine}"); } if (Anti_De4dot.IsChecked == true) { AntiDe4dot.Execute(module.Assembly); ConsoleLog.AppendText($"{time} Processing Anti De4dot{Environment.NewLine}"); } if (JumpCflow.IsChecked == true) { JumpCFlow.Execute(module); ConsoleLog.AppendText($"{time} Processing Jump Control flow{Environment.NewLine}"); } if (AntiDebug.IsChecked == true) { Anti_Debug.Execute(module); ConsoleLog.AppendText($"{time} Processing Anti Debug{Environment.NewLine}"); } if (Anti_Dump.IsChecked == true) { AntiDump.Execute(module); ConsoleLog.AppendText($"{time} Processing Anti Dump{Environment.NewLine}"); } if (AntiTamper.IsChecked == true) { Protection.Anti.AntiTamper.Execute(module); ConsoleLog.AppendText($"{time} Processing Anti Tamper{Environment.NewLine}"); } if (InvalidMD.IsChecked == true) { InvalidMDPhase.Execute(module.Assembly); ConsoleLog.AppendText($"{time} Processing Invalid MetaData{Environment.NewLine}"); } var text2 = Path.GetDirectoryName(LoadBox.Text); if (text2 != null && !text2.EndsWith("\\")) { text2 += "\\"; } var path = $"{text2}{Path.GetFileNameWithoutExtension(LoadBox.Text)}_protected{Path.GetExtension(LoadBox.Text)}"; module.Write(path, new ModuleWriterOptions(module) { PEHeadersOptions = { NumberOfRvaAndSizes = 13 }, Logger = DummyLogger.NoThrowInstance }); ConsoleLog.AppendText($"{time} {path}"); if (AntiTamper.IsChecked == true) { Protection.Anti.AntiTamper.Sha256(path); } }
public static IProcessInfo TryResolveTargetProcess(RunningProcessArguments identifiers, ConsoleLog console) { var processResolver = new ProcessResolver(new ProcessFinder()); try { return(processResolver.ResolveTargetProcess(identifiers.Pid, identifiers.Name, identifiers.AppPoolNamePrefix)); } catch (ProcessNotSpecifiedException ex) { throw new ErrorWithExitCodeException(1, ex.Message) { ShowUsage = true }; } catch (ProcessNotFoundException ex) when(ex.Candidates.Any()) { new ProcessListDescriber().DescribeCandidateProcesses(ex.Candidates.ToList(), console); if (Bootstrap.WasUsed) { throw ErrorWithExitCodeException.Propagate(3); } throw new ErrorWithExitCodeException(3, "Please specify a unique process Id using the -p switch."); } catch (ProcessNotFoundException ex) { throw new ErrorWithExitCodeException(3, ex.Message); } }
public scfdivineFormatDecoder() { _ConsoleLog = ConsoleLog.Instance; }
public ConsoleLog AddCh(ConsoleLevel level, string channel, object[] objects) { var log = new ConsoleLog(); log.message = GetStringOf(objects, emptyRefList); log.level = level; log.channel = channel; log.Time = DateTime.UtcNow; if (emptyRefList.Count > 0) { log.references = emptyRefList; emptyRefList = new List<WeakReference>(); } Add(log); return log; }
public static string GetVersion() { ConsoleLog.Println("Developer Console Alpha 0.1"); return(null); }
private void btnSetIP_Click(object sender, RoutedEventArgs e) { if (isInternetup) { if (_isCodingSvcIPSet) { if (!_isStationIDSet) { //UnSetIP //Clear ComboBox and Console Log this.comboID.Items.Clear(); //_ConsoleLogList.Clear(); //this.lvConsoleLog.ItemsSource = _ConsoleLogList; //Cut off the proxy / channel _CallOut_CodingService.Close(); _CallOut_CodingService = null; //Remove the IP Address in config file Properties.Settings.Default.CodingIP = ""; Properties.Settings.Default.Save(); this.txtCodingSvcIP.IsEnabled = true; _isCodingSvcIPSet = false; this.btnSetIP.Content = "Set IP"; } else { MessageBox.Show("Unset Station ID before unset IP address..."); } } else { //Set IP //Trigger to create Coding Service Client with the input IP try { string endpointaddress = "net.tcp://" + this.txtCodingSvcIP.Text.Trim() + ":8000/CallOut_CodingService/service"; _CallOut_CodingService = new ServiceReference1.CallOut_CodingServiceClient(new InstanceContext(this), "NetTcpBinding_CallOut_CodingService", endpointaddress); Log("Open coding service proxy"); _CallOut_CodingService.Open(); //Save the IP address that is confirm Properties.Settings.Default.CodingIP = this.txtCodingSvcIP.Text.Trim(); Properties.Settings.Default.Save(); //Fill up the combobox items foreach (StationStatus station in _CallOut_CodingService.GetStationStatus()) { this.comboID.Items.Add(station.Station); } //Fill the combobox selected text this.comboID.Text = Properties.Settings.Default.CurrentID; //DataGrid Bind //_ConsoleLogList.Clear(); //Load out the console log status from configfile if (this.comboID.Text != "") { this.comboID.IsEnabled = false; if (Properties.Settings.Default.ConsoleLogList != null) { foreach (string log in Properties.Settings.Default.ConsoleLogList) { string[] parts = log.Split(','); //Check is it corresponding stationID if (parts[0] == this.comboID.Text) { ConsoleLog consolelog = new ConsoleLog(); consolelog.CodingID = parts[1]; consolelog.AckTimeStamp = parts[2]; consolelog.AckFrom = parts[3]; consolelog.AckStatus = parts[4]; _ConsoleLogList.Add(consolelog); } } } } this.lvConsoleLog.ItemsSource = _ConsoleLogList; this.txtCodingSvcIP.IsEnabled = false; _isCodingSvcIPSet = true; this.btnSetIP.Content = "Unset IP"; } catch (Exception E) { _CallOut_CodingService = null; MessageBox.Show("Invalid IP address..."); } } } else { ShowMessageBox("Please check the internet connection to continue"); } }
public static string GetCurrentTime() { ConsoleLog.Println("当前时间: " + DateTime.Now); return(null); }
private void MyWindow_Loaded(object sender, RoutedEventArgs e) { // Capture the UI synchronization context _uiSyncContext = SynchronizationContext.Current; //Fill in the IP address from IP config file string[] lineOfContents = File.ReadAllLines(@"..\..\..\..\IPConfigFile.txt"); this.txtCodingSvcIP.Text = lineOfContents[3].Trim(); //Check whether CodingIP exist if (Properties.Settings.Default.CodingIP != null && Properties.Settings.Default.CodingIP != "") { this.txtCodingSvcIP.Text = Properties.Settings.Default.CodingIP; this.txtCodingSvcIP.IsEnabled = false; _isCodingSvcIPSet = true; this.btnSetIP.Content = "Unset IP"; string endpointaddress = "net.tcp://" + this.txtCodingSvcIP.Text.Trim() + ":8000/CallOut_CodingService/service"; EndpointAddress endpointaddr = new EndpointAddress(new Uri(endpointaddress)); _CallOut_CodingService = new ServiceReference1.CallOut_CodingServiceClient(new InstanceContext(this), "NetTcpBinding_CallOut_CodingService", endpointaddr); Log("open new coding service proxy from setting window"); _CallOut_CodingService.Open(); //Connection is UP!!! //Fill up the combobox items foreach (StationStatus station in _CallOut_CodingService.GetStationStatus()) { this.comboID.Items.Add(station.Station); } //Fill the combobox selected text this.comboID.Text = Properties.Settings.Default.CurrentID; //DataGrid Bind _ConsoleLogList.Clear(); //Load out the console log status from configfile if (this.comboID.Text != "") { this.comboID.IsEnabled = false; _isStationIDSet = true; this.btnSetID.Content = "Unset"; if (Properties.Settings.Default.ConsoleLogList != null) { foreach (string log in Properties.Settings.Default.ConsoleLogList) { string[] parts = log.Split(','); //Check is it corresponding stationID if (parts[0] == this.comboID.Text) { ConsoleLog consolelog = new ConsoleLog(); consolelog.CodingID = parts[1]; consolelog.AckTimeStamp = parts[2]; consolelog.AckFrom = parts[3]; consolelog.AckStatus = parts[4]; _ConsoleLogList.Add(consolelog); } } } } this.lvConsoleLog.ItemsSource = _ConsoleLogList; } }
public override void Execute(string[] arguments) { ConsoleLog.Println(Method.Invoke(null, null) as string); }
private void AddExternalEntityLinks(ConsoleLog log) { log.Log("Building entity level graph external links - start"); FAASModel _context = new FAASModel(); var f = (from r in _context.EntityRelationships select new { RelationshipId = r.Id, TargetEntityId = r.CalledEntityId, SourceEntityId = r.CallingEntityId, TargetUnit = (from t in _context.Entities where t.Id == r.CalledEntityId select new { t.NormalisedUnit }).FirstOrDefault(), SourceUnit = (from t in _context.Entities where t.Id == r.CallingEntityId select new { t.NormalisedUnit }).FirstOrDefault() }); //46364 error foreach (var a in f) { //add check to see: does reverse (target, source) relationship exist? var loopbackExist = (from m in _entityRels where m.CalledEntityId == a.SourceEntityId && m.CallingEntityId == a.TargetEntityId select m); //build external (bucket to bucket) links if (a.SourceUnit.NormalisedUnit != a.TargetUnit.NormalisedUnit) { var ent1 = (from m in _entities where m.Id == a.SourceEntityId select m).FirstOrDefault(); Entity x = (Entity)ent1; //get node or add if doesnt exist Node source = GetNode(ent1); var ent2 = (from m in _entities where m.Id == a.TargetEntityId select m).FirstOrDefault(); Entity xx = (Entity)ent2; //get node or add if doesnt exist Node target = GetNode(ent2); AddLink(source, target); } } log.Log("Building entity level graph external links - complete"); }
public bool Failed(string why_failed) { ConsoleLog.Warn("[RLVapi/Failed] " + CommandName + ": " + why_failed); return(false); }
public void PrintGraph(ConsoleLog log) { log.Log("Saving Entity Links graph file - start"); //start the graph file TextWriter wgraph = new StreamWriter(GetFromConfig("EntityGraphFilePath")); //structural data (links) wgraph.WriteLine(string.Format("Graph \r\n {{ \r\n ### metadata ### \r\n @name=\"HSA\"; \r\n @description=\"A Housing SA System Graph\"; \r\n @numNodes={0}; \r\n @numLinks={1}; \r\n @numPaths=0; \r\n @numPathLinks=0; \r\n \r\n ### structural data ### \r\n @links=[ \r\n", _entityNodes.Count, _entityLinks.Count)); foreach (Link l in _entityLinks) { string line; if (!l.Id.Equals(_entityLinks.Count - 1)) { line = string.Format("{{ {0}; {1}; }}, ", l.Source, l.Target); wgraph.WriteLine(line); } else if (l.Id.Equals(_entityLinks.Count - 1)) { line = string.Format("{{ {0}; {1}; }} ", l.Source, l.Target); wgraph.WriteLine(line); } } //start the attribute data (tree links) wgraph.WriteLine(string.Format("\r\n ]; \r\n @paths=; \r\n ### attribute data ### \r\n @enumerations=; \r\n @attributeDefinitions=[ \r\n {{" + "@name=$root; \r\n @type=bool; \r\n @default=|| false ||; \r\n @nodeValues=[ {{ @id=0; @value=T; }} ]; \r\n @linkValues=; \r\n @pathValues=; \r\n }}, \r\n {{ \r\n @name=$tree_link; \r\n @type=bool; \r\n @default=|| false ||; \r\n @nodeValues=; \r\n @linkValues=[")); foreach (Link tl in _entityTreeLinks) { int curElement = _entityTreeLinks.IndexOf(tl); if (!curElement.Equals(_entityTreeLinks.Count - 1)) { string line = string.Format("{{ {0}; T; }}, ", tl.Id); wgraph.WriteLine(line); } else if (curElement.Equals(_entityTreeLinks.Count - 1)) { string line = string.Format("{{ {0}; T; }} ", tl.Id); wgraph.WriteLine(line); } } // (labels) wgraph.WriteLine(string.Format("]; \r\n @pathValues=; \r\n }}, \r\n {{ \r\n @name=$labels; \r\n @type=string; \r\n @default=; \r\n @nodeValues=[ ")); foreach (Node n in _entityNodes) { if (!n.id.Equals(_entityNodes.Count - 1)) { string line = string.Format("{{ {0}; \"{1}\"; }}, ", n.id, FormatLabel(n.name)); wgraph.WriteLine(line); } else if (n.id.Equals(_entityNodes.Count - 1)) { string line = string.Format("{{ {0}; \"{1}\"; }} ", n.id, FormatLabel(n.name)); wgraph.WriteLine(line); } } //Closing line wgraph.WriteLine(string.Format("];\r\n @linkValues=; \r\n @pathValues=; \r\n }} \r\n ]; \r\n @qualifiers=[ \r\n {{ \r\n @type=$spanning_tree; \r\n @name=$sample_spanning_tree; \r\n @description=; \r\n @attributes=[ \r\n {{ @attribute=0; @alias=$root; }}, \r\n {{ @attribute=1; @alias=$tree_link; }} \r\n ]; \r\n }} \r\n ]; \r\n ### visualization hints ### \r\n @filters=; \r\n @selectors=; \r\n @displays=; \r\n @presentations=; \r\n ### interface hints ### \r\n @presentationMenus=; \r\n @displayMenus=; \r\n @selectorMenus=; \r\n @filterMenus=; \r\n @attributeMenus=; \r\n }}")); wgraph.Close(); log.Log("Printing graph file - complete"); }
public override bool CallFunction(string[] args) { if (base.CallFunction(args) == true) { Dictionary <string, ParcelFlags> flags = parcel_static.get_flags_list(); List <string> get_flags = new List <string>(); List <string> otherargs = new List <string>(args); string target = otherargs[0]; otherargs.RemoveAt(0); if (otherargs.Count == 0) { otherargs.Add("ALL"); } if (otherargs[0] == "ALL") { foreach (string A in flags.Keys) { get_flags.Add(A); } } else { foreach (string a in otherargs) { if (flags.ContainsKey(a) == true) { get_flags.Add(a); } else { ConsoleLog.Warn("Flag: " + a + " is unknown"); } } } if (get_flags.Count > 0) { int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); Parcel p = bot.GetClient.Network.CurrentSim.Parcels[localid]; StringBuilder reply = new StringBuilder(); string addon = ""; foreach (string cfg in get_flags) { if (flags.ContainsKey(cfg) == true) { reply.Append(addon); reply.Append(cfg); reply.Append("="); reply.Append(p.Flags.HasFlag(flags[cfg]).ToString()); if (addon != ",") { addon = ","; } } } return(bot.GetCommandsInterface.SmartCommandReply(target, reply.ToString(), CommandName)); } else { return(Failed("No accepted flags")); } } return(false); }
public TestHelper() { l = new ConsoleLog(); tw = new FakeStringWriter(l); Console.SetOut(tw); }
bool cbFunc8self8(object obj) { List <UserRanking> objList = obj as List <UserRanking>; List <UserRanking> rankingList = null; if (null == objList) { return(true); } else { rankingList = objList; } if (null == rankingList || rankingList.Count == 0) { return(true); } int selfScore = requestPack.PageIndex; UserRanking ur = new UserRanking(); ur.Score = selfScore; int pos = rankingList.BinarySearch(ur, new comp()); int h, l, maxPaiHangNum; maxPaiHangNum = objList.Count; //self responsePack.Items.Add(new RankData() { UserName = "", Score = int.MaxValue }); h = rankingList[0].Score; l = rankingList[rankingList.Count - 1].Score > selfScore ? selfScore : rankingList[rankingList.Count - 1].Score; int maxSend = GameConfigMgr.Instance().getInt("rank_send_num", 10); if (maxSend > rankingList.Count) { maxSend = 20; } if (pos < 0) { pos = ~pos; } int theNumOf3 = (maxSend - 3); int half = theNumOf3 / 2; int begin = pos - half; int end = pos + half; if (begin < 0) { begin = 0; end = maxSend; } if (end > rankingList.Count) { end = rankingList.Count; begin = end - theNumOf3; if (begin < 0) { begin = 0; ConsoleLog.showErrorInfo(0, "Action1001,begin<0.UserID:" + requestPack.UserID); } if (pos == rankingList.Count) { begin += 1; } } int cnt = Math.Min(begin, 3); for (int i = 0; i < cnt; ++i) { if (rankingList[i].UserID == requestPack.UserID) { continue; } RankData rd = new RankData(); rd.Score = rankingList[i].Score; rd.UserName = rankingList[i].UserName; rd.UserID = rankingList[i].UserID; responsePack.Items.Add(rd); } for (int i = begin; i < end; ++i) { if (rankingList[i].UserID == requestPack.UserID) { continue; } RankData rd = new RankData(); rd.Score = rankingList[i].Score; rd.UserName = rankingList[i].UserName; rd.UserID = rankingList[i].UserID; responsePack.Items.Add(rd); } RankData self = new RankData(); self.UserID = requestPack.UserID; self.UserName = "******"; self.Score = selfScore; responsePack.Items.Add(self); responsePack.Items.Sort(new compRD()); if (pos < 0) { pos = ~pos; if (pos + 1 > 99999) { pos = 99998; } } if (pos >= 99999) { pos = 99998; } if (begin >= 99999) { begin = 99998 - maxSend; } if (end >= 99999) { end = 99998; } responsePack.Items[0].UserName = h + "," + l + "," + rankingList.Count + "," + pos + "," + begin + "," + end; // ��߷֣���ͷ֣��������Լ����� //ConsoleLog.showNotifyInfo(responsePack.Items[0].UserName); return(true); }
private bool AddToDisplayableLogList (ConsoleLog _consoleLog) { // First check if tag for this is active or not int _tagID = _consoleLog.TagID; ConsoleTag _logTag = m_consoleTags[_tagID]; if (!_logTag.IsActive) return false; // Update log message counters if (_consoleLog.Type == eConsoleLogType.INFO) InfoLogsCounter++; else if (_consoleLog.Type == eConsoleLogType.WARNING) WarningLogsCounter++; else ErrorLogsCounter++; // Next we need to check log-type if (((int)_consoleLog.Type & (int)m_allowedLogTypes) == 0) return false; // Now that it passed our configurations, add it to the list m_displayableConsoleLogsList.Add(_consoleLog); return true; }
public async Task <bool> Start() { if (_isRunning) { return(true); } loadConfigurationFromDB(_IoTHubAliasName, _msgProcessorFactoryModel); fetchAvailableIoTHub(); _msgProcessorFactoryModel.SfDocumentDBHelper = await fetchDocumentDB(); _msgProcessorFactoryModel.SfblobStorageHelper = new BlobStorageHelper(_CompatibleEventHub.StorageConnectionString, "telemetry"); _msgProcessorFactoryModel.SfQueueClient = QueueClient.CreateFromConnectionString(Program._sbConnectionString, Program._sbAlarmOpsQueue); _msgProcessorFactoryModel.SfInfraQueueClient = QueueClient.CreateFromConnectionString(Program._sbConnectionString, Program._sbInfraOpsQueue); _msgProcessorFactoryModel.IsIoTHubPrimary = _isPrimary; _msgProcessorFactoryModel.IoTHubAlias = _IoTHubAliasName; string eventProcessorHostName = _companyId + "-" + _IoTHubAliasName.ToLower(); if (eventProcessorHostName.Contains(" ")) { eventProcessorHostName = eventProcessorHostName.Replace(' ', Program.REPLACE_SPACE_TO_DASH); } string leaseName = eventProcessorHostName; _eventProcessorHost = new EventProcessorHost( eventProcessorHostName, // Task ID _CompatibleEventHub.EndpointName, // Endpoint: messages/events _CompatibleEventHub.ConsumerGroup, // Consumer Group _CompatibleEventHub.IoTHubConnectionString, // IoT Hub Connection String _CompatibleEventHub.StorageConnectionString, leaseName); ConsoleLog.WriteToConsole("Registering IoTHubAliasEventMessageReceiver on {0} ...", _IoTHubAliasName); var options = new EventProcessorOptions { InitialOffsetProvider = (partitionId) => DateTime.UtcNow }; options.ExceptionReceived += (sender, e) => { ConsoleLog.WriteToConsole("EventProcessorOptions Exception:{0}", e.Exception); ConsoleLog.WriteBlobLogError("EventProcessorOptions Exception:{0}", e.Exception); }; try { //await _eventProcessorHost.RegisterEventProcessorAsync<sfEventMessage>(options); await _eventProcessorHost.RegisterEventProcessorFactoryAsync(new SfEventMessageProcessorFactory(_msgProcessorFactoryModel), options); _isRunning = true; } catch (Exception ex) { _isRunning = false; //keepFailStatus(); //string hubname = _isPrimary ? "Primary" : "Secondary"; //ConsoleLog.WriteToConsole("{0} IoTHub Fail, try switch to another IoTHub - Exception: {1}", hubname, ex.Message); //ConsoleLog.WriteBlobLogError("{0} IoTHub Fail, try switch to another IoTHub - Exception: {1}", hubname, ex.Message); ConsoleLog.WriteBlobLogError("IoTHub Fail, Closed. - Exception: {0}", ex.Message); /* Send out a message: restart to Topic */ //SfOperationTaskHelper.RestartIoTHubRecevicer( // _companyId, // _IoTHubAliasName, // Program.GetEventProcessorHostName(_IoTHubAliasName), // "null"); Environment.Exit(0); } return(true); }
private void Start() { consoleCommandsRepository = ConsoleCommandsRepository.Instance; consoleLog = ConsoleLog.Instance; }
protected ReadContext ReadNodeProcess(string filePath, string nodeName) { FileStream stream = new FileStream(filePath, FileMode.Open); System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(stream); ReadArgs readArgs = null; ReadContext context = new ReadContext(); bool readIsFinish = false; if (nodeName == null) { reader.Read(); } else { reader.ReadToFollowing(nodeName); } do { int nowDepth = reader.Depth; switch (reader.NodeType) { case System.Xml.XmlNodeType.Element: ConsoleLog.WriteLine(System.Xml.XmlNodeType.Element + "-" + reader.Name); //该条件成立时,判定读取节点为GroupNode if (context.PreviousNodeType == System.Xml.XmlNodeType.Element) { readArgs.Type = XmlNodeType.Group; ReadSingleNodeStart?.Invoke(context, readArgs); if (reader.Depth == context.PreviousDepth && readArgs.Name == nodeName) { readIsFinish = true; context.PopParentNode(); break; } } readArgs = new ReadArgs(); context.NodeIsEnd = ReadElement(reader, readArgs, context); context.PreviousNodeType = System.Xml.XmlNodeType.Element; context.PreviousDepth = nowDepth; break; case System.Xml.XmlNodeType.Text: ConsoleLog.WriteLine(System.Xml.XmlNodeType.Text + "-" + reader.Name); //判定当前节点为ContentNode readArgs.Type = XmlNodeType.Content; ReadSingleNodeStart?.Invoke(context, readArgs); context.NodeIsEnd = ReadText(reader, readArgs, context); context.PreviousNodeType = System.Xml.XmlNodeType.Text; context.PreviousDepth = nowDepth; break; case System.Xml.XmlNodeType.EndElement: ConsoleLog.WriteLine(System.Xml.XmlNodeType.EndElement + "-" + reader.Name); //当条件成立时,判定节点为GroupNode if (context.PreviousNodeType == System.Xml.XmlNodeType.Element) { readArgs.Type = XmlNodeType.Group; ReadSingleNodeStart?.Invoke(context, readArgs); } context.NodeIsEnd = ReadEndElement(reader, readArgs, context); ReadSingleNodeEnd?.Invoke(context, readArgs); if (reader.Name == nodeName) { readIsFinish = true; } readArgs = new ReadArgs(); context.PreviousNodeType = System.Xml.XmlNodeType.EndElement; context.PreviousDepth = nowDepth; break; } if (readIsFinish) { break; } }while (reader.Read()); reader.Close(); return(context); }
static void Main(string[] args) { // ## LOG //Default log Log.Write("Log test"); //Write by type Log.Write(LogTypeEnum.SUCCESS, "Success log"); Log.Write(LogTypeEnum.INFO, "Info log"); Log.Write(LogTypeEnum.PROCESS, "Process log"); Log.Write(LogTypeEnum.TRACKING, "Tracking log"); Log.Write(LogTypeEnum.WARNING, "Warning log"); Log.Write(LogTypeEnum.ERROR, "Error log"); Log.Write(LogTypeEnum.EXCEPTION, "Exception log"); //Write with format Log.Write(LogTypeEnum.INFO, "Format of the log {0}", "AnayaRojo"); //Write exception Log.Write(new Exception("Log exception")); // ## CONSOLE LOG //Default log ConsoleLog.Show("Log test"); //Show by type ConsoleLog.Show(LogTypeEnum.SUCCESS, "Success log"); ConsoleLog.Show(LogTypeEnum.INFO, "Info log"); ConsoleLog.Show(LogTypeEnum.PROCESS, "Process log"); ConsoleLog.Show(LogTypeEnum.TRACKING, "Tracking log"); ConsoleLog.Show(LogTypeEnum.WARNING, "Warning log"); ConsoleLog.Show(LogTypeEnum.ERROR, "Error log"); ConsoleLog.Show(LogTypeEnum.EXCEPTION, "Exception log"); //Show with format ConsoleLog.Show(LogTypeEnum.INFO, "Format of the log {0}", "AnayaRojo"); //Show exception ConsoleLog.Show(new Exception("Log exception")); // ## EVENT LOG //Default log EventLog.Save("Log test"); //Save by type EventLog.Save(LogTypeEnum.SUCCESS, "Success log"); EventLog.Save(LogTypeEnum.INFO, "Info log"); EventLog.Save(LogTypeEnum.PROCESS, "Process log"); EventLog.Save(LogTypeEnum.TRACKING, "Tracking log"); EventLog.Save(LogTypeEnum.WARNING, "Warning log"); EventLog.Save(LogTypeEnum.ERROR, "Error log"); EventLog.Save(LogTypeEnum.EXCEPTION, "Exception log"); //Save with format EventLog.Save(LogTypeEnum.INFO, "Format of the log {0}", "AnayaRojo"); //Save exception EventLog.Save(new Exception("Log exception")); // ## DATA BASE LOG //Default log DataBaseLog.Save("Log test"); //Save by type DataBaseLog.Save(LogTypeEnum.SUCCESS, "Success log"); DataBaseLog.Save(LogTypeEnum.INFO, "Info log"); DataBaseLog.Save(LogTypeEnum.PROCESS, "Process log"); DataBaseLog.Save(LogTypeEnum.TRACKING, "Tracking log"); DataBaseLog.Save(LogTypeEnum.WARNING, "Warning log"); DataBaseLog.Save(LogTypeEnum.ERROR, "Error log"); DataBaseLog.Save(LogTypeEnum.EXCEPTION, "Exception log"); //Save with format DataBaseLog.Save(LogTypeEnum.INFO, "Format of the log {0}", "AnayaRojo"); //Save exception DataBaseLog.Save(new Exception("Log exception")); // ## MAIL LOG //Default log MailLog.Send("Log test"); //Send by type MailLog.Send(LogTypeEnum.SUCCESS, "Success log"); MailLog.Send(LogTypeEnum.INFO, "Info log"); MailLog.Send(LogTypeEnum.PROCESS, "Process log"); MailLog.Send(LogTypeEnum.TRACKING, "Tracking log"); MailLog.Send(LogTypeEnum.WARNING, "Warning log"); MailLog.Send(LogTypeEnum.ERROR, "Error log"); MailLog.Send(LogTypeEnum.EXCEPTION, "Exception log"); //Send with format MailLog.Send(LogTypeEnum.INFO, "Format of the log {0}", "AnayaRojo"); //Send exception MailLog.Send(new Exception("Log exception")); }
public override bool TakeAction() { var cache = new ShareCacheStruct <ShareRealItemCnt>(); var persionCache = new PersonalCacheStruct <HappyModeData>(); int keyId = utils.KeyUInt2Int(requestPack.the3rdUserID); HappyModeData hmd = persionCache.FindKey(keyId.ToString()); List <int> keys = GameConfigMgr.Instance().getHappyDataKeys(); if (hmd != null) { doReflesh(hmd, keys); } for (int i = 0; i < keys.Count; ++i) { memoryRealInfoDataModel.HappyData hd = GameConfigMgr.Instance().getHappyData(keys[i]); ShareRealItemCnt sric = cache.FindKey(keys[i]); if (null != hd && null != sric) { RealItemData rid = new RealItemData(); rid.id = hd.itemID; rid.name = hd.name; rid.happyPoint = hd.needHappyPoint; rid.num = sric.num; rid.timeForReflesh = (sric.preUpdateTime.AddMinutes(hd.MinuteForReflesh) - System.DateTime.Now); rid.uiStatus = 0; if (0 == rid.num) { rid.uiStatus = 1; } if (null != hmd) { bool findIt = false; if (hmd.realItemBuyCntInRefleshTime.ContainsKey(rid.id)) { findIt = hmd.realItemBuyCntInRefleshTime[rid.id].cnt > 0; } bool canReplace = hd.canReplace == 1; if (false == canReplace) { if (hmd.RealItemInfoLst.Exists((o) => { return(o.realItemID == rid.id); })) { rid.uiStatus = 2; } } else { if (findIt) { rid.uiStatus = 2; } } } responsePack.Data.Add(rid); } else { ConsoleLog.showErrorInfo(0, "is null" + (null == hd).ToString() + ":" + (null == sric).ToString()); } } //ConsoleLog.showErrorInfo(0, "responsePack cnt:"+responsePack.Data.Count); responsePack.errorCode = 0; return(true); }
public void SetUp() { testFile = Path.GetTempFileName(); log = new ConsoleLog(); sdoutWriter = Console.Out; }
public override void Run(string[] args) { if (args.Length < 2) { Usage("not enough arguments"); } try { var oLog4NetCfg = new Log4Net().Init(); m_oLog = new ConsoleLog(new SafeILog(this)); m_oDB = new SqlConnection(oLog4NetCfg.Environment, m_oLog); var service = new EBusinessService(); var refNum = args[1]; if (args[0] == "limited") { var result = service.GetLimitedBusinessData(refNum, 1, false, false); Console.WriteLine("Output XML:"); Console.WriteLine(); Console.WriteLine(result.OutputXml); Console.WriteLine(); Console.WriteLine("Limited business with ref number = {0}", refNum); Console.WriteLine(JsonConvert.SerializeObject(result)); } else if (args[0] == "nonlimited") { var result = service.GetNotLimitedBusinessData(refNum, 1, false, false); Console.WriteLine("Output XML:"); Console.WriteLine(); Console.WriteLine(result.OutputXml); Console.WriteLine(); Console.WriteLine("Non Limited business with ref number = {0}", refNum); Console.WriteLine(JsonConvert.SerializeObject(result)); } else if (args[0] == "targeting") { if (args.Length < 4) { throw new Exception("not enough parameters"); } TargetResults.LegalStatus status = TargetResults.LegalStatus.DontCare; if (args[3] == "limited") { status = TargetResults.LegalStatus.Limited; } if (args[3] == "nonlimited") { status = TargetResults.LegalStatus.NonLimited; } var limitedRefNum = ""; if (args.Length == 5) { limitedRefNum = args[4]; } var result = service.TargetBusiness(refNum, args[2], 1, status, limitedRefNum); Console.WriteLine("Output XML:"); Console.WriteLine(); Console.WriteLine(result.OutStr); Console.WriteLine(); Console.WriteLine("Json Targeting Companies for {0} {1}:", refNum, args[2]); Console.WriteLine(JsonConvert.SerializeObject(result)); } else { Usage("wrong params"); } } catch (Exception ex) { Usage(ex.Message); } }
private void OnLogSelectedHandler(ConsoleLog log) { focusedLog = log; console.Focus(DrawGuiBodyHandler); }
public override bool CallFunction(string[] args) { if (base.CallFunction(args) == true) { Dictionary <string, ParcelFlags> flags = parcel_static.get_flags_list(); List <string> get_flags = new List <string>(); List <string> otherargs = new List <string>(args); string target = otherargs[0]; otherargs.RemoveAt(0); if (otherargs.Count == 0) { otherargs.Add("ALL"); } if (otherargs[0] == "ALL") { foreach (string A in flags.Keys) { get_flags.Add(A); } } else { foreach (string a in otherargs) { if (flags.ContainsKey(a) == true) { get_flags.Add(a); } else { ConsoleLog.Warn("Flag: " + a + " is unknown"); } } } if (get_flags.Count > 0) { int localid = bot.GetClient.Parcels.GetParcelLocalID(bot.GetClient.Network.CurrentSim, bot.GetClient.Self.SimPosition); if (bot.GetClient.Network.CurrentSim.Parcels.ContainsKey(localid) == true) { Parcel p = bot.GetClient.Network.CurrentSim.Parcels[localid]; Dictionary <string, string> collection = new Dictionary <string, string>(); foreach (string cfg in get_flags) { if (flags.ContainsKey(cfg) == true) { collection.Add(cfg, p.Flags.HasFlag(flags[cfg]).ToString()); } } return(bot.GetCommandsInterface.SmartCommandReply(true, target, p.Name, CommandName, collection)); } else { return(Failed("Unable to find parcel in memory, please wait and try again")); } } else { return(Failed("No accepted flags")); } } return(false); }
private void Start() { consoleRect = new Rect(0, 0, Screen.width, Mathf.Min(300, Screen.height)); consoleLog = ConsoleLog.Instance; }