private static SafeHResource GetResourceFromEnumeration(SafeHCluster hCluster, SafeHClusEnum hEnum, uint index)
        {
            uint num;
            uint lpcchName = 0;
            uint num3 = SafeNativeMethods.ClusterEnum(hEnum, index, out num, null, ref lpcchName);
            switch (num3)
            {
                case 0x103:
                    return null;

                case 0:
                case 0xea:
                {
                    StringBuilder lpszName = new StringBuilder((int) (++lpcchName));
                    num3 = SafeNativeMethods.ClusterEnum(hEnum, index, out num, lpszName, ref lpcchName);
                    if (num3 == 0)
                    {
                        string str = lpszName.ToString();
                        if (DebugTrace.Verbose)
                        {
                            DebugTrace.Trace(TraceLevel.Verbose, "Opening cluster resource {0}", str);
                        }
                        SafeHResource resource = SafeNativeMethods.OpenClusterResource(hCluster, str);
                        if (resource.IsInvalid)
                        {
                            int num4 = Marshal.GetLastWin32Error();
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationProviderException(Microsoft.Transactions.SR.GetString("OpenClusterResourceFailed", new object[] { num4 })));
                        }
                        return resource;
                    }
                    break;
                }
            }
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationProviderException(Microsoft.Transactions.SR.GetString("ClusterEnumFailed", new object[] { num3 })));
        }
Ejemplo n.º 2
0
        public static SafeHResource GetTransactionManagerClusterResource(string virtualServerName, string transactionManagerResourceType)
        {
            if (DebugTrace.Info)
            {
                DebugTrace.Trace(TraceLevel.Info, "Looking for cluster resource of type {0} dependent on network name {1}", transactionManagerResourceType, virtualServerName);
            }
            SafeHCluster hCluster = SafeNativeMethods.OpenCluster(null);

            if (hCluster.IsInvalid)
            {
                int num = Marshal.GetLastWin32Error();
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationProviderException(Microsoft.Transactions.SR.GetString("OpenClusterFailed", new object[] { num })));
            }
            using (hCluster)
            {
                SafeHClusEnum hEnum = SafeNativeMethods.ClusterOpenEnum(hCluster, ClusterEnum.Resource);
                if (hEnum.IsInvalid)
                {
                    int num2 = Marshal.GetLastWin32Error();
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationProviderException(Microsoft.Transactions.SR.GetString("ClusterOpenEnumFailed", new object[] { num2 })));
                }
                using (hEnum)
                {
                    uint index = 0;
                    while (true)
                    {
                        SafeHResource hResource = GetResourceFromEnumeration(hCluster, hEnum, index);
                        if (hResource == null)
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationProviderException(Microsoft.Transactions.SR.GetString("ClusterResourceNotFound", new object[] { virtualServerName })));
                        }
                        try
                        {
                            if (IsTransactionManager(hResource, virtualServerName, transactionManagerResourceType))
                            {
                                return(hResource);
                            }
                        }
                        catch
                        {
                            hResource.Dispose();
                            throw;
                        }
                        index++;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private static SafeHResource GetResourceFromEnumeration(SafeHCluster hCluster, SafeHClusEnum hEnum, uint index)
        {
            uint num;
            uint lpcchName = 0;
            uint num3      = SafeNativeMethods.ClusterEnum(hEnum, index, out num, null, ref lpcchName);

            switch (num3)
            {
            case 0x103:
                return(null);

            case 0:
            case 0xea:
            {
                StringBuilder lpszName = new StringBuilder((int)(++lpcchName));
                num3 = SafeNativeMethods.ClusterEnum(hEnum, index, out num, lpszName, ref lpcchName);
                if (num3 == 0)
                {
                    string str = lpszName.ToString();
                    if (DebugTrace.Verbose)
                    {
                        DebugTrace.Trace(TraceLevel.Verbose, "Opening cluster resource {0}", str);
                    }
                    SafeHResource resource = SafeNativeMethods.OpenClusterResource(hCluster, str);
                    if (resource.IsInvalid)
                    {
                        int num4 = Marshal.GetLastWin32Error();
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationProviderException(Microsoft.Transactions.SR.GetString("OpenClusterResourceFailed", new object[] { num4 })));
                    }
                    return(resource);
                }
                break;
            }
            }
            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ConfigurationProviderException(Microsoft.Transactions.SR.GetString("ClusterEnumFailed", new object[] { num3 })));
        }
Ejemplo n.º 4
0
 public static extern SafeHResource OpenClusterResource([In] SafeHCluster hCluster, [In, MarshalAs(UnmanagedType.LPWStr)] string lpszResourceName);
Ejemplo n.º 5
0
 public static extern SafeHClusEnum ClusterOpenEnum([In] SafeHCluster hCluster, [In] Microsoft.Transactions.Wsat.Clusters.ClusterEnum dwType);