private void timer1_Tick(object sender, EventArgs e) { IntPtr pWindow; Process[] proc = Process.GetProcessesByName(mangosName); if (proc.Length == 0) { } pPointer = (IntPtr)proc[0].Id; pWindow = (IntPtr)proc[0].MainWindowHandle; Win32.SetForegroundWindow(pWindow); if (sTimer < Convert.ToDouble(textBox2.Text)) { if (sTimer < (Convert.ToDouble(textBox2.Text) - 1)) { timeLeft = timeLeft - 1; MainFunctions.SendToConsole("broadcast Server shutting down in: " + timeLeft + " minutes"); SendKeys.SendWait("{ENTER}"); sTimer++; } else { if (timeLeft == 1) { timeLeft += 0.25; } timer1.Interval = 15000; timeLeft = timeLeft - 0.25; MainFunctions.SendToConsole("broadcast Server shutting down in: " + (timeLeft * 60) + " seconds"); SendKeys.SendWait("{ENTER}"); sTimer += 0.25; } } else { MainFunctions.SendToConsole("exit"); SendKeys.SendWait("{ENTER}"); WriteLog("Shutdown counter ended! Shutting down MaNGOS NOW!", Color.Red); sTimer = 0; timeLeft = 5; timer1.Enabled = false; } Win32.SetForegroundWindow(this.Handle); HookToConsole.RemoveFrom(); ReadConsole(); }
private void button16_Click(object sender, EventArgs e) { IntPtr pWindow; Process[] proc = Process.GetProcessesByName(mangosName); if (proc.Length == 0) { } pPointer = (IntPtr)proc[0].Id; pWindow = (IntPtr)proc[0].MainWindowHandle; Win32.SetForegroundWindow(pWindow); MainFunctions.SendToConsole(textBox6.Text); SendKeys.SendWait("{ENTER}"); Win32.SetForegroundWindow(this.Handle); HookToConsole.RemoveFrom(); ReadConsole(); WriteLog("Custom command: \"" + textBox6.Text + "\" sent to MaNGOS console!", Color.Blue); }
private void button7_Click(object sender, EventArgs e) { WriteLog("Scripts loaded", Color.Gray); IntPtr pWindow; Process[] proc = Process.GetProcessesByName(mangosName); if (proc.Length == 0) { } pPointer = (IntPtr)proc[0].Id; pWindow = (IntPtr)proc[0].MainWindowHandle; Win32.SetForegroundWindow(pWindow); MainFunctions.SendToConsole("loadscripts"); SendKeys.SendWait("{ENTER}"); Win32.SetForegroundWindow(this.Handle); HookToConsole.RemoveFrom(); ReadConsole(); }
public void SendMail(string mailFrom, string mailToSupport, string subject, string body) { try { EventLog.saveMessage("Sending mail to:" + mailToSupport); MailMessage messageForSupport = new MailMessage(mailFrom, mailToSupport, subject, body); SmtpClient clientSupport = new SmtpClient(MainFunctions.GetValueFromWebConfig("MailServer")); clientSupport.UseDefaultCredentials = true; clientSupport.Credentials = new System.Net.NetworkCredential(mailFrom, MainFunctions.GetValueFromWebConfig("MailFromPassword")); clientSupport.Send(messageForSupport); EventLog.saveMessage("Mail is sent to :" + mailToSupport); } catch (Exception exx) { EventLog.saveMassage("Грешка при изпращане на e-mail на: '" + mailToSupport + "'", exx); } }
private void button13_Click(object sender, EventArgs e) { IntPtr pWindow; Process[] proc = Process.GetProcessesByName(mangosName); if (proc.Length == 0) { } pPointer = (IntPtr)proc[0].Id; pWindow = (IntPtr)proc[0].MainWindowHandle; Win32.SetForegroundWindow(pWindow); MainFunctions.SendToConsole("motd " + Convert.ToString(textBox5.Text)); SendKeys.SendWait("{ENTER}"); Win32.SetForegroundWindow(this.Handle); HookToConsole.RemoveFrom(); ReadConsole(); WriteLog("MOTD changed to: " + textBox5.Text, Color.Red); textBox6.Text = ""; }
private void button12_Click(object sender, EventArgs e) { IntPtr pWindow; Process[] proc = Process.GetProcessesByName(mangosName); if (proc.Length == 0) { } pPointer = (IntPtr)proc[0].Id; pWindow = (IntPtr)proc[0].MainWindowHandle; Win32.SetForegroundWindow(pWindow); MainFunctions.SendToConsole("kick " + Convert.ToString(listBox1.SelectedItem)); SendKeys.SendWait("{ENTER}"); Win32.SetForegroundWindow(this.Handle); HookToConsole.RemoveFrom(); ReadConsole(); WriteLog("Account: " + listBox1.SelectedItem + " kicked!", Color.Red); button4_Click(null, null); }
private void RefreshList(string itemLanguage) { ShopContext shopContext = new ShopContext(); Types = MainFunctions.GetFoodTypes(itemLanguage); FoodTypeBox.ItemsSource = Types.ToArray(); Foods = shopContext.FoodDictionary .Join(shopContext.Language, f => f.LanguageID, l => l.LanguageID, (f, l) => new { foodName = f.Name, Language = l.Name }) .Where(l => l.Language == itemLanguage).Select(f => f.foodName.ToString()).ToList(); FoodBox.ItemsSource = Foods.ToArray(); Units = shopContext.UnitDictionary .Join(shopContext.Language, u => u.LanguageID, l => l.LanguageID, (u, l) => new { UnitId = u.UnitID, UnitName = u.Name, Language = l.Name }) .Where(l => l.Language == itemLanguage).Select(u => new { UnitId = u.UnitId, UnitName = u.UnitName.ToString() }) .Join(shopContext.Unit, n => n.UnitId, u => u.UnitID, (n, u) => new UnitPropertis { Step = (float)u.UnitStep, Name = n.UnitName }).ToList(); FoodUnitBox.ItemsSource = Units.ToArray(); }
//List<WordAndItsReplacer> Replaced = new List<WordAndItsReplacer>(); private string Analyze() { string retVal = _Sentense; HaifaDeafEntities km = new HaifaDeafEntities(); /////قائمة الكلمات الثنائية المستبدلة //foreach (var c in toget) //{ // if (retVal.Contains(c)) // { // var rep = new WordAndItsReplacer() { WordID = c, WordReplacer = MainFunctions.GiveID() }; // Replaced.Add(rep); // retVal = retVal.Replace(c, rep.WordReplacer); // } //} // تقطيع الجمل حسب النقطة var Paragraphs = MainFunctions.Split(retVal, "."); string retSentense = ""; foreach (var P in Paragraphs) { string temp = P.Trim(); // الان هنا سيتم صياغة الجملة بمنظورها النهائي if (temp.Contains("!")) { temp = temp.Replace("!", ""); retSentense += "تعجب، "; } if (temp.Contains("?") || temp.Contains("؟")) { temp = temp.Replace("?", "").Replace("؟", ""); retSentense += "استفهام، "; } // إشارة | لكي أقوم بفصل المقدمة عن النهاية retSentense = retSentense + temp; } return(retSentense); }
public void LevelLoop() { while (true) { Console.WriteLine("To go to main menu, press 9. To exit game, press 0."); int key = ServiceFunctions.ChoosingRightKey(Console.ReadKey().KeyChar); switch (key) { case 9: MainFunctions.MainMenu(); break; case 0: MainFunctions.Exit_Game(); break; default: break; } } }
private void button18_Click(object sender, EventArgs e) { rStarted = false; if (checkBox2.Checked == true) { if (Process.GetProcessesByName(mangosName).Length > 0) { IntPtr pWindow; Process[] proc = Process.GetProcessesByName(mangosName); pPointer = (IntPtr)proc[0].Id; pWindow = (IntPtr)proc[0].MainWindowHandle; Win32.SetForegroundWindow(pWindow); MainFunctions.SendToConsole("exit"); SendKeys.SendWait("{ENTER}"); Win32.SetForegroundWindow(this.Handle); HookToConsole.RemoveFrom(); ReadConsole(); WriteLog("MaNGOS Restarted Manually!", Color.Red); } else { WriteLog("MaNGOS requested to be restarted, but process not found!", Color.Red); } } if (checkBox3.Checked == true) { if (Process.GetProcessesByName(realmName).Length > 0) { Process[] Proc = Process.GetProcessesByName(realmName); Proc[0].Kill(); WriteLog("Realm Restarted Manually!", Color.Red); } else { WriteLog("Realm requested to be restarted, but process not found!", Color.Red); } } restarterButton_Click(null, null); }
/// <summary> /// Interactively creates a new address. /// </summary> /// <returns>The new address.</returns> public static Address Create() { string typeOfAddressAsString = MainFunctions.ReadLine("Type: (Home/work/other) ").ToLower(); char firstLetter = 'h'; AddressType typeOfAddress = AddressType.Home; try { firstLetter = typeOfAddressAsString.ToCharArray()[0]; switch (firstLetter) { case 'w': typeOfAddress = AddressType.Work; break; case 'o': typeOfAddress = AddressType.Other; break; default: Console.WriteLine("Keeping default of Home"); break; } } catch (IndexOutOfRangeException) { Console.WriteLine("Keeping default of Home"); } string streetAddress = MainFunctions.GetAndValidateInput("Street Address", RegexPatterns.Address["Street Address"]); string city = MainFunctions.GetAndValidateInput("City", RegexPatterns.Address["City"]); string state = MainFunctions.GetAndValidateInput("State", RegexPatterns.Address["State"]); string postalCode = MainFunctions.GetAndValidateInput("Postal Code", RegexPatterns.Address["Postal Code"]); Address newAddress = typeOfAddress == AddressType.Home ? new Address(streetAddress, city, state, postalCode) : new Address(typeOfAddress, streetAddress, city, state, postalCode); return(newAddress); }
/// <summary> /// Interactively creates a new phone number. /// </summary> /// <returns>The new phone number.</returns> public static PhoneNumber Create() { string typeOfPhoneNumberAsString = MainFunctions.ReadLine("Type: (Home/work/mobile/other) ").ToLower(); char firstLetter = 'h'; PhoneNumberType typeOfPhoneNumber = PhoneNumberType.Home; try { firstLetter = typeOfPhoneNumberAsString.ToCharArray()[0]; switch (firstLetter) { case 'w': typeOfPhoneNumber = PhoneNumberType.Work; break; case 'm': typeOfPhoneNumber = PhoneNumberType.Mobile; break; case 'o': typeOfPhoneNumber = PhoneNumberType.Other; break; default: Console.WriteLine("Keeping default of Home"); break; } } catch (IndexOutOfRangeException) { Console.WriteLine("Keeping default of Home"); } string number = MainFunctions.GetAndValidateInput("Phone Number", RegexPatterns.PhoneNumber); PhoneNumber newPhoneNumber = new PhoneNumber(typeOfPhoneNumber, number); return(newPhoneNumber); }
/// <summary> /// Interactively modifies an address. /// </summary> public void Edit() { bool editType = MainFunctions.InputStartsWith("Edit address type? (y/N) ", "y"); if (editType) { string typeOfAddressAsString = MainFunctions.ReadLine("Type: (Home/work/other) ").ToLower(); char firstLetter = 'h'; AddressType typeOfAddress = AddressType.Home; try { firstLetter = typeOfAddressAsString.ToCharArray()[0]; switch (firstLetter) { case 'w': typeOfAddress = AddressType.Work; break; case 'o': typeOfAddress = AddressType.Other; break; default: Console.WriteLine("Keeping default of Home"); break; } } catch (IndexOutOfRangeException) { Console.WriteLine("Keeping default of Home"); } TypeOfAddress = typeOfAddress; } Console.WriteLine(); bool editStreetAddress = MainFunctions.InputStartsWith("Edit street address? (y/N) ", "y"); if (editStreetAddress) { StreetAddress = MainFunctions.GetAndValidateInput("Street Address", RegexPatterns.Address["Street Address"]); } Console.WriteLine(); bool editCity = MainFunctions.InputStartsWith("Edit city? (y/N) ", "y"); if (editCity) { City = MainFunctions.GetAndValidateInput("City", RegexPatterns.Address["City"]); } Console.WriteLine(); bool editState = MainFunctions.InputStartsWith("Edit state? (y/N) ", "y"); if (editState) { State = MainFunctions.GetAndValidateInput("State", RegexPatterns.Address["State"]); } Console.WriteLine(); bool editPostalCode = MainFunctions.InputStartsWith("Edit postal code? (y/N) ", "y"); if (editPostalCode) { PostalCode = MainFunctions.GetAndValidateInput("Postal Code", RegexPatterns.Address["Postal Code"]); } }
public void TestMoneyFunctions(float baseDPT, float multDPT, float addDPT, float expectedResponse) { float actualResponse = MainFunctions.moneyMultiplyer(baseDPT, multDPT, addDPT); Assert.That(actualResponse == expectedResponse); }
static void Main(string[] args) { Options arguments = Parser.Default.ParseArguments <Options>(args).MapResult(options => options, _ => null); Logger logger = new Logger(true, arguments.LogFile != null ? arguments.LogFile : null); logger.Log("Started"); // Server logger.Log($"Connecting to server {arguments.ServerName}"); PIServer piServer = PIUtil.GetPIServer(arguments.ServerName); logger.Log($"Connecting to system {arguments.SystemName}"); PISystem piSystem = AFUtil.GetPISystem(arguments.SystemName); logger.Log("Connected"); // Tags logger.Log($"Reading tags from {arguments.InputFile}"); List <AbstractRetrievePoints> tagClasses = null; switch (arguments.InputType) { case "RecordedTag": tagClasses = MainFunctions.LoadTagClassesRecorded( arguments.InputFile, arguments.OutputDirectory, arguments.TimeResolution, arguments.NumYears, arguments.PageSize, piServer, piSystem, arguments.NumParallelTasks, logger); break; case "InterpolatedTag": tagClasses = MainFunctions.LoadTagClassesInterpolated( arguments.InputFile, arguments.OutputDirectory, arguments.TimeResolution, arguments.NumYears, arguments.PageSize, piServer, piSystem, arguments.NumParallelTasks, logger); break; case "RecordedAttribute": tagClasses = MainFunctions.LoadAttributeClassesRecorded( arguments.InputFile, arguments.OutputDirectory, arguments.TimeResolution, arguments.NumYears, arguments.PageSize, piServer, piSystem, AFUtil.GetDatabase(piSystem, arguments.DatabaseName), arguments.NumParallelTasks, logger); break; case "InterpolatedAttribute": tagClasses = MainFunctions.LoadAttributeClassesInterpolated( arguments.InputFile, arguments.OutputDirectory, arguments.TimeResolution, arguments.NumYears, arguments.PageSize, piServer, piSystem, AFUtil.GetDatabase(piSystem, arguments.DatabaseName), arguments.NumParallelTasks, logger); break; default: break; } logger.Log($"Tags read"); logger.Log($"Reading tag data from {arguments.ServerName}, numParallelTasks = {arguments.NumParallelTasks}"); MainFunctions.DoStuffParallelForeach(tagClasses, arguments.NumParallelTasks, logger); logger.Log($"Data read"); logger.Log("Finished - press Enter to close terminal"); logger.Close(); Console.ReadLine(); }
/// <summary> /// Interactively creates a new email address. /// </summary> /// <returns>The new email address.</returns> public static EmailAddress Create() { string typeOfEmailAddressAsString = MainFunctions.ReadLine("Type: (Personal/work/school/other) ").ToLower(); char firstLetter = 'h'; EmailAddressType typeOfEmailAddress = EmailAddressType.Personal; try { firstLetter = typeOfEmailAddressAsString.ToCharArray()[0]; switch (firstLetter) { case 'w': typeOfEmailAddress = EmailAddressType.Work; break; case 's': typeOfEmailAddress = EmailAddressType.School; break; case 'o': typeOfEmailAddress = EmailAddressType.Other; break; default: Console.WriteLine("Keeping default of Personal"); break; } } catch (IndexOutOfRangeException) { Console.WriteLine("Keeping default of Personal"); } string address = ""; while (true) { string emailAddressString = MainFunctions.ReadLine("Email Address: "); try { MailAddress mailAddress = new MailAddress(emailAddressString); } catch (FormatException) { Console.Write("Invalid email address. Press any key to retry..."); Console.ReadKey(); Console.Clear(); continue; } catch (ArgumentException) { Console.Write("Invalid email address. Press any key to retry..."); Console.ReadKey(); Console.Clear(); continue; } address = emailAddressString; break; } EmailAddress newEmailAddress = new EmailAddress(typeOfEmailAddress, address); return(newEmailAddress); }
/// <summary> /// Interactively modifies an email address. /// </summary> public void Edit() { bool editType = MainFunctions.InputStartsWith("Edit email address type? (y/N) ", "y"); if (editType) { string typeOfEmailAddressAsString = MainFunctions.ReadLine("Type: (Personal/work/school/other) ").ToLower(); char firstLetter = 'h'; EmailAddressType typeOfEmailAddress = EmailAddressType.Personal; try { firstLetter = typeOfEmailAddressAsString.ToCharArray()[0]; switch (firstLetter) { case 'w': typeOfEmailAddress = EmailAddressType.Work; break; case 's': typeOfEmailAddress = EmailAddressType.School; break; case 'o': typeOfEmailAddress = EmailAddressType.Other; break; default: Console.WriteLine("Keeping default of Personal"); break; } } catch (IndexOutOfRangeException) { Console.WriteLine("Keeping default of Personal"); } TypeOfEmailAddress = typeOfEmailAddress; } Console.WriteLine(); bool editAddress = MainFunctions.InputStartsWith("Edit address? (y/N) ", "y"); if (editAddress) { string address = ""; while (true) { string emailAddressString = MainFunctions.ReadLine("Email Address: "); try { MailAddress mailAddress = new MailAddress(emailAddressString); } catch (FormatException) { Console.Write("Invalid email address. Press any key to retry..."); Console.ReadKey(); Console.Clear(); continue; } catch (ArgumentException) { Console.Write("Invalid email address. Press any key to retry..."); Console.ReadKey(); Console.Clear(); continue; } address = emailAddressString; break; } Address = address; } }
/// <summary> /// Interactively modifies a fax number. /// </summary> public override void Edit() { Number = MainFunctions.GetAndValidateInput("Fax Number", RegexPatterns.PhoneNumber); }
/// <summary> /// Interactively creates a new contact. /// </summary> /// <returns>The new contact.</returns> public static Contact Create() { string firstName = MainFunctions.GetAndValidateInput("First Name", RegexPatterns.Name); string lastName = MainFunctions.GetAndValidateInput("Last Name", RegexPatterns.Name); string fullName = string.Format("{0} {1}", firstName, lastName); Contact newContact = new Contact(fullName); bool addAddresses = !MainFunctions.InputStartsWith("Add addresses? (Y/n) ", "n"); if (addAddresses) { while (true) { Console.Clear(); Address newAddress = Address.Create(); Console.WriteLine(newAddress); bool addressOK = !MainFunctions.InputStartsWith("Is this address OK? (Y/n) ", "n"); if (addressOK) { newContact.Addresses.Add(newAddress); Console.WriteLine("Added new address to new contact's set of addresses."); } else { Console.WriteLine("Discarded new address."); } bool addAnother = !MainFunctions.InputStartsWith("Add another? (Y/n) ", "n"); if (!addAnother) { break; } } } bool addPhoneNumbers = !MainFunctions.InputStartsWith("Add phone numbers? (Y/n) ", "n"); if (addPhoneNumbers) { while (true) { Console.Clear(); PhoneNumber newPhoneNumber = PhoneNumber.Create(); Console.WriteLine(newPhoneNumber); bool addressOK = !MainFunctions.InputStartsWith("Is this phone number OK? (Y/n) ", "n"); if (addressOK) { newContact.PhoneNumbers.Add(newPhoneNumber); Console.WriteLine("Added new phone number to new contact's set of phone numbers."); } else { Console.WriteLine("Discarded new phone number."); } bool addAnother = !MainFunctions.InputStartsWith("Add another? (Y/n) ", "n"); if (!addAnother) { break; } } } bool addFaxNumbers = !MainFunctions.InputStartsWith("Add fax numbers? (Y/n) ", "n"); if (addFaxNumbers) { while (true) { Console.Clear(); FaxNumber newFaxNumber = FaxNumber.Create(); Console.WriteLine(newFaxNumber); bool addressOK = !MainFunctions.InputStartsWith("Is this fax number OK? (Y/n) ", "n"); if (addressOK) { newContact.FaxNumbers.Add(newFaxNumber); Console.WriteLine("Added new fax number to new contact's set of fax numbers."); } else { Console.WriteLine("Discarded new fax number."); } bool addAnother = !MainFunctions.InputStartsWith("Add another? (Y/n) ", "n"); if (!addAnother) { break; } } } bool addEmailAddresses = !MainFunctions.InputStartsWith("Add email addresses? (Y/n) ", "n"); if (addEmailAddresses) { while (true) { Console.Clear(); EmailAddress newEmailAddress = EmailAddress.Create(); Console.WriteLine(newEmailAddress); bool emailAddressOK = !MainFunctions.InputStartsWith("Is this email address OK? (Y/n) ", "n"); if (emailAddressOK) { newContact.EmailAddresses.Add(newEmailAddress); Console.WriteLine("Added new email address to new contact's set of email addresses."); } else { Console.WriteLine("Discarded new email address."); } bool addAnother = !MainFunctions.InputStartsWith("Add another? (Y/n) ", "n"); if (!addAnother) { break; } } } return(newContact); }
/// <summary> /// Interactively modifies a contact. /// </summary> public void Edit() { bool editName = MainFunctions.InputStartsWith("Edit name? (y/N) ", "y"); if (editName) { string firstName = MainFunctions.GetAndValidateInput("First Name", RegexPatterns.Name); string lastName = MainFunctions.GetAndValidateInput("Last Name", RegexPatterns.Name); Name = string.Format("{0} {1}", firstName, lastName); } Console.WriteLine("\n"); bool editAddresses = MainFunctions.InputStartsWith("Edit addresses? (y/N) ", "y"); if (editAddresses) { foreach (Address address in Addresses) { Console.WriteLine(address); bool editAddress = MainFunctions.InputStartsWith("\nEdit this address? (y/N) ", "y"); if (editAddress) { Console.WriteLine(); address.Edit(); } } } Console.WriteLine("\n"); bool editPhoneNumbers = MainFunctions.InputStartsWith("Edit phone numbers? (y/N) ", "y"); if (editPhoneNumbers) { foreach (PhoneNumber phoneNumber in PhoneNumbers) { Console.WriteLine(phoneNumber); bool editPhoneNumber = MainFunctions.InputStartsWith("\nEdit this phone number? (y/N) ", "y"); if (editPhoneNumber) { Console.WriteLine(); phoneNumber.Edit(); } } } Console.WriteLine("\n"); bool editFaxNumbers = MainFunctions.InputStartsWith("Edit fax numbers? (y/N) ", "y"); if (editAddresses) { foreach (FaxNumber faxNumber in FaxNumbers) { Console.WriteLine(faxNumber); bool editFaxNumber = MainFunctions.InputStartsWith("\nEdit this fax number? (y/N) ", "y"); if (editFaxNumber) { Console.WriteLine(); faxNumber.Edit(); } } } Console.WriteLine("\n"); bool editEmailAddresses = MainFunctions.InputStartsWith("Edit email addresses? (y/N) ", "y"); if (editEmailAddresses) { foreach (EmailAddress emailAddress in EmailAddresses) { Console.WriteLine(emailAddress); bool editEmailAddress = MainFunctions.InputStartsWith("\nEdit this email address? (y/N) ", "y"); if (editEmailAddress) { emailAddress.Edit(); } } } }