コード例 #1
0
        /// <summary>
        /// Removes the connection to a server.
        /// </summary>
        /// <param name="executionOptions">Specifies the modality of execution for disconnecting from a server.</param>
        /// <returns>The result of disconnecting from a server.</returns>
        /// <include
        ///  file='TBNC.doc.xml'
        ///  path='//class[@name="ObjectSpaceElement"]/method[@name="Disconnect"]/doc/*'
        /// />
        public virtual int Disconnect(ExecutionOptions executionOptions)
        {
            int res = (int)EnumResultCode.E_FAIL;

            try
            {
                OTCExecutionOptions options = new OTCExecutionOptions();

                if (executionOptions != null)
                {
                    options.m_executionType    = (byte)executionOptions.ExecutionType;
                    options.m_executionContext = (uint)executionOptions.ExecutionContext;
                }
                else
                {
                    options.m_executionType    = (byte)EnumExecutionType.SYNCHRONOUS;
                    options.m_executionContext = 0;
                }

                EnumObjectState m_targetState = EnumObjectState.DISCONNECTED;
                OTBFunctions.OTCChangeTargetState(this.Handle, (byte)m_targetState, 1);
                res = OTBFunctions.OTCPerformStateTransition(this.Handle, 1, ref options);
            }
            catch (Exception exc)
            {
                Application.Instance.Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.CLIENT,
                    "ObjectSpaceElement.Disconnect",
                    exc.ToString());
            }
            return(res);
        }
コード例 #2
0
        //-
        #endregion

        /// <summary>
        /// Performs the transition from the current state to the target state.
        /// </summary>
        /// <param name="deep">Indicates if changing the target state should be propagated down to the child objects or not.</param>
        /// <param name="executionOptions">Specifies the modality of execution for state transition.</param>
        /// <returns>The result of performing the state transition.</returns>
        /// <include
        ///  file='TBNC.doc.xml'
        ///  path='//class[@name="ObjectSpaceElement"]/method[@name="PerformStateTransition"]/doc/*'
        /// />
        public virtual int PerformStateTransition(bool deep, ExecutionOptions executionOptions)
        {
            int res = (int)EnumResultCode.E_FAIL;

            try
            {
                OTCExecutionOptions options = new OTCExecutionOptions();

                if (executionOptions != null)
                {
                    options.m_executionType    = (byte)executionOptions.ExecutionType;
                    options.m_executionContext = (uint)executionOptions.ExecutionContext;
                }
                else
                {
                    options.m_executionType    = (byte)EnumExecutionType.SYNCHRONOUS;
                    options.m_executionContext = 0;
                }

                if (deep == false)
                {
                    // performs the state transition for the object itself
                    res = OTBFunctions.OTCPerformStateTransition(this.Handle, 0, ref options);
                }
                if (deep == true)
                {
                    // performs the state transition for the whole subtree of the object
                    res = OTBFunctions.OTCPerformStateTransition(this.Handle, 1, ref options);
                }
            }
            catch (Exception exc)
            {
                Application.Instance.Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.CLIENT,
                    "ObjectSpaceElement.PerformStateTransition",
                    exc.ToString());
            }
            return(res);
        }