示例#1
0
        ///<summary></summary>
        public static bool GetBool(MethodBase methodBase, params object[] parameters)
        {
            if (RemotingClient.RemotingRole != RemotingRole.ClientWeb)
            {
                throw new ApplicationException("Meth.GetBool may only be used when RemotingRole is ClientWeb.");
            }
            DtoGetBool dto = new DtoGetBool();

            dto.MethodName = methodBase.DeclaringType.Namespace + "."
                             + methodBase.DeclaringType.Name + "." + methodBase.Name;
            dto.Params               = DtoObject.ConstructArray(methodBase, parameters);
            dto.Credentials          = new Credentials();
            dto.Credentials.Username = Security.CurUser.UserName;
            dto.Credentials.Password = Security.PasswordTyped;          //.CurUser.Password;
            bool retval;

            try {
                retval = RemotingClient.ProcessGetBool(dto);
            }
            catch (ODException ex) {
                if (ex.ErrorCode == (int)ODException.ErrorCodes.CheckUserAndPasswordFailed)
                {
                    CredentialsFailed();                    //The application pauses here in the main thread to wait for user input.
                    retval = GetBool(methodBase, parameters);
                }
                else
                {
                    throw;
                }
            }
            return(retval);
        }
示例#2
0
 public static bool GetIsMiddleTierAvailable(MethodBase methodBase, params object[] parameters)
 {
     if (RemotingClient.RemotingRole != RemotingRole.ClientWeb)
     {
         throw new ApplicationException("Meth.GetIsMiddleTierAvailable may only be used when RemotingRole is ClientWeb.");
     }
     try {
         DtoGetBool dto = new DtoGetBool();
         dto.MethodName = methodBase.DeclaringType.Namespace + "."
                          + methodBase.DeclaringType.Name + "." + methodBase.Name;
         dto.Params               = DtoObject.ConstructArray(methodBase, parameters);
         dto.Credentials          = new Credentials();
         dto.Credentials.Username = Security.CurUser.UserName;
         dto.Credentials.Password = Security.PasswordTyped;              //.CurUser.Password;
         //Passing hasLostConnection=false allows this method to throw an exception, such as if the Middle Tier connection has been lost.
         return(RemotingClient.ProcessGetBool(dto, false));
     }
     catch (WebException wex) {
         //If no connection monitoring desired or this is a WebException that we aren't explicitly looking for then bubble up the exception.
         //WebException class: https://docs.microsoft.com/en-us/dotnet/api/system.net.webexception?view=netframework-4.7.2
         //WebException.Status property: https://docs.microsoft.com/en-us/dotnet/api/system.net.webexception.status?view=netframework-4.7.2
         //Handling WebExceptions: https://docs.microsoft.com/en-us/dotnet/framework/network-programming/handling-errors?view=netframework-4.7.2
         if (wex.Status != WebExceptionStatus.ConnectFailure)
         {
             throw;
         }
         return(false);               //Indicates to DtoProcessor.IsMiddleTierAvailable() that the Middle Tier connection has not been restored.
     }
 }
示例#3
0
文件: Meth.cs 项目: nampn/ODental
 ///<summary></summary>
 public static bool GetBool(MethodBase methodBase, params object[] parameters)
 {
     if (RemotingClient.RemotingRole != RemotingRole.ClientWeb)
     {
         throw new ApplicationException("Meth.GetBool may only be used when RemotingRole is ClientWeb.");
     }
                 #if DEBUG
     /*
      *      //Verify that it returns string
      *      MethodInfo methodInfo=methodBase.ReflectedType.GetMethod(methodBase.Name);
      *      if(methodInfo.ReturnType != typeof(bool)) {
      *              throw new ApplicationException("Meth.GetBool calling class must return bool.");
      *      }*/
                 #endif
     DtoGetBool dto = new DtoGetBool();
     dto.MethodName           = methodBase.DeclaringType.Name + "." + methodBase.Name;
     dto.Params               = DtoObject.ConstructArray(parameters, GetParamTypes(methodBase));
     dto.Credentials          = new Credentials();
     dto.Credentials.Username = Security.CurUser.UserName;
     dto.Credentials.Password = Security.PasswordTyped;          //.CurUser.Password;
     return(RemotingClient.ProcessGetBool(dto));
 }