Example #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);
            }
        }
Example #2
0
        /// <summary>
        /// Update the application controls data source.
        /// </summary>
        public void UpdateAppControlDataSource(Workspace kws)
        {
            foreach (BaseAppControl ctrl in m_mainForm.AppControlTree.Values)
            {
                KwsApp app = (kws == null) ? null : kws.GetApp(ctrl.ID);

                try
                {
                    ctrl.SetDataSource(app);
                }

                // Handle the error and continue updating the controls source
                // if possible.
                catch (Exception ex)
                {
                    if (app != null) kws.HandleAppFailure(app, ex);
                    else Base.HandleException(ex, true);
                }
            }
        }