public string Choose(string DriverProgID)
        {
            string str;

            try
            {
                if (string.IsNullOrEmpty(this.m_sDeviceType))
                {
                    throw new ASCOM.Utilities.Exceptions.InvalidValueException("Unknown device type, DeviceType property has not been set");
                }
                this.m_frmChooser.DeviceType = this.m_sDeviceType;
                this.m_frmChooser.StartSel   = DriverProgID;
                int num = (int)this.m_frmChooser.ShowDialog();
                str = this.m_frmChooser.Result;
                this.m_frmChooser.Dispose();
                this.m_frmChooser = null;
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                Exception exception = ex;
                int       num       = (int)Interaction.MsgBox((object)("Chooser Exception: " + exception.ToString()), MsgBoxStyle.OkOnly, (object)null);
                EventLogCode.LogEvent("Chooser", "Exception", EventLogEntryType.Error, GlobalConstants.EventLogErrors.ChooserException, exception.ToString());
                str = "";
                //ProjectData.ClearProjectError();
            }
            return(str);
        }
Exemple #2
0
 private void GetProfileMutex(string Method, string Parameters)
 {
     this.GotMutex = this.ProfileMutex.WaitOne(5000, false);
     if (!this.GotMutex)
     {
         this.TL.LogMessage("GetProfileMutex", "***** WARNING ***** Timed out waiting for Profile mutex in " + Method + ", parameters: " + Parameters);
         EventLogCode.LogEvent(Method, "Timed out waiting for Profile mutex in " + Method + ", parameters: " + Parameters, EventLogEntryType.Error, GlobalConstants.EventLogErrors.XMLProfileMutexTimeout, (string)null);
         throw new ProfilePersistenceException("Timed out waiting for Profile mutex in " + Method + ", parameters: " + Parameters);
     }
 }
Exemple #3
0
        public Timer()
        {
            this.Tick         += new Timer.TickEventHandler(this.Timer_Tick);
            this.disposedValue = false;
            this.TL            = new TraceLogger("", "Timer");
            this.TraceEnabled  = RegistryCommonCode.GetBool("Trace Timer", false);
            this.TL.Enabled    = this.TraceEnabled;
            this.TL.LogMessage("New", "Started on thread: " + Thread.CurrentThread.ManagedThreadId.ToString());
            this.FormTimer = new System.Windows.Forms.Timer();
            this.TL.LogMessage("New", "Created FormTimer");
            this.FormTimer.Enabled  = false;
            this.FormTimer.Interval = 1000;
            this.TL.LogMessage("New", "Set FormTimer interval");
            this.TimersTimer = new System.Timers.Timer();
            this.TL.LogMessage("New", "Created TimersTimer");
            this.TimersTimer.Enabled  = false;
            this.TimersTimer.Interval = 1000.0;
            this.TL.LogMessage("New", "Set TimersTimer interval");
            try
            {
                this.TL.LogMessage("New", "Process FileName \"" + Process.GetCurrentProcess().MainModule.FileName + "\"");
                PEReader peReader = new PEReader(Process.GetCurrentProcess().MainModule.FileName, this.TL);
                this.TL.LogMessage("New", "SubSystem " + peReader.SubSystem().ToString());
                switch (peReader.SubSystem())
                {
                case PEReader.SubSystemType.WINDOWS_GUI:
                    this.IsForm = true;
                    break;

                case PEReader.SubSystemType.WINDOWS_CUI:
                    this.IsForm = false;
                    break;

                default:
                    this.IsForm = false;
                    break;
                }
                this.IsForm = !this.ForceTimer(this.IsForm);
                this.TL.LogMessage("New", "IsForm: " + Conversions.ToString(this.IsForm));
            }
            catch (Exception ex)
            {
                //ProjectData.SetProjectError(ex);
                Exception exception = ex;
                this.TL.LogMessageCrLf("New Exception", exception.ToString());
                EventLogCode.LogEvent("Timer:New", "Exception", EventLogEntryType.Error, GlobalConstants.EventLogErrors.TimerSetupException, exception.ToString());
                //ProjectData.ClearProjectError();
            }
        }
        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);
        }
Exemple #5
0
        private SortedList <string, string> ReadValues(string p_SubKeyName)
        {
            SortedList <string, string> sortedList = new SortedList <string, string>();
            bool flag1 = false;
            bool flag2 = false;

            this.swSupport.Reset();
            this.swSupport.Start();
            if (Operators.CompareString(Strings.Left(p_SubKeyName, 1), "\\", false) != 0)
            {
                p_SubKeyName = "\\" + p_SubKeyName;
            }
            this.TL.LogMessage("  ReadValues", "  SubKeyName: " + p_SubKeyName);
            string Left  = "Profile.xml";
            int    num   = -1;
            bool   flag3 = this.FileStore.get_Exists(p_SubKeyName + "\\Profile.xml");
            bool   flag4 = this.FileStore.get_Exists(p_SubKeyName + "\\ProfileOriginal.xml");

            this.FileStore.get_Exists(p_SubKeyName + "\\ProfileNew.xml");
            if (!flag3 & !flag4)
            {
                throw new ProfileNotFoundException("No profile files exist for this key: " + p_SubKeyName);
            }
            do
            {
                checked { ++num; }
                try
                {
                    using (XmlReader xmlReader = XmlReader.Create(this.FileStore.get_FullPath(p_SubKeyName + "\\" + Left), new XmlReaderSettings()
                    {
                        IgnoreWhitespace = true
                    }))
                    {
                        xmlReader.Read();
                        xmlReader.Read();
                        while (xmlReader.Read())
                        {
                            if (xmlReader.NodeType == XmlNodeType.Element)
                            {
                                string name = xmlReader.Name;
                                if (Operators.CompareString(name, "DefaultElement", false) == 0)
                                {
                                    sortedList.Add("***** DefaultValueName *****", xmlReader.GetAttribute("Value"));
                                    this.TL.LogMessage("    ReadValues", "    found ***** DefaultValueName ***** = " + sortedList["***** DefaultValueName *****"]);
                                }
                                else if (Operators.CompareString(name, "Element", false) == 0)
                                {
                                    string attribute = xmlReader.GetAttribute("Name");
                                    sortedList.Add(attribute, xmlReader.GetAttribute("Value"));
                                    this.TL.LogMessage("    ReadValues", "    found " + attribute + " = " + sortedList[attribute]);
                                }
                                else
                                {
                                    this.TL.LogMessage("    ReadValues", "    ## Found unexpected Reader.Name: " + xmlReader.Name.ToString());
                                }
                            }
                        }
                        xmlReader.Close();
                    }
                    this.swSupport.Stop();
                    this.TL.LogMessage("  ReadValues", "  added to cache - " + Conversions.ToString(this.swSupport.ElapsedMilliseconds) + " milliseconds");
                    flag1 = true;
                }
                catch (Exception ex)
                {
                    //ProjectData.SetProjectError(ex);
                    Exception inner = ex;
                    flag2 = true;
                    if (num == 1)
                    {
                        if (Operators.CompareString(Left, "Profile.xml", false) == 0)
                        {
                            Left = "ProfileOriginal.xml";
                            num  = -1;
                            EventLogCode.LogEvent("XMLAccess:ReadValues", "Error reading profile on final retry - attempting recovery from previous version", EventLogEntryType.Warning, GlobalConstants.EventLogErrors.XMLAccessRecoveryPreviousVersion, inner.ToString());
                            this.TL.LogMessageCrLf("  ReadValues", "Final retry exception - attempting recovery from previous version: " + inner.ToString());
                        }
                        else
                        {
                            EventLogCode.LogEvent("XMLAccess:ReadValues", "Error reading profile on final retry", EventLogEntryType.Error, GlobalConstants.EventLogErrors.XMLAccessReadError, inner.ToString());
                            this.TL.LogMessageCrLf("  ReadValues", "Final retry exception: " + inner.ToString());
                            throw new ProfilePersistenceException("XMLAccess Exception", inner);
                        }
                    }
                    else
                    {
                        EventLogCode.LogEvent("XMLAccess:ReadValues", "Error reading profile - retry: " + Conversions.ToString(num), EventLogEntryType.Warning, GlobalConstants.EventLogErrors.XMLAccessRecoveryPreviousVersion, inner.Message);
                        this.TL.LogMessageCrLf("  ReadValues", "Retry " + Conversions.ToString(num) + " exception: " + inner.ToString());
                    }
                    //ProjectData.ClearProjectError();
                }
                if (flag2)
                {
                    Thread.Sleep(200);
                }
            }while (!flag1);
            if (flag2)
            {
                EventLogCode.LogEvent("XMLAccess:ReadValues", "Recovered from read error OK", EventLogEntryType.SuccessAudit, GlobalConstants.EventLogErrors.XMLAccessRecoveredOK, (string)null);
                this.TL.LogMessage("  ReadValues", "Recovered from read error OK");
            }
            return(sortedList);
        }