예제 #1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="packet">The switch packet.</param>
        internal SwitchEventReceivedArgs(SwitchPacket packet)
        {
            ArgCollection properties;
            ArgCollection variables;
            string        eventName;

            this.TimeUtc = packet.Headers.Get("Event-Date-GMT", DateTime.MinValue);

            if (packet.Headers.TryGetValue("Event-Name", out eventName))
            {
                this.EventName = eventName;
                this.EventCode = SwitchHelper.ParseEventCode(eventName);
            }
            else
            {
                // I don't think this should ever happen.

                SysLog.LogWarning("SwitchConnection received an event without an [Event-Name] property.");

                this.EventName = string.Empty;
                this.EventCode = default(SwitchEventCode);
            }

            SwitchHelper.ProcessEventProperties(packet.Headers, out properties, out variables);

            this.Properties  = properties;
            this.Variables   = variables;
            this.ContentType = packet.ContentType;
            this.Content     = packet.Content;
            this.ContentText = packet.ContentText;
        }
예제 #2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="packet">The received switch packet.</param>
        internal CommandDisposition(SwitchPacket packet)
        {
            ArgCollection properties;
            ArgCollection variables;

            SwitchHelper.ProcessEventProperties(packet.Headers, out properties, out variables);

            this.Properties = properties;
            this.Variables  = variables;

            switch (packet.PacketType)
            {
            case SwitchPacketType.ExecuteAck:

                this.Success      = packet.ExecuteAccepted;
                this.ResponseText = Properties.Get("Reply-Text", string.Empty);
                this.JobID        = Properties.Get("Job-UUID", Guid.Empty);
                break;

            case SwitchPacketType.ExecuteResponse:

                this.Success      = true;
                this.ResponseText = packet.ContentText;
                break;

            default:

                Assertion.Fail("Unexpected packet type.");
                break;
            }
        }
예제 #3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="packet">The switch packet holding the job completion event.</param>
        internal SwitchLogEntryReceivedArgs(SwitchPacket packet)
        {
            ArgCollection properties;
            ArgCollection variables;

            SwitchHelper.ProcessEventProperties(packet.Headers, out properties, out variables);

            this.Properties  = properties;
            this.Variables   = variables;
            this.MessageText = packet.ContentText;
        }
예제 #4
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="packet">The switch packet holding the job completion event.</param>
        internal SwitchJobCompletedArgs(SwitchPacket packet)
        {
            ArgCollection properties;
            ArgCollection variables;
            string        value;
            Guid          jobID;

            Assertion.Test(packet.EventCode == SwitchEventCode.BackgroundJob);

            if (packet.Headers.TryGetValue("Job-UUID", out value) && Guid.TryParse(value, out jobID))
            {
                this.JobID = jobID;
            }

            SwitchHelper.ProcessEventProperties(packet.Headers, out properties, out variables);

            this.Properties = properties;
            this.Variables  = variables;
            this.ReplyText  = packet.ContentText;
        }