private void SaveConfig() { FuEQ.SetEQFolderForToon(m_currentToon, m_currentServer, txtEqFolder.Text); Cfg.set("LootMinutes", txtLootMinutes.Text); Cfg.set("LootLookupMinutes", txtLootLookupMinutes.Text); Cfg.setEncrypted("HttpUsername", txtFuUsername.Text); Cfg.setEncrypted("HttpPassword", txtFuPassword.Text); }
public static string GetEQFolderForToon(string toon, string server) { Dictionary <string, string> section = Cfg.getList(String.Format("{0}-{1}", toon, server)); if (section.ContainsKey("EqFolder")) { return(section["EqFolder"]); } return(""); }
public static void SendLogsToServer() { // check for logs that didnt make it (either new or failed last time) string logPath = Path.Combine(GetAppFolder(), LogFolder); // should do them in the right order var logs = Directory.EnumerateFiles(logPath); List <string> failures = new List <string>(); FuHttp h = new FuHttp(); if (!h.Login(Cfg.getEncrypted("HttpUsername"), Cfg.getEncrypted("HttpPassword"))) { //MessageBox.Show("There was a problem with your Fu Website credentials"); return; } foreach (string log in logs) { string fname = log; string logFile = Path.GetFileName(log); if (logFile.StartsWith("COMPLETE_") || logFile.StartsWith("INCOMPLETE_")) { // already finished, skip } else { try { string response = h.UploadLog(fname); if (response.ToLower() == "success") { string newFilePath = Path.Combine(Path.GetDirectoryName(fname), String.Format("COMPLETE_{0}", Path.GetFileName(fname))); System.IO.File.Move(fname, newFilePath); } else { string newFilePath = Path.Combine(Path.GetDirectoryName(fname), String.Format("INCOMPLETE_{0}", Path.GetFileName(fname))); System.IO.File.Move(fname, newFilePath); failures.Add(response); } } catch (Exception e) { string newFilePath = Path.Combine(Path.GetDirectoryName(fname), String.Format("INCOMPLETE_{0}", Path.GetFileName(fname))); System.IO.File.Move(fname, newFilePath); failures.Add(e.Message); } } } if (failures.Count > 0) { MessageBox.Show("Transmission error(s)!" + Environment.NewLine + String.Join(Environment.NewLine, failures.ToArray())); } }
public string UploadLog(string filePath) { if (!m_Authorized) { return("Bad username/password"); } string fileName = Path.GetFileName(filePath); string[] bits = fileName.Split('_'); if (bits.Length != 4) { return("Something did not compute"); } Dictionary <string, string> d = new Dictionary <string, string> { ["sid"] = m_WebClient.SID, ["toon"] = bits[2], ["type"] = bits[0], ["server"] = bits[1], ["file"] = File.ReadAllText(filePath, Encoding.UTF8) }; try { String url = Cfg.get("HttpUploadUrl"); //m_WebClient.DownloadData(u); PreparePost(url); byte[] toSend = FormBytes(d); byte[] respB = m_WebClient.UploadData(url, "POST", toSend); string response = Encoding.UTF8.GetString(respB); // check the response for success if (response.ToLower().Contains("success")) { return("success"); } return(response); } catch (Exception e) { return(e.Message); } }
private void LoadConfig() { cmbToons.Items.Clear(); cmbToons.Items.AddRange(FuEQ.GetToons().ToArray()); if (cmbToons.Items.Count > 0) { cmbToons.Enabled = true; if (m_currentToon.Length > 0 && m_currentServer.Length > 0) { int i = cmbToons.Items.IndexOf(String.Format("{0} - {1}", m_currentServer, m_currentToon)); if (i > -1) { cmbToons.SelectedIndex = i; } } else if (cmbToons.Items.Count > 0) { cmbToons.SelectedIndex = 0; } string[] toonBits = cmbToons.Items[cmbToons.SelectedIndex].ToString().Split(new string[] { " - " }, StringSplitOptions.None); if (toonBits.Length == 2) { m_currentToon = toonBits[1]; m_currentServer = toonBits[0]; EnableRestOfUI(); } } else { cmbToons.Enabled = false; // force them to add a toon DisableRestOfUI(); } txtEqFolder.Text = FuEQ.GetEQFolderForToon(m_currentToon, m_currentServer); // txtEqFolder.Text = Cfg.get("EqFolder"); txtLootMinutes.Text = Cfg.get("LootMinutes"); txtLootLookupMinutes.Text = Cfg.get("LootLookupMinutes"); txtEqCharacter.Text = ""; txtEqServer.Text = "bristle"; txtFuUsername.Text = Cfg.getEncrypted("HttpUsername"); txtFuPassword.Text = Cfg.getEncrypted("HttpPassword"); }
private void UpgradeOld() { string toon = Cfg.get("EqToon"); if (toon.Length > 0) { string server = Cfg.get("EqServerShortName"); string folder = Cfg.get("EqFolder"); FuEQ.SetToons(new List <string> { String.Format("{0} - {1}", server, toon) }); FuEQ.SetEQFolderForToon(toon, server, folder); Cfg.delete("EqToon"); Cfg.delete("EqServerShortName"); Cfg.delete("EqFolder"); Cfg.delete("EqLogFolder"); } }
public bool Login(string username, string password) { Dictionary <string, string> d = new Dictionary <string, string> { ["username"] = username, ["password"] = password, ["redirect"] = "../index.php", ["login"] = "******" }; byte[] result; PreparePost(Cfg.get("HttpLoginUrl")); try { result = m_WebClient.UploadData(Cfg.get("HttpLoginUrl"), FormBytes(d)); } catch (WebException e) { MessageBox.Show(e.Message, "Error connecting to FU Website"); m_Authorized = false; return(false); } string html = Encoding.UTF8.GetString(result).ToLower(); if (html.Contains(String.Format("welcome, {0}!", username.ToLower()))) { m_Authorized = true; return(true); } MessageBox.Show("Invalid FU Website Username/Password"); m_Authorized = false; return(false); }
static void Main(string[] args) { bool debug = false; if (IsInstalled() || debug) { if (!HasConfig() && !debug) { // make an empty config file BuildEmptyConfigFile(); command = "config"; } } else { // install and create config file if (MessageBox.Show("About to install", "FuRaidTool", MessageBoxButtons.OKCancel) == DialogResult.OK) { Install(); } return; // probably wont get hit because install kills this process } appFolder = Path.GetDirectoryName(Application.ExecutablePath); float minutes = -1; if (command == "config" || args.Length == 0) { command = "config"; //command = "loot"; } else if (args.Length == 1) { command = args[0]; } else { command = args[0].ToLower(); toon = args[1]; if (args.Length > 2) { server = args[2]; } else { server = "bristle"; } } switch (command) { case "config": FuHttp f = new FuHttp(); ConfigForm cf = new ConfigForm(); cf.AppPath = Application.ExecutablePath; cf.ShowDialog(); break; case "loot": if (minutes == -1) { if (!float.TryParse(Cfg.get("LootMinutes"), out minutes)) { minutes = 10; } } if (UpdateLoot(toon, server, minutes)) { SendLogsToServer(); Process.Start("http://fuworldorder.net/admin/loot/loot_assignments.php"); } break; case "lootlookup": if (minutes == -1) { if (!float.TryParse(Cfg.get("LootLookupMinutes"), out minutes)) { minutes = 3; } } DoLootLookup(toon, server, minutes); break; case "attendance": if (UpdateRaidAttendance(toon, server)) { SendLogsToServer(); Process.Start("http://fuworldorder.net/admin/raid/attendance.php"); } break; case "guildroster": if (UpdateGuildRoster(toon, server)) { SendLogsToServer(); Process.Start("http://fuworldorder.net/admin/raid/attendance.php"); } break; case "sendlogs": SendLogsToServer(); break; } }
public static MemoryStream ParseRoster(string toon, string server) { // get the guild dump // looking for last file of format fu world order-<datetime>.txt in eq\Fu World Order-20161226-090424.txt MemoryStream ms = new MemoryStream(); StreamWriter sw = new StreamWriter(ms, Encoding.ASCII); string lastdumpfile = GetLastFile(FuEQ.GetEQFolderForToon(toon, server), String.Format("{0}_{1}-*.txt", Cfg.get("EqGuildName"), server)); if (String.IsNullOrEmpty(lastdumpfile)) { return(ms); } try { sw.Write(File.ReadAllText(lastdumpfile)); } catch (Exception e) { return(ms); // failure reading file } sw.Flush(); ms.Position = 0; return(ms); }
public static void SetEQFolderForToon(string toon, string server, string folder) { Cfg.setList(String.Format("{0}-{1}", toon, server), new Dictionary <string, string> { ["EqFolder"] = folder }); }
public static void SetToons(List <string> toons) { Cfg.set("_toons", String.Join(",", toons)); }
public static List <string> GetToons() { return(Cfg.get("_toons").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).ToList()); }