public void ExecuteCommand(Extension.IEnsoService service, Command command) { Logging.AddActionLog(string.Format("ClipboardManager: Executing command '{0}' ...", command.Name)); if (command.Name == "copy full path" || command.Name == "put on clipboard") { CraftSynth.BuildingBlocks.IO.Clipboard.SetTextToClipboard(command.parametersOnExecute[0].GetValueAsText()); Logging.AddActionLog(string.Format("ClipboardManager: full path copied to clipboard: {0}", command.parametersOnExecute[0].GetValueAsText())); MessagesHandler.Display(string.Format("Copied to clipboard: {0}", command.parametersOnExecute[0].GetValueAsText())); EnsoPlus.NotifyOtherApplicationsAboutClipboardChange(); } else if ((command.Name == "save-clipboard-as" && command.Postfix == "[work item name]") || (command.Name == "save-clipboard-as" && command.Postfix == "[work item name] and copy its file path")) { string clipboardContentsFormat = CraftSynth.BuildingBlocks.IO.Clipboard.GetClipboardFormatName(); if (clipboardContentsFormat == DataFormats.Bitmap) { Image clipboardImage = CraftSynth.BuildingBlocks.IO.Clipboard.GetImageFromClipboard(); string imageFilePath = command.parametersOnExecute[0].GetValueAsText(); try { if (!Directory.Exists(Settings.Current.ImagesFolder)) { Directory.CreateDirectory(Settings.Current.ImagesFolder); } imageFilePath = Path.Combine(Settings.Current.ImagesFolder, command.parametersOnExecute[0].GetValueAsText() + ".png"); clipboardImage.Save(imageFilePath, System.Drawing.Imaging.ImageFormat.Png); Logging.AddActionLog(string.Format("ClipboardManager: clipboard image saved to: {0}", imageFilePath)); MessagesHandler.Display("Saved."); if (command.Postfix.CompareTo("[work item name] and copy its file path") == 0) { CraftSynth.BuildingBlocks.IO.Clipboard.SetTextToClipboard(imageFilePath); Logging.AddActionLog(string.Format("ClipboardManager: file path '{0}' copied to clipboard.", imageFilePath)); MessagesHandler.Display("Image saved and its file path copied."); EnsoPlus.NotifyOtherApplicationsAboutClipboardChange(); } } catch (Exception exception) { throw new ApplicationException(string.Format("Clipboard manager: Failed to save clipboard image to '{0}'.", imageFilePath), exception); } } else { MessagesHandler.Display("Clipboard contents unrecognized. Only bitmap supported so far."); } } //else // if (command.Name == "command name" && command.Postfix == "postfix [item] [item2]") // { // MessagesHandler.Display( string.Format("Executing {0} ...", command.Name)); // } else { throw new ApplicationException(string.Format("ClipboardManager: Command not found. Command: {0} {1}", command.Name, command.Postfix)); } }
public void ExecuteCommand(Extension.IEnsoService service, Command command) { Logging.AddActionLog(string.Format("MessagesDisplayer: Executing command '{0}' ...", command.Name)); if (command.Name == "display-last-message") { MessagesHandler.Display(MessagesHandler.GetLastFromHistory(), false); Logging.AddActionLog(string.Format("MessagesDisplayer: Last message '{0}' displayed.", MessagesHandler.GetLastFromHistory())); } else //if (command.Name == "command name" && command.Postfix == "postfix [item] [item2]") //{ // MessagesHandler.Display( string.Format("Executing {0} ...", command.Name)); //} //else // if (command.Name == "command name" && command.Postfix == "postfix [item] [item2]") // { // MessagesHandler.Display( string.Format("Executing {0} ...", command.Name)); // } // else { throw new ApplicationException(string.Format("MessagesDisplayer: Command not found. Command: {0} {1}", command.Name, command.Postfix)); } }
private void SetSourceFolderOnBackupProfile(Extension.IEnsoService service, Command command, string name, string sourceFolder) { string filePath = WorkItemsProviders.BackupProfiles.BackupProfiles.GetFilePath(name); BackupProfile backupProfile = null; if (File.Exists(filePath)) { backupProfile = WorkItemsProviders.BackupProfiles.BackupProfiles.Load(name); } else { backupProfile = new BackupProfile(); backupProfile.Name = name; } backupProfile.SourceFolder = sourceFolder; WorkItemsProviders.BackupProfiles.BackupProfiles.Save(backupProfile); if (string.IsNullOrEmpty(backupProfile.DestinationFolder)) { SuggestionsCache.DropCache(this.GetType()); MessagesHandler.Display(string.Format("Profile created. Use 'set as backup destination...' command now.", command.Name)); } else { MessagesHandler.Display(string.Format(string.Format("Profile updated. You can now use 'backup {0}' command to create backups quickly.", name))); } }
protected void Page_Load(object sender, EventArgs e) { if (!Login()) { ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>opener.location.href=opener.location.href;self.close();</script>"); } else { if (!Page.IsPostBack) { Type.Items.Add(Root.rm.GetString("Feedtxt6")); Type.Items.Add(Root.rm.GetString("Feedtxt7")); Type.Items[0].Selected = true; Button2.Text = Root.rm.GetString("Feedtxt8"); if (Request["live"] != null) { livechat.Visible = true; } else { livechat.Visible = false; } } else { Panel1.Visible = false; Panel2.Visible = true; MessagesHandler.SendMail("*****@*****.**", "*****@*****.**", "[Tustena - I Wish][" + UC.UserName + "]" + IWSubject.Text, Type.SelectedItem.Text + Environment.NewLine + IWNote.Text); } } }
public void GetShouldReturnExpectedList() { var storedMessages = new List <MessageData> { new MessageData { Content = "Message 1" }, new MessageData { Content = "Message 2" } }; var expected = new List <Message> { new Message { Content = storedMessages[0].Content }, new Message { Content = storedMessages[1].Content }, }; mockRepository.Setup(repository => repository.FetchAll()).Returns(storedMessages); var handler = new MessagesHandler(mockRepository.Object); var actual = handler.GetMessages(); Assert.Equal(storedMessages.Count, actual.Count()); // Need to implement IEquality on Message to make the test comparison slicker // Assert.Equal(expected, actual); for (var index = 0; index < storedMessages.Count; index++) { Assert.Equal(expected[index].Content, actual.ElementAt(index).Content); } }
static void hangUpTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { if (leftToThick <= 0) { hangUpTimer.Stop(); Dialer.Cancel(); } else { //StringBuilder sb = new StringBuilder(); //int i = leftToThick; //while (i-- > 0) sb.Append('*'); string message = string.Empty; //string subMessage = string.Empty; if (contactToDial is ContactUnknown) { message = string.Format("Calling {0} ...", contactToDial.number); } else { message = string.Format("Calling {0} ...", contactToDial.name); //subMessage = string.Format("{0}", contactToDial.number); } MessagesHandler.Display(message, string.Format("Use phone now. {0} seconds to hang up...", leftToThick)); leftToThick--; } }
/// <summary> /// Attempt to appeal the currently selected grade /// </summary> private void AppealGrade() { // Check that a grade was selected if (SelectedGrade.CourseName != string.Empty) { // Check that a appeal text was entered if (AppealText.Count() > 0) { // Send an appeal message to the relevent teacher MessagesHandler.CreateMessage("בקשת ערעור", AppealText, MessageRecipientsTypes.Person, ConnectedPerson.personID, SelectedGrade.TeacherID); // Report that the appeal has been sent to the user _messageBoxService.ShowMessage("הוזן ערעור", "הוזנה בקשת ערעור במקצוע " + SelectedGrade.CourseName, MessageType.OK_MESSAGE, MessagePurpose.INFORMATION); // Clear after appeal AppealText = string.Empty; } else { // Report invalid input _messageBoxService.ShowMessage("נכשל בהזנת ערעור", "אנא הזן הודעה לערעור", MessageType.OK_MESSAGE, MessagePurpose.ERROR); } } else { // Report invalid input _messageBoxService.ShowMessage("נכשל בהזנת ערעור", "אנא בחר מקצוע לפני הזנת בקשת ערעור", MessageType.OK_MESSAGE, MessagePurpose.ERROR); } }
private async Task OnMessageReceivedAsync(SocketMessage message) { if (!MessagesHandler.TryParseMessageAndCheck(message, out SocketUserMessage userMessage)) { return; } if (ContainsPhrase(message.Content, "uh ?oh")) { await message.Channel.SendMessageAsync("uh oh"); } else if (ContainsPhrase(message.Content, "oh ?no")) { await message.Channel.SendMessageAsync("oh no"); } else if (ContainsPhrase(message.Content, "m[aá]m pravdu.*\\?", false)) { await userMessage.ReplyAsync(ThreadSafeRandom.Next(0, 2) == 1? "Ano, máš pravdu." : "Ne, nemáš pravdu.", allowedMentions : CheckAndFixAllowedMentions(null)); } else if (ContainsPhrase(message.Content, "^je [cč]erstv[aá]")) { await message.Channel.SendMessageAsync("Není čerstvá!"); } else if (ContainsPhrase(message.Content, "^nen[ií] [cč]erstv[aá]")) { await message.Channel.SendMessageAsync("Je čerstvá!"); } else if (ContainsPhrase(message.Content, "^PR$")) { await message.Channel.SendMessageAsync("https://github.com/Inkluzitron/Inkluzitron"); } }
public void ExecuteCommand(IEnsoService service, Command command) { Logging.AddActionLog(string.Format("WebSearcher: Executing command '{0}' ...", command.Name)); if (command.Name == "learn as web search command with name") { ShortcutTemplates.CreateShortcutTemplate(command.parametersOnExecute[0].GetValueAsText(), command.parametersOnExecute[1].GetValueAsText()); SuggestionsCache.DropCache(typeof(WorkItemsProviders.ShortcutTemplates.ShortcutTemplates)); EnsoPlus.current.Reinitialize(); string message = string.Format("{0} is now a command.", command.parametersOnExecute[0].GetValueAsText()); Logging.AddActionLog(string.Format("WebSearcher: {0}", message)); MessagesHandler.Display(message); } else { string shortcutFilePath = ShortcutTemplates.BuildFilePath(command.Name); string template = ShortcutTemplates.GetTemplate(shortcutFilePath); string queryString = string.Format(template, command.parametersOnExecute[0].GetValueAsText()); Process process = new Process(); process.StartInfo.UseShellExecute = true; process.StartInfo.FileName = queryString; Logging.AddActionLog(string.Format("WebSearcher: Starting '{0}' ...", process.StartInfo.FileName)); process.Start(); } }
public void ExecuteCommand(Extension.IEnsoService service, Command command) { Logging.AddActionLog(string.Format("CommandsManager: Executing command '{0}' ...", command.Name)); if (command.Name == "repeat") { Logging.AddActionLog(string.Format("CommandsManager: Repeating last command: {0}", CommandsHistory.GetLast().caption)); CommandsHistory.GetLast().Execute(service); } else if (command.Name == "remove" || command.Name == "forget") { command.parametersOnExecute[0].GetProvider().Remove(command.parametersOnExecute[0]); Logging.AddActionLog(string.Format("CommandsManager: Command '{0}' removed.", command.parametersOnExecute[0].GetCaption())); MessagesHandler.Display(string.Format("{0} removed.", command.parametersOnExecute[0].GetCaption())); } else if (command.Name == "command name" && command.Postfix == "postfix [item] [item2]") { MessagesHandler.Display(string.Format("Executing {0} ...", command.Name)); } else { throw new ApplicationException(string.Format("HistoryManager: Command not found. Command: {0} {1}", command.Name, command.Postfix)); } }
public DisconnectJob( MessagesHandler mh, IServiceScopeFactory serviceScopeFactory) { _messagesHandler = mh; _serviceScopeFactory = serviceScopeFactory; }
public Task <IEnumerable <object> > Handle(IEnumerable <object> messages, MessagesHandler next) { messages.OfType <TestEventOne>().ForEach(m => m.Message = "behavior"); var result = next(messages); return(result); }
private void FinishCommand(string commandName, List <Process> selectedProcesses, IEnsoService service) { string message = string.Empty; if (commandName == "kill") { foreach (Process p in selectedProcesses) { p.Kill(); message += string.Format(",\r\n{0} ({1})", p.ProcessName, p.Id); MessagesHandler.Display(message + "Killed"); } message = message + " - Killed all"; Logging.AddActionLog(string.Format("ProcessesManager: {0}", message)); MessagesHandler.Display(message); } else if (commandName == "restart process") { List <string> processesFilePaths = new List <string>(); //call kill foreach (Process p in selectedProcesses) { processesFilePaths.Add(p.MainModule.FileName); p.Kill(); } //wait foreach (Process p in selectedProcesses) { ContinueWhenProcessIsNotActive(p); if (message != string.Empty) { message += ","; } message += string.Format("\r\n{0} ({1})", p.ProcessName, p.Id); MessagesHandler.Display(message + "Killed"); } message = message + " - Killed all"; Logging.AddActionLog(string.Format("ProcessesManager: {0}", message)); MessagesHandler.Display(message); //start message = string.Empty; foreach (string processFilePath in processesFilePaths) { CraftSynth.BuildingBlocks.WindowsNT.Misc.OpenFile(processFilePath); if (message != string.Empty) { message += ","; } message += string.Format("\r\n{0} ", Path.GetFileName(processFilePath)); MessagesHandler.Display(message + "Restarted"); } message = message + " - Restarted all"; Logging.AddActionLog(string.Format("ProcessesManager: {0}", message)); MessagesHandler.Display(message); } }
//[STAThreadAttribute] public static void Main() { Logging.AddActionLog("Starting Enso+ ..."); //IsFirstRun = !File.Exists(Settings.FilePath); //Not working //Application.ThreadException += new ThreadExceptionEventHandler(BuildingBlocks.Exceptions.EnterpriseLibrary.ExceptionHandler.Application_ThreadException); Application.ThreadException += Application_ThreadException; try { if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Count() >= 2) { MessageBox.Show("Enso+ is already running."); } else { //Logging.AddActionLog("Starting EnsoPlus.Guard in not running already ..."); string ensoPlusGuardExeFilePath = Path.Combine(CraftSynth.BuildingBlocks.Common.Misc.ApplicationRootFolderPath, "EnsoPlus.Guard.exe"); CraftSynth.BuildingBlocks.WindowsNT.Misc.OpenFile(ensoPlusGuardExeFilePath); Helper.PreDeleteLogs(); if (Settings.Current.firstRun || !File.Exists(Path.Combine(Common.Helper.GetEnsoPlusWorkingFolder(), "Version.txt"))) { Common.HandlerForPreviousVersions.OfferImportingOfSettingsFromPreviousVersion(); } if (Settings.Current.firstRun) { Settings.Current.firstRun = false; Settings.Current.Save(); } extensionPlus = new EnsoPlus(); var mergedCommands = extensionPlus.GetMergedCommands(); cornerLauncher = new CornerLauncher(mergedCommands, OnClose); // extensionPlus.OnCommand( mergedCommands[mergedCommands.Keys.Single(k=>k=="open")].sourceCommands[0], string.Empty); ParameterInput.Init(); Logging.AddActionLog(string.Format("Started Enso+ {0}", CraftSynth.BuildingBlocks.Common.Misc.version ?? string.Empty)); MessagesHandler.Display("Welcome to Enso+"); var f = new FormMain(); f.Visible = false; f.Width = 0; f.Height = 0; Application.Run(f); } } catch (Exception exception) { Logging.AddErrorLog("Server: Starting failed: " + exception.Message); Common.Logging.AddExceptionLog(exception); } }
private void Submitbtn_Click(object sender, EventArgs e) { MessagesHandler.SendMail(MailAddress.Text, FromAddress.Text, "[Tustena] " + MailObject.Text, MailMessage.Text + "<br>" + FillTemplate(int.Parse(Request.Params["e"]))); ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('" + Root.rm.GetString("Esttxt24") + "');self.close();parent.HideBox();</script>"); }
public VoteService(DiscordSocketClient client, ScheduledTasksService scheduledTasksService, VoteDefinitionParser parser, DatabaseFactory dbFactory, MessagesHandler messagesHandler, VoteTranslations voteTranslations) { MessagesHandler = messagesHandler; Client = client; ScheduledTasksService = scheduledTasksService; Parser = parser; DbFactory = dbFactory; VoteTranslations = voteTranslations; }
public Task <IEnumerable <object> > Handle(IEnumerable <object> messages, MessagesHandler next) { EnterCount++; var result = next(messages); ExitCount++; return(result); }
public void AddShouldCallOnRepositoryWithCorrectValue() { var message = new Message { Content = "New message" }; var handler = new MessagesHandler(mockRepository.Object); handler.AddMessage(message); mockRepository.Verify(repository => repository.Add(It.Is <MessageData>(arg => arg.Content == "New message"))); }
/// <summary> /// Send a message to the relevent recipients about an update in an event /// </summary> /// <param name="schoolEvent">The event to report</param> private void SendMessageAboutEvent(Event schoolEvent, ActionOnEvent action) { string eventTitle; string eventMessage; // Create the event message & title depedning on the type of action that happens to the event switch (action) { case ActionOnEvent.Created: { eventTitle = "הוזן אירוע חדש ביומן!"; eventMessage = ConnectedPerson.firstName + " " + ConnectedPerson.lastName + " יצר את האירוע '" + schoolEvent.name + "' בתאריך " + schoolEvent.eventDate; break; } case ActionOnEvent.Deleted: { eventTitle = "נמחק אירוע!"; eventMessage = ConnectedPerson.firstName + " " + ConnectedPerson.lastName + " מחק את האירוע '" + schoolEvent.name + "' שהיה בתאריך " + schoolEvent.eventDate; break; } case ActionOnEvent.Updated: { eventTitle = "עודכנו פרטי אירוע!"; eventMessage = ConnectedPerson.firstName + " " + ConnectedPerson.lastName + " עדכן את האירוע '" + schoolEvent.name + "' שבתאריך " + schoolEvent.eventDate; break; } default: { throw new ArgumentException("Invalid ActionOnEvent type"); } } // Check to whom to send the message depending on the recipients of the event // Check if its a school event (has no specified recipients) if (schoolEvent.recipientID == null && schoolEvent.recipientClassID == null) { MessagesHandler.CreateMessage(eventTitle, eventMessage, MessageRecipientsTypes.Everyone); } // Check if its an event for a specific class else if (schoolEvent.recipientClassID != null) { MessagesHandler.CreateMessage(eventTitle, eventMessage, MessageRecipientsTypes.Class, null, schoolEvent.recipientClassID.Value); } // All other events are aimed for a specific person else { MessagesHandler.CreateMessage(eventTitle, eventMessage, MessageRecipientsTypes.Person, null, schoolEvent.recipientID.Value); } }
public VersusController( VersusContext context, UserManager <User> um, IMobileMessagingClient mmc, MessagesHandler messagesHandler) { _context = context; _userManager = um; _mmc = mmc; _messagesHandler = messagesHandler; }
public static void Postfix(MechComponent __instance) { try { MessagesHandler.PublishComponentState(__instance); } catch (Exception e) { Control.mod.Logger.LogError(e); } }
public async Task <IReadOnlyCollection <object> > Handle( IReadOnlyCollection <object> messages, MessagesHandler next) { foreach (var message in messages.OfType <IOutboundEnvelope>()) { message.Headers.Add("generated-by", "silverback"); } return(await next(messages)); }
public static void Redial() { if (lastDialedContact == null) { MessagesHandler.Display("No calls since program start"); } else { Dialer.Dial(lastDialedContact); } }
public MessagesController( IMobileMessagingClient mmc, UserManager <User> um, VersusContext vc, MessagesHandler messagesHandler) { _mmc = mmc; _userManager = um; _messagesHandler = messagesHandler; _context = vc; }
public Task <IEnumerable <object> > Handle(IEnumerable <object> messages, MessagesHandler next) { _calls?.Add("unsorted"); EnterCount++; var result = next(messages); ExitCount++; return(result); }
public void AssignPasteKeyCombination(IEnsoService service) { List <Keys> selectedKeyCombination = KeyCombinationRetriever.Execute(null); if (selectedKeyCombination != null) { Settings.Current.pasteKeyCombination = CraftSynth.BuildingBlocks.UI.WindowsForms.KeysHelper.ToCommaSeparatedCodesString(selectedKeyCombination); Settings.Save(); MessagesHandler.Display(CraftSynth.BuildingBlocks.UI.WindowsForms.KeysHelper.ToUserFriendlyString(selectedKeyCombination) + " is now key combination for paste operation. Please restart Selection Listener."); } }
private void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } }
public ActionResult GetMessages(int rcvId) { //int id = (int)TempData["currentUser"]; User u = (User)Session[WebUtil.CURRENT_USER]; int id = u.Id; List <Messages> sndmsgs = new MessagesHandler().GetAllSendMessages(id, rcvId); List <Messages> rcvdmsgs = new MessagesHandler().GetAllReceivedMessages(id, rcvId); sndmsgs.AddRange(rcvdmsgs); sndmsgs = sndmsgs.OrderBy(x => x.TimeOfMsg).ToList(); return(Json(new { list = sndmsgs }, JsonRequestBehavior.AllowGet)); }
public int ConversationCount() { User currentUser = (User)Session[WebUtil.CURRENT_USER]; if (currentUser != null) { int convoCount = new MessagesHandler().UserConversations(currentUser.Id).Count(); return(convoCount); } return(0); }
public Dictionary <string, IWorkItem> GetSuggestions() { Dictionary <string, IWorkItem> suggestions = new Dictionary <string, IWorkItem>(); foreach (EnsoMessage ensoMessage in MessagesHandler.GetAllFromHistory()) { DisplayMessage displayMessage = new DisplayMessage(ensoMessage.Text, ensoMessage.Subtext); displayMessage.provider = this; suggestions[displayMessage.GetCaption()] = displayMessage; } return(suggestions); }