示例#1
0
        public LoginGUI()
        {
            InitializeComponent();
            this.FormClosing += (o, x) =>
            {
                if (username.Text.Length > 0 && password.Text.Length > 0)
                {
                    settings.Update("username", username.Text);
                    settings.Update("password", password.Text);
                    settings.Update("remember", rememberCredentials.Checked);
                }

                if (rememberCredentials.Checked)
                {
                    settings.writeOPT();
                }
            };

            if (settings.GetBool("remember"))
            {
                username.Text = settings.GetString("username");
                password.Text = settings.GetString("password");
                rememberCredentials.Checked = settings.GetBool("remember");
            }
        }
示例#2
0
文件: Data.cs 项目: odasm/Grimoire
        private async void ts_file_new_Click(object sender, EventArgs e)
        {
            Paths.Description = "Please select a Dump Directory";
            string dumpDirectory = Paths.FolderPath;

            if (Paths.FolderResult != DialogResult.OK)
            {
                return;
            }

            string buildDirectory = OPT.GetString("build.directory");

            tab_disabled = true;

            await Task.Run(() =>
            {
                try { core.BuildDataFiles(dumpDirectory, buildDirectory); }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Build Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            });

            // TODO: Core reset

            ts_status.Text = string.Empty;

            tab_disabled = false;
        }
示例#3
0
文件: Data.cs 项目: odasm/Grimoire
        private async void grid_cs_export_Click(object sender, EventArgs e)
        {
            if (grid.Rows.Count == 0)
            {
                return;
            }

            string buildDir = OPT.GetString("build.directory");

            for (int i = 0; i < grid.SelectedRows.Count; i++)
            {
                IndexEntry entry = core.GetEntry(grid.SelectedRows[i].Cells[0].Value.ToString());

                ts_status.Text = string.Format("Exporting: {0}...", entry.Name);

                lManager.Enter(Logs.Sender.DATA, Logs.Level.NOTICE, "Exporting: {0} to directory:\n\t- {1}\n\t- Size: {2}", entry.Name, buildDir, entry.Length);

                try
                {
                    await Task.Run(() =>
                    {
                        core.ExportFileEntry(buildDir, entry);
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Export Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.ERROR, ex);
                }

                ts_status.Text = string.Empty;
            }
        }
示例#4
0
        public void TS_Load_File_Click(object sender, EventArgs e)
        {
            if (!structLoaded)
            {
                MessageBox.Show("You can not do that until a structure has been loaded!", "Structure Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            Paths.DefaultDirectory = OPT.GetString("rdb.load.directory");
            Paths.DefaultFileName  = core.FileName;
            string fileName = Paths.FilePath;

            if (Paths.FileResult != DialogResult.OK)
            {
                lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "User cancelled file load on tab: {0}", tManager.Text);
                return;
            }

            string ext = Path.GetExtension(fileName).ToLower();

            switch (ext)
            {
            case ".rdb":
                lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "Loading RDB from physical file with .rdb extension");
                load_file(fileName);
                break;

            case ".000":
                lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "Loading RDB from Rappelz Client");
                load_data_file(fileName);
                break;
            }
        }
示例#5
0
        private async void ts_save_file_csv_Click(object sender, EventArgs e)
        {
            actionSW.Reset();
            actionSW.Start();

            ts_prog.Maximum = core.RowCount;
            ts_prog.Value   = 0;

            string csvStr = string.Empty;

            await Task.Run(() => { csvStr = generateCSV(); });

            actionSW.Stop();

            lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "\t-Ready! ({0}ms)", actionSW.ElapsedMilliseconds.ToString("D4"));

            string csvDir  = OPT.GetString("rdb.csv.directory") ?? string.Concat(Directory.GetCurrentDirectory(), @"\CSV");
            string csvPath = string.Format(@"{0}\{1}_{2}.csv", csvDir, core.FileName, DateTime.UtcNow.ToString("MM-dd-yyyy"));

            if (!Directory.Exists(csvDir))
            {
                Directory.CreateDirectory(csvDir);
            }

            File.WriteAllText(csvPath, csvStr.ToString());

            string msg = string.Format("{0} written to .csv file at: {1}", tManager.Text, csvPath);

            lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, msg);

            ts_prog.Value   = 0;
            ts_prog.Maximum = 100;

            MessageBox.Show(msg, "Export Complete", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
        }
示例#6
0
        /// <summary>
        /// Initializes the client listener
        /// </summary>
        /// <returns></returns>
        public bool Start()
        {
            Socket listener = new Socket(SocketType.Stream, ProtocolType.Tcp);

            try
            {
                IPAddress ip;
                if (!IPAddress.TryParse(OPT.GetString("io.ip"), out ip))
                {
                    Console.WriteLine("Failed to parse Server IP ({0})", OPT.GetString("io.ip"));
                    return(false);
                }
                listener.Bind(new IPEndPoint(ip, int.Parse(OPT.GetString("io.port"))));
                listener.Listen(100);
                listener.BeginAccept(new AsyncCallback(AcceptCallback), listener);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine("At ClientManager.Start()");

                listener.Close();
                return(false);
            }

            return(true);
        }
示例#7
0
        /// <summary>
        /// Initializes the client listener
        /// </summary>
        /// <returns></returns>
        public bool Start()
        {
            Socket listener = new Socket(SocketType.Stream, ProtocolType.Tcp);

            try
            {
                IPAddress ip;
                if (!IPAddress.TryParse(OPT.GetString("io.ip"), out ip))
                {
                    Output.Write(new Message()
                    {
                        Text = string.Format("Failed to parse Server IP ({0})", OPT.GetString("io.ip")), AddBreak = true
                    });
                    return(false);
                }

                listener.Bind(new IPEndPoint(ip, int.Parse(OPT.GetString("io.port"))));
                listener.Listen(100);
                listener.BeginAccept(new AsyncCallback(AcceptCallback), listener);
            }
            catch (Exception e)
            {
                Output.Write(new Message()
                {
                    Text = string.Format("Error occured initializing Client Listener!\n\t {0}", e.Message), AddBreak = true
                });

                listener.Close();
                return(false);
            }

            return(true);
        }
示例#8
0
文件: Data.cs 项目: odasm/Grimoire
        private async void grid_cs_insert_Click(object sender, EventArgs e)
        {
            string filepath = Paths.FilePath;

            if (Paths.FileResult == DialogResult.OK)
            {
                ts_status.Text = string.Format("Importing: {0}...", Path.GetFileName(filepath));

                tab_disabled = true;

                try
                {
                    await Task.Run(() =>
                    {
                        core.ImportFileEntry(filepath);
                        core.Save(OPT.GetString("build.directory"));
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Import Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.ERROR, ex);
                }
                finally
                {
                    tab_disabled   = false;
                    ts_status.Text = string.Empty;
                }
            }
        }
示例#9
0
        static void Main(string[] args)
        {
            Output.Splash();

            Console.Write("Loading settings from config.opt...");
            settings.Start();
            Output.Write(new Message()
            {
                Lines = new List <string>()
                {
                    "[OK]"
                }, ForeColors = new List <ConsoleColor>()
                {
                    ConsoleColor.Green
                }
            });
            Console.WriteLine("\t- {0} settings loaded!", settings.Count);

            if (settings.GetString("client.path") == "0")
            {
                Console.WriteLine("This appears to be your first start! You must configure me!");
                Configure();
                settings.Write();
            }

            if (settings.GetBool("backups"))
            {
                Console.WriteLine("Reminder: Backups are currently on.");
            }


            Console.Write("Starting the File Manager...");
            FileManager.Start();
            Output.Write(new Message()
            {
                Lines = new List <string>()
                {
                    "[OK]"
                }, ForeColors = new List <ConsoleColor>()
                {
                    ConsoleColor.Green
                }
            });

            if (settings.GetBool("auto.load"))
            {
                loadIndex();
            }
            else
            {
                Console.WriteLine("Would you like to load your data.000 now?");
                if (Input.YesNo)
                {
                    loadIndex();
                }
            }

            wait();
        }
示例#10
0
 public rdbTab(string key)
 {
     InitializeComponent();
     this.key                = key;
     gridUtil                = new Utilities.Grid();
     ts_save_enc.Checked     = OPT.GetBool("rdb.save.hashed");
     ts_save_w_ascii.Checked = OPT.GetBool("rdb.use.ascii");
     structsDir              = OPT.GetString("rdb.structures.directory") ?? string.Format(@"{0}\Structures\", Directory.GetCurrentDirectory());
 }
示例#11
0
文件: Data.cs 项目: Rappelz/Grimoire
        public async void TS_File_New_Click(object sender, EventArgs e)
        {
            Paths.Description = "Please select a Dump Directory";
            string dumpDirectory = Paths.FolderPath;

            if (Paths.FolderResult != DialogResult.OK)
            {
                return;
            }

            string buildDirectory = OPT.GetString("build.directory");

            lManager.Enter(Logs.Sender.DATA, Logs.Level.NOTICE, "Building new client to:\n\t-{0}", buildDirectory);

            tab_disabled = true;

            await Task.Run(() =>
            {
                try
                {
                    core.Backups = false;
                    core.BuildDataFiles(dumpDirectory, buildDirectory);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Build Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.ERROR, ex);
                    return;
                }
                finally
                {
                    string msg = "Client build completed!";
                    MessageBox.Show(msg, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.NOTICE, msg);

                    if (OPT.GetBool("data.clear_on_create"))
                    {
                        core.Clear();
                    }
                    else
                    {
                        display_data();
                    }

                    core.Backups = true;
                }
            });

            ts_status.Text = string.Empty;

            tab_disabled = false;
        }
示例#12
0
        public async void TS_Load_Data_Click(object sender, EventArgs e)
        {
            if (!structLoaded)
            {
                MessageBox.Show("You can not do that until a structure has been loaded!", "Structure Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            dCore                  = new DataCore.Core(Encodings.GetByName(ts_enc_list.Text));
            Paths.Title            = "Select client data.000";
            Paths.DefaultDirectory = OPT.GetString("data.load.directory");
            string dataPath = Paths.FilePath;

            if (Paths.FileResult == DialogResult.OK)
            {
                lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "RDB Tab: {0} attempting load file selection from index at path:\n\t- {1}", tManager.Text, dataPath);

                List <DataCore.Structures.IndexEntry> results = null;

                await Task.Run(() =>
                {
                    dCore.Load(dataPath);
                    results = dCore.GetEntriesByExtensions("rdb", "ref");
                });

                lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "File list retrived successfully!\n\t- Selections available: {0}", results.Count);

                using (Grimoire.GUI.ListSelect selectGUI = new GUI.ListSelect("Select RDB", results))
                {
                    selectGUI.FormClosing += (o, x) =>
                    {
                        if (selectGUI.DialogResult == DialogResult.OK)
                        {
                            string fileName = selectGUI.SelectedText;
                            DataCore.Structures.IndexEntry finalResult = results.Find(i => i.Name == fileName);
                            byte[] fileBytes = dCore.GetFileBytes(finalResult);

                            if (fileBytes.Length > 0)
                            {
                                load_file(fileName, fileBytes);
                            }
                        }
                        else
                        {
                            lManager.Enter(Logs.Sender.RDB, Logs.Level.DEBUG, "User cancelled Data load on RDB Tab: {0}", tManager.Text);
                            return;
                        }
                    };
                    selectGUI.ShowDialog(Grimoire.GUI.Main.Instance);
                }
            }
        }
示例#13
0
        void loadCore()
        {
            Paths.DefaultDirectory = OPT.GetString("data.load.directory");

            string filePath = Paths.FilePath;

            if (Paths.FileResult != DialogResult.OK)
            {
                return;
            }

            Core.Load(filePath);
        }
示例#14
0
文件: Data.cs 项目: odasm/Grimoire
        private void ts_file_load_Click(object sender, EventArgs e)
        {
            Paths.DefaultDirectory = OPT.GetString("data.load.directory");

            string filePath = Paths.FilePath;

            if (Paths.FileResult != DialogResult.OK)
            {
                return;
            }

            load(filePath);
        }
示例#15
0
        static void Main(string[] args)
        {
            OPT.LoadSettings();
            DesCipher = new XDes(OPT.GetString("des.key"));

            clientList = new Dictionary <int, Client>();

            Console.WriteLine("Indexing legacy file names...");
            OPT.LoadLegacyFiles();
            Console.WriteLine("\t- {0} legacy files indexed!", OPT.LegacyCount);

            Console.WriteLine("Indexing delete file names...");
            OPT.LoadDeleteFiles();
            Console.WriteLine("\t- {0} delete files indexed!", OPT.DeleteCount);

            IndexManager.Build(false);

            Console.Write("Checking for tmp directory...");
            if (!Directory.Exists(tmpPath))
            {
                Directory.CreateDirectory(tmpPath);
            }
            Console.Write("[OK]\n\t- Cleaning up temp files...");

            int cleanedCount = 0;

            foreach (string filePath in Directory.GetFiles(tmpPath))
            {
                File.Delete(filePath);
                cleanedCount++;
            }
            Console.WriteLine("[OK] ({0} files cleared!)", cleanedCount);

            Console.Write("Initializing client listener... ");
            if (ClientManager.Instance.Start())
            {
                Console.WriteLine("[OK]");
            }

            Console.Write("Initializing Index Rebuild Service...");
            int rebuildInterval = OPT.GetInt("rebuild.interval") * 1000;

            indexTimer = new Timer(indexTick, null, rebuildInterval, rebuildInterval);
            Console.WriteLine("[OK]");

            Console.Write("Initializing OTP Reset Service...");
            otpTimer = new Timer(otpTick, null, 0, 300000);
            Console.WriteLine("[OK]");

            Console.ReadLine();
        }
示例#16
0
文件: Data.cs 项目: Rappelz/Grimoire
        public void TS_File_Load_Click(object sender, EventArgs e)
        {
            Paths.DefaultDirectory = OPT.GetString("data.load.directory");
            Paths.DefaultFileName  = "data.000";

            string filePath = Paths.FilePath;

            if (Paths.FileResult != DialogResult.OK)
            {
                return;
            }

            load(filePath);
        }
示例#17
0
文件: Data.cs 项目: odasm/Grimoire
        private async void extensions_cs_export_Click(object sender, EventArgs e)
        {
            string buildDirectory = OPT.GetString("build.directory");

            string ext = extensions.SelectedNode.Text;

            if (ext.Length == 3)
            {
                List <IndexEntry> entries = core.GetEntriesByExtension(ext);

                ts_status.Text = string.Format("Exporting: {0}...", ext);

                tab_disabled = true;

                try
                {
                    await Task.Run(() =>
                    {
                        if (ext == "all")
                        {
                            core.ExportAllEntries(buildDirectory);
                        }
                        else
                        {
                            buildDirectory += string.Format(@"\{0}\", ext);

                            if (!Directory.Exists(buildDirectory))
                            {
                                Directory.CreateDirectory(buildDirectory);
                            }

                            core.ExportExtEntries(buildDirectory, ext);
                        }
                    });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Extension Export Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.ERROR, ex);
                }
                finally
                {
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.NOTICE, "Exported {0} Rows from Tab: {1}", entries.Count, tManager.Text);
                }

                ts_status.Text = string.Empty;

                tab_disabled = false;
            }
        }
示例#18
0
        static void Main(string[] args)
        {
            string processName_1 = "launcher";
            string processName_2 = "client";

            Console.Write("Loading configuration info from config.opt...");
            OPT.Read();
            Console.WriteLine("[OK]");

            Console.Write("Checking for open Launcher...");

            if (Process.GetProcessesByName(processName_1).Length > 0)
            {
                foreach (var process in Process.GetProcessesByName(processName_1))
                {
                    process.Kill();
                }
            }

            if (Process.GetProcessesByName(processName_2).Length > 0)
            {
                foreach (var process in Process.GetProcessesByName(processName_2))
                {
                    process.Kill();
                }
            }

            Console.Write("[OK]\nConnecting to the Portal Server...");
            try
            {
                if (ServerManager.Instance.Start(OPT.GetString("ip"), OPT.GetInt("port")))
                {
                    Console.Write("[OK]\nRequesting communication key...");
                    ServerPackets.Instance.US_RequestDesKey();
                }
                else
                {
                    Console.WriteLine("[FAIL]");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Errors:\n\t{0}", ex.ToString());
            }

            Console.ReadLine();
        }
示例#19
0
        public void TS_Load_File_Click(object sender, EventArgs e)
        {
            if (!structLoaded)
            {
                MessageBox.Show("You can not do that until a structure has been loaded!", "Structure Exception", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }

            Paths.DefaultDirectory = OPT.GetString("rdb.load.directory");
            string fileName = Paths.FilePath;

            if (Paths.FileResult != DialogResult.OK)
            {
                lManager.Enter(Logs.Sender.RDB, Logs.Level.NOTICE, "User cancelled file load on tab: {0}", tManager.Text);
                return;
            }

            load_file(fileName);
        }
示例#20
0
文件: GUI.cs 项目: odasm/rMOD
        private async void saveFileBtn_Click(object sender, EventArgs e)
        {
            DataCore.Core dCore = new DataCore.Core();

            if (RDBControls.GridRows > 0)
            {
                string savePath = OPT.GetString("save.directory");
                if (string.IsNullOrEmpty(savePath))
                {
                    string structFileName = structFileName = string.Format(@"{0}.{1}", StructureManager.FileName(RDBControls.StructureListValue), rCore.Extension);
                    string fileName       = OPT.GetBool("save.hashed") ? dCore.EncodeName(structFileName) : structFileName;

                    using (SaveFileDialog sfDlg = new SaveFileDialog()
                    {
                        Filter = "All files (*.*)|*.*|RDB files (*.rdb)|*.rdb|REF files (*.ref)|*.ref", Title = "Define the name of your rdb", FileName = fileName
                    })
                    {
                        if (sfDlg.ShowDialog(this) == DialogResult.OK)
                        {
                            if (!string.IsNullOrEmpty(sfDlg.FileName))
                            {
                                savePath = sfDlg.FileName;
                            }
                        }
                    }
                }
                else
                {
                    savePath += GuessName.Result(RDBControls.StructureListValue, NameType.File);
                }

                if (!string.IsNullOrEmpty(savePath))
                {
                    await Task.Run(() => { rdbCores[tabIdx].WriteRDB(savePath); });
                }
            }
        }
示例#21
0
        private void insert_files(string[] filePaths)
        {
            using (GUI.MessageListBox msgbox = new GUI.MessageListBox("Review Files", "You are about to import the following files!\r\n\r\nAre you sure you want to do that?", filePaths))
            {
                msgbox.ShowDialog(GUI.Main.Instance);
                if (msgbox.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
            }

            try
            {
                foreach (string filePath in filePaths)
                {
                    tab_disabled = true;
                    string msg = string.Format("Importing: {0}...", Path.GetFileName(filePath));
                    ts_status.Text = msg;
                    lManager.Enter(Logs.Sender.DATA, Logs.Level.NOTICE, msg);

                    core.ImportFileEntry(filePath);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Import Exception", MessageBoxButtons.OK, MessageBoxIcon.Error);
                lManager.Enter(Logs.Sender.DATA, Logs.Level.ERROR, ex);
            }
            finally
            {
                core.Save(OPT.GetString("build.directory"));

                tab_disabled   = false;
                ts_status.Text = string.Empty;
            }
        }
示例#22
0
        private async void GUI_Shown(object sender, EventArgs e)
        {
            OPT.LoadSettings();
            DesCipher = new XDes(OPT.GetString("des.key"));

            Statistics.SetIO();
            Statistics.StartUptime();

            clientList = new Dictionary <int, Client>();

            Output.Write(new Structures.Message()
            {
                Text = "Indexing legacy file names..."
            });
            OPT.LoadLegacyIndex();
            Output.Write(new Structures.Message()
            {
                Text = string.Format("[OK]\n\t- {0} legacy files indexed!", OPT.LegacyCount), AddBreak = true
            });

            Output.Write(new Structures.Message()
            {
                Text = "Indexing delete file names..."
            });
            OPT.LoadDeleteFiles();
            Output.Write(new Structures.Message()
            {
                Text = string.Format("[OK]\n\t- {0} delete files indexed!", OPT.DeleteCount), AddBreak = true
            });

            await Task.Run(() => { IndexManager.Build(false); });

            Output.Write(new Structures.Message()
            {
                Text = "Checking for tmp directory..."
            });
            if (!Directory.Exists(tmpPath))
            {
                Directory.CreateDirectory(tmpPath);
            }
            Output.Write(new Structures.Message()
            {
                Text = "[OK]", AddBreak = true
            });

            clearTmp();

            Output.Write(new Structures.Message()
            {
                Text = string.Format("Initializing client listener...{0}", (ClientManager.Instance.Start()) ? "[OK]" : "[FAIL]"), AddBreak = true
            });

            Output.Write(new Structures.Message()
            {
                Text = "Initializing Index Rebuild Service..."
            });
            int rebuildInterval = OPT.GetInt("rebuild.interval") * 1000;

            indexTimer = new Timer()
            {
                Enabled = true, Interval = rebuildInterval
            };
            indexTimer.Tick += indexTick;
            indexTimer.Start();
            Output.Write(new Structures.Message()
            {
                Text = "[OK]", AddBreak = true
            });

            Output.Write(new Structures.Message()
            {
                Text = "Initializing OTP Reset Service..."
            });
            otpTimer = new Timer()
            {
                Enabled = true, Interval = 300000
            };
            otpTimer.Tick += otpTick;
            Output.Write(new Structures.Message()
            {
                Text = "[OK]", AddBreak = true
            });

            Output.Write(new Structures.Message()
            {
                Text = "Initializing Statistics Update Service..."
            });
            Statistics.StartUpdating();
            Output.Write(new Structures.Message()
            {
                Text = "[OK]", AddBreak = true
            });

            toolTip.SetToolTip(setWTBtn, "Sets the Updates folder last write time to the current time");
        }