private static void LogMessages(StiReport report, LogMonitor logMonitor) { if (report.ReportRenderingMessages == null || report.ReportRenderingMessages.Count <= 0) { return; } }
protected override void OnInit(params string[] arguments) { Monitor = new LogMonitor(); var word = "可乐|雪碧"; Identity = Guid.NewGuid().ToString(); AddRequest( new Request( string.Format("http://news.baidu.com/ns?word={0}&tn=news&from=news&cl=2&pn=0&rn=20&ct=1", word), new Dictionary <string, dynamic> { { "Keyword", word }, { "guid", _guid } }) { Headers = new Dictionary <string, object> { { "Upgrade-Insecure-Requests", "1" } }, Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8" }); AddEntityType <BaiduSearchEntry>() .SetRequestExtractor(new AutoIncrementRequestExtractor("&pn=0", 1)) .SetLastPageChecker(new TestLastPageChecker()); AddPipeline(new CollectionEntityPipeline()); }
public void ReadAllText_UTF8() { var log = new List <string>(); LogMonitor logMonitor = (eventType, eventName, message) => { if (eventName == "FilesUtility" && eventType == Logging.EventType.Warning) { log.Add($"{message}"); } }; var testPath = Path.GetTempFileName(); string sampleText = "111\r\n¤\r\n333"; File.WriteAllText(testPath, sampleText, Encoding.UTF8); var files = new FilesUtility(new ConsoleLogProvider(logMonitor)); string readText; try { readText = files.ReadAllText(testPath); } finally { File.Delete(testPath); } Assert.AreEqual(sampleText, readText); Assert.AreEqual("", TestUtility.Dump(log)); }
public virtual void CheckReadPermit() { if (!DoesUserHaveViewRoles()) { LogMonitor.Log(new LogMessageEntry(DeniedAccessReadLog, string.Format(Resources.EUserDoesNotHaveViewPermitions, HeaderRu))); UserRoles.UserDoesNotHavePermitions(string.Format(Resources.EUserDoesNotHaveViewPermitions, Header)); } }
public static void Start() { if (!GameUtility.IsDebugBuild || !Object.op_Equality((Object)LogMonitor.mInstnace, (Object)null)) { return; } LogMonitor.mInstnace = (LogMonitor) new GameObject(nameof(LogMonitor)).AddComponent <LogMonitor>(); }
protected override void MyInit(params string[] arguments) { Monitor = new LogMonitor(); AddPipeline(new ConsoleEntityPipeline()); AddStartUrl("http://www.baidu.com"); AddStartUrl("http://www.sohu.com"); AddEntityType <BaiduEntity>(); AddEntityType <SohuEntity>(); }
protected override void MyInit(params string[] arguments) { Monitor = new LogMonitor(); Identity = Guid.NewGuid().ToString("N"); Scheduler = new RedisScheduler("127.0.0.1:6379,serviceName=Scheduler.NET,keepAlive=8,allowAdmin=True,connectTimeout=10000,password=,abortConnect=True,connectRetry=20"); AddStartUrl("https://baidu.com"); AddPipeline(new ConsoleEntityPipeline()); AddEntityType <TestEntity>(); }
/// <summary> /// Handles the AfterExecute event before a query has been executed /// </summary> /// <param name="Guid">The GUID.</param> /// <param name="ID">The ID.</param> /// <param name="CustomIn">The custom in.</param> /// <param name="CustomOut">The custom out.</param> private void QueryExecute_BeforeExecute(string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) { if (this.DisplayTransactionLog) { string database = ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo.AdvancedOptions["DATABASE"]; string connectionString = ConnectionManager.GetConnectionString(ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo); this.startLsn = LogMonitor.StartMonitoring(connectionString, database); } }
protected override void OnInit(params string[] arguments) { Monitor = new LogMonitor(); AddStartUrl("http://news.baidu.com/ns?word=可乐|雪碧&tn=news&from=news&cl=2&pn=0&rn=20&ct=1", new Dictionary <string, dynamic> { { "Keyword", "可乐|雪碧" } }); EmptySleepTime = 1000; AddEntityType <BaiduSearchEntry>(); AddPageProcessors(new MyProcessor()); AddPipeline(new MyPipeline()); }
public async Task <IHttpActionResult> GetLogMonitor(int id) { LogMonitor logMonitor = await db.LogMonitors.FindAsync(id); if (logMonitor == null) { return(NotFound()); } return(Ok(logMonitor)); }
protected override void OnPreRender(EventArgs e) { if (!IsPostBack) { EnsureChildControls(); LogMonitor.Log(new LogMessageEntry(ViewLog, HeaderRu, RvsSavedProperties.GetFromJournal(this))); } base.OnPreRender(e); ScriptManager.RegisterScriptControl(this); }
/// <summary> /// 初始化日志 /// </summary> static Logger() { ReleaseRefDLL("zlib32.dll", Properties.Resources.zlib32); ReleaseRefDLL("zlib64.dll", Properties.Resources.zlib64); var logger = LoggerFactory.CreateLogger(Config.Environment); _tokenBucket = new TokenBucket <LogBase>(Config.MaxHandleNum); _monitor = new LogMonitor <LogBase>(Config.MaxThrdNum, Config.MaxUploadNum, _tokenBucket); _monitor.Start(logger); }
public async Task <IHttpActionResult> PostLogMonitor(LogMonitor logMonitor) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.LogMonitors.Add(logMonitor); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = logMonitor.Id }, logMonitor)); }
protected override void MyInit(params string[] arguments) { Scheduler.Depth = 100; Monitor = new LogMonitor(); Identity = Guid.NewGuid().ToString(); ThreadNum = 1; EmptySleepTime = 5000; ExitWhenComplete = true; PipelineCachedSize = 1; SkipTargetUrlsWhenResultIsEmpty = false; AddPipeline(new CollectionEntityPipeline()); AddStartUrl("http://www.cas.cn/kx/kpwz/index.shtml"); AddEntityType <ArticleSummary>(); }
// Start is called before the first frame update void Start() { if (instance == null) { instance = this; DontDestroyOnLoad(this); } else { Destroy(gameObject); } print("data path : " + Application.persistentDataPath); }
protected override void MyInit(params string[] arguments) { Monitor = new LogMonitor(); var word = "可乐|雪碧"; Identity = Guid.NewGuid().ToString(); AddStartUrl(string.Format("http://news.baidu.com/ns?word={0}&tn=news&from=news&cl=2&pn=0&rn=20&ct=1", word), new Dictionary <string, dynamic> { { "Keyword", word }, { "guid", _guid } }); AddEntityType <BaiduSearchEntry>(new AutoIncrementTargetUrlsExtractor("&pn=0", 1, new TestTargetUrlsExtractorTermination())); AddPipeline(new CollectionEntityPipeline()); }
List <LogMonitor> GetLogMonitors(string logLocation) { IEnumerable <string> folderPaths = GetLogDirectoryPaths(logLocation); var logMonitors = new List <LogMonitor>(); foreach (var path in folderPaths) { try { var monitor = new LogMonitor(path); logMonitors.Add(monitor); } catch { } } return(logMonitors); }
/// <summary> /// Monitor the chat client on the background thread /// </summary> public override void Monitor() { string message; if (TryGet(out message)) { if (!ConsumeMessage(message)) { if (LogMonitor != null) { LogMonitor.Invoke(message); } m_Message = message; } } }
/// <summary> /// Handles the AfterExecute event once a query has been executed /// </summary> /// <param name="Guid">The GUID.</param> /// <param name="ID">The ID.</param> /// <param name="CustomIn">The custom in.</param> /// <param name="CustomOut">The custom out.</param> private void QueryExecute_AfterExecute(string Guid, int ID, object CustomIn, object CustomOut) { if (this.DisplayTransactionLog) { string database = ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo.AdvancedOptions["DATABASE"]; string connectionString = ConnectionManager.GetConnectionString(ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo.UIConnectionInfo); // Get all window pointers for the app List <IntPtr> pointers = GetChildWindows(ServiceCache.MainShellWindow.Handle); // Get the active doc window Window w = dte.ActiveDocument.Windows.Item(1); if (w.Document != null) { foreach (IntPtr ptr in pointers) { // Try and match the windows based on the caption if (w.Caption.StartsWith(GetText(ptr))) { // Enumerate through the window pointers to find the tab control foreach (IntPtr controlPtr in GetChildWindows(ptr)) { if (ClassName(controlPtr).StartsWith("WindowsForms10.SysTabControl32.app.0.")) { TabControl tabControl = (TabControl)Control.FromHandle(controlPtr); TransactionLogTabPage transactionLogTabPage = new TransactionLogTabPage(); transactionLogTabPage.SetTransactionLogData(LogMonitor.StopMonitoring(database, startLsn, connectionString)); tabControl.TabPages.Add(transactionLogTabPage); transactionLogTabPage.PageClicked += delegate(object sender, PageEventArgs args) { PageViewerContainer c = this.windowManager.CreatePageViewerWindow(connectionString, args.RowId); c.PageViewerWindow.SetLogData((sender as TransactionLogTabPage).LogContents); }; return; } } } } } } }
protected override void OnInit(params string[] arguments) { Monitor = new LogMonitor(); Identity = "HeadlessSpider"; var word = "可乐|雪碧"; AddRequest(string.Format("http://news.baidu.com/ns?word={0}&tn=news&from=news&cl=2&pn=0&rn=20&ct=1", word), new Dictionary <string, dynamic> { { "Keyword", word } }); Downloader = new WebDriverDownloader(Browser.Chrome, new Option { Headless = true }); EmptySleepTime = 6000; AddPipeline(new ConsoleEntityPipeline()); AddEntityType <BaiduSearchEntry>(); }
public MainWindow(App app, MainWindowSettings settings) { // argument checks if (app == null) { throw new ArgumentNullException(nameof(app)); } if (settings == null) { throw new ArgumentNullException(nameof(settings)); } // initialize members this.app = app; this.settings = settings; this.UIState = UIStateFlags.InitialState; this.logMonitor = new LogMonitor(this); this.logLevelMenuItemGroup = null; this.maxLogCount = 300; this.settingsWindow = null; this.aboutWindow = null; // initialize components InitializeComponent(); GUIForWindowsGUISettings guiSettings = this.Command.GUISettings; this.logLevelMenuItemGroup = new Tuple <MenuItem, TraceLevel>[] { new Tuple <MenuItem, TraceLevel>(this.offMenuItem, TraceLevel.Off), new Tuple <MenuItem, TraceLevel>(this.errorMenuItem, TraceLevel.Error), new Tuple <MenuItem, TraceLevel>(this.warningMenuItem, TraceLevel.Warning), new Tuple <MenuItem, TraceLevel>(this.infoMenuItem, TraceLevel.Info), new Tuple <MenuItem, TraceLevel>(this.verboseMenuItem, TraceLevel.Verbose) }; UpdateLogLevelUI(Logger.LogLevel); this.chaseLastLogMenuItem.IsChecked = guiSettings.ChaseLastLog; this.app.UIStateChanged += app_UIStateChanged; UpdateUIState(); Logger.AddLogMonitor(this.logMonitor); return; }
private static void Log(LogMonitor logMonitor, string guid, WebReportManager reportManager) { LogMessageType logType; string message; if (HttpContext.Current != null && HttpContext.Current.Session != null && HttpContext.Current.Session["logcode" + guid] != null) { logType = (LogMessageType)HttpContext.Current.Session["logcode" + guid]; message = (string)HttpContext.Current.Session["logmsg" + guid]; } else { logType = reportManager.GetLogCode(reportManager.Plugin); message = reportManager.GetLogInformation().Replace("\r\n", "<br/>"); } if (logType != LogMessageType.None) { logMonitor.Log(new LogMessageEntry(logType, message)); } }
public void ReadAllText_Default() { if (Encoding.Default == Encoding.UTF8) { Assert.Inconclusive("Default encoding is UTF8."); } var log = new List <string>(); LogMonitor logMonitor = (eventType, eventName, message) => { if (eventName == "FilesUtility" && eventType == Logging.EventType.Warning) { log.Add($"{message()}"); } }; var testPath = Path.GetTempFileName(); string sampleText = "111\r\n¤\r\n333"; File.WriteAllText(testPath, sampleText, CodePagesEncodingProvider.Instance.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage)); var files = new FilesUtility(new ConsoleLogProvider(logMonitor)); string readText; try { readText = files.ReadAllText(testPath); } finally { File.Delete(testPath); } Assert.AreEqual(sampleText, readText); TestUtility.AssertContains( TestUtility.Dump(log), new[] { "invalid UTF-8 character at line 2", "Reading with default system encoding" }); }
/// <summary> /// This constructor is intended for usage before dependency injection is initialized, and for manual usage in unit testing. /// </summary> public ConsoleLogProvider(LogMonitor logMonitor = null, EventType?minLogLevel = null) { _logMonitor = logMonitor; _minLogLevel = minLogLevel ?? ConsoleLogger.DefaultMinLogLevel; }
public ConsoleLogger(EventType minLogLevel, string eventName = null, LogMonitor logMonitor = null) { Name = eventName; _logMonitor = logMonitor; _minLogLevel = minLogLevel; }
public static Stream GetReport(bool useReturnStream, string pluginName, string guid, StorageValues storageValues, string culture, Page page, string format, string command, LogMonitor logMonitor, bool expToWord, Dictionary <string, object> constants, StiWebViewer report, out string fileNameExtention, bool RoleCheck) { var originalUICulture = Thread.CurrentThread.CurrentUICulture; var originalCulture = Thread.CurrentThread.CurrentCulture; try { if (string.IsNullOrEmpty(culture)) { culture = "ru-ru"; } Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture = new CultureInfo(culture == "ru" ? "ru-ru" : (culture == "kz" ? "kk-kz" : culture)); fileNameExtention = ""; WebInitializer.Initialize(); var webReportManager = new WebReportManager(new TreeView()); if (string.IsNullOrEmpty(pluginName)) { return(null); } webReportManager.RoleCheck = RoleCheck; webReportManager.Plugin = webReportManager.GetPlugins()[pluginName]; if (webReportManager.Plugin != null) { webReportManager.Plugin.InitializeReportCulture(culture); var values = storageValues; var webReportPlugin = (IWebReportPlugin)webReportManager.Plugin; var stiPlugin = (IStimulsoftReportPlugin)webReportPlugin; webReportPlugin.Page = page; webReportManager.CreateView(); if (!string.IsNullOrEmpty(webReportManager.Plugin.CultureParameter)) { values.SetStorageValues( webReportManager.Plugin.CultureParameter, webReportManager.Plugin.InitializedKzCulture); } webReportManager.InitValues(values, webReportPlugin.InitSavedValuesInvisibleConditions); webReportPlugin.Constants = constants; if (!string.IsNullOrEmpty(webReportManager.Plugin.CultureParameter) && stiPlugin.Report.Dictionary.Variables.Contains(webReportManager.Plugin.CultureParameter)) { if (webReportManager.Plugin.SupportRuKz) { stiPlugin.Report[webReportManager.Plugin.CultureParameter] = webReportManager.Plugin.InitializedKzCulture; } else { stiPlugin.Report[webReportManager.Plugin.CultureParameter] = webReportManager.Plugin.InitializedCulture; } } try { webReportManager.ShowReport(); } catch (ConstraintException e) { var allErrors = webReportManager.Plugin.Table.DataSet?.GetAllErrors(); if (!string.IsNullOrEmpty(allErrors)) { throw new Exception(allErrors, e); } var errors = webReportManager.Plugin.Table.GetErrors(); if (errors.Length > 0) { throw new Exception(errors.Select(r => r.RowError).Aggregate((v1, v2) => v1 + "; " + v2), e); } throw; } var section = ReportInitializerSection.GetReportInitializerSection(); if (section != null && !string.IsNullOrEmpty(section.PropSaveDataFile)) { if (webReportManager.Plugin.Table.DataSet != null) { webReportManager.Plugin.Table.DataSet.WriteXml(section.PropSaveDataFile); } else { webReportManager.Plugin.Table.WriteXml(section.PropSaveDataFile); } } if (HttpContext.Current != null && HttpContext.Current.Request.QueryString["GetDataSet"] == "on" && UserRoles.IsInRole(UserRoles.ADMIN)) { using (var stream = new MemoryStream()) { if (webReportManager.Plugin.Table.DataSet != null) { webReportManager.Plugin.Table.DataSet.WriteXml(stream); } else { webReportManager.Plugin.Table.WriteXml(stream); } stream.Position = 0; PageHelper.DownloadFile(stream, "data.xml", HttpContext.Current.Response); } } var autoExport = webReportPlugin as IReportAutoExport; DBDataContext.AddViewReports( Tools.Security.User.GetSID(), HttpContext.Current?.User.Identity.Name ?? "anonymous", HttpContext.Current?.User.Identity.Name ?? "anonymous", ReportInitializerSection.GetReportInitializerSection().ReportPageViewer + "?ClassName=" + pluginName, HttpContext.Current?.Request.Url.GetLeftPart(UriPartial.Authority) ?? "https://maxat", Environment.MachineName, useReturnStream || autoExport != null || expToWord || stiPlugin.AutoExportTo != null, webReportManager.Plugin.GetType()); Log(logMonitor, guid, webReportManager); if (useReturnStream) { StiExportFormat stiExportFormat; try { stiExportFormat = (StiExportFormat)Enum.Parse(typeof(StiExportFormat), format); } catch (Exception) { var stiCustomExportType = (CustomExportType)Enum.Parse(typeof(CustomExportType), format); return(ExportWithoutShow( webReportManager.Report, stiCustomExportType, true, out fileNameExtention)); } fileNameExtention = WebReportManager.GetFileExtension(stiExportFormat); return(ExportWithoutShow(webReportManager.Report, stiExportFormat, true)); } //webReportManager.Report.EndRender += (sender, args) => LogMessages(webReportManager.Report, logMonitor); if (autoExport != null) { autoExport.Export(); } if (!expToWord && stiPlugin.AutoExportTo == null) { report.Report = webReportManager.Report; page.Cache.Insert(report.Report.ReportName, report.Report, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 10, 0), CacheItemPriority.NotRemovable, null); report.ResetCurrentPage(); } else if (webReportPlugin.CustomExportType != CustomExportType.None) { return(ExportWithoutShow( webReportManager.Report, webReportPlugin.CustomExportType, false, out fileNameExtention)); } else if (stiPlugin.AutoExportTo != null) { return(ExportWithoutShow(webReportManager.Report, stiPlugin.AutoExportTo.Value, false)); } else { return(ExportWithoutShow(webReportManager.Report, StiExportFormat.Word2007, false)); } } } finally { Thread.CurrentThread.CurrentUICulture = originalUICulture; Thread.CurrentThread.CurrentCulture = originalCulture; } return(null); }
public ConsoleLogProvider(LogMonitor logMonitor) { _logMonitor = logMonitor; }
public ConsoleLogger(string eventName = null, LogMonitor logMonitor = null) { Name = eventName; _logMonitor = logMonitor; }
public ConsoleLogger(string eventName = null, LogMonitor logMonitor = null) { _eventName = eventName; _logMonitor = logMonitor; }
private void UserControlLogMonitor_Load(object sender, EventArgs e) { _logMonitor = new LogMonitor(); _logMonitor.OnNewLogs += LogMonitor_OnNewLogs; _logMonitor.OnReseted += LogMonitor_OnReseted; }
public ConsoleLogger(string eventName = null, LogMonitor logMonitor = null) : this(DefaultMinLogLevel, eventName, logMonitor) { }