void HandleMasterNavigation(MasterNavigationMessage masterNavigation) { switch (masterNavigation.NavigationType) { case MasterNaviationType.ContactList: OpenContactList.Execute(null); break; case MasterNaviationType.QuoteList: OpenQuoteList.Execute(null); break; case MasterNaviationType.Logout: LogoutCommand.Execute(null); break; case MasterNaviationType.Quote: QuoteCommand.Execute(masterNavigation.NavigationData); break; case MasterNaviationType.ContactUs: ContactUsCommand.Execute(null); break; } }
//询价Command private void SendQuoteCommandBtn_Click(object sender, RoutedEventArgs e) { string exchangeCode = this.QuoteCommand.Text; int commandSequence = 1; QuoteCommand quoteCommand = new QuoteCommand(commandSequence); quoteCommand.InstrumentID = Guid.NewGuid(); quoteCommand.QuoteLot = 10; quoteCommand.CustomerID = Guid.NewGuid(); quoteCommand.BSStatus = 1; ManagerClient.AddCommand(quoteCommand); }
private static Message Convert(QuoteCommand quoteCommand) { //XmlNode node = quoteCommand.Content.Attributes["Quote"]; //Guid customerId = new Guid(node.Attributes["CustomerID"].Value); //Guid instrumentId = new Guid(node.Attributes["InstrumentID"].Value); //double quoteLot = double.Parse(node.Attributes["QuoteLot"].Value); //int bSStatus = int.Parse(node.Attributes["BSStatus"].Value); //QuoteMessage quoteMessage = new QuoteMessage(customerId,instrumentId,quoteLot,bSStatus); //QuoteMessage quoteMessage = new QuoteMessage(quoteCommand.CustomerID, quoteCommand.InstrumentID, quoteCommand.QuoteLot,quoteCommand.BSStatus); DispatchableQuote quoteMessage = new DispatchableQuote("WF01",quoteCommand.CustomerID, quoteCommand.InstrumentID, quoteCommand.QuoteLot, quoteCommand.BSStatus); return quoteMessage.MessageToSend; }
static async Task Run() { var bot = new TelegramBotClient("353997582:AAFfZJRBIbt1dGNQDIjWUS5nXBV367LyfXI"); var me = await bot.GetMeAsync(); ICommand weatherCommand = new WeatherCommand(Log.Logger); ICommand quoteCommand = new QuoteCommand(Log.Logger); ICommand defaultCommand = new DefaultCommand(Log.Logger); ICommand[] commands = new ICommand[] { weatherCommand, quoteCommand, defaultCommand }; Console.WriteLine("Hello my name is {0}", me.Username); var offset = 0; while (true) { var updates = await bot.GetUpdatesAsync(offset); foreach (var update in updates) { foreach (var command in commands) { if (command.IsApplicable(update)) { command.Execude(update, bot).Wait(); break; } } offset = update.Id + 1; } await Task.Delay(1000); } }
private void SendQuoteCommandBtn_Click(object sender, RoutedEventArgs e) { string exchangeCode = this.QuoteCommand.Text; int commandSequence = 1; QuoteCommand quoteCommand = new QuoteCommand(commandSequence); if (quoteIndex >= 2 && quoteIndex <= 6) { quoteCommand.CustomerID = new Guid("9538eb6e-57b1-45fa-8595-58df7aabcfc8"); quoteCommand.QuoteLot = 8; if (quoteIndex == 3) { quoteCommand.BSStatus = 1; quoteCommand.InstrumentID = new Guid("66adc06c-c5fe-4428-867f-be97650eb3b" + 1); } else if (quoteIndex % 2 == 0 && quoteIndex != 2) { quoteCommand.BSStatus = 0; quoteCommand.InstrumentID = new Guid("66adc06c-c5fe-4428-867f-be97650eb3b" + 2); } else { quoteCommand.BSStatus = 2; quoteCommand.InstrumentID = new Guid("66adc06c-c5fe-4428-867f-be97650eb3b" + 3); } } else { quoteCommand.InstrumentID = new Guid("66adc06c-c5fe-4428-867f-be97650eb3b" + quoteIndex); quoteCommand.CustomerID = new Guid("9538eb6e-57b1-45fa-8595-58df7aabcfc8"); quoteCommand.QuoteLot = 10; quoteCommand.BSStatus = 1; } quoteCommand.CustomerID = new Guid("9538eb6e-57b1-45fa-8595-58df7aabcfc9"); ManagerClient.AddCommand(quoteCommand); quoteIndex++; }
private void SetUpTest(QuoteEntity foundQuote) { _repositoryMock.Setup(x => x.Single(It.IsAny <ISpecification <QuoteEntity> >())).Returns(foundQuote); _quoteCommand = new QuoteCommand(_repositoryMock.Object); }
private static Message Convert(string exchagenCode, QuoteCommand quoteCommand) { QuoteMessage quoteMessage = new QuoteMessage(exchagenCode, quoteCommand.CustomerID, quoteCommand.InstrumentID, quoteCommand.QuoteLot, quoteCommand.BSStatus); return quoteMessage; }
static void Main(string[] args) { string url = "irc.chat.twitch.tv"; int port = 80; string user = "******"; string oAuthToken = System.IO.File.ReadAllText(@"token.txt"); // token.txt must be in the same folder as EXE string channel = "lobosjr"; //Set up one IrcClient, only one is required it allows better cooldown managerment and traffic will //never cause this code to run slower then any twitch cool down for bots. TwitchClientFactory icf = new TwitchClientFactory(); ITwitchClient client = icf.create(url, port, user, oAuthToken, channel, 600, new OperationRequestEventRaiser(), new PrivMessageEventRaiser(), new WhisperMessageEventRaiser()); client.DefaultMessageHandler += (o, e) => { Console.WriteLine(string.Format("System: {0}", e.Raw)); }; //Set up Legacy Item -> IEquipment converter. LegacyItemEquipmentConverter liec = new LegacyItemEquipmentConverter(); //Set up Equipment repository, if legacy then this will load all items from old files and convert them //into IEquipment in memory. IEquipmentRepository equipmentRepository = LegacyEquipmentRepository .getInstance(liec, LegacyEquipmentRepository.LEGACY_ITEM_BRIDGE_FILE_PATH, LegacyEquipmentRepository.LEGACY_ITEM_PREFIX_FILE_PATH); //Set up Player Repository, Factory and default ILevelObservers ILevelObserver levelUpNotifier = new LevelupNotifier(client); PlayerFactory pf = new PlayerFactory(3, 20, levelUpNotifier); ILevelObserver classChoiceNotifier = new ClassChoiceNotifier(client, pf, 3); pf.GetCurrentDefaultObservers().Add(classChoiceNotifier); IPlayerRepository playerRepo = LegacyPlayerRepository.getInstance(3, 20, pf, equipmentRepository, LegacyPlayerRepository.LEGACY_USER_COINS_FILE_PATH, LegacyPlayerRepository.LEGACY_USER_XP_FILE_PATH, LegacyPlayerRepository.LEGACY_USER_CLASS_FILE_PATH, "players.json"); //Set up Adventure repository. IAdventureRepository adventureRepository = LegacyAdventureRepository .getInstance(LegacyAdventureRepository.LEGACY_DUNGEON_BRIDGE_FILE_PATH, LegacyAdventureRepository.LEGACY_DUNGEON_FILE_PATH_PREFIX, equipmentRepository); //Set up Adventure manager who's Run() func should be used to run adventures on a daemon thread IAdventureManager adventureManager = new AdventureManager(client, 3); new Thread(() => { Thread.CurrentThread.Name = "Adventure Manager"; Thread.CurrentThread.IsBackground = true; adventureManager.Run(); }).Start(); //Set up Party Pool, this keeps track of current parties. IPartyPool partyPool = new PartyPool(client); //Set up Group finder, use the current adventure managers queue. Decide party size capacity for // group finder. GroupFinderFactory gff = new GroupFinderFactory(); IGroupFinder groupFinder = gff.Create(partyPool, 3, adventureRepository, adventureManager); //Set up FutureTask Registry which will keep track of time based operations FutureTaskRegistry futureTaskRegistry = new FutureTaskRegistry(); //Set up Custom Command Factory and Repository for the Command Manager allowing //for saved custom commands to be used aswell as providing capability for new //custom commands to be created from chat(broadcaster/mod only). CustomCommandFactory ccf = new CustomCommandFactory(); CustomCommandRepository ccr = new CustomCommandRepository(); CommandManager commandManager = new CommandManager(client, ccf, ccr); //Initialise all commands to be added to the command manager, seperated by //the source of the request, either PRVMSG or WHISPER. #region Initialisation of Commands #region General Commands UptimeCommand uptime = new UptimeCommand(); Command <IPrivRequest> broadcasting = new BroadcastingFlagCommand(user, playerRepo, pf, uptime, client, futureTaskRegistry, 1, 3, 2, TimeSpan.FromMinutes(30)); Command <IPrivRequest> time = new TimeCommand(); Command <IPrivRequest> playlist = new PlaylistCommand("http://open.spotify.com/user/1251282601/playlist/2j1FVSjJ4zdJiqGQgXgW3t"); Command <IPrivRequest> opinion = new OpinionCommand(); Command <IPrivRequest> pun = new PunCommand(); Command <IPrivRequest> quote = new QuoteCommand(); Command <IPrivRequest> raffle = new RaffleCommand(client, 5, futureTaskRegistry); #endregion #region RPG Commands #region General Command <IWhisperRequest> stats = new StatsCommand(pf, playerRepo); Command <IWhisperRequest> inventory = new InventoryCommand(pf, playerRepo); Command <IWhisperRequest> item = new ItemCommand(equipmentRepository, pf, playerRepo); Command <IWhisperRequest> equip = new EquipCommand(equipmentRepository, pf, playerRepo); Command <IWhisperRequest> unequip = new UnequipCommand(equipmentRepository, pf, playerRepo); Command <IWhisperRequest> shop = new ShopCommand(); Command <IWhisperRequest> classChoice = new ClassChoice(pf, playerRepo, 3); Command <IWhisperRequest> gloat = new GloatCommand(client, pf, playerRepo); Command <IWhisperRequest> respec = new RespecCommand(pf, playerRepo); Command <IWhisperRequest> daily = new DailyCommand(pf, playerRepo); Command <IWhisperRequest> queue = new QueueCommand(groupFinder, pf, playerRepo); Command <IWhisperRequest> leaveQueue = new LeaveQueueCommand(groupFinder, pf, playerRepo); Command <IWhisperRequest> queueTime = new QueueTimeCommand(groupFinder, pf, playerRepo); #endregion #region Party Commands Command <IWhisperRequest> createParty = new CreatePartyCommand(partyPool, pf, playerRepo); Command <IWhisperRequest> pendingInvite = new PendingInvite(partyPool, pf, playerRepo); Command <IWhisperRequest> leaveParty = new LeavePartyCommand(pf, playerRepo); #region Party Leader Commands Command <IWhisperRequest> partyAdd = new AddPartyCommand(client, pf, playerRepo); Command <IWhisperRequest> partyKick = new KickPartyCommand(client, pf, playerRepo); Command <IWhisperRequest> partyStart = new StartPartyCommand(groupFinder, pf, playerRepo); Command <IWhisperRequest> partyPromote = new PromotePartyCommand(client, pf, playerRepo); #endregion #endregion #region Broadcaster only Command <IWhisperRequest> addPlayerXp = new AddPlayerXP(pf, playerRepo); Command <IWhisperRequest> addPlayerCoin = new AddPlayerCoin(pf, playerRepo); Command <IWhisperRequest> setPlayerLevel = new SetPlayerLevel(pf, playerRepo); #endregion #endregion #endregion commandManager.AddAll(uptime, broadcasting, time, playlist, opinion, pun, quote, raffle); commandManager.AddAll(stats, inventory, item, equip, unequip, shop, classChoice, gloat, respec, daily, queue, leaveQueue, queueTime, createParty, pendingInvite, leaveParty, partyAdd, partyKick, partyStart, partyPromote, addPlayerXp, addPlayerCoin, setPlayerLevel); //Provide Handles for events raised by client, multiple handles can be added //allow for parsing of PRVMSG chat for mirroring certain messages. #region Client Event Handling client.AddOperationHandler += commandManager.Handle; client.CancelOperationHandler += commandManager.Handle; client.DeleteOperationHandler += commandManager.Handle; client.EditOperationHandler += commandManager.Handle; client.InfoOperationHandler += commandManager.Handle; client.PrivHandler += (o, e) => { Console.WriteLine(string.Format("{0}: {1}", e.User, e.Message)); }; client.PrivRequestHandler += commandManager.Handle; client.WhisperHandler += (o, e) => { Console.WriteLine(string.Format("Whisper {0}: {1}", e.User, e.Message)); }; client.WhisperRequestHandler += commandManager.Handle; #endregion //new thread for sending messages back to twitch server. new Thread(() => { Thread.CurrentThread.Name = "Twitch Client"; Thread.CurrentThread.IsBackground = true; client.Run(); }).Start(); futureTaskRegistry.Run(); }
public async void CallRowAction(RowAction action) { switch (action.ActionType) { case RowActionType.Favorite: FavoriteCommand.Execute(action.Parameter as Tweet); break; case RowActionType.Retweet: RetweetCommand.Execute(action.Parameter as Tweet); break; case RowActionType.Quote: QuoteCommand.Execute(action.Parameter as Tweet); break; case RowActionType.Reply: ReplyCommand.Execute(action.Parameter as Tweet); break; case RowActionType.TweetDetail: var tweetParameter = action.Parameter as TweetDetailParameter; TweetDetailCommand.Execute(tweetParameter); break; case RowActionType.UserDetail: var userParameter = action.Parameter as UserDetailParameter; UserDetailCommand.Execute(userParameter); break; case RowActionType.Search: var searchParameter = action.Parameter as SearchDetailParameter; SearchCommand.Execute(searchParameter); break; case RowActionType.Browse: BrowseCommand.Execute(action.Parameter.ToString()); break; case RowActionType.Description: DescriptionDommand.Execute(action.Parameter as Tweet); break; case RowActionType.Delete: var tweet = action.Parameter as Tweet; var client = AccountList.Where(q => q.UserInfomation.screen_name == tweet.user.screen_name).Select(q => q.TwitterClient).Single(); await client.DestroyStatusAsync(tweet); break; case RowActionType.DirectMessage: var dmParameter = action.Parameter as DirectMessageDetailParameter; DirectMessageDetailCommand.Execute(dmParameter); break; case RowActionType.Share: break; case RowActionType.SavePreviewImage: Uri uri = action.Parameter as Uri; FolderPicker picker = new FolderPicker(); picker.FileTypeFilter.Add(".png"); picker.FileTypeFilter.Add(".jpg"); picker.FileTypeFilter.Add(".bmp"); picker.FileTypeFilter.Add(".gif"); var folder = await picker.PickSingleFolderAsync(); if (folder != null) { HttpClient hClient = new HttpClient(); var bytes = await hClient.GetByteArrayAsync(uri); var file = await folder.CreateFileAsync(DateTime.Now.ToString("yyyMMhhmmss") + ".png"); DataWriter writer = new DataWriter(await file.OpenAsync(FileAccessMode.ReadWrite)); writer.WriteBytes(bytes); await writer.StoreAsync(); await writer.FlushAsync(); writer.DetachStream(); await NotificationAsync(new NotificationMessage { Message = "画像を保存しました", TweetMessage = Tweet.ZeroTweet }); } break; } }
private void SetUpTest(QuoteEntity foundQuote) { _quoteCommand = new QuoteCommand(new FakeRepo { SingleToReturn = foundQuote }); }