Example #1
0
        /// <summary>
        /// Translates Syslog messages to Eventlog messages
        /// Using Pri part as source, and log them to Windows EventLog
        /// </summary>
        /// <param name="endPoint">IP/port number from datagram sender</param>
        /// <param name="strReceived">Syslog message</param>
        private void Log(EndPoint endPoint, string strReceived)
        {
            Pri pri = new Pri(m_regex.Match(strReceived).Groups[1].Value);

            EventLogEntryType eventLogEntryType = Severity2EventLogEntryType(pri.Severity);

            string strMessage = string.Format("{0} : {1}", endPoint, m_regex.Replace(strReceived, evaluator));

            EventLog myLog = new EventLog(m_EventLog);

            myLog.Source = pri.ToString();
            myLog.WriteEntry(strMessage, eventLogEntryType);
            myLog.Close();
            myLog.Dispose();
        }
Example #2
0
		/// <summary>
		/// Translates Syslog messages to Eventlog messages
		/// Using Pri part as source, and log them to Windows EventLog
		/// </summary>
		/// <param name="endPoint">IP/port number from datagram sender</param>
		/// <param name="strReceived">Syslog message</param>
		private void Log(EndPoint endPoint, string strReceived)
		{
			Pri pri = new Pri(m_regex.Match(strReceived).Groups[1].Value);

			EventLogEntryType eventLogEntryType = Severity2EventLogEntryType(pri.Severity);

			string strMessage = string.Format("{0} : {1}", endPoint, m_regex.Replace(strReceived, evaluator));

			EventLog myLog = new EventLog(m_EventLog);
			myLog.Source = pri.ToString();
			myLog.WriteEntry(strMessage, eventLogEntryType);
			myLog.Close();
			myLog.Dispose();
		}
Example #3
0
		/// <summary>
		/// Evaluator is being used to translate every decimal Pri header in
		/// a Syslog message to an 'Facility.Severity ' string.
		/// </summary>
		/// <param name="match">Any Pri header match in a message</param>
		/// <returns>Translated decimal Pri header to 'Facility.Severity '</returns>
		private string evaluator(Match match)
		{
			Pri pri = new Pri(match.Groups[1].Value);

			return pri.ToString()+" ";
		}
Example #4
0
 private void CreateDirectoryStructure(Pri.LongPath.DirectoryInfo directory)
 {
     if (!directory.Parent.Exists)
         CreateDirectoryStructure(directory.Parent);
     directory.Create();
 }
Example #5
0
        /// <summary>
        /// Creates a xml message based on the data in the object. It is used before the message is send to the server.
        /// </summary>
        protected virtual XmlDocument CreateXmlMessage()
        {
            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("NOTIFICATION");

            if (NotificationTypeSpecified)
            {
                root.Attributes.Append(doc.CreateAttribute("ver")).Value = ((int)NotificationType).ToString(CultureInfo.InvariantCulture);
            }

            root.Attributes.Append(doc.CreateAttribute("id")).Value = Id.ToString();
            if (siteId > 0)
            {
                root.Attributes.Append(doc.CreateAttribute("siteid")).Value = SiteId.ToString();
            }
            if (siteUrl.Length > 0)
            {
                root.Attributes.Append(doc.CreateAttribute("siteurl")).Value = SiteUrl;
            }

            XmlElement to = doc.CreateElement("TO");

            if (ReceiverMemberIdLow.Length > 0 && ReceiverMemberIdHigh.Length > 0)
            {
                to.Attributes.Append(doc.CreateAttribute("pid")).Value = ReceiverMemberIdLow.ToString() + ":" + ReceiverMemberIdHigh.ToString();
            }
            if (ReceiverAccount.Length > 0)
            {
                to.Attributes.Append(doc.CreateAttribute("name")).Value = ReceiverAccount;
            }
            if (ReceiverOfflineMail.Length > 0)
            {
                to.Attributes.Append(doc.CreateAttribute("email")).Value = ReceiverOfflineMail;
            }
            if (SendDevice.Length > 0)
            {
                XmlElement via = doc.CreateElement("VIA");
                via.Attributes.Append(doc.CreateAttribute("agent")).Value = SendDevice;
                to.AppendChild(via);
            }
            root.AppendChild(to);

            XmlElement from = doc.CreateElement("FROM");

            if (SenderMemberIdLow.Length > 0 && SenderMemberIdHigh.Length > 0)
            {
                from.Attributes.Append(doc.CreateAttribute("pid")).Value = SenderMemberIdLow.ToString() + ":" + SenderMemberIdHigh.ToString();
            }
            if (SenderAccount.Length > 0)
            {
                from.Attributes.Append(doc.CreateAttribute("name")).Value = SenderAccount;
            }
            root.AppendChild(from);

            XmlElement msg = doc.CreateElement("MSG");

            if (Pri.Length > 0)
            {
                msg.Attributes.Append(doc.CreateAttribute("pri")).Value = Pri.ToString();
            }

            msg.Attributes.Append(doc.CreateAttribute("id")).Value = MessageId.ToString();

            if (ActionUrl.Length > 0)
            {
                XmlElement action = doc.CreateElement("ACTION");
                action.Attributes.Append(doc.CreateAttribute("url")).Value = ActionUrl;
                msg.AppendChild(action);
            }
            if (SubcriptionUrl.Length > 0)
            {
                XmlElement subscr = doc.CreateElement("SUBSCR");
                subscr.Attributes.Append(doc.CreateAttribute("url")).Value = SubcriptionUrl;
                msg.AppendChild(subscr);
            }
            if (CatId.Length > 0)
            {
                XmlElement cat = doc.CreateElement("CAT");
                cat.Attributes.Append(doc.CreateAttribute("id")).Value = CatId.ToString();
                msg.AppendChild(cat);
            }

            XmlElement body = doc.CreateElement("BODY");

            if (Language.Length > 0)
            {
                body.Attributes.Append(doc.CreateAttribute("id")).Value = Language;
            }
            if (IconUrl.Length > 0)
            {
                body.Attributes.Append(doc.CreateAttribute("icon")).Value = IconUrl;
            }
            if (Text.Length > 0)
            {
                XmlElement textEl = doc.CreateElement("TEXT");
                textEl.AppendChild(doc.CreateTextNode(Text));
                body.AppendChild(textEl);
            }

            if (OfflineText.Length > 0)
            {
                XmlElement emailTextEl = doc.CreateElement("EMAILTEXT");
                emailTextEl.AppendChild(doc.CreateTextNode(OfflineText));
                body.AppendChild(emailTextEl);
            }
            msg.AppendChild(body);

            root.AppendChild(msg);

            doc.AppendChild(root);

            return(doc);
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            // call the method to move the from one position to another
            int winer = 0;

            winer = instanceRunning.moveFirst(pictureBox1, timer1);
            if (winer != 1)
            {
                winer = instanceRunning.move2nd(pictureBox2, timer1);
                if (winer != 2)
                {
                    winer = instanceRunning.move3rd(pictureBox3, timer1);
                    if (winer != 3)
                    {
                        winer = instanceRunning.move4th(pictureBox4, timer1);
                    }
                }
            }

            if (winer > 0)
            {
                if (Simran.Checked == true)
                {
                    if (winer == DogSimran.Value)
                    {
                        budgetSimran.Text = "" + Simn.increment(Convert.ToInt32(budgetSimran.Text.ToString()), Convert.ToInt32(BetSimran.Value));

                        //  budgetSimran.Text = "" + instancePlayer.player1(budgetSimran, Convert.ToInt32(BetSimran.Value), Convert.ToInt32(DogSimran.Value), winer);
                    }
                    else
                    {
                        budgetSimran.Text = "" + Simn.decrement(Convert.ToInt32(budgetSimran.Text.ToString()), Convert.ToInt32(BetSimran.Value));
                        //    budgetSimran.Text = "" + instancePlayer.player1(budgetSimran, Convert.ToInt32(BetSimran.Value), Convert.ToInt32(DogSimran.Value), winer);
                    }
                }

                if (Priya.Checked == true)
                {
                    if (winer == BetPriya.Value)
                    {
                        BudgetPriya.Text = "" + Pri.increment(Convert.ToInt32(BudgetPriya.Text.ToString()), Convert.ToInt32(BetPriya.Value));
                    }
                    else
                    {
                        BudgetPriya.Text = "" + Pri.deccrement(Convert.ToInt32(BudgetPriya.Text.ToString()), Convert.ToInt32(BetPriya.Value));
                    }
                    // BudgetPriya.Text = "" + instancePlayer.player2(BudgetPriya, Convert.ToInt32(BetPriya.Value), Convert.ToInt32(DogPriya.Value), winer);
                }

                if (Mannat.Checked == true)
                {
                    if (winer == BetMannat.Value)
                    {
                        budgetMannat.Text = "" + Man.increment(Convert.ToInt32(budgetMannat.Text.ToString()), Convert.ToInt32(BetMannat.Value));
                    }
                    else
                    {
                        budgetMannat.Text = "" + Man.deccrement(Convert.ToInt32(budgetMannat.Text.ToString()), Convert.ToInt32(BetMannat.Value));
                    }
                    //budgetMannat.Text = "" + instancePlayer.player2(budgetMannat, Convert.ToInt32(BetMannat.Value), Convert.ToInt32(DogMannat.Value), winer);
                }

                pictureBox1.Left = 0;
                pictureBox2.Left = 0;
                pictureBox3.Left = 0;
                pictureBox4.Left = 0;

                Simran.Checked = false;
                Priya.Checked  = false;
                Mannat.Checked = false;

                BetMannat.Value = 0;
                BetPriya.Value  = 0;
                BetSimran.Value = 0;

                DogMannat.Value = 0;
                DogPriya.Value  = 0;
                DogSimran.Value = 0;

                chk             = 0;
                btnGo.Visible   = false;
                lblPlayer1.Text = "";
                lblPlayer2.Text = "";
                lblPlayer3.Text = "";
            }
        }
Example #7
0
        /// <summary>
        /// Evaluator is being used to translate every decimal Pri header in
        /// a Syslog message to an 'Facility.Severity ' string.
        /// </summary>
        /// <param name="match">Any Pri header match in a message</param>
        /// <returns>Translated decimal Pri header to 'Facility.Severity '</returns>
        private string evaluator(Match match)
        {
            Pri pri = new Pri(match.Groups[1].Value);

            return(pri.ToString() + " ");
        }