Beispiel #1
0
        VmAfdGetHeartbeatStatus()
        {
            string siteName = string.Empty;
            IntPtr pStatus  = IntPtr.Zero;
            VMAFD_HEARTBEAT_STATUS result = new VMAFD_HEARTBEAT_STATUS();

            try
            {
                UInt32 error = Adaptor.VmAfdGetHeartbeatStatusA(
                    this.session.ServerContext,
                    out pStatus);
                if (error != 0)
                {
                    throw new VmAfdException(error);
                }

                result = MarshalHeartbeatStatus(pStatus);
            }
            finally
            {
                if (pStatus != IntPtr.Zero)
                {
                    Adaptor.VmAfdFreeHeartbeatStatusA(pStatus);
                }
            }

            return(result);
        }
Beispiel #2
0
        private static VMAFD_HEARTBEAT_STATUS MarshalHeartbeatStatus(IntPtr pStatus)
        {
            VMAFD_HB_STATUS        status;
            VMAFD_HEARTBEAT_STATUS result = new VMAFD_HEARTBEAT_STATUS();

            status = (VMAFD_HB_STATUS)Marshal.PtrToStructure(
                pStatus,
                typeof(VMAFD_HB_STATUS));
            result.dwCount  = status.dwCount;
            result.bIsAlive = status.bIsAlive;
            if (result.dwCount > 0)
            {
                result.info = new List <VMAFD_HB_INFO>();
            }
            for (int i = 0; i < status.dwCount; ++i)
            {
                var    sizeOfStruct = Marshal.SizeOf(typeof(VMAFD_HB_INFO));
                IntPtr pStatusEntry = (IntPtr)(
                    (long)status.pHeartbeatInfoArr +
                    i * sizeOfStruct);
                var infoEntry = (VMAFD_HB_INFO)Marshal.PtrToStructure(
                    pStatusEntry,
                    typeof(VMAFD_HB_INFO));
                result.info.Add(infoEntry);
            }
            return(result);
        }
Beispiel #3
0
        public void CdcGetDCStatus(
            string pwszDCName,
            string pwszDomainName,
            out CDC_DC_STATUS_INFO dcStatus,
            out VMAFD_HEARTBEAT_STATUS hbStatus
            )
        {
            string siteName       = string.Empty;
            IntPtr dcNativeStatus = IntPtr.Zero;
            IntPtr hbHbStatus     = IntPtr.Zero;

            try
            {
                UInt32 error = Adaptor.CdcGetDCStatusInfoA(
                    this.session.ServerContext,
                    pwszDCName,
                    pwszDomainName,
                    out dcNativeStatus,
                    out hbHbStatus);
                if (error != 0)
                {
                    throw new VmAfdException(error);
                }

                dcStatus = MarshalCdcDcStatusInfo(dcNativeStatus);
                hbStatus = MarshalHeartbeatStatus(hbHbStatus);
            }
            finally
            {
                if (dcNativeStatus != IntPtr.Zero)
                {
                    Adaptor.CdcFreeDCStatusInfoA(dcNativeStatus);
                }

                if (hbHbStatus != IntPtr.Zero)
                {
                    Adaptor.VmAfdFreeHeartbeatStatusA(hbHbStatus);
                }
            }
        }