Example #1
0
        /// <summary>
        /// Gives the specific condition names which the event server supports for the current event category.
        /// </summary>
        /// <param name="conditionNames">A list with the condition names for the current event category. </param>
        /// <param name="executionOptions">Specifies the modality of execution for quering the condition names.</param>
        /// <returns>The result of quering the condition names.</returns>
        /// <include
        ///  file='TBNC.doc.xml'
        ///  path='//class[@name="AeCategory"]/method[@name="QueryAeConditionNames"]/doc/*'
        /// />
        public virtual int QueryAeConditionNames(
            out string[] conditionNames,
            ExecutionOptions executionOptions)
        {
            int res = (int)EnumResultCode.E_FAIL;

            conditionNames = new string[0];

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

                res = OTBFunctions.OTCQueryAEConditions(
                    this.Session.Handle,
                    m_Id,
                    out count,
                    out pConditionNames,
                    ref options);

                //reset the conditionNameList
                if (m_conditionNameList != null)
                {
                    m_conditionNameList = null;
                }                 //	end if

                if (ResultCode.SUCCEEDED(res))
                {
                    if (options.m_executionType == (byte)EnumExecutionType.SYNCHRONOUS)
                    {
                        conditionNames = new string[count];
                        int ptrSize = Marshal.SizeOf(typeof(IntPtr));
                        for (int i = 0; i < count; i++)
                        {
                            IntPtr conditionName =
                                (IntPtr)Marshal.PtrToStructure(OTBFunctions.GetIntPtrOffset(pConditionNames, i * ptrSize), typeof(IntPtr));
                            conditionNames[i] = Marshal.PtrToStringUni(conditionName);
                            OTBFunctions.OTFreeMemory(conditionName);
                        }                         //	end for
                        //refresh the condition names list
                        m_conditionNameList = conditionNames;

                        OTBFunctions.OTFreeMemory(pConditionNames);
                    }                     //	end if
                }
                else
                {
                    Application.Instance.Trace(
                        EnumTraceLevel.ERR,
                        EnumTraceGroup.CLIENT,
                        "AeCategory.QueryAeConditionNames",
                        " Quering condition names failed! Result: " + res);
                }
            }
            catch (Exception exc)
            {
                Application.Instance.Trace(
                    EnumTraceLevel.ERR,
                    EnumTraceGroup.CLIENT,
                    "AeCategory.QueryAeConditionNames",
                    exc.ToString());
            }
            return(res);
        }