Exemple #1
0
        /// <summary>
        /// This is the method where you have the ability to change the parsed CST
        /// Template object before the translation completes.
        /// </summary>
        /// <param name="template"></param>
        public void Process(CstTemplate template, ILog log)
        {
            foreach (CstToken token in template.Tokens)
            {
                // I put this break here just to save on performance because this sample plugin does nothing.
                break;

                // If the token is a template code token, then do the replacements.
                if ((token.TokenType == CstTokenType.Code) ||
                    (token.TokenType == CstTokenType.ResponseWriteShortcutCode) ||
                    (token.TokenType == CstTokenType.RunAtServerCode))
                {
                    if (template.Language == CstTemplate.LANGUAGE_CSHARP)
                    {
                        token.Text = token.Text.Replace("Response.WriteLine()", "output.writeln(\"\")");
                    }

                    if (template.Language == CstTemplate.LANGUAGE_VBNET)
                    {
                        token.Text = token.Text.Replace("Response.WriteLine", "output.writeln \"\")");
                    }
                }

                log.AddEntry("Ran Special Plugin Conversion.");
            }
        }
        public static ErrorLogEntry LogError(this ILog log, Exception exc, LogContext context = null)
        {
            var ee = new ErrorLogEntry(context, exc);

            log.AddEntry(ee);
            return(ee);
        }
		/// <summary>
		/// This is the method where you have the ability to change the parsed CST 
		/// Template object before the translation completes.
		/// </summary>
		/// <param name="template"></param>
		public void Process(CstTemplate template, ILog log)
		{
			foreach (CstToken token in template.Tokens) 
			{
				// I put this break here just to save on performance because this sample plugin does nothing.
				break;

				// If the token is a template code token, then do the replacements.
				if ((token.TokenType == CstTokenType.Code) ||
					(token.TokenType == CstTokenType.ResponseWriteShortcutCode) ||
					(token.TokenType == CstTokenType.RunAtServerCode)) 
				{
					if (template.Language == CstTemplate.LANGUAGE_CSHARP) 
					{
						token.Text = token.Text.Replace("Response.WriteLine()", "output.writeln(\"\")");
					}

					if (template.Language == CstTemplate.LANGUAGE_VBNET) 
					{
						token.Text = token.Text.Replace("Response.WriteLine", "output.writeln \"\")");
					}
				}

				log.AddEntry("Ran Special Plugin Conversion.");
			}
		}
Exemple #4
0
        public static DbCommandInfoLogEntry LogDbCommand(this ILog log, IDbCommand command, long executionTime, int rowCount)
        {
            var entry = new DbCommandInfoLogEntry(command, executionTime, rowCount);

            log.AddEntry(entry);
            return(entry);
        }
Exemple #5
0
        public static EventLogEntry LogEvent(this ILog log, string category, string eventType, EventSeverity severity, string message, string details = null,
                                             Guid?objectId = null, string objectName = null, int?intParam = null, OperationContext context = null)
        {
            var entry = new EventLogEntry(category, eventType, severity, message, details, objectId, objectName, intParam, context);

            log.AddEntry(entry);
            return(entry);
        }
Exemple #6
0
        public static ErrorLogEntry LogRemoteError(this ILog log, string message, string details, string appName = null,
                                                   string userName = null, DateTime?remoteTime = null, Guid?id = null)
        {
            var entry = new ErrorLogEntry(null, message, details, ErrorKind.Remote, appName, userName, remoteTime);

            if (id != null)
            {
                entry.Id = id.Value;
            }
            log.AddEntry(entry);
            return(entry);
        }
Exemple #7
0
        /// <summary>
        ///  Clean up the leftovers
        /// </summary>
        public override void OnReleased()
        {
            try
            {
                // Make sure we reset the notification sound back to normal, or we might really screw something up
                ChirpPanel cp = ChirpPanel.instance;
                if (cp != null)
                    cp.m_NotificationSound = null;

                // Make sure the Irc client is really gone so it releases the Irc port
                if (IrcClient != null)
                    IrcClient.Dispose();

                IrcClient = null;
            }
            catch (Exception ex)
            {
                Logger.AddEntry(ex);
            }
        }
        /// <summary>
        /// On timer we're going to check the message queue and post one of the messages
        /// </summary>
        private void _messageTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (IsPaused)
            {
                return;
            }

            try
            {
                ReflectionHelper.SetPrivateVariable <bool>(MessageManager.instance, "m_canShowMessage", true);

                if (_messageQueue.Count == 0)
                {
                    return;
                }

                // First order by priority. Then by @Name mentions UNLESS they've disabled it, then by send date
                KeyValuePair <MessagePriority, TwitchIrcMessage> messagePair = _messageQueue.OrderBy(x => x.Key).ThenByDescending(x => x.Value.IsIrcUserMentioned || !Configuration.ConfigurationSettings.PrioritizePersonallyAddressedMessages).ThenBy(x => x.Value.QueueTime).FirstOrDefault();

                if (messagePair.Equals(default(KeyValuePair <MessagePriority, TwitchIrcMessage>)))
                {
                    return;
                }

                // This is where we check for filters. If the person doesn't want to see certain messages, cut them off here
                if (!Configuration.ConfigurationSettings.ShowGeneralChatMessages && messagePair.Key == MessagePriority.GeneralChat)
                {
                    _messageQueue.Remove(messagePair);
                    if (_messageQueue.Count > 0)
                    {
                        _messageTimer_Elapsed(null, null);
                    }
                    return;
                }
                if (!Configuration.ConfigurationSettings.ShowSubscriberChatMessages && messagePair.Key == MessagePriority.Subscriber)
                {
                    _messageQueue.Remove(messagePair);
                    if (_messageQueue.Count > 0)
                    {
                        _messageTimer_Elapsed(null, null);
                    }
                    return;
                }
                if (!Configuration.ConfigurationSettings.ShowModeratorChatMessages && messagePair.Key == MessagePriority.Moderator)
                {
                    _messageQueue.Remove(messagePair);
                    if (_messageQueue.Count > 0)
                    {
                        _messageTimer_Elapsed(null, null);
                    }
                    return;
                }

                // If it doesn't have a CitizenId, get one
                if (!messagePair.Value.IsCitizenIdSet)
                {
                    messagePair.Value.CitizenId = ChirperExtension.GetCitizenId(messagePair.Value.CitizenName);
                }

                if (messagePair.Value.CitizenId != 0u)
                {
                    // We don't need to stinkin' countdown timer. I want to use my own, but I'm going to leave the delta timer alone
                    // just in case someone wants to post their own messages and expect a reasonable timer countdown
                    ReflectionHelper.SetPrivateVariable <bool>(MessageManager.instance, "m_canShowMessage", true);
                    MessageManager.instance.QueueMessage(new Message(messagePair.Value.CitizenName,
                                                                     messagePair.Value.Message, "", messagePair.Value.CitizenId));
                }

                _messageQueue.Remove(messagePair);

                // Clear out general chat if there's too many messages
                if (_messageQueue.Count > Configuration.ConfigurationSettings.MaximumGeneralChatMessageQueue)
                {
                    _messageQueue.RemoveAll(x => x.Key == MessagePriority.GeneralChat);
                }

                // Still too many messages, get rid of sub chat
                if (_messageQueue.Count > Configuration.ConfigurationSettings.MaximumSubscriberChatMessageQueue)
                {
                    _messageQueue.RemoveAll(x => x.Key == MessagePriority.Subscriber);
                }

                // Still too many messages, get rid of mod chat
                if (_messageQueue.Count > Configuration.ConfigurationSettings.MaximumModeratorChatMessageQueue)
                {
                    _messageQueue.RemoveAll(x => x.Key == MessagePriority.Moderator);
                }
            }
            catch (Exception ex)
            {
                _log.AddEntry(ex);
            }
        }
Exemple #9
0
        private void IncludeFiles()
        {
            log.AddEntry("Searching for included files...");

            Regex ex = new Regex(REGEXP_INCLUDE, (RegexOptions.Multiline | RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture));

            int    currentStartIndex = 0;
            string filename          = string.Empty,
                   filetext          = string.Empty;

            while (currentStartIndex >= 0)
            {
                Match match = ex.Match(cstText, currentStartIndex);

                if (match.Success)
                {
                    log.AddEntry("--> Found match: {0}", match.Value.ToString());

                    filename = PullCapturedAttribute(match, "file");
                    log.AddEntry("--> Including file: {0}", filename);

                    filename = Path.Combine(cstFileInfo.DirectoryName, filename);

                    LoadFileText(filename, ref filetext);

                    cstText = cstText.Remove(match.Index, match.Length);
                    cstText = cstText.Insert(match.Index, filetext);

                    currentStartIndex = match.Index + filetext.Length;
                }
                else
                {
                    currentStartIndex = -1;
                }
            }
        }
Exemple #10
0
        public static void WriteMessage(this ILog log, string message, params object[] args)
        {
            var msg = Util.SafeFormat(message, args);

            log.AddEntry(new InfoLogEntry(LogContext.SystemLogContext, msg, null));
        }
Exemple #11
0
 public static void LogError(this ILog log, string message)
 {
     log.AddEntry(new ErrorLogEntry(LogContext.SystemLogContext, message, null));
 }
Exemple #12
0
        /// <summary>
        /// Hier spielt der Gewinner vom Winning Bracket (winner) gegen den Gewinner vom Loserbracket (loser)
        /// Der Gewinner hat dabei zwei Versuche, wenn er beim ersten mal verliert hat er noch eine Chance da man nur bei zwei Niederlagen rausfliegt
        /// </summary>
        /// <param name="winner"></param>
        /// <param name="loser"></param>
        private void PlayFinale(Player winner, Player loser)
        {
            Console.WriteLine(ShowFinale());
            Console.WriteLine("Who is the Winner?");
            Console.WriteLine(winner.ToString() + " Or " + loser.ToString());
            bool correctPlayerInput = false;

            while (!correctPlayerInput)
            {
                string whoWonInput = Console.ReadLine();
                if (whoWonInput == winner.PlayerName.Title || whoWonInput == winner.PlayerID.ToString())
                {
                    Console.WriteLine("You Choose: " + winner.ToString());
                    Console.WriteLine("Winner of the Tournament: " + winner.ToString());
                    log.AddEntry("Winner: " + winner.ToString());
                    var match = new TournamentBracketLogRoundMatch(winner.ToString(), loser.ToString(), whoWonInput == winner.PlayerName.Title || whoWonInput == winner.PlayerID.ToString());
                    TournamentDoubleKoLog.FinalMatches.Add(match);
                    break;
                }
                else if (whoWonInput == loser.PlayerName.Title || whoWonInput == loser.PlayerID.ToString())
                {
                    var match = new TournamentBracketLogRoundMatch(winner.ToString(), loser.ToString(), whoWonInput == winner.PlayerName.Title || whoWonInput == winner.PlayerID.ToString());
                    TournamentDoubleKoLog.FinalMatches.Add(match);
                    Console.WriteLine("You Choose: " + loser.ToString());
                    Console.WriteLine("Second Chance!");
                    Console.WriteLine("Who is the Winner?");
                    Console.WriteLine(winner.ToString() + " Or " + loser.ToString());
                    while (!correctPlayerInput)
                    {
                        string WhoWonTournament = Console.ReadLine();
                        if (WhoWonTournament == winner.PlayerName.Title || WhoWonTournament == winner.PlayerID.ToString())
                        {
                            Console.WriteLine("You Choose: " + winner.ToString());
                            Console.WriteLine("Winner of the Tournament: " + winner.ToString());
                            log.AddEntry("Winner: " + winner.ToString());
                            correctPlayerInput = true;
                        }
                        else if (WhoWonTournament == loser.PlayerName.Title || WhoWonTournament == loser.PlayerID.ToString())
                        {
                            Console.WriteLine("You Choose: " + loser.ToString());
                            Console.WriteLine("Winner of the Tournament: " + loser.ToString());
                            log.AddEntry("Winner: " + loser.ToString());
                            correctPlayerInput = true;
                        }
                        if (correctPlayerInput)
                        {
                            var secondFinal = new TournamentBracketLogRoundMatch(winner.ToString(), loser.ToString(), WhoWonTournament == winner.PlayerName.Title || WhoWonTournament == winner.PlayerID.ToString());
                            TournamentDoubleKoLog.FinalMatches.Add(secondFinal);
                        }
                        else
                        {
                            Console.WriteLine("Wrong Input! Try Again.");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Wrong Input! Try Again.");
                }
                Console.WriteLine();
            }
        }
Exemple #13
0
        public void StartElimination()
        {
            Console.WriteLine(CreateTree(Players));
            Console.WriteLine("Elimination starts!");
            int round = 1;

            while (Players.Count != 1)
            {
                Console.WriteLine("Next Round!");
                var           tournamentBracketLogRound = new TournamentBracketLogRound(round);
                List <Player> losers = new List <Player>();
                for (int i = 0; i < Players.Count - 1; i += 2)
                {
                    if (Players[i].PlayerID.Id == 0 || Players[i + 1].PlayerID.Id == 0) // prüfen ob im Match eine Wildcard vorhanden ist
                    {
                        if (Players[i].PlayerID.Id == 0)
                        {
                            losers.Add(Players[i]);
                            tournamentBracketLogRound.AddMatch(Players[i].ToString(), Players[i + 1].ToString(), false);
                        }
                        else
                        {
                            losers.Add(Players[i + 1]);
                            tournamentBracketLogRound.AddMatch(Players[i].ToString(), Players[i + 1].ToString(), true);
                        }
                    }
                    else
                    {
                        Console.WriteLine("Who is the Winner? Name or ID");
                        Console.WriteLine(Players[i].ToString() + " Or " + Players[i + 1].ToString());
                        bool correctPlayerInput = false;
                        while (!correctPlayerInput)
                        {
                            string whoWonInput = Console.ReadLine();
                            if (whoWonInput == Players[i].PlayerName.Title || whoWonInput == Players[i].PlayerID.ToString())
                            {
                                Console.WriteLine("You Choose: " + Players[i].ToString());
                                losers.Add(Players[i + 1]);
                                correctPlayerInput = true;
                            }
                            else if (whoWonInput == Players[i + 1].PlayerName.Title || whoWonInput == Players[i + 1].PlayerID.ToString())
                            {
                                Console.WriteLine("You Choose: " + Players[i + 1].ToString());
                                losers.Add(Players[i]);
                                correctPlayerInput = true;
                            }
                            else
                            {
                                Console.WriteLine("Wrong Input! Try Again.");
                            }
                            if (correctPlayerInput)
                            {
                                tournamentBracketLogRound.AddMatch(Players[i].ToString(), Players[i + 1].ToString(), whoWonInput == Players[i].PlayerName.Title || whoWonInput == Players[i].PlayerID.ToString());
                            }
                            Console.WriteLine();
                        }
                    }
                }

                EliminateLosingPlayers(losers);
                round++;
                TournamentBracketLog.Rounds.Add(tournamentBracketLogRound);

                if (Players.Count != 1)
                {
                    Console.Clear();
                    Console.WriteLine(CreateTree(Players));
                }
            }
            Console.Clear();
            Console.WriteLine("Winner of the Tournament: " + Players[0].ToString());
            log.AddEntry("Winner: " + Players[0].ToString());
            CreateLogOfTournament(log);
        }