/// <summary>Restores the configuration, i.e. reads the original configuration from some configuration file or take some default values and show these configuration. /// </summary> public void RestoreConfiguration() { cBoxAddLogfileOnDropdownListFails.Checked = ExcelLogger.GetAddOnDataAdviceFails(); cBoxPopupGlobalLogfileForm.Checked = ExcelLogger.GetPopupGlobalLogfileBoxOnError(); var restoredLoggingLevel = ExcelPool.GetLoggingLevelFromConfigFile(); foreach (var item in comboBoxGlobalLoggingLevel.Items) { var itemValue = item as EnumString <ExcelPoolLoggingLevel>; if ((itemValue != null) && (itemValue.Value == restoredLoggingLevel)) { comboBoxGlobalLoggingLevel.SelectedItem = item; break; } } var outputUsage = ExcelObjectLogger.GetOutputUsage(); foreach (var item in comboBoxLocalOutputUsage.Items) { var itemValue = item as EnumString <ExcelLogger.OutputUsage>; if ((itemValue != null) && (itemValue.Value == outputUsage)) { comboBoxLocalOutputUsage.SelectedItem = item; break; } } editLocalOutputFolder.Text = ExcelObjectLogger.GetOutputFolder(); m_ConfigurationChanged = false; }
/// <summary>Store the configuration, i.e. write a specific configuration file. /// </summary> public void StoreConfiguration() { ExcelLogger.SetAddOnDataAdviceFails(cBoxAddLogfileOnDropdownListFails.Checked); ExcelLogger.SetPopupGlobalLogfileBoxOnError(cBoxPopupGlobalLogfileForm.Checked); var userGlobalLoggingLevel = comboBoxGlobalLoggingLevel.SelectedItem as EnumString <ExcelPoolLoggingLevel>; if (userGlobalLoggingLevel != null) { ExcelPool.StoreLoggingLevel(userGlobalLoggingLevel.Value); } else { ExcelPool.StoreLoggingLevel(ExcelPoolLoggingLevel.None); } var outputUsage = comboBoxLocalOutputUsage.SelectedItem as EnumString <ExcelLogger.OutputUsage>; if (outputUsage != null) { ExcelObjectLogger.SetOutputUsage(outputUsage.Value); } else { ExcelObjectLogger.SetOutputUsage(ExcelLogger.OutputUsage.None); } ExcelObjectLogger.SetOutputFolder(editLocalOutputFolder.Text); ExcelAddIn.Configuration.Save(); m_ConfigurationChanged = false; }
/// <summary>Initializes a new instance of the <see cref="ExcelObjectLogger" /> class. /// </summary> /// <param name="senderObjectTypeName">The object type name of the source object that adds the message.</param> /// <param name="senderObjectType">The type of the source object that adds the message.</param> /// <param name="senderObjectName">The name of the source object that adds the message.</param> /// <param name="channel">A specific channel, i.e. a name or category, for example <c>YieldCurveConstruction</c> etc.</param> /// <param name="excelLogger">The reference to the Excel logger (for fatal error messages etc.).</param> public ExcelObjectLogger(string senderObjectTypeName, Type senderObjectType, string senderObjectName, string channel, ExcelLogger excelLogger) { m_ObjectTypeName = senderObjectTypeName; m_ObjectType = senderObjectType; m_ObjectName = senderObjectName; m_Channel = channel; m_ExcelLogger = excelLogger; m_ListOfMessages = new List <LogFileRow>(); if (sm_OutputUsage == ExcelLogger.OutputUsage.New) { string fileName = null; if ((senderObjectTypeName != null) && (senderObjectTypeName != "")) { fileName = senderObjectTypeName; } if ((senderObjectName != null) && (senderObjectName != "")) { if (fileName != null) { fileName += "." + senderObjectName; } else { fileName = senderObjectName; } } if (fileName == null) { fileName = "UnknownObject"; } //fileName = Path.GetRandomFileName(); fileName += Guid.NewGuid().ToString() + ".log"; // alternativ: DirectoryInfo info = new DirectoryInfo(sm_OutputFolder); long uniqueKey = info.LastWriteTime.Ticks + 1L; string f = String.Format("fsssdf{0}.text", uniqueKey); m_StreamWriter = new StreamWriter(Path.Combine(sm_OutputFolder, fileName)); //m_StreamWriter.Close(); } }