static void Main(string[] args) { try { databaseconfigpath = args[0]; Console.WriteLine("Using databaseconfigfile " + args[0]); } catch (Exception e) { Console.WriteLine("No databaseconfigpath was given. Exiting..." + e.Message); databaseconfigpath = ""; } try { portconfigpath = args[1]; Console.WriteLine("Using portconfigfile " + args[1]); } catch (Exception e) { Console.WriteLine("No portconfigpath was given, using default ports. (exception message: " + e.Message + ")"); portconfigpath = ""; } PortManager.instance(); Thread.Sleep(1000); //Console.WriteLine("here"); DatabaseController dc = DatabaseController.instance(); Thread.Sleep(1000); LoginController lc = LoginController.instance(); Thread.Sleep(100); MatchController mc = MatchController.instance(); Thread.Sleep(100); MiscController miscc = MiscController.instance(); Thread.Sleep(100); Thread login = new Thread(lc.logincontrol); login.Start(); Thread match = new Thread(mc.handleRequests); match.Start(); Thread misc = new Thread(miscc.handleRequests); misc.Start(); //string res = dc.GetAgeAndGender("theVilandry"); //Console.WriteLine(res); //dc.successfulRegister("admin", "admin".GetHashCode().ToString(), 1, 1); }
/// <summary> /// Handles the main asynchronous execution and handling of command events. /// </summary> private static async Task MainAsync(string token) { // Set up client var discord = new DiscordClient(new DiscordConfiguration() { Token = token, TokenType = TokenType.Bot, MinimumLogLevel = LogLevel.Debug }); // Set up command prefix discord.UseCommandsNext(new CommandsNextConfiguration() { StringPrefixes = new[] { "!" } }); // Register module controllers TagController.Register(discord); ModerationController.Register(discord); MiscController.Register(discord); await discord.ConnectAsync(); await Task.Delay(-1); }
public EngineDialog(string CarModel, string BrandName, MiscController miscController) { InitializeComponent(); this.CarModelName = CarModel; this.BrandName = BrandName; this.miscController = miscController; }
/// <summary> /// Update Constructor. Call if you want to load an automobile for updates. /// </summary> /// <param name="miscController">Controller for small operations - side table controller</param> /// <param name="automobileController">Controller for the automobile table.</param> /// <param name="Model">The AutomobileDataModel you are going to update.</param> public AutomobileDataInput(MiscController miscController, AutomobileController automobileController, AutomobileDataModel Model) { InitializeComponent(); this.miscController = miscController; this.automobileController = automobileController; this.Model = Model; }
public PartsEditor(MiscController miscController, SparePartsDataModel model) { InitializeComponent(); this.MiscController = miscController; this.Model = model; LoadModel(); }
private void SendInvoiceNotification() { // try { // Read task parameters Contract contract = (Contract)TaskManager.TaskParameters[SystemTaskParams.PARAM_CONTRACT]; Invoice invoice = (Invoice)TaskManager.TaskParameters[SystemTaskParams.PARAM_INVOICE]; List <InvoiceItem> invoiceLines = (List <InvoiceItem>)TaskManager.TaskParameters[SystemTaskParams.PARAM_INVOICE_LINES]; KeyValueBunch extraArgs = (KeyValueBunch)TaskManager.TaskParameters[SystemTaskParams.PARAM_EXTRA_ARGS]; // modify invoice direct url if (extraArgs != null && !String.IsNullOrEmpty(extraArgs["InvoiceDirectURL"])) { extraArgs["InvoiceDirectURL"] += "&InvoiceId=" + invoice.InvoiceId; } // int smtpResult = MiscController.SendNewInvoiceNotification(invoice, invoiceLines, extraArgs); // if (smtpResult != 0) { TaskManager.WriteWarning("Unable to send e-mail notification"); TaskManager.WriteParameter("SMTP Status", smtpResult); } } catch (Exception ex) { TaskManager.WriteError(ex); } }
public MainWindow() { InitializeComponent(); curUser = new User(); login = new LoginController(); privatechat = new PrivateChatController(curUser); misc = new MiscController(); this.privateChatHistory.IsReadOnly = true; errPopup = new Popup(); hideButtons(); privateChatHistory.Document.Blocks.Clear(); curUser.HasOngoingChat = false; curUser.HasOngoingChatSearch = false; privatechat.chatBegins += OnChatBegins; privatechat.MessageArrived += OnRandomChatMessageArrived; privatechat.chatEnded += OnChatEnded; privatechat.lostConnection += OnServerDown; misc.lostConnection += OnServerDown; privatechat.inqueue += OnAlreadyJoined; this.ResizeMode = ResizeMode.NoResize; this.messageTextBox.MaxLength = 1024; }
public PartsDialog(MiscController miscController, bool isFromMaintenanceCard) { InitializeComponent(); this.MiscController = miscController; this.IsFromMaintenanceCard = isFromMaintenanceCard; SelectedParts = new List <PartsViewModel>(); }
private void SendPaymentNotification() { // try { // Read task parameters Invoice invoice = (Invoice)TaskManager.TaskParameters[SystemTaskParams.PARAM_INVOICE]; CustomerPayment payment = (CustomerPayment)TaskManager.TaskParameters[SystemTaskParams.PARAM_PAYMENT]; // if (payment.Status == TransactionStatus.Approved) { // int smtpResult = MiscController.SendPaymentReceivedNotification(payment); // if (smtpResult != 0) { TaskManager.WriteWarning("Unable to send e-mail notification"); TaskManager.WriteParameter("SMTP Status", smtpResult); } } } catch (Exception ex) { TaskManager.WriteError(ex); } }
public ServiceHistory(int Id, AutomobileController automobileController, MiscController miscController) { InitializeComponent(); this.AutomobileController = automobileController; this.MiscController = miscController; AutomobileId = Id; }
public void ConvSaveTest2() { MiscController mc = MiscController.instance(); Thread thread = new Thread(mc.handleRequests); thread.Start(); string msg = "KNOCKNOCK|CONVSAVE|1|friend|NotTaken|NotTaken"; TcpClient client = new TcpClient("localhost", PortManager.instance().Miscport); NetworkStream stream = client.GetStream(); byte[] attempt = Encoding.Unicode.GetBytes(msg); stream.Write(attempt); Thread.Sleep(10); string res = Utility.ClientReadFromNetworkStream(stream); ///note that its the server's read function, which is different and requires the KNOCKNOCK| trailer. Console.WriteLine(res + "|"); Assert.AreEqual(res, "OK"); }
public Card(AutomobileController automobileController, MiscController miscController, MaintenanceCardDataModel card) { InitializeComponent(); this.AutomobileController = automobileController; this.MiscController = miscController; this.CardModel = card; }
private void LoadParts() { if (lb_AllParts.Items.Count > 0) { lb_AllParts.Items.Clear(); } lb_AllParts.Items.AddRange(MiscController.GetSparePartsViewModels().ToArray()); }
// remove parts private void b_Remove_Click(object sender, EventArgs e) { if (lb_Parts.SelectedIndex > -1) { var part = ConvertViewModel_To_DataModel((PartsViewModel)lb_Parts.SelectedItem); MiscController.UnlinkPartsAndMaintenanceCards(part.Id, CardModel.Id); lb_Parts.Items.RemoveAt(lb_Parts.SelectedIndex); } }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { var selected = (PartsViewModel)lb_AllParts.SelectedItem; if (!MiscController.DeletePartById(selected.Id)) { MessageBox.Show("Error!\n Can't delete part because it's used by a maintenance card.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } LoadParts(); }
private void editToolStripMenuItem_Click(object sender, EventArgs e) { var selected = (PartsViewModel)lb_AllParts.SelectedItem; var pEditor = new PartsEditor(MiscController, MiscController.GetPartsById(selected.Id)); if (pEditor.ShowDialog() == DialogResult.OK) { LoadParts(); } }
private void SendServiceStatusChangedNotification() { // send an e-mail notification try { BackgroundTask topTask = TaskManager.TopTask; bool sendNotification = Utils.ParseBool(topTask.GetParamValue(SystemTaskParams.PARAM_SEND_EMAIL), false); // Ensure notification is required if (!sendNotification) { TaskManager.Write("Notification send is not required, thus skipped"); return; } Service service = (Service)topTask.GetParamValue(SystemTaskParams.PARAM_SERVICE); int smtpResult = 0; switch (service.Status) { case ServiceStatus.Active: smtpResult = MiscController.SendServiceActivatedNotification(service.ServiceId); break; case ServiceStatus.Suspended: smtpResult = MiscController.SendServiceSuspendedNotification(service.ServiceId); break; case ServiceStatus.Cancelled: smtpResult = MiscController.SendServiceCanceledNotification(service.ServiceId); break; } // if (smtpResult != 0) { TaskManager.WriteWarning("Unable to send e-mail notification"); TaskManager.WriteParameter("SMTP Status", smtpResult); } } catch (Exception ex) { TaskManager.WriteError(ex); } }
public static async Task Menu() { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(" 1. Seven Day Forecast"); Console.WriteLine(" 2. Seven Day Forecast (Hourly)"); Console.WriteLine(" 3. Seven Day History (Hourly)"); Console.WriteLine(" 4. Change Location (Zip Code)"); Console.WriteLine(" 5. Toggle Metric/Imperial"); Console.WriteLine(""); Console.WriteLine(" Esc. to Exit"); Console.ForegroundColor = ConsoleColor.Gray; ConsoleKey menuChoice = Console.ReadKey(true).Key; switch (menuChoice) { case ConsoleKey.D1: await SevenDayForecastView.SevenDayForecast(); break; case ConsoleKey.NumPad1: await SevenDayForecastView.SevenDayForecast(); break; case ConsoleKey.D2: await SevenDayForecastHourlyView.SevenDayForecastHourly(); break; case ConsoleKey.NumPad2: await SevenDayForecastHourlyView.SevenDayForecastHourly(); break; case ConsoleKey.D3: await SevenDayHistoryHourlyView.SevenDayHistoryHourly(); break; case ConsoleKey.NumPad3: await SevenDayHistoryHourlyView.SevenDayHistoryHourly(); break; case ConsoleKey.D4: await APICallsView.UpdateZipView(); break; case ConsoleKey.NumPad4: await APICallsView.UpdateZipView(); break; case ConsoleKey.D5: MiscController.FlipIsImperial(); await MainWelcomeView.Welcome(); break; case ConsoleKey.NumPad5: MiscController.FlipIsImperial(); await MainWelcomeView.Welcome(); break; case ConsoleKey.Escape: Environment.Exit(0); break; default: await MainWelcomeView.Welcome(); break; } }
private void btn_OK_Click(object sender, EventArgs e) { if (decimal.TryParse(tb_Price.Text, out decimal price) && price > 0) { if (Model == null) { Model = new SparePartsDataModel(); } Model.Name = tb_Name.Text; Model.Price = price; MiscController.AddOrUpdateParts(Model); } else { MessageBox.Show("Invalid Price", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void UpdateMaintenanceCard() { if (ValidateInput()) { var employeeName = tb_Employee.Text; double.TryParse(tb_labour.Text, out double labourPrice); var departureTime = dtp_departure.Value; var arrivalTime = dtp_arrival.Value; var description = rtb_Description.Text; var parts = Array.ConvertAll( lb_Parts.Items.Cast <PartsViewModel>().ToArray(), ConvertViewModel_To_DataModel); CardModel.DateOfDeparture = departureTime; CardModel.EmployeeName = employeeName; CardModel.Description = description; CardModel.DateOfDeparture = departureTime; if (CardModel.DateOfArrival.Date != arrivalTime.Date) { CardModel.DateOfArrival = arrivalTime; } foreach (var p in parts) { MiscController.LinkPartsToMaintenanceCards(p.Id, this.CardModel.Id); } CardModel.Finished = cb_Finished.Checked; AutomobileController.SaveMaintenanceCard(CardModel); this.Close(); } else { MessageBox.Show("Invalid Input!", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } }
public void FriendlisttTest() { MiscController mc = MiscController.instance(); Thread thread = new Thread(mc.handleRequests); thread.Start(); string msg = "KNOCKNOCK|FRIENDLOAD|friend"; TcpClient client = new TcpClient("localhost", PortManager.instance().Miscport); NetworkStream stream = client.GetStream(); byte[] attempt = Encoding.Unicode.GetBytes(msg); stream.Write(attempt); Thread.Sleep(10); string res = Utility.ClientReadFromNetworkStream(stream); ///note that its the server's read function, which is different and requires the KNOCKNOCK| trailer. Console.WriteLine(res + "|"); string[] resparts = res.Split("!"); string[] mutual = resparts[0].Split("|"); string[] onlysender = resparts[1].Split("|"); string[] onlytarget = resparts[2].Split("|"); Assert.AreEqual(mutual.Length, 1); Assert.AreEqual(onlysender.Length, 1); Assert.AreEqual(onlytarget.Length, 1); Assert.AreEqual(mutual[0], "mutual"); Assert.AreEqual(onlysender[0], "OnlySender"); Assert.AreEqual(onlytarget[0], "OnlyTarget"); }
private void Save() { if (!boundaries) { return; } //save = new Boundaries(); Scene scene = new Scene(); scene.parts = new List <Part>(); foreach (Transform part in boundaries.transform) { if (part.gameObject.name.Contains("Background")) { foreach (Transform background in part) { foreach (BackgroundType type in Enum.GetValues(typeof(BackgroundType))) { if (background.gameObject.name.Contains(type.ToString())) { scene.background = type; scene.bgPosition = background.localPosition; break; } } } } else if (part.gameObject.name.Contains("Part")) { Part newPart = new Part(); newPart.position = part.localPosition; newPart.levels = new List <Level>(); foreach (Transform level in part) { Level newLevel = new Level(); newLevel.relPosition = level.localPosition; newLevel.regions = new List <Region>(); newLevel.cameraLimits = new List <Limits>(); foreach (Transform region in level) { if (region.gameObject.name.Contains("Limit")) { Limits newLimit = new Limits(); newLimit.type = (Commandments.LimitsType)region.localScale.z; newLimit.relPosition = region.localPosition; newLimit.point1 = region.GetComponent <EdgeCollider2D>().points[0]; newLimit.point2 = region.GetComponent <EdgeCollider2D>().points[1]; newLevel.cameraLimits.Add(newLimit); } if (region.gameObject.name.Contains("Region")) { Region newRegion = new Region(); newRegion.relPosition = region.localPosition; newRegion.subRegions = new List <ContinuosRegion>(); newRegion.walls = new List <Wall>(); newRegion.shrines = new List <ShrineController>(); newRegion.chest = new List <ChestController>(); newRegion.misc = new List <MiscController>(); newRegion.yokai = new List <YokaiController>(); foreach (Transform subRegion in region) { if (subRegion.gameObject.name.Contains("grounds")) { foreach (Transform grounds in subRegion) { ContinuosRegion newSubRegion = new ContinuosRegion(); newSubRegion.relPosition = grounds.localPosition; newSubRegion.grounds = new List <Ground>(); newSubRegion.inverted = grounds.localScale.y == -1; newSubRegion.rotated = grounds.eulerAngles.z == 180; Floor floor = region.GetComponent <Floor>(); if (floor) { newSubRegion.accelRatio = floor.accelTimeRatio; newSubRegion.speedRatio = floor.maxSpeedRatio; } foreach (Commandments.Element element in Enum.GetValues(typeof(Commandments.Element))) { if (grounds.gameObject.name.Contains(element.ToString())) { newSubRegion.element = element; break; } } foreach (Transform ground in grounds) { foreach (GroundType id in Enum.GetValues(typeof(GroundType))) { foreach (GroundSize size in Enum.GetValues(typeof(GroundSize))) { if ((ground.gameObject.name.StartsWith(id.ToString() + size.ToString()))) { Ground newGround = new Ground(); newSubRegion.type = id; newGround.size = size; newSubRegion.grounds.Add(newGround); break; } } } } newRegion.subRegions.Add(newSubRegion); } } else if (subRegion.gameObject.name.Contains("walls")) { foreach (Transform walls in subRegion) { Wall wall = new Wall(); wall.relPosition = walls.localPosition; wall.elements = new List <WallSize>(); wall.inverted = walls.localScale.x == -1; wall.rotated = walls.eulerAngles.z == 180; foreach (Commandments.Element element in Enum.GetValues(typeof(Commandments.Element))) { if (walls.gameObject.name.Contains(element.ToString())) { wall.element = element; break; } } foreach (Transform wallsize in walls) { foreach (WallType id in Enum.GetValues(typeof(WallType))) { foreach (WallSize size in Enum.GetValues(typeof(WallSize))) { if (wallsize.gameObject.name.StartsWith(id.ToString() + size.ToString())) { wall.elements.Add(size); wall.type = id; break; } } } } newRegion.walls.Add(wall); } } else if (subRegion.gameObject.name.Contains("shrines")) { foreach (Transform shrines in subRegion) { Shrine shrine = shrines.GetComponentInChildren <Shrine>(); if (shrine) { ShrineController newController = new ShrineController(); newController.type = shrine.id; newController.pos = shrines.localPosition; newRegion.shrines.Add(newController); } } } else if (subRegion.gameObject.name.Contains("chests")) { foreach (Transform chest in subRegion) { Chest chestObj = chest.GetComponentInChildren <Chest>(); if (chestObj) { ChestController newController = new ChestController(); newController.type = chestObj.type; newController.pos = chest.localPosition; newRegion.chest.Add(newController); } } } else if (subRegion.gameObject.name.Contains("misc")) { foreach (Transform obj in subRegion) { foreach (MiscType id in Enum.GetValues(typeof(MiscType))) { foreach (Commandments.Element element in Enum.GetValues(typeof(Commandments.Element))) { if ((obj.gameObject.name.StartsWith(id.ToString())) && (obj.gameObject.name.Contains(element.ToString()))) { MiscController newController = new MiscController(); newController.type = id; newController.element = element; newController.pos = obj.localPosition; newRegion.misc.Add(newController); break; } } } } } else if (subRegion.gameObject.name.Contains("yokais")) { foreach (Transform obj in subRegion) { foreach (Beastiary.YokaiID id in Enum.GetValues(typeof(Beastiary.YokaiID))) { if (obj.gameObject.name.StartsWith(id.ToString())) { YokaiController newController = new YokaiController(); newController.type = id; newController.pos = obj.localPosition; Enemy script = obj.gameObject.GetComponentInChildren <Enemy>(); if (script) { newController.pos = script.editorStartPosition - subRegion.position; } newRegion.yokai.Add(newController); break; } } } } } newLevel.regions.Add(newRegion); } } newPart.levels.Add(newLevel); } scene.parts.Add(newPart); } } if (scene.parts.Count < 1) { return; } save.scenes[asd] = scene; save.Save("Assets/Resources/JSON/fireBoundaries.json"); }
public DatabaseInfoLoader(string ApplicationPath, MiscController miscController) { applicationPath = ApplicationPath; this.miscController = miscController; }
public static async Task SevenDayForecastHourly() { var infoReturn = JsonConvert.DeserializeObject <SevenDayForecastHourlyModel>(LocalValuesModel.SevenDayForecastHourly); var snip = infoReturn.Properties.Periods; Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Cyan; Console.Write("{0,-12}", " TIME"); var dayList = MiscController.CreateDayListForecast(); for (int i = 0; i < 7; i++) { Console.Write("{0,-15}", $" {dayList[i]}"); } var hourArray = MiscController.CreateTwentyFourHours(); bool column; bool color = true; foreach (string hour in hourArray) { Console.ForegroundColor = ConsoleColor.Yellow; if (color) { Console.ForegroundColor = ConsoleColor.Gray; } Console.WriteLine(""); Console.Write("{0,-12}", $" {hour}"); color = !color; if (color) { Console.ForegroundColor = ConsoleColor.Yellow; } else { Console.ForegroundColor = ConsoleColor.Gray; } column = true; for (var i = 0; i < 7; i++) { for (var j = 0; j < snip.Count; j++) { if (hour == snip[j].StartTime.ToString("HH:00") && dayList[i] == snip[j].StartTime.ToString("MMM-dd")) { Console.Write("{0,-15}", $"{Math.Round((decimal)UnitConverterController.ConvertCelsiusToFahrenheit(snip[j].Temperature.Value), 0)}{LocalValuesModel.TempEnd} / " + $"{Math.Round((decimal)UnitConverterController.ConvertKilometerToMile(Convert.ToDecimal(snip[j].WindSpeed.Substring(0, 2).Trim())))}{LocalValuesModel.SpeedEnd}"); column = false; } } if (column) { Console.Write("{0,-15}", ""); } } } Console.WriteLine(""); await MenuView.ReturnToWelcome(); }
public PartsEditor(MiscController miscController) { InitializeComponent(); this.MiscController = miscController; }
public Dependancies() { DatabaseContext = new AutomobileDbContext(); MiscController = new MiscController(DatabaseContext); AutomobileController = new AutomobileController(DatabaseContext); }
public static void SetUpClass() { controller = GetClient().Misc; }