Ejemplo n.º 1
0
        private void HandleLogOffOrOnProcessDotIni(RMSQLiteConnection DB, string offOrOn, string inOrOut)
        {
            AddToLog("Importing settings for log" + offOrOn + "process.ini");
            using (IniFile Ini = new IniFile(StringUtils.PathCombine(ProcessUtils.StartupPath, "config", "log" + offOrOn + "process.ini")))
            {
                // Erase old sections
                string[] Sections = Ini.ReadSections();
                foreach (string Section in Sections)
                {
                    Ini.EraseSection(Section);
                }

                SQL = "SELECT * FROM Log" + inOrOut + "ProcessTbl ORDER BY StepNumber";
                DB.ExecuteReader(SQL);
                while (DB.Reader.Read())
                {
                    string Name = "Log" + offOrOn + "Process" + DB.Reader["StepNumber"].ToString();
                    string Action = CommandToAction(DB.Reader["Command"].ToString());
                    string Parameters = DB.Reader["Parameters"].ToString();
                    string RequiredAccess = DB.Reader["RequiredAccess"].ToString();

                    if (Action == DB.Reader["Command"].ToString())
                    {
                        AddToLog(" - Ignoring command that no longer exists (" + Action + ")");
                    }
                    else
                    {
                        // See if we need to add the logon/off process as a door
                        if (Action == "RunDoor")
                        {
                            string[] CommandAndParameters = DB.Reader["Parameters"].ToString().Split(' ');
                            string Command = CommandAndParameters[0];
                            string DoorParameters = string.Join(" ", CommandAndParameters, 1, CommandAndParameters.Length - 1);
                            bool Native = DB.Reader["Command"].ToString() == "EXEC";

                            using (IniFile DoorIni = new IniFile(StringUtils.PathCombine(ProcessUtils.StartupPath, "doors", GetSafeDoorFileName(Name) + ".ini")))
                            {
                                DoorIni.WriteString("DOOR", "Name", Name);
                                DoorIni.WriteString("DOOR", "Command", Command);
                                DoorIni.WriteString("DOOR", "Parameters", DoorParameters);
                                DoorIni.WriteString("DOOR", "Native", Native.ToString());
                                DoorIni.WriteString("DOOR", "ForceQuitDelay", "5");
                                DoorIni.WriteString("DOOR", "WindowStyle", "Minimized");
                            }

                            AddToLog(" - Added Door = " + Name);
                            AddToLog("         Command = " + Command);
                            AddToLog("         Parameters = " + DoorParameters);
                            AddToLog("         Native = " + Native.ToString());

                            // Override settings to be used below
                            Action = "RunDoor";
                            Parameters = Name;
                        }

                        Ini.WriteString(Name, "Name", Name);
                        Ini.WriteString(Name, "Action", Action);
                        Ini.WriteString(Name, "Parameters", Parameters);
                        Ini.WriteString(Name, "RequiredAccess", RequiredAccess);

                        AddToLog(" - Added Name = " + Name);
                        AddToLog("         Action = " + Action);
                        AddToLog("         Parameters = " + Parameters);
                        AddToLog("         RequiredAccess = " + RequiredAccess);
                    }
                }
                DB.Reader.Close();
            }
            AddToLog("");
        }
Ejemplo n.º 2
0
        private static void Menu()
        {
            string AnsiHeader = StringUtils.PathCombine(ProcessUtils.StartupPath, _MenuFile + "-Header.ans");
            string AnsiMenu = StringUtils.PathCombine(ProcessUtils.StartupPath, _MenuFile + ".ans");
            SortedDictionary<char, string> Servers = new SortedDictionary<char, string>();
            string ServersIni = StringUtils.PathCombine(ProcessUtils.StartupPath, _MenuFile + ".ini");

            if (File.Exists(ServersIni))
            {
                using (IniFile Ini = new IniFile(ServersIni))
                {
                    char HotKey = 'A';
                    string[] Sections = Ini.ReadSections();
                    foreach (string Section in Sections)
                    {
                        Servers.Add(HotKey, Section);
                        HotKey = (char)(HotKey + 1);
                    }

                    // Going to repeatedly display this menu until the user hits ESC to quit
                    while (true)
                    {
                        // Reset display for re-display of menu
                        Door.TextAttr(7);
                        Door.ClrScr();
                        Door.GotoXY(1, 1);

                        // Check whether we display a custom menu or the canned menu
                        if (File.Exists(AnsiMenu))
                        {
                            // Custom menu
                            Door.DisplayFile(AnsiMenu, 0);
                        }
                        else
                        {
                            // Canned menu, check if we display a custom header
                            if (File.Exists(AnsiHeader))
                            {
                                // Custom header
                                Door.DisplayFile(AnsiHeader, 0);
                            }
                            Door.WriteLn();

                            // Menu options
                            foreach (KeyValuePair<char, string> KVP in Servers)
                            {
                                Door.WriteLn("  |0F[|0E" + KVP.Key.ToString() + "|0F]|07 " + KVP.Value);
                            }
                            Door.WriteLn();
                            Door.Write("  |0FYour choice (|0EESC|0F to abort):|07 ");
                        }

                        char? Ch = Door.ReadKey();
                        if (Ch == null)
                        {
                            // Must have timed out waiting for input
                            return;
                        }
                        else if ((char)Ch == '\x1B')
                        {
                            // Aborting
                            return;
                        }
                        else
                        {
                            // Ensure key is valid
                            HotKey = char.ToUpper((char)Ch);
                            if (Servers.ContainsKey(HotKey))
                            {
                                // Valid option, set the parameters and connect
                                List<string> Args = new List<string>();
                                string[] Keys = Ini.ReadSection(Servers[HotKey]);
                                foreach (string Key in Keys)
                                {
                                    Args.Add("-" + Key + Ini.ReadString(Servers[HotKey], Key, ""));
                                }
                                HandleCLPs(Args.ToArray());

                                // Clear the screen and connect
                                Door.ClrScr();
                                Door.GotoXY(1, 1);
                                Connect();

                                // Disconnectd, pause to show the user the disconnect message
                                Door.ClearBuffers();
                                Door.WriteLn();
                                Door.TextAttr(15);
                                Door.Write(new string(' ', 30) + "Hit any key to continue");
                                Door.TextAttr(7);
                                Door.ReadKey();
                            }
                        }
                    }
                }
            }
            else
            {
                Door.WriteLn();
                Door.WriteLn(" Oops, your SysOp didn't set this door up correctly!");
                Door.WriteLn();
                Door.WriteLn(" Tell them to either pass the -S parameter, or create a " + _MenuFile + ".ini file");
                Door.WriteLn();

                Door.ClearBuffers();
                Door.TextAttr(15);
                Door.Write(new string(' ', 30) + "Hit any key to quit");
                Door.TextAttr(7);
                Door.ReadKey();
            }
        }
Ejemplo n.º 3
0
        public static string[] GetHostnames()
        {
            List<string> Result = new List<string>();

            using (IniFile Ini = new IniFile(Config.Default.FileName))
            {
                // Get section names (but not the CONFIGURATION section, since that's not a host)
                string[] Sections = Ini.ReadSections();
                foreach (string Section in Sections)
                {
                    if (Section.ToUpper() != "CONFIGURATION") Result.Add(Section);
                }
            }

            Result.Sort();
            return Result.ToArray();
        }