public DeviceComms( Settings config, int deviceId ) { logger.LogMessage( Convert.ToString(deviceId), "Creating device interface"); //Get the config //read the flat set and parse for devices accessed through this hardware interface //store into subdevices by address as id id = deviceId; databuff = new char[256]; deviceMap = new Hashtable(); }
public void Dispose() { logger.LogMessage(this.GetType().ToString(), "Dome class disposing"); if ( domePort.checkConnected(DeviceComms.ConnectionState.disconnected) != DeviceComms.ConnectionState.disconnected) //write back state we want to keep config.Save(); //turn off timer aTimer.Enabled = false; }
private void WriteToLog(string text, int level) { if (level <= Properties.Settings.Default.LogLevel) { if (log_window_enabled && L != null) { //The following is statement is required to ensure safe threading code if (L.txtLogWindow.InvokeRequired) { SetTextCallback d = new SetTextCallback(SetText); L.Invoke(d, new object[] { text }); } else { L.txtLogWindow.Text += text + "\r\n"; // The following 2 lines force the textbox to scroll down automatically as new lines added. L.txtLogWindow.Select(L.txtLogWindow.Text.Length, 0); L.txtLogWindow.ScrollToCaret(); } } if (Properties.Settings.Default.LogToFile) { trace.LogMessage(traceSource, text); //w.Write(text + "\r\n"); } } }
internal static string DriverCompatibilityMessage(string ProgID, VersionCode.Bitness RequiredBitness, TraceLogger TL) { string result = ""; TL.LogMessage("DriverCompatibility", " ProgID: " + ProgID + ", Bitness: " + RequiredBitness.ToString()); Console.WriteLine($"DriverCompatibility: ProgID: '{ProgID}', Bitness: {RequiredBitness}"); return(result); }
internal static void RunningVersions(TraceLogger TL) { AppDomain currentDomain = AppDomain.CurrentDomain; OperatingSystem osVersion = Environment.OSVersion; try { TL.LogMessage("Versions", "Main Process: " + Process.GetCurrentProcess().MainModule.FileName); FileVersionInfo fileVersionInfo = Process.GetCurrentProcess().MainModule.FileVersionInfo; TL.LogMessageCrLf("Versions", " Product: " + fileVersionInfo.ProductName + " " + fileVersionInfo.ProductVersion); TL.LogMessageCrLf("Versions", " File: " + fileVersionInfo.FileDescription + " " + fileVersionInfo.FileVersion); TL.LogMessageCrLf("Versions", " Language: " + fileVersionInfo.Language); TL.BlankLine(); } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessage("Versions", "Exception EX0: " + exception.ToString()); //ProjectData.ClearProjectError(); } try { TL.LogMessage("Versions", "OS Version: " + Conversions.ToString((int)osVersion.Platform) + ", Service Pack: " + osVersion.ServicePack + ", Full: " + osVersion.VersionString); switch (VersionCode.OSBits()) { case VersionCode.Bitness.Bits32: TL.LogMessage("Versions", "Operating system is 32bit"); break; case VersionCode.Bitness.Bits64: TL.LogMessage("Versions", "Operating system is 64bit"); break; default: TL.LogMessage("Versions", "Operating system is unknown bits, PTR length is: " + Conversions.ToString(IntPtr.Size)); break; } switch (VersionCode.ApplicationBits()) { case VersionCode.Bitness.Bits32: TL.LogMessage("Versions", "Application is 32bit"); break; case VersionCode.Bitness.Bits64: TL.LogMessage("Versions", "Application is 64bit"); break; default: TL.LogMessage("Versions", "Application is unknown bits, PTR length is: " + Conversions.ToString(IntPtr.Size)); break; } TL.LogMessage("Versions", ""); TL.LogMessage("Versions", "CLR version: " + Environment.Version.ToString()); string userDomainName = Environment.UserDomainName; string userName = Environment.UserName; string machineName = Environment.MachineName; int processorCount = Environment.ProcessorCount; string systemDirectory = Environment.SystemDirectory; long workingSet = Environment.WorkingSet; TL.LogMessage("Versions", "Machine name: " + machineName + " UserName: "******" DomainName: " + userDomainName); TL.LogMessage("Versions", "Number of processors: " + Conversions.ToString(processorCount) + " System directory: " + systemDirectory + " Working set size: " + Conversions.ToString(workingSet) + " bytes"); TL.LogMessage("Versions", ""); TL.LogMessage("Versions", "My Documents: " + Environment.GetFolderPath(Environment.SpecialFolder.Personal)); TL.LogMessage("Versions", "Application Data: " + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); TL.LogMessage("Versions", "Common Application Data: " + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)); TL.LogMessage("Versions", "Program Files: " + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); TL.LogMessage("Versions", "Common Files: " + Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)); TL.LogMessage("Versions", "System: " + Environment.GetFolderPath(Environment.SpecialFolder.System)); TL.LogMessage("Versions", "Current: " + Environment.CurrentDirectory); TL.LogMessage("Versions", ""); Assembly[] assemblies = currentDomain.GetAssemblies(); int index = 0; while (index < assemblies.Length) { Assembly assembly = assemblies[index]; TL.LogMessage("Versions", "Loaded Assemblies: " + assembly.GetName().Name + " " + assembly.GetName().Version.ToString()); checked { ++index; } } TL.LogMessage("Versions", ""); VersionCode.AssemblyInfo(TL, "Entry Assembly", Assembly.GetEntryAssembly()); VersionCode.AssemblyInfo(TL, "Executing Assembly", Assembly.GetExecutingAssembly()); TL.BlankLine(); } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessageCrLf("Versions", "Unexpected exception: " + exception.ToString()); //ProjectData.ClearProjectError(); } }
internal static void AssemblyInfo(TraceLogger TL, string AssName, Assembly Ass) { string fileName = (string)null; AssName = Strings.Left(AssName + ":" + Strings.Space(20), 19); if (Ass != null) { try { AssemblyName name = Ass.GetName(); if (name == null) { TL.LogMessage("Versions", AssName + " Assembly name is missing, cannot determine version"); } else { Version version = name.Version; if ((object)version == null) { TL.LogMessage("Versions", AssName + " Assembly version is missing, cannot determine version"); } else { string str = version.ToString(); if (!string.IsNullOrEmpty(str)) { TL.LogMessage("Versions", AssName + " AssemblyVersion: " + str); } else { TL.LogMessage("Versions", AssName + " Assembly version string is null or empty, cannot determine assembly version"); } } } } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessage("AssemblyInfo", "Exception EX1: " + exception.ToString()); //ProjectData.ClearProjectError(); } try { fileName = Ass.Location; if (string.IsNullOrEmpty(fileName)) { TL.LogMessage("Versions", AssName + "Assembly location is missing, cannot determine file version"); } else { FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(fileName); if (versionInfo == null) { TL.LogMessage("Versions", AssName + " File version object is null, cannot determine file version number"); } else { string fileVersion = versionInfo.FileVersion; if (!string.IsNullOrEmpty(fileVersion)) { TL.LogMessage("Versions", AssName + " FileVersion: " + fileVersion); } else { TL.LogMessage("Versions", AssName + " File version string is null or empty, cannot determine file version"); } } } } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessage("AssemblyInfo", "Exception EX2: " + exception.ToString()); //ProjectData.ClearProjectError(); } try { AssemblyName name = Ass.GetName(); if (name == null) { TL.LogMessage("Versions", AssName + " Assembly name is missing, cannot determine full name"); } else { string fullName = name.FullName; if (!string.IsNullOrEmpty(fullName)) { TL.LogMessage("Versions", AssName + " Name: " + fullName); } else { TL.LogMessage("Versions", AssName + " Full name string is null or empty, cannot determine full name"); } } } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessage("AssemblyInfo", "Exception EX3: " + exception.ToString()); //ProjectData.ClearProjectError(); } try { TL.LogMessage("Versions", AssName + " CodeBase: " + Ass.GetName().CodeBase); } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessage("AssemblyInfo", "Exception EX4: " + exception.ToString()); //ProjectData.ClearProjectError(); } try { if (!string.IsNullOrEmpty(fileName)) { TL.LogMessage("Versions", AssName + " Location: " + fileName); } else { TL.LogMessage("Versions", AssName + " Location is null or empty, cannot display location"); } } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessage("AssemblyInfo", "Exception EX5: " + exception.ToString()); //ProjectData.ClearProjectError(); } try { TL.LogMessage("Versions", AssName + " From GAC: " + Ass.GlobalAssemblyCache.ToString()); } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessage("AssemblyInfo", "Exception EX6: " + exception.ToString()); //ProjectData.ClearProjectError(); } } else { TL.LogMessage("Versions", AssName + " No assembly found"); } }
internal static string ConditionPlatformVersion(string PlatformVersion, IAscomDataStore Profile, TraceLogger TL) { string str = PlatformVersion; if (Profile != null) { try { string withoutExtension = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName); TL?.LogMessage("ConditionPlatformVersion", " ModuleFileName: \"" + withoutExtension + "\" \"" + Process.GetCurrentProcess().MainModule.FileName + "\""); //if (Operators.CompareString(Strings.Left(withoutExtension.ToUpper(), 3), "IS-", false) == 0) if (withoutExtension.ToUpper().StartsWith("IS-")) { TL?.LogMessage("ConditionPlatformVersion", " Inno installer temporary executable detected, searching for parent process!"); TL?.LogMessage("ConditionPlatformVersion", " Old Module Filename: " + withoutExtension); PerformanceCounter performanceCounter = new PerformanceCounter("Process", "Creating Process ID", Process.GetCurrentProcess().ProcessName); withoutExtension = Path.GetFileNameWithoutExtension(Process.GetProcessById(checked ((int)Math.Round((double)performanceCounter.NextValue()))).MainModule.FileName); TL?.LogMessage("ConditionPlatformVersion", " New Module Filename: " + withoutExtension); performanceCounter.Close(); performanceCounter.Dispose(); } SortedList <string, string> sortedList1 = Profile.EnumProfile("ForcePlatformVersion"); IEnumerator <System.Collections.Generic.KeyValuePair <string, string> > enumerator1 = null; try { enumerator1 = sortedList1.GetEnumerator(); while (enumerator1.MoveNext()) { System.Collections.Generic.KeyValuePair <string, string> current = enumerator1.Current; TL?.LogMessage("ConditionPlatformVersion", " ForcedFileName: \"" + current.Key + "\" \"" + current.Value + "\" \"" + Strings.UCase(Path.GetFileNameWithoutExtension(current.Key)) + "\" \"" + Strings.UCase(Path.GetFileName(current.Key)) + "\" \"" + Strings.UCase(current.Key) + "\" \"" + current.Key + "\" \"" + Strings.UCase(withoutExtension) + "\""); string Left = !current.Key.Contains(".") ? current.Key : Path.GetFileNameWithoutExtension(current.Key); if (Operators.CompareString(Left, "", false) != 0 && Strings.UCase(withoutExtension).StartsWith(Strings.UCase(Left))) { str = current.Value; TL?.LogMessage("ConditionPlatformVersion", " Matched file: \"" + withoutExtension + "\" \"" + Left + "\""); } } } finally { if (enumerator1 != null) { enumerator1.Dispose(); } } SortedList <string, string> sortedList2 = Profile.EnumProfile("ForcePlatformVersionSeparator"); IEnumerator <System.Collections.Generic.KeyValuePair <string, string> > enumerator2 = null; try { enumerator2 = sortedList2.GetEnumerator(); while (enumerator2.MoveNext()) { System.Collections.Generic.KeyValuePair <string, string> current = enumerator2.Current; TL?.LogMessage("ConditionPlatformVersion", " ForcedFileName: \"" + current.Key + "\" \"" + current.Value + "\" \"" + Strings.UCase(Path.GetFileNameWithoutExtension(current.Key)) + "\" \"" + Strings.UCase(Path.GetFileName(current.Key)) + "\" \"" + Strings.UCase(current.Key) + "\" \"" + current.Key + "\" \"" + Strings.UCase(withoutExtension) + "\""); if (!current.Key.Contains(".")) { } if (Operators.CompareString(Strings.UCase(Path.GetFileNameWithoutExtension(current.Key)), Strings.UCase(withoutExtension), false) == 0) { if (string.IsNullOrEmpty(current.Value)) { str = str.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); TL?.LogMessage("ConditionPlatformVersion", " String IsNullOrEmpty: \"" + str + "\""); } else { str = str.Replace(".", current.Value); TL?.LogMessage("ConditionPlatformVersion", " String Is: \"" + current.Value + "\" \"" + str + "\""); } TL?.LogMessage("ConditionPlatformVersion", " Matched file: \"" + withoutExtension + "\" \"" + current.Key + "\""); } } } finally { if (enumerator2 != null) { enumerator2.Dispose(); } } } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL?.LogMessageCrLf("ConditionPlatformVersion", "Exception: " + exception.ToString()); EventLogCode.LogEvent("ConditionPlatformVersion", "Exception: ", EventLogEntryType.Error, GlobalConstants.EventLogErrors.VB6HelperProfileException, exception.ToString()); //ProjectData.ClearProjectError(); } } TL?.LogMessage("ConditionPlatformVersion", " Returning: \"" + str + "\""); return(str); }