コード例 #1
0
        public SyslogMessage(string hostName, string msg)
        {
            ValidateHost(hostName);
            ValidateMessage(msg);

            _messageTime = DateTime.UtcNow;
            _facility = DefaultFacility;
            _severity = DefaultSeverity;
            _localTime = DateTime.Now;
            _localHost = hostName;
            _message = msg;
        }
コード例 #2
0
		public SyslogMessage(string hostName, string msg, FacilityCode fc,
			SeverityCode sc, DateTime localTime)
		{
			ValidateHost(hostName);
			ValidateMessage(msg);

			_messageTime = DateTime.UtcNow;
			_facility = fc;
			_severity = sc;
			_localTime = localTime;
			_localHost = hostName;
			_message = msg;
		}
コード例 #3
0
        public SyslogMessage(string hostName, string msg, FacilityCode fc,
                             SeverityCode sc, DateTime localTime)
        {
            ValidateHost(hostName);
            ValidateMessage(msg);

            _messageTime = DateTime.UtcNow;
            _facility    = fc;
            _severity    = sc;
            _localTime   = localTime;
            _localHost   = hostName;
            _message     = msg;
        }
コード例 #4
0
 public override int GetHashCode() {
   int hash = 1;
   if (ClientId != 0L) hash ^= ClientId.GetHashCode();
   if (ClientName.Length != 0) hash ^= ClientName.GetHashCode();
   if (FacilityId != 0L) hash ^= FacilityId.GetHashCode();
   if (FacilityCode.Length != 0) hash ^= FacilityCode.GetHashCode();
   if (FacilityName.Length != 0) hash ^= FacilityName.GetHashCode();
   hash ^= data_.GetHashCode();
   if (_unknownFields != null) {
     hash ^= _unknownFields.GetHashCode();
   }
   return hash;
 }
コード例 #5
0
ファイル: Program.cs プロジェクト: thom20m1/HotelRestConsumer
        static void Main(string[] args)
        {
            HotelCode    hotelCode    = new HotelCode();
            GuestCode    guestCode    = new GuestCode("Guests");
            RoomCode     roomCode     = new RoomCode("Rooms");
            BookingCode  bookingCode  = new BookingCode("Bookings");
            FacilityCode facilityCode = new FacilityCode("Facilities");

            hotelCode.DoTheStuff();
            guestCode.DoTheStuff();
            roomCode.DoTheStuff();
            bookingCode.DoTheStuff();
            facilityCode.DoTheStuff();

            KeepConsoleWindowOpen();
        }
コード例 #6
0
ファイル: SyslogMessage.cs プロジェクト: hagenson/SysLogSharp
        /// <summary>
        /// Creates a new instance of the SyslogMessage class.
        /// </summary>
        /// <param name="priority">Specifies the encoded PRI field, containing the facility and severity values.</param>
        /// <param name="timestamp">Specifies the timestamp, if present in the packet.</param>
        /// <param name="hostname">Specifies the hostname, if present in the packet.  The hostname can only be present if the timestamp is also present (RFC3164).</param>
        /// <param name="message">Specifies the textual content of the message.</param>
        public SyslogMessage(int priority, DateTime timestamp, string hostname, string message)
        {
            if (priority > 0)
            {
                // The facility code is the nearest whole number of the priority value divided by 8
                _facility = (FacilityCode)(int)Math.Floor((double)priority / 8);
                // The severity code is the remainder of the priority value divided by 8
                _severity = (SeverityCode) (priority % 8);
            }
            else
            {
                _facility = FacilityCode.None;
                _severity = SeverityCode.None;
            }

            _timestamp = timestamp;
            _hostname = hostname;
            _message = message;
        }
コード例 #7
0
        private static void ParseCode(string code, out FacilityCode fc, out SeverityCode sc)
        {
            int numericCode  = Convert.ToInt32(code);
            int facilityCode = numericCode / 8;
            int severityCode = numericCode % 8;

            if (!Enum.IsDefined(typeof(FacilityCode), facilityCode))
            {
                throw new ArgumentException(String.Format("Invalid facility code {0}", facilityCode),
                                            "code");
            }
            fc = (FacilityCode)facilityCode;

            if (!Enum.IsDefined(typeof(SeverityCode), severityCode))
            {
                throw new ArgumentException(String.Format("Invalid severity code {0}", severityCode),
                                            "code");
            }
            sc = (SeverityCode)severityCode;
        }
コード例 #8
0
ファイル: ErrorInfo.cs プロジェクト: rlefever68/Wulka
        private static int BuildErrorNumber(FacilityCode facilityCode, int errorCode, ErrorType errorType)
        {
            //
            //  Error values are 32 bit values laid out as follows:
            //
            //   3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1
            //   1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
            //  +---+-+-+-----------------------+-------------------------------+
            //  |Sev|C|R|     Facility          |               Code            |
            //  +---+-+-+-----------------------+-------------------------------+
            //
            //  where
            //
            //      Sev - is the severity code
            //
            //          00 - Success
            //          01 - Informational
            //          10 - Warning
            //          11 - Error
            //
            //      C - is the Customer code flag
            //
            //      R - is a reserved bit
            //
            //      Facility - is the facility code
            //
            //      Code - is the facility's status code
            //
            int errorNumber;

            unchecked // use unchecked to suppress overflow checking
            {
                int       isError         = (int)errorType;
                const int isCustomerValue = 0x20000000;
                errorNumber = isError
                              | isCustomerValue
                              | (0x0FFF0000 & ((int)facilityCode << 16))
                              | (0x0000FFFF & errorCode);
            }
            return(errorNumber);
        }
コード例 #9
0
		private static void ParseCode(string code, out FacilityCode fc, out SeverityCode sc)
		{
			int numericCode = Convert.ToInt32(code);
			int facilityCode = numericCode / 8;
			int severityCode = numericCode % 8;

			if (!Enum.IsDefined(typeof(FacilityCode), facilityCode))
				throw new ArgumentException(String.Format("Invalid facility code {0}", facilityCode),
					"code");
			fc = (FacilityCode) facilityCode;

			if (!Enum.IsDefined(typeof(SeverityCode), severityCode))
				throw new ArgumentException(String.Format("Invalid severity code {0}", severityCode),
					"code");
			sc = (SeverityCode) severityCode;
		}
コード例 #10
0
 /// <summary>
 /// Creates facility infos per given facility code.
 /// </summary>
 /// <param name="facilityCode">The facility code.</param>
 /// <returns></returns>
 public static FacilityInfo CreateFacilityInfo(FacilityCode facilityCode)
 {
     return(new FacilityInfo(facilityCode, "Wulka." + facilityCode));
 }
コード例 #11
0
 /// <summary>Creates a new <see cref="NTStatus"/> from provided values.</summary>
 /// <param name="severity">The severity level.</param>
 /// <param name="customerDefined">The bit is set for customer-defined values and clear for Microsoft-defined values.</param>
 /// <param name="facility">The facility.</param>
 /// <param name="code">The code.</param>
 /// <returns>The resulting <see cref="NTStatus"/>.</returns>
 public static NTStatus Make(SeverityLevel severity, bool customerDefined, FacilityCode facility, ushort code) => Make(severity, customerDefined, (ushort)facility, code);
コード例 #12
0
ファイル: HRESULT.cs プロジェクト: kouweizhong/vanara
 /// <summary>Creates a new <see cref="HRESULT"/> from provided values.</summary>
 /// <param name="severe">if set to <c>false</c>, sets the severity bit to 1.</param>
 /// <param name="facility">The facility.</param>
 /// <param name="code">The code.</param>
 /// <returns>The resulting <see cref="HRESULT"/>.</returns>
 public static HRESULT Make(bool severe, FacilityCode facility, uint code) => Make(severe, (uint)facility, code);
コード例 #13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FacilityInfo"/> class.
 /// </summary>
 /// <param name="code">The code.</param>
 /// <param name="name">The name.</param>
 public FacilityInfo(FacilityCode code, string name)
 {
     Code = code;
     Name = name;
 }