Esempio n. 1
0
        internal static SyncFromAllServersOperationException CreateSyncAllException(IntPtr errorInfo, bool singleError)
        {
            if (errorInfo == IntPtr.Zero)
            {
                return(new SyncFromAllServersOperationException());
            }
            if (singleError)
            {
                DS_REPSYNCALL_ERRINFO structure = new DS_REPSYNCALL_ERRINFO();
                Marshal.PtrToStructure(errorInfo, structure);
                string errorMessage = GetErrorMessage(structure.dwWin32Err, false);
                string sourceServer = Marshal.PtrToStringUni(structure.pszSrcId);
                string targetServer = Marshal.PtrToStringUni(structure.pszSvrId);
                if (structure.dwWin32Err == ERROR_CANCELLED)
                {
                    return(null);
                }
                SyncFromAllServersErrorInformation information = new SyncFromAllServersErrorInformation(structure.error, structure.dwWin32Err, errorMessage, sourceServer, targetServer);
                return(new SyncFromAllServersOperationException(Res.GetString("DSSyncAllFailure"), null, new SyncFromAllServersErrorInformation[] { information }));
            }
            IntPtr    ptr  = Marshal.ReadIntPtr(errorInfo);
            ArrayList list = new ArrayList();
            int       num  = 0;

            while (ptr != IntPtr.Zero)
            {
                DS_REPSYNCALL_ERRINFO ds_repsyncall_errinfo2 = new DS_REPSYNCALL_ERRINFO();
                Marshal.PtrToStructure(ptr, ds_repsyncall_errinfo2);
                if (ds_repsyncall_errinfo2.dwWin32Err != ERROR_CANCELLED)
                {
                    string str4 = GetErrorMessage(ds_repsyncall_errinfo2.dwWin32Err, false);
                    string str5 = Marshal.PtrToStringUni(ds_repsyncall_errinfo2.pszSrcId);
                    string str6 = Marshal.PtrToStringUni(ds_repsyncall_errinfo2.pszSvrId);
                    SyncFromAllServersErrorInformation information2 = new SyncFromAllServersErrorInformation(ds_repsyncall_errinfo2.error, ds_repsyncall_errinfo2.dwWin32Err, str4, str5, str6);
                    list.Add(information2);
                }
                num++;
                ptr = Marshal.ReadIntPtr(errorInfo, num * Marshal.SizeOf(typeof(IntPtr)));
            }
            if (list.Count == 0)
            {
                return(null);
            }
            SyncFromAllServersErrorInformation[] errors = new SyncFromAllServersErrorInformation[list.Count];
            for (int i = 0; i < list.Count; i++)
            {
                SyncFromAllServersErrorInformation information3 = (SyncFromAllServersErrorInformation)list[i];
                errors[i] = new SyncFromAllServersErrorInformation(information3.ErrorCategory, information3.ErrorCode, information3.ErrorMessage, information3.SourceServer, information3.TargetServer);
            }
            return(new SyncFromAllServersOperationException(Res.GetString("DSSyncAllFailure"), null, errors));
        }
 internal static SyncFromAllServersOperationException CreateSyncAllException(IntPtr errorInfo, bool singleError)
 {
     if (errorInfo == IntPtr.Zero)
     {
         return new SyncFromAllServersOperationException();
     }
     if (singleError)
     {
         DS_REPSYNCALL_ERRINFO structure = new DS_REPSYNCALL_ERRINFO();
         Marshal.PtrToStructure(errorInfo, structure);
         string errorMessage = GetErrorMessage(structure.dwWin32Err, false);
         string sourceServer = Marshal.PtrToStringUni(structure.pszSrcId);
         string targetServer = Marshal.PtrToStringUni(structure.pszSvrId);
         if (structure.dwWin32Err == ERROR_CANCELLED)
         {
             return null;
         }
         SyncFromAllServersErrorInformation information = new SyncFromAllServersErrorInformation(structure.error, structure.dwWin32Err, errorMessage, sourceServer, targetServer);
         return new SyncFromAllServersOperationException(Res.GetString("DSSyncAllFailure"), null, new SyncFromAllServersErrorInformation[] { information });
     }
     IntPtr ptr = Marshal.ReadIntPtr(errorInfo);
     ArrayList list = new ArrayList();
     int num = 0;
     while (ptr != IntPtr.Zero)
     {
         DS_REPSYNCALL_ERRINFO ds_repsyncall_errinfo2 = new DS_REPSYNCALL_ERRINFO();
         Marshal.PtrToStructure(ptr, ds_repsyncall_errinfo2);
         if (ds_repsyncall_errinfo2.dwWin32Err != ERROR_CANCELLED)
         {
             string str4 = GetErrorMessage(ds_repsyncall_errinfo2.dwWin32Err, false);
             string str5 = Marshal.PtrToStringUni(ds_repsyncall_errinfo2.pszSrcId);
             string str6 = Marshal.PtrToStringUni(ds_repsyncall_errinfo2.pszSvrId);
             SyncFromAllServersErrorInformation information2 = new SyncFromAllServersErrorInformation(ds_repsyncall_errinfo2.error, ds_repsyncall_errinfo2.dwWin32Err, str4, str5, str6);
             list.Add(information2);
         }
         num++;
         ptr = Marshal.ReadIntPtr(errorInfo, num * Marshal.SizeOf(typeof(IntPtr)));
     }
     if (list.Count == 0)
     {
         return null;
     }
     SyncFromAllServersErrorInformation[] errors = new SyncFromAllServersErrorInformation[list.Count];
     for (int i = 0; i < list.Count; i++)
     {
         SyncFromAllServersErrorInformation information3 = (SyncFromAllServersErrorInformation) list[i];
         errors[i] = new SyncFromAllServersErrorInformation(information3.ErrorCategory, information3.ErrorCode, information3.ErrorMessage, information3.SourceServer, information3.TargetServer);
     }
     return new SyncFromAllServersOperationException(Res.GetString("DSSyncAllFailure"), null, errors);
 }
Esempio n. 3
0
        internal static SyncFromAllServersOperationException?CreateSyncAllException(IntPtr errorInfo, bool singleError)
        {
            if (errorInfo == (IntPtr)0)
            {
                return(new SyncFromAllServersOperationException());
            }

            if (singleError)
            {
                // single error
                DS_REPSYNCALL_ERRINFO error = new DS_REPSYNCALL_ERRINFO();
                Marshal.PtrToStructure(errorInfo, error);
                string message = GetErrorMessage(error.dwWin32Err, false);
                string?source  = Marshal.PtrToStringUni(error.pszSrcId);
                string?target  = Marshal.PtrToStringUni(error.pszSvrId);

                if (error.dwWin32Err == ERROR_CANCELLED)
                {
                    // this is a special case. the failure is because user specifies SyncAllOptions.CheckServerAlivenessOnly, ignore it here
                    return(null);
                }
                else
                {
                    SyncFromAllServersErrorInformation managedError = new SyncFromAllServersErrorInformation(error.error, error.dwWin32Err, message, source, target);
                    return(new SyncFromAllServersOperationException(SR.DSSyncAllFailure, null, new SyncFromAllServersErrorInformation[] { managedError }));
                }
            }
            else
            {
                // it is a NULL terminated array of DS_REPSYNCALL_ERRINFO
                IntPtr    tempPtr   = Marshal.ReadIntPtr(errorInfo);
                ArrayList errorList = new ArrayList();
                int       i         = 0;
                while (tempPtr != (IntPtr)0)
                {
                    DS_REPSYNCALL_ERRINFO error = new DS_REPSYNCALL_ERRINFO();
                    Marshal.PtrToStructure(tempPtr, error);
                    // this is a special case. the failure is because user specifies SyncAllOptions.CheckServerAlivenessOnly, ignore it here
                    if (error.dwWin32Err != ERROR_CANCELLED)
                    {
                        string message = GetErrorMessage(error.dwWin32Err, false);
                        string?source  = Marshal.PtrToStringUni(error.pszSrcId);
                        string?target  = Marshal.PtrToStringUni(error.pszSvrId);
                        SyncFromAllServersErrorInformation managedError = new SyncFromAllServersErrorInformation(error.error, error.dwWin32Err, message, source, target);

                        errorList.Add(managedError);
                    }

                    i++;
                    tempPtr = Marshal.ReadIntPtr(errorInfo, i * IntPtr.Size);
                }
                // no error information, so we should not throw exception.
                if (errorList.Count == 0)
                {
                    return(null);
                }

                SyncFromAllServersErrorInformation[] info = new SyncFromAllServersErrorInformation[errorList.Count];
                for (int j = 0; j < errorList.Count; j++)
                {
                    SyncFromAllServersErrorInformation tmp = (SyncFromAllServersErrorInformation)errorList[j] !;
                    info[j] = new SyncFromAllServersErrorInformation(tmp.ErrorCategory, tmp.ErrorCode, tmp.ErrorMessage, tmp.SourceServer, tmp.TargetServer);
                }

                return(new SyncFromAllServersOperationException(SR.DSSyncAllFailure, null, info));
            }
        }
Esempio n. 4
0
 internal static SyncFromAllServersOperationException CreateSyncAllException(IntPtr errorInfo, bool singleError)
 {
     if (errorInfo != (IntPtr)0)
     {
         if (!singleError)
         {
             IntPtr    intPtr     = Marshal.ReadIntPtr(errorInfo);
             ArrayList arrayLists = new ArrayList();
             int       num        = 0;
             while (intPtr != (IntPtr)0)
             {
                 DS_REPSYNCALL_ERRINFO dSREPSYNCALLERRINFO = new DS_REPSYNCALL_ERRINFO();
                 Marshal.PtrToStructure(intPtr, dSREPSYNCALLERRINFO);
                 if (dSREPSYNCALLERRINFO.dwWin32Err != ExceptionHelper.ERROR_CANCELLED)
                 {
                     string errorMessage = ExceptionHelper.GetErrorMessage(dSREPSYNCALLERRINFO.dwWin32Err, false);
                     string stringUni    = Marshal.PtrToStringUni(dSREPSYNCALLERRINFO.pszSrcId);
                     string str          = Marshal.PtrToStringUni(dSREPSYNCALLERRINFO.pszSvrId);
                     SyncFromAllServersErrorInformation syncFromAllServersErrorInformation = new SyncFromAllServersErrorInformation(dSREPSYNCALLERRINFO.error, dSREPSYNCALLERRINFO.dwWin32Err, errorMessage, stringUni, str);
                     arrayLists.Add(syncFromAllServersErrorInformation);
                 }
                 num++;
                 intPtr = Marshal.ReadIntPtr(errorInfo, num * Marshal.SizeOf(typeof(IntPtr)));
             }
             if (arrayLists.Count != 0)
             {
                 SyncFromAllServersErrorInformation[] syncFromAllServersErrorInformationArray = new SyncFromAllServersErrorInformation[arrayLists.Count];
                 for (int i = 0; i < arrayLists.Count; i++)
                 {
                     SyncFromAllServersErrorInformation item = (SyncFromAllServersErrorInformation)arrayLists[i];
                     syncFromAllServersErrorInformationArray[i] = new SyncFromAllServersErrorInformation(item.ErrorCategory, item.ErrorCode, item.ErrorMessage, item.SourceServer, item.TargetServer);
                 }
                 return(new SyncFromAllServersOperationException(Res.GetString("DSSyncAllFailure"), null, syncFromAllServersErrorInformationArray));
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             DS_REPSYNCALL_ERRINFO dSREPSYNCALLERRINFO1 = new DS_REPSYNCALL_ERRINFO();
             Marshal.PtrToStructure(errorInfo, dSREPSYNCALLERRINFO1);
             string errorMessage1 = ExceptionHelper.GetErrorMessage(dSREPSYNCALLERRINFO1.dwWin32Err, false);
             string stringUni1    = Marshal.PtrToStringUni(dSREPSYNCALLERRINFO1.pszSrcId);
             string str1          = Marshal.PtrToStringUni(dSREPSYNCALLERRINFO1.pszSvrId);
             if (dSREPSYNCALLERRINFO1.dwWin32Err != ExceptionHelper.ERROR_CANCELLED)
             {
                 SyncFromAllServersErrorInformation   syncFromAllServersErrorInformation1      = new SyncFromAllServersErrorInformation(dSREPSYNCALLERRINFO1.error, dSREPSYNCALLERRINFO1.dwWin32Err, errorMessage1, stringUni1, str1);
                 SyncFromAllServersErrorInformation[] syncFromAllServersErrorInformationArray1 = new SyncFromAllServersErrorInformation[1];
                 syncFromAllServersErrorInformationArray1[0] = syncFromAllServersErrorInformation1;
                 return(new SyncFromAllServersOperationException(Res.GetString("DSSyncAllFailure"), null, syncFromAllServersErrorInformationArray1));
             }
             else
             {
                 return(null);
             }
         }
     }
     else
     {
         return(new SyncFromAllServersOperationException());
     }
 }
Esempio n. 5
0
        internal static SyncFromAllServersOperationException CreateSyncAllException(IntPtr errorInfo, bool singleError)
        {
            if (errorInfo == (IntPtr)0)
                return new SyncFromAllServersOperationException();

            if (singleError)
            {
                // single error
                DS_REPSYNCALL_ERRINFO error = new DS_REPSYNCALL_ERRINFO();
                Marshal.PtrToStructure(errorInfo, error);
                string message = GetErrorMessage(error.dwWin32Err, false);
                string source = Marshal.PtrToStringUni(error.pszSrcId);
                string target = Marshal.PtrToStringUni(error.pszSvrId);

                if (error.dwWin32Err == s_ERROR_CANCELLED)
                {
                    // this is a special case. the failure is because user specifies SyncAllOptions.CheckServerAlivenessOnly, ignore it here
                    return null;
                }
                else
                {
                    SyncFromAllServersErrorInformation managedError = new SyncFromAllServersErrorInformation(error.error, error.dwWin32Err, message, source, target);
                    return new SyncFromAllServersOperationException(Res.GetString(Res.DSSyncAllFailure), null, new SyncFromAllServersErrorInformation[] { managedError });
                }
            }
            else
            {
                // it is a NULL terminated array of DS_REPSYNCALL_ERRINFO
                IntPtr tempPtr = Marshal.ReadIntPtr(errorInfo);
                ArrayList errorList = new ArrayList();
                int i = 0;
                while (tempPtr != (IntPtr)0)
                {
                    DS_REPSYNCALL_ERRINFO error = new DS_REPSYNCALL_ERRINFO();
                    Marshal.PtrToStructure(tempPtr, error);
                    // this is a special case. the failure is because user specifies SyncAllOptions.CheckServerAlivenessOnly, ignore it here
                    if (error.dwWin32Err != s_ERROR_CANCELLED)
                    {
                        string message = GetErrorMessage(error.dwWin32Err, false);
                        string source = Marshal.PtrToStringUni(error.pszSrcId);
                        string target = Marshal.PtrToStringUni(error.pszSvrId);
                        SyncFromAllServersErrorInformation managedError = new SyncFromAllServersErrorInformation(error.error, error.dwWin32Err, message, source, target);

                        errorList.Add(managedError);
                    }

                    i++;
                    tempPtr = Marshal.ReadIntPtr(errorInfo, i * Marshal.SizeOf(typeof(IntPtr)));
                }
                // no error information, so we should not throw exception.
                if (errorList.Count == 0)
                    return null;

                SyncFromAllServersErrorInformation[] info = new SyncFromAllServersErrorInformation[errorList.Count];
                for (int j = 0; j < errorList.Count; j++)
                {
                    SyncFromAllServersErrorInformation tmp = (SyncFromAllServersErrorInformation)errorList[j];
                    info[j] = new SyncFromAllServersErrorInformation(tmp.ErrorCategory, tmp.ErrorCode, tmp.ErrorMessage, tmp.SourceServer, tmp.TargetServer);
                }

                return new SyncFromAllServersOperationException(Res.GetString(Res.DSSyncAllFailure), null, info);
            }
        }
Esempio n. 6
0
		internal static SyncFromAllServersOperationException CreateSyncAllException(IntPtr errorInfo, bool singleError)
		{
			if (errorInfo != (IntPtr)0)
			{
				if (!singleError)
				{
					IntPtr intPtr = Marshal.ReadIntPtr(errorInfo);
					ArrayList arrayLists = new ArrayList();
					int num = 0;
					while (intPtr != (IntPtr)0)
					{
						DS_REPSYNCALL_ERRINFO dSREPSYNCALLERRINFO = new DS_REPSYNCALL_ERRINFO();
						Marshal.PtrToStructure(intPtr, dSREPSYNCALLERRINFO);
						if (dSREPSYNCALLERRINFO.dwWin32Err != ExceptionHelper.ERROR_CANCELLED)
						{
							string errorMessage = ExceptionHelper.GetErrorMessage(dSREPSYNCALLERRINFO.dwWin32Err, false);
							string stringUni = Marshal.PtrToStringUni(dSREPSYNCALLERRINFO.pszSrcId);
							string str = Marshal.PtrToStringUni(dSREPSYNCALLERRINFO.pszSvrId);
							SyncFromAllServersErrorInformation syncFromAllServersErrorInformation = new SyncFromAllServersErrorInformation(dSREPSYNCALLERRINFO.error, dSREPSYNCALLERRINFO.dwWin32Err, errorMessage, stringUni, str);
							arrayLists.Add(syncFromAllServersErrorInformation);
						}
						num++;
						intPtr = Marshal.ReadIntPtr(errorInfo, num * Marshal.SizeOf(typeof(IntPtr)));
					}
					if (arrayLists.Count != 0)
					{
						SyncFromAllServersErrorInformation[] syncFromAllServersErrorInformationArray = new SyncFromAllServersErrorInformation[arrayLists.Count];
						for (int i = 0; i < arrayLists.Count; i++)
						{
							SyncFromAllServersErrorInformation item = (SyncFromAllServersErrorInformation)arrayLists[i];
							syncFromAllServersErrorInformationArray[i] = new SyncFromAllServersErrorInformation(item.ErrorCategory, item.ErrorCode, item.ErrorMessage, item.SourceServer, item.TargetServer);
						}
						return new SyncFromAllServersOperationException(Res.GetString("DSSyncAllFailure"), null, syncFromAllServersErrorInformationArray);
					}
					else
					{
						return null;
					}
				}
				else
				{
					DS_REPSYNCALL_ERRINFO dSREPSYNCALLERRINFO1 = new DS_REPSYNCALL_ERRINFO();
					Marshal.PtrToStructure(errorInfo, dSREPSYNCALLERRINFO1);
					string errorMessage1 = ExceptionHelper.GetErrorMessage(dSREPSYNCALLERRINFO1.dwWin32Err, false);
					string stringUni1 = Marshal.PtrToStringUni(dSREPSYNCALLERRINFO1.pszSrcId);
					string str1 = Marshal.PtrToStringUni(dSREPSYNCALLERRINFO1.pszSvrId);
					if (dSREPSYNCALLERRINFO1.dwWin32Err != ExceptionHelper.ERROR_CANCELLED)
					{
						SyncFromAllServersErrorInformation syncFromAllServersErrorInformation1 = new SyncFromAllServersErrorInformation(dSREPSYNCALLERRINFO1.error, dSREPSYNCALLERRINFO1.dwWin32Err, errorMessage1, stringUni1, str1);
						SyncFromAllServersErrorInformation[] syncFromAllServersErrorInformationArray1 = new SyncFromAllServersErrorInformation[1];
						syncFromAllServersErrorInformationArray1[0] = syncFromAllServersErrorInformation1;
						return new SyncFromAllServersOperationException(Res.GetString("DSSyncAllFailure"), null, syncFromAllServersErrorInformationArray1);
					}
					else
					{
						return null;
					}
				}
			}
			else
			{
				return new SyncFromAllServersOperationException();
			}
		}