private void Log(string message) { try { LogMessageEvent?.Invoke(this, message); } catch { } }
//Raise a MessageEvent (passes a message to the container, which should be logged) protected virtual void Log(string message, LogMessageEvent.Intents intent, LogMessageEvent.Targets target) { if (LogMessageSent != null) { LogMessageEvent e = new LogMessageEvent(message, intent, target); LogMessageSent(this, e); } }
private void OnExportCompleted(object sender, ExportCompletedEventArgs e) { GlymaExportUserState userState = e.UserState as GlymaExportUserState; if (userState != null) { try { ProgressRecord progressRecord = new ProgressRecord(0, "Exporting Glyma Map", string.Format("Creating output file: {0}", Output)); progressRecord.SecondsRemaining = -1; progressRecord.PercentComplete = 100; lock (pr_lock) { this.ProgressRecord = progressRecord; ProgressEvent.Set(); //notify of change to progress } //Delete the file if it already exists before the move operation if (File.Exists(Output)) { File.Delete(Output); } File.Move(e.FileLocation, Output); progressRecord = new ProgressRecord(0, "Exporting Glyma Map", "Export completed"); progressRecord.SecondsRemaining = -1; progressRecord.PercentComplete = 100; progressRecord.RecordType = ProgressRecordType.Completed; lock (pr_lock) { this.ProgressRecord = progressRecord; ProgressEvent.Set(); //notify of change to progress } } catch (Exception ex) { lock (msg_lock) { this.Message = string.Format("Failed to move the temporary file '{0}' to the output file location.\r\n\r\nException: {1}", e.FileLocation, ex); LogMessageEvent.Set(); } } finally { userState.Completed.Set(); //signal that the export has completed Completed.Set(); //signal that the Cmdlet has completed } } }
// сообщения для лога /// <summary> /// добавить в лог новое сообщение /// </summary> private void SendLogMessage(string message, LogMessageType type) { LogMessageEvent?.Invoke(message, type); }
public static void WriteToLog(string message, LogLevel level = LogLevel.Info) { LogMessageEvent?.Invoke(message, level); appendLogMessage(message, level); }
private void OnInitialiseMapManagerCompleted(object sender, InitialiseMapManagerEventArgs e) { if (e.IsInitialised) { ProgressRecord progressRecord = new ProgressRecord(0, "Exporting Glyma Map", string.Format("Initialising {0} export processor", ExportFormat.ToString())); progressRecord.SecondsRemaining = -1; progressRecord.PercentComplete = 5; progressRecord.RecordType = ProgressRecordType.Processing; lock (pr_lock) { this.ProgressRecord = progressRecord; ProgressEvent.Set(); //notify of change to progress } ExportUtilityFactory exportFactory = new ExportUtilityFactory(MapManager); IExportUtility exportUtil = null; switch (MapSchema) { case "IBIS": switch (ExportFormat) { case "Compendium": exportUtil = exportFactory.CreateExportUtility(MapType.IBIS, ExportType.Compendium); break; case "Word": exportUtil = exportFactory.CreateExportUtility(MapType.IBIS, ExportType.Word); break; case "PDF": exportUtil = exportFactory.CreateExportUtility(MapType.IBIS, ExportType.PDF); break; case "GlymaXML": //exportUtil = exportFactory.CreateExportUtility(MapType.IBIS, ExportType.GlymaXml); lock (msg_lock) { Message = "Exporting to GlymaXML format is currently not supported"; LogMessageEvent.Set(); } break; } break; } exportUtil.ExportCompleted += OnExportCompleted; exportUtil.ProgressChanged += OnProgressChanged; ExportPropertiesDictionary exportProps = CreateExportProperties(); GlymaExportUserState userState = new GlymaExportUserState(Output); progressRecord = new ProgressRecord(0, "Exporting Glyma Map", "Export Progress: 0%"); progressRecord.SecondsRemaining = -1; progressRecord.PercentComplete = 10; progressRecord.RecordType = ProgressRecordType.Processing; lock (pr_lock) { this.ProgressRecord = progressRecord; ProgressEvent.Set(); //notify of change to progress } exportUtil.ExportMap(Domain, Map, exportProps, null, userState); bool signalled = userState.Completed.WaitOne(Timeout.Infinite); //wait for the export to completed if (!signalled) { Completed.Set(); //since it's inifinite timeout this shouldn't happen } } else { lock (msg_lock) { this.Message = string.Format("Failed to initialise the web service client: {0}", e.ErrorMessage); LogMessageEvent.Set(); } Completed.Set(); } }
//Raise a MessageEvent (passes a message to the container, which should be logged) protected virtual void Log(string message, LogMessageEvent.Intents intent, LogMessageEvent.Targets target) { if (LogMessageSent != null) { LogMessageEvent e = new LogMessageEvent(message, intent, target); LogMessageSent(this, e); } }
private static void Log(string message) { LogMessageEvent?.Invoke(null, message); }
/// <summary> /// prompt a log message from the logHelper /// </summary> /// <param name="sender">the logHelper</param> /// <param name="lme">the message</param> private void loadLogMessage(object sender, LogMessageEvent lme) { tempS = lme.message; tempS += "\n"; uiDispatcher.Invoke(delegateConsoleUpdate); }
protected virtual void OnLogMessage(LogEventArgs args) => LogMessageEvent?.Invoke(this, args);