示例#1
0
        /// <summary>
        /// Dispatch an ANP event to the appropriate handler.
        /// </summary>
        private KwsAnpEventStatus DispatchAnpEventToHandler(AnpMsg msg)
        {
            // If this event version is not supported, disable the workspace.
            if (msg.Minor > KAnp.Minor)
            {
                RequestTaskSwitch(KwsTask.Stop, new EAnpExUpgradeKwm());
                return(KwsAnpEventStatus.Unprocessed);
            }

            // Dispatch to the appropriate handler.
            try
            {
                UInt32            ns     = KAnp.GetNsFromType(msg.Type);
                KwsAnpEventStatus status = KwsAnpEventStatus.Unprocessed;

                // Non-application-specific event.
                if (ns == KAnp.KANP_NS_KWS)
                {
                    status = m_kws.KcdEventHandler.HandleAnpEvent(msg);
                }

                // Application-specific event.
                else
                {
                    // Trivially process whiteboard events.
                    if (ns == KAnp.KANP_NS_WB)
                    {
                        return(KwsAnpEventStatus.Processed);
                    }

                    // Locate the application.
                    KwsApp app = m_kws.GetApp(ns);
                    if (app == null)
                    {
                        throw new Exception("unknown application of type " + ns);
                    }

                    // Dispatch.
                    status = app.HandleAnpEvent(msg);
                }

                // Throw an exception if we cannot process an event that we
                // should have been able to process.
                if (status == KwsAnpEventStatus.Unprocessed && m_kws.IsOfflineCapable())
                {
                    throw new Exception("failed to process KCD event");
                }

                return(status);
            }

            catch (Exception ex)
            {
                HandleMiscFailure(ex);
                return(KwsAnpEventStatus.Unprocessed);
            }
        }
示例#2
0
        /// <summary>
        /// Update the status of the KAnp event specified.
        /// </summary>
        public void UpdateKAnpEventStatus(UInt64 kwsID, UInt64 msgID, KwsAnpEventStatus status)
        {
            try
            {
                String s = "UPDATE kanp_events SET status = " + (UInt32)status +
                           " WHERE kws_id = " + kwsID + " AND evt_id = " + msgID;
                m_db.ExecNQ(s);
            }

            catch (Exception ex)
            {
                KBase.HandleException(ex, true);
            }
        }
示例#3
0
        /// <summary>
        /// Store the KAnp event specified with the status specified.
        /// </summary>
        public void StoreKAnpEvent(UInt64 kwsID, AnpMsg msg, KwsAnpEventStatus status)
        {
            try
            {
                DbCommand cmd = m_db.GetCmd("INSERT INTO kanp_events (kws_id, evt_id, evt_data, status) VALUES (?, ?, ?, ?);");
                m_db.AddParamToCmd(cmd, kwsID);
                m_db.AddParamToCmd(cmd, msg.ID);
                m_db.AddParamToCmd(cmd, msg.ToByteArray(true));
                m_db.AddParamToCmd(cmd, status);
                cmd.ExecuteNonQuery();
            }

            catch (Exception ex)
            {
                KBase.HandleException(ex, true);
            }
        }
示例#4
0
        /// <summary>
        /// Dispatch an KCD event and update the state as needed.
        /// </summary>
        private void DispatchKcdEvent(AnpMsg msg)
        {
            // Dispatch the event to the appropriate handler.
            KwsAnpEventStatus newStatus = DispatchAnpEventToHandler(msg);

            // For quenching purposes we assume the event was processed.
            WmSm.HandleKcdEventProcessed();

            // If the ANP event has been processed, update its entry in the
            // database and the catch up state as required.
            if (newStatus == KwsAnpEventStatus.Processed)
            {
                if (msg.ID > 0)
                {
                    Debug.Assert(m_ks.NbUnprocessedEvent > 0);
                    m_kws.UpdateKAnpEventStatusInDb(msg.ID, KwsAnpEventStatus.Processed);
                    m_ks.NbUnprocessedEvent--;
                    UpdateKcdEventUpToDateState();
                    m_kws.OnStateChange(WmStateChange.Permanent);
                }
            }
        }
示例#5
0
        /// <summary>
        /// Update the status of the KAnp event specified.
        /// </summary>
        public void UpdateKAnpEventStatus(UInt64 kwsID, UInt64 msgID, KwsAnpEventStatus status)
        {
            try
            {
                String s = "UPDATE kanp_events SET status = " + (UInt32)status +
                           " WHERE kws_id = " + kwsID + " AND evt_id = " + msgID;
                m_db.ExecNQ(s);
            }

            catch (Exception ex)
            {
                KBase.HandleException(ex, true);
            }
        }
示例#6
0
        /// <summary>
        /// Store the KAnp event specified with the status specified.
        /// </summary>
        public void StoreKAnpEvent(UInt64 kwsID, AnpMsg msg, KwsAnpEventStatus status)
        {
            try
            {
                DbCommand cmd = m_db.GetCmd("INSERT INTO kanp_events (kws_id, evt_id, evt_data, status) VALUES (?, ?, ?, ?);");
                m_db.AddParamToCmd(cmd, kwsID);
                m_db.AddParamToCmd(cmd, msg.ID);
                m_db.AddParamToCmd(cmd, msg.ToByteArray(true));
                m_db.AddParamToCmd(cmd, status);
                cmd.ExecuteNonQuery();
            }

            catch (Exception ex)
            {
                KBase.HandleException(ex, true);
            }
        }
示例#7
0
文件: Workspace.cs 项目: tmbx/kwm-ng
 /// <summary>
 /// Update the status of the KAnp event specified in the database.
 /// </summary>
 public void UpdateKAnpEventStatusInDb(UInt64 msgID, KwsAnpEventStatus status)
 {
     Wm.LocalDbBroker.UpdateKAnpEventStatus(InternalID, msgID, status);
 }
示例#8
0
文件: Workspace.cs 项目: tmbx/kwm-ng
        ///////////////////////////////////////////
        // Interface methods for state machines. //
        ///////////////////////////////////////////

        /// <summary>
        /// Store the event specified in the database with the status specified.
        /// </summary>
        public void StoreKAnpEventInDb(AnpMsg msg, KwsAnpEventStatus status)
        {
            Wm.LocalDbBroker.StoreKAnpEvent(InternalID, msg, status);
        }
示例#9
0
文件: Workspace.cs 项目: tmbx/kwm
 /// <summary>
 /// Update the status of the event specified in the database.
 /// </summary>
 public void UpdateEventStatusInDb(UInt64 msgID, KwsAnpEventStatus status)
 {
     m_wm.LocalDbBroker.UpdateKwsEventStatus(InternalID, msgID, status);
 }
示例#10
0
文件: Workspace.cs 项目: tmbx/kwm
 /// <summary>
 /// Store the event specified in the database with the status specified.
 /// </summary>
 public void StoreEventInDb(AnpMsg msg, KwsAnpEventStatus status)
 {
     m_wm.LocalDbBroker.StoreKwsEvent(InternalID, msg, status);
 }