コード例 #1
0
ファイル: Meth.cs プロジェクト: ChemBrain/OpenDental
        ///<summary></summary>
        public static double GetDouble(MethodBase methodBase, params object[] parameters)
        {
            if (RemotingClient.RemotingRole != RemotingRole.ClientWeb)
            {
                throw new ApplicationException("Meth.GetDouble may only be used when RemotingRole is ClientWeb.");
            }
#if DEBUG
            //Verify that it returns a double
            MethodInfo methodInfo = null;
            try {
                methodInfo = methodBase.ReflectedType.GetMethod(methodBase.Name);
            }
            catch (AmbiguousMatchException) {
                //Ambiguous match exceptions do not matter for the middle tier and are just annoying when they get thrown here.  Ignore them.
            }
            if (methodInfo != null && methodInfo.ReturnType != typeof(double))
            {
                throw new ApplicationException("Meth.GetDouble calling class must return double.");
            }
#endif
            DtoGetDouble dto = new DtoGetDouble();
            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;
            dto.ComputerName         = Security.CurComputerName;
            double retval = 0;
            try {
                retval = RemotingClient.ProcessGetDouble(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 = GetDouble(methodBase, parameters);
                }
                else
                {
                    throw;
                }
            }
            return(retval);
        }