public void addToModifiedProbeLoggerList(Logger p) { Logger existLogger = ModifiedLoggerList.FirstOrDefault((loggerInList) => { if (String.Equals(p.contextName, loggerInList.contextName) && String.Equals(p.loggerName, loggerInList.loggerName)) { return(true); } return(false); }); if (existLogger == null) { ModifiedLoggerList.Add(p); } else { if (existLogger.loggerLevel != p.loggerLevel || existLogger.setLoggerLevel != p.setLoggerLevel) { existLogger.loggerLevel = p.loggerLevel; existLogger.setLoggerLevel = p.setLoggerLevel; ConfigLoggerWindow.refreshModifiedLoggerListCollectionView(); } } }
private void processResponse(byte[] data) { if (data == null) { return; } string message = Encoding.UTF8.GetString(data, 0, data.Length); LogCommandResponse logCommandResponse = JsonConvert.DeserializeObject <LogCommandResponse>(message); switch (logCommandResponse.command) { case LogCommand.COMMAND_PROBE_RESPONSE: { string contextName = logCommandResponse.contextName; Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (!ServicesList.Contains(contextName)) { ServicesList.Add(contextName); } logCommandResponse.probeLoggers?.ForEach(p => { //if (!p.loggerName.StartsWith("com.yyn")) //{ // return; //} p.contextName = contextName; { Logger existLogger = LoggerList.FirstOrDefault((loggerInList) => { if (String.Equals(p.contextName, loggerInList.contextName) && String.Equals(p.loggerName, loggerInList.loggerName)) { return(true); } return(false); }); if (existLogger == null) { p.setLoggerLevel = p.loggerLevel; LoggerList.Add(p); } else { if (existLogger.loggerLevel != p.loggerLevel || existLogger.setLoggerLevel != p.setLoggerLevel) { existLogger.loggerLevel = p.loggerLevel; existLogger.setLoggerLevel = p.setLoggerLevel; ConfigLoggerWindow.refreshList(); } } if (p.configured) { addToModifiedProbeLoggerList(p); } } }); }), null); } break; case LogCommand.COMMAND_PROBE_SERVICE_RESPONSE: { ProbeServiceResponse probeServiceResponse = JsonConvert.DeserializeObject <ProbeServiceResponse>(message); string contextName = probeServiceResponse.contextName; if (!String.IsNullOrEmpty(probeServiceResponse.contextName)) { Application.Current.Dispatcher.BeginInvoke(new Action(() => { if (!ServicesList.Contains(contextName)) { ServicesList.Add(contextName); } }), null); } } break; case LogCommand.COMMAND_LOG_OUTPUT: { MainWindow.AppendMessageStatic(logCommandResponse.mesasge); } break; } }