示例#1
0
        /// <summary>
        /// Gives the sub-condition names which are associated with a specified condition name.
        /// The condition must be supported by the event server for the current category.
        /// </summary>
        /// <param name="conditionName">A condition name, as returned by the <see cref="QueryAeConditionNames"/> method.</param>
        /// <param name="subConditionNames">A list with the sub-condition names associated with the specified condition.</param>
        /// <param name="executionOptions">Specifies the modality of execution for quering the sub-condition names.</param>
        /// <returns>The result of quering the sub-condition names.</returns>
        /// <include
        ///  file='TBNC.doc.xml'
        ///  path='//class[@name="AeCategory"]/method[@name="QueryAeSubConditionNames"]/doc/*'
        /// />
        public virtual int QueryAeSubConditionNames(
            string conditionName,
            out string[] subConditionNames,
            ExecutionOptions executionOptions)
        {
            int res = (int)EnumResultCode.E_FAIL;

            subConditionNames = new string[0];

            if (this.Session == null)
            {
                Application.Instance.Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.CLIENT,
                    "AeCategory.QueryAeSubConditionNames",
                    "The Session property of the Category cannot be null! Set the property to a value before calling QueryAeSubConditionNames!");
                return(res);
            }
            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;
                }

                uint   count = 0;
                IntPtr pSubConditionNames = IntPtr.Zero;

                res = OTBFunctions.OTCQueryAESubConditions(
                    this.Session.Handle,
                    conditionName,
                    out count,
                    out pSubConditionNames,
                    ref options);

                if (ResultCode.SUCCEEDED(res))
                {
                    if (options.m_executionType == (byte)EnumExecutionType.SYNCHRONOUS)
                    {
                        subConditionNames = new string[count];
                        int ptrSize = Marshal.SizeOf(typeof(IntPtr));
                        for (int i = 0; i < count; i++)
                        {
                            IntPtr subConditionName =
                                (IntPtr)Marshal.PtrToStructure(OTBFunctions.GetIntPtrOffset(pSubConditionNames, i * ptrSize), typeof(IntPtr));
                            subConditionNames[i] = Marshal.PtrToStringUni(subConditionName);
                            OTBFunctions.OTFreeMemory(subConditionName);
                        }                 //	end for
                        OTBFunctions.OTFreeMemory(pSubConditionNames);
                    }                     //	end if
                }
                else
                {
                    Application.Instance.Trace(
                        EnumTraceLevel.ERR,
                        EnumTraceGroup.CLIENT,
                        "AeCategory.QueryAeSubConditionNames",
                        " Quering sub condition names failed! Result: " + res);
                }
            }
            catch (Exception exc)
            {
                Application.Instance.Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.CLIENT,
                    "AeCategory.QueryAeSubConditionNames",
                    exc.ToString());
            }
            return(res);
        }