Пример #1
0
        /********************************************************************************/

        private void HandlePayload_StartEventInterval(string payload)
        {
            RequestData.NewEvent newEvent = JsonConvert.DeserializeObject <RequestData.NewEvent>(payload);

            // the event is already active, just need to log this message
            UCEventLog.LogMessage("start event interval: " + newEvent.EventId + "\n" + payload);
        }
Пример #2
0
        /********************************************************************************/

        private void HandlePayload_CancelEvent(string payload)
        {
            RequestData.EndEvent endEvent = JsonConvert.DeserializeObject <RequestData.EndEvent>(payload);

            UCEventList.CancelEvent(endEvent);

            UCEventLog.LogMessage("cancel event: " + endEvent.EventId + "\n" + payload);
        }
Пример #3
0
        /********************************************************************************/

        private void HandlePayload_ModifyEvent(string payload)
        {
            RequestData.NewEvent newEvent = JsonConvert.DeserializeObject <RequestData.NewEvent>(payload);

            UCEventList.ModifyEvent(newEvent);

            UCEventLog.LogMessage("modify event: " + newEvent.EventId + "\n" + payload);
        }
Пример #4
0
        /********************************************************************************/

        private void Form_Closed(object sender, FormClosedEventArgs e)
        {
            try
            {
                m_listener.Stop();
            }
            catch (Exception exception)
            {
                UCEventLog.LogMessage("Form1_Load exception: " + exception.Message);
            }
        }
Пример #5
0
        /********************************************************************************/

        private void Form_Load(object sender, EventArgs e)
        {
            try
            {
                m_listener.Start(new Listener.Listener.RequestHandler(HandleRequest), "8383");
            }
            catch (Exception exception)
            {
                UCEventLog.LogMessage("Form1_Load exception: " + exception.Message);
            }
        }
Пример #6
0
        /********************************************************************************/

        /*
         * Function called by the listener when a call to an endpoint has been made
         */
        private void HandleRequest(Uri uri, string payload)
        {
            // get the endpoint name to access dictionary
            string key = Path.GetFileName(uri.AbsolutePath.TrimEnd('/', '\\'));

            if (m_eventHandlers.Keys.Contains(key))
            {
                // cause the specific handlers to be executed in the GUI thread
                this.BeginInvoke((MethodInvoker) delegate() { m_eventHandlers[key](payload); });
            }
            else
            {
                UCEventLog.LogMessage("unable to handle request; ur no match: " + key);
            }
        }
Пример #7
0
        /********************************************************************************/

        private void btnClearEvents_Click(object sender, EventArgs e)
        {
            string message =
                "{ " +
                "    \"namespace\": \"ven.clearEvents\"," +
                "    \"parameters\": { }" +
                "}";

            string response;

            if (!Http.Request.Post(m_novaUri, message, out response))
            {
                UCEventLog.LogMessage("Error sending message: " + message + ", response: " + response);
            }
            else
            {
                UCEventLog.LogMessage("Successfully sent message: " + message + ", response: " + response);
            }
        }
Пример #8
0
        /********************************************************************************/

        private void settingsToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult result = m_settingsForm.ShowDialog();

                if (result != DialogResult.OK)
                {
                    return;
                }

                m_novaUri = new Uri(m_settingsForm.NovaUri);

                m_listener.Stop();

                m_listener.Start(new Listener.Listener.RequestHandler(HandleRequest), m_settingsForm.ListeningPort);
            }
            catch (Exception exception)
            {
                UCEventLog.LogMessage("Form1_Load exception: " + exception.Message);
            }
        }