Exemplo n.º 1
0
 public static object[] GenerateObjects(DtoObject[] parameters)
 {
     object[] retVal=new object[parameters.Length];
     for(int i=0;i<parameters.Length;i++) {
         retVal[i]=parameters[i].Obj;
     }
     return retVal;
 }
Exemplo n.º 2
0
 public static Type[] GenerateTypes(DtoObject[] parameters,string assemb)
 {
     Type[] retVal=new Type[parameters.Length];
     for(int i=0;i<parameters.Length;i++) {
         retVal[i]=ConvertNameToType(parameters[i].TypeName,assemb);
     }
     return retVal;
 }
Exemplo n.º 3
0
 ///<summary>We must pass in a matching array of types for situations where nulls are used in parameters.  Otherwise, we won't know the parameter type.</summary>
 public static DtoObject[] ConstructArray(object[] objArray,Type[] objTypes)
 {
     DtoObject[] retVal=new DtoObject[objArray.Length];
     for(int i=0;i<objArray.Length;i++) {
         retVal[i]=new DtoObject(objArray[i],objTypes[i]);
     }
     return retVal;
 }
Exemplo n.º 4
0
 ///<summary></summary>
 public static DataTable GetTable(MethodBase methodBase, params object[] parameters)
 {
     if (RemotingClient.RemotingRole != RemotingRole.ClientWeb)
     {
         throw new ApplicationException("Meth.GetTable may only be used when RemotingRole is ClientWeb.");
     }
                 #if DEBUG
     //Verify that it returns a DataTable
     MethodInfo methodInfo = methodBase.ReflectedType.GetMethod(methodBase.Name);
     if (methodInfo.ReturnType != typeof(DataTable))
     {
         throw new ApplicationException("Meth.GetTable calling class must return DataTable.");
     }
                 #endif
     DtoGetTable dto = new DtoGetTable();
     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.ProcessGetTable(dto));
 }
Exemplo n.º 5
0
        ///<summary>We must pass in the MethodBase for the method that is being invoked for situations where nulls are used in parameters.
        ///Otherwise, we won't know the parameter types of the arguments that the method takes.
        ///MethodBase is also required for identifying unique parameters (e.g. detecting if the only parameter is an array).
        ///This method needs to create a "deep copy" of all objects passed in because we will be escaping characters within string variables.
        ///Since we do not know what objects are being passed in, we decided to use JSON to generically serialize each object.
        ///JSON seems to handle invalid characters better than XML even though it has its own quirks.
        ///Throws exceptions if an invalid amount of objects was passed in for the desired method.</summary>
        public static DtoObject[] ConstructArray(MethodBase methodBase, object[] objArray)
        {
            ParameterInfo[]        arrayParameterInfos = methodBase.GetParameters();
            DtoObject[]            retVal       = new DtoObject[arrayParameterInfos.Length];
            JsonSerializerSettings jsonSettings = new JsonSerializerSettings()
            {
                TypeNameHandling = TypeNameHandling.Auto
            };
            bool isSingleArray = false;

            //Methods that only have one parameter that is an array get treated differently for some reason.
            //Their objArray will contain an entry for every entity within the array instead of a single object that is the array itself.
            //E.g. invoking a method signature like "Method(object[])" with several objects will translate to X objects (object1,object2,object3...)
            //instead of a single object (object[]) but a method like "Method(object[],bool)" or even "Method(bool,object[])"
            //will translate correctly into two objects (object[],bool) or (bool,object[]).
            //Therefore, when we have exactly one parameter, check to see if it is an array and if it is, artifically group together all objects
            //that were passed into objArray so that we end up with one and only one DtoObject that represents an array of objects.
            //NOTE: The exception to the rule above is a method with a single array whose element type is a primitive or an array.
            //      An array of primitives or enums will correctly translate to a single array (int[]) instead of (int1,int2,int3...) for whatever reason.
            if (arrayParameterInfos.Length == 1 &&
                arrayParameterInfos[0].ParameterType.IsArray &&
                !(arrayParameterInfos[0].ParameterType.GetElementType().IsPrimitive || arrayParameterInfos[0].ParameterType.GetElementType().IsEnum))
            {
                isSingleArray = true;
            }
            //Methods that utilize the params keyword will allow a variable number of arguments in its invocation.
            //Therefore, the number of objects passed in objArray is not guaranteed to be the same length as arrayParameterInfos.
            //Only validate that the length of both arrays are equal when an array is the only argument passed in OR the params keyword is not used.
            if (!isSingleArray && arrayParameterInfos.All(x => x.GetCustomAttributes(typeof(ParamArrayAttribute)).Count() == 0))
            {
                //Verify that the correct number of objects were passed in.
                if (objArray.Length != arrayParameterInfos.Length)
                {
                    throw new ApplicationException("Middle Tier, incorrect number of parameters passed to method " + methodBase.Name + ".\r\n"
                                                   + "Expected parameter count: " + arrayParameterInfos.Length + "\r\n"
                                                   + "Actual parameter count: " + objArray.Length);
                }
            }
            for (int i = 0; i < arrayParameterInfos.Length; i++)
            {
                object objCur = objArray[i];
                if (isSingleArray)
                {
                    objCur = objArray;                  //We need to treat this object as the entire array of objects that was passed in.
                }
                Type      typeCur     = arrayParameterInfos[i].ParameterType;
                DtoObject dtoCur      = new DtoObject(objCur, typeCur);
                Type      typeElement = typeCur;
                if (typeCur != typeof(string) && typeCur.IsGenericType)               //get the type of the items in the List
                {
                    typeElement = typeCur.GetGenericArguments()[0];
                }
                if (objCur == null ||
                    (typeCur == typeof(string) && string.IsNullOrEmpty(objCur.ToString())) ||                  //if object is a string and is null or empty, just add as-is
                    (typeElement != typeof(string) && typeElement.IsValueType))                     //if object is either value typed or a list of value typed objs, just add as-is
                {
                    retVal[i] = dtoCur;
                    continue;
                }
                //we only need to create a deep copy of all objects that are strings or complex objects which may contain strings.
                retVal[i] = JsonConvert.DeserializeObject <DtoObject>(JsonConvert.SerializeObject(dtoCur, jsonSettings), jsonSettings);
                if (typeCur.FullName == "System.Data.DataTable")
                {
#if DEBUG
                    //Make sure that there are no duplicate columns in the DataTable because it is not supported by JSON deserialization.  See task #835007.
                    if (((DataTable)objCur).Columns.OfType <DataColumn>().GroupBy(x => x.ColumnName.ToLower())
                        .ToDictionary(x => x.Key, x => x.ToList())
                        .Any(x => x.Value.Count > 1))
                    {
                        throw new Exception("Duplicate columns are not allowed when deserializing DataTables with JSON (which is case insensitive).");
                    }
#endif
                    //DtoObject.Obj in the case of DataTables are left as JArray when deserialized from Json.  Do work to change it back to DataTable
                    retVal[i].Obj = JsonConvert.DeserializeObject <DataTable>(retVal[i].Obj.ToString());
                }
            }
            return(retVal);
        }
Exemplo n.º 6
0
 ///<summary>Pass in a serialized dto.  It returns a dto which must be deserialized by the client.
 ///Set serverMapPath to the root directory of the OpenDentalServerConfig.xml.  Typically Server.MapPath(".") from a web service.
 ///Optional parameter because it is not necessary for Unit Tests (mock server).</summary>
 public static string ProcessDto(string dtoString, string serverMapPath = "")
 {
     try {
         #region Normalize DateTime
         if (!_isMiddleTierInitialized)
         {
             //If this fails, the exception will throw and be serialized and sent to the client.
             ODInitialize.Initialize();
             //Because Security._curUserT is a thread static field, we need to make sure that any new threads that are spawned have that field set.
             ODThread.AddInitializeHandler <Userod>(() => Security.CurUser.Copy(), user => Security.CurUser = user);
             //Same thing for PasswordTyped.
             ODThread.AddInitializeHandler <string>(() => Security.PasswordTyped, password => Security.PasswordTyped = password);
             //Ditto for CurComputerName
             ODThread.AddInitializeHandler <string>(() => Security.CurComputerName, computerName => Security.CurComputerName = computerName);
             //Calling CDT.Class1.Decrypt will cause CDT to verify the assembly and then save the encryption key. This needs to be done here because
             //if we later call CDT.Class1.Decrypt inside a thread, we won't we able to find OpenDentalServer.dll in the call stack.
             ODException.SwallowAnyException(() => CDT.Class1.Decrypt("odv2e$fakeciphertext", out _));
             _isMiddleTierInitialized = true;
         }
         #endregion
         #region Initialize Database Connection
         //Always attempt to set the database connection settings from the config file if they haven't been set yet.
         //We use to ONLY load in database settings when Security.LogInWeb was called but that is not good enough now that we have more services.
         //E.g. We do not want to manually call "Security.LogInWeb" from the CEMT when all we want is a single preference value.
         if (string.IsNullOrEmpty(DataConnection.GetServerName()) && string.IsNullOrEmpty(DataConnection.GetConnectionString()))
         {
             RemotingClient.RemotingRole = RemotingRole.ServerWeb;
             //the application virtual path is usually /OpenDentalServer, but may be different if hosting multiple databases on one IIS server
             string configFilePath = "";
             if (!string.IsNullOrWhiteSpace(HostingEnvironment.ApplicationVirtualPath) && HostingEnvironment.ApplicationVirtualPath.Length > 1)
             {
                 //There can be multiple config files within a physical path that is shared by multiple IIS ASP.NET applications.
                 //In order for the same physical path to host multiple applications, they each need a unique config file for db connection settings.
                 //Each application will have a unique ApplicationVirtualPath which we will use to identify the corresponding config.xml.
                 configFilePath = ODFileUtils.CombinePaths(serverMapPath, HostingEnvironment.ApplicationVirtualPath.Trim('/') + "Config.xml");
             }
             if (string.IsNullOrWhiteSpace(configFilePath) ||
                 !File.Exists(configFilePath))                           //returns false if the file doesn't exist, user doesn't have permission for file, path is blank or null
             {
                 //either configFilePath not set or file doesn't exist, default to OpenDentalServerConfig.xml
                 configFilePath = ODFileUtils.CombinePaths(serverMapPath, "OpenDentalServerConfig.xml");
             }
             Userods.LoadDatabaseInfoFromFile(configFilePath);
         }
         #endregion
         DataTransferObject dto            = DataTransferObject.Deserialize(dtoString);
         DtoInformation     dtoInformation = new DtoInformation(dto);
         if (dtoInformation.FullNameComponents.Length == 3 && dtoInformation.FullNameComponents[2].ToLower() == "hashpassword")
         {
             return(dtoInformation.GetHashPassword());
         }
         //Set Security.CurUser so that queries can be run against the db as if it were this user.
         Security.CurUser = Userods.CheckUserAndPassword(dto.Credentials.Username, dto.Credentials.Password
                                                         , Programs.UsingEcwTightOrFullMode());
         Security.PasswordTyped = dto.Credentials.Password;
         //Set the computer name so securitylog entries use the client's computer name instead of the middle tier server name
         //Older clients might not include ComputerName in the dto, so we need to make sure it's not null.
         Security.CurComputerName = dto.ComputerName ?? "";
         Type type = dto.GetType();
         #region DtoGetTable
         if (type == typeof(DtoGetTable))
         {
             DataTable dt = (DataTable)dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             return(XmlConverter.TableToXml(dt));
         }
         #endregion
         #region DtoGetTableLow
         else if (type == typeof(DtoGetTableLow))
         {
             DataTable dt = Reports.GetTable((string)dtoInformation.ParamObjs[0]);
             return(XmlConverter.TableToXml(dt));
         }
         #endregion
         #region DtoGetDS
         else if (type == typeof(DtoGetDS))
         {
             DataSet ds = (DataSet)dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             return(XmlConverter.DsToXml(ds));
         }
         #endregion
         #region DtoGetSerializableDictionary
         else if (type == typeof(DtoGetSerializableDictionary))
         {
             Object objResult  = dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             Type   returnType = dtoInformation.MethodInfo.ReturnType;
             return(XmlConverterSerializer.Serialize(returnType, objResult));
         }
         #endregion
         #region DtoGetLong
         else if (type == typeof(DtoGetLong))
         {
             long longResult = (long)dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             return(longResult.ToString());
         }
         #endregion
         #region DtoGetInt
         else if (type == typeof(DtoGetInt))
         {
             int intResult = (int)dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             return(intResult.ToString());
         }
         #endregion
         #region DtoGetDouble
         else if (type == typeof(DtoGetDouble))
         {
             double doubleResult = (double)dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             return(doubleResult.ToString());
         }
         #endregion
         #region DtoGetVoid
         else if (type == typeof(DtoGetVoid))
         {
             dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             return("0");
         }
         #endregion
         #region DtoGetObject
         else if (type == typeof(DtoGetObject))
         {
             if (dtoInformation.ClassName == "Security" && dtoInformation.MethodName == "LogInWeb")
             {
                 dtoInformation.Parameters[2] = new DtoObject(serverMapPath, typeof(string));                     //because we can't access this variable from within OpenDentBusiness.
                 RemotingClient.RemotingRole  = RemotingRole.ServerWeb;
                 //We just changed the number of parameters so we need to regenerate ParamObjs.
                 dtoInformation.ParamObjs = DtoObject.GenerateObjects(dtoInformation.Parameters);
             }
             Object objResult  = dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             Type   returnType = dtoInformation.MethodInfo.ReturnType;
             if (returnType.IsInterface)
             {
                 objResult  = new DtoObject(objResult, objResult?.GetType() ?? returnType);
                 returnType = typeof(DtoObject);
             }
             return(XmlConverterSerializer.Serialize(returnType, objResult));
         }
         #endregion
         #region DtoGetString
         else if (type == typeof(DtoGetString))
         {
             string strResult = (string)dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             return(XmlConverter.XmlEscape(strResult));
         }
         #endregion
         #region DtoGetBool
         else if (type == typeof(DtoGetBool))
         {
             bool boolResult = (bool)dtoInformation.MethodInfo.Invoke(null, dtoInformation.ParamObjs);
             return(boolResult.ToString());
         }
         #endregion
         else
         {
             throw new NotSupportedException("Dto type not supported: " + type.FullName);
         }
     }
     catch (Exception e) {
         DtoException exception = new DtoException();
         if (e.InnerException == null)
         {
             exception = GetDtoException(e);
         }
         else
         {
             exception = GetDtoException(e.InnerException);
         }
         return(exception.Serialize());
     }
 }
Exemplo n.º 7
0
 ///<summary>Pass in a serialized dto.  It returns a dto which must be deserialized by the client.
 ///Set serverMapPath to the root directory of the OpenDentalServerConfig.xml.  Typically Server.MapPath(".") from a web service.
 ///Optional parameter because it is not necessary for Unit Tests (mock server).</summary>
 public static string ProcessDto(string dtoString, string serverMapPath = "")
 {
                 #if DEBUG
     //System.Threading.Thread.Sleep(100);//to test slowness issues with web service.
                 #endif
     DataTransferObject dto = DataTransferObject.Deserialize(dtoString);
     try {
         string[] methNameComps = GetComponentsFromDtoMeth(dto.MethodName);
         if (methNameComps.Length == 3 && methNameComps[2].ToLower() == "hashpassword")
         {
             return(GetHashPassword(dto));
         }
         //Always attempt to set the database connection settings from the config file if they haven't been set yet.
         //We use to ONLY load in database settings when Security.LogInWeb was called but that is not good enough now that we have more services.
         //E.g. We do not want to manually call "Security.LogInWeb" from the CEMT when all we want is a single preference value.
         if (string.IsNullOrEmpty(DataConnection.GetServerName()) && string.IsNullOrEmpty(DataConnection.GetConnectionString()))
         {
             RemotingClient.RemotingRole = RemotingRole.ServerWeb;
             //the application virtual path is usually /OpenDentalServer, but may be different if hosting multiple databases on one IIS server
             string configFilePath = "";
             if (!string.IsNullOrWhiteSpace(HostingEnvironment.ApplicationVirtualPath) && HostingEnvironment.ApplicationVirtualPath.Length > 1)
             {
                 //There can be multiple config files within a physical path that is shared by multiple IIS ASP.NET applications.
                 //In order for the same physical path to host multiple applications, they each need a unique config file for db connection settings.
                 //Each application will have a unique ApplicationVirtualPath which we will use to identify the corresponding config.xml.
                 configFilePath = ODFileUtils.CombinePaths(serverMapPath, HostingEnvironment.ApplicationVirtualPath.Trim('/') + "Config.xml");
             }
             if (string.IsNullOrWhiteSpace(configFilePath) ||
                 !File.Exists(configFilePath))                           //returns false if the file doesn't exist, user doesn't have permission for file, path is blank or null
             {
                 //either configFilePath not set or file doesn't exist, default to OpenDentalServerConfig.xml
                 configFilePath = ODFileUtils.CombinePaths(serverMapPath, "OpenDentalServerConfig.xml");
             }
             Userods.LoadDatabaseInfoFromFile(configFilePath);
         }
         //Set Security.CurUser so that queries can be run against the db as if it were this user.
         Security.CurUser = Userods.CheckUserAndPassword(dto.Credentials.Username
                                                         , dto.Credentials.Password
                                                         , Programs.IsEnabled(ProgramName.eClinicalWorks));
         Security.PasswordTyped = dto.Credentials.Password;
         Type type = dto.GetType();
         #region DtoGetTable
         if (type == typeof(DtoGetTable))
         {
             DtoGetTable dtoGetTable        = (DtoGetTable)dto;
             string[]    fullNameComponents = GetComponentsFromDtoMeth(dtoGetTable.MethodName);
             string      assemblyName       = fullNameComponents[0];       //OpenDentBusiness or else a plugin name
             string      className          = fullNameComponents[1];
             string      methodName         = fullNameComponents[2];
             Type        classType          = null;
             Assembly    ass = Plugins.GetAssembly(assemblyName);
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetTable.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetTable.MethodName);
             }
             object[]  paramObjs = DtoObject.GenerateObjects(parameters);
             DataTable dt        = (DataTable)methodInfo.Invoke(null, paramObjs);
             String    response  = XmlConverter.TableToXml(dt);
             return(response);
         }
         #endregion
         #region DtoGetTableLow
         else if (type == typeof(DtoGetTableLow))
         {
             DtoGetTableLow dtoGetTableLow = (DtoGetTableLow)dto;
             DtoObject[]    parameters     = dtoGetTableLow.Params;
             object[]       paramObjs      = DtoObject.GenerateObjects(parameters);
             DataTable      dt             = Reports.GetTable((string)paramObjs[0]);
             String         response       = XmlConverter.TableToXml(dt);
             return(response);
         }
         #endregion
         #region DtoGetDS
         else if (type == typeof(DtoGetDS))
         {
             DtoGetDS dtoGetDS           = (DtoGetDS)dto;
             string[] fullNameComponents = GetComponentsFromDtoMeth(dtoGetDS.MethodName);
             string   assemblyName       = fullNameComponents[0];          //OpenDentBusiness or else a plugin name
             string   className          = fullNameComponents[1];
             string   methodName         = fullNameComponents[2];
             Type     classType          = null;
             Assembly ass = Plugins.GetAssembly(assemblyName);
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetDS.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetDS.MethodName);
             }
             object[] paramObjs = DtoObject.GenerateObjects(parameters);
             DataSet  ds        = (DataSet)methodInfo.Invoke(null, paramObjs);
             String   response  = XmlConverter.DsToXml(ds);
             return(response);
         }
         #endregion
         #region DtoGetSerializableDictionary
         else if (type == typeof(DtoGetSerializableDictionary))
         {
             DtoGetSerializableDictionary dtoGetSD = (DtoGetSerializableDictionary)dto;
             string[] fullNameComponents           = GetComponentsFromDtoMeth(dtoGetSD.MethodName);
             string   assemblyName = fullNameComponents[0];                //OpenDentBusiness or else a plugin name
             string   className    = fullNameComponents[1];
             string   methodName   = fullNameComponents[2];
             Type     classType    = null;
             Assembly ass          = Plugins.GetAssembly(assemblyName);
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetSD.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetSD.MethodName);
             }
             object[] paramObjs  = DtoObject.GenerateObjects(parameters);
             Object   objResult  = methodInfo.Invoke(null, paramObjs);
             Type     returnType = methodInfo.ReturnType;
             return(XmlConverter.Serialize(returnType, objResult));
         }
         #endregion
         #region DtoGetLong
         else if (type == typeof(DtoGetLong))
         {
             DtoGetLong dtoGetLong         = (DtoGetLong)dto;
             string[]   fullNameComponents = GetComponentsFromDtoMeth(dtoGetLong.MethodName);
             string     assemblyName       = fullNameComponents[0];        //OpenDentBusiness or else a plugin name
             string     className          = fullNameComponents[1];
             string     methodName         = fullNameComponents[2];
             Type       classType          = null;
             Assembly   ass = Plugins.GetAssembly(assemblyName);
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetLong.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetLong.MethodName);
             }
             object[] paramObjs  = DtoObject.GenerateObjects(parameters);
             long     longResult = (long)methodInfo.Invoke(null, paramObjs);
             return(longResult.ToString());
         }
         #endregion
         #region DtoGetInt
         else if (type == typeof(DtoGetInt))
         {
             DtoGetInt dtoGetInt          = (DtoGetInt)dto;
             string[]  fullNameComponents = GetComponentsFromDtoMeth(dtoGetInt.MethodName);
             string    assemblyName       = fullNameComponents[0];         //OpenDentBusiness or else a plugin name
             string    className          = fullNameComponents[1];
             string    methodName         = fullNameComponents[2];
             Type      classType          = null;
             Assembly  ass = Plugins.GetAssembly(assemblyName);
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetInt.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetInt.MethodName);
             }
             object[] paramObjs = DtoObject.GenerateObjects(parameters);
             int      intResult = (int)methodInfo.Invoke(null, paramObjs);
             return(intResult.ToString());
         }
         #endregion
         #region DtoGetDouble
         else if (type == typeof(DtoGetDouble))
         {
             DtoGetDouble dtoGetDouble       = (DtoGetDouble)dto;
             string[]     fullNameComponents = GetComponentsFromDtoMeth(dtoGetDouble.MethodName);
             string       assemblyName       = fullNameComponents[0];      //OpenDentBusiness or else a plugin name
             string       className          = fullNameComponents[1];
             string       methodName         = fullNameComponents[2];
             Type         classType          = null;
             Assembly     ass = Plugins.GetAssembly(assemblyName);
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetDouble.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetDouble.MethodName);
             }
             object[] paramObjs    = DtoObject.GenerateObjects(parameters);
             double   doubleResult = (double)methodInfo.Invoke(null, paramObjs);
             return(doubleResult.ToString());
         }
         #endregion
         #region DtoGetVoid
         else if (type == typeof(DtoGetVoid))
         {
             DtoGetVoid dtoGetVoid         = (DtoGetVoid)dto;
             string[]   fullNameComponents = GetComponentsFromDtoMeth(dtoGetVoid.MethodName);
             string     assemblyName       = fullNameComponents[0];        //OpenDentBusiness or else a plugin name
             string     className          = fullNameComponents[1];
             string     methodName         = fullNameComponents[2];
             Type       classType          = null;
             Assembly   ass = Plugins.GetAssembly(assemblyName);
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetVoid.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetVoid.MethodName);
             }
             object[] paramObjs = DtoObject.GenerateObjects(parameters);
             methodInfo.Invoke(null, paramObjs);
             return("0");
         }
         #endregion
         #region DtoGetObject
         else if (type == typeof(DtoGetObject))
         {
             DtoGetObject dtoGetObject       = (DtoGetObject)dto;
             string[]     fullNameComponents = GetComponentsFromDtoMeth(dtoGetObject.MethodName);
             string       assemblyName       = fullNameComponents[0];      //OpenDentBusiness or else a plugin name
             string       className          = fullNameComponents[1];
             string       methodName         = fullNameComponents[2];
             //if(className != "Security" || methodName != "LogInWeb") {//because credentials will be checked inside that method
             //	Userods.CheckCredentials(dtoGetObject.Credentials);//will throw exception if fails.
             //}
             Type     classType = null;
             Assembly ass       = Plugins.GetAssembly(assemblyName);
             //if(className!="Security" || methodName!="LogInWeb") {//Do this for everything except Security.LogInWeb, because Plugins.GetAssembly will fail in that case.
             //	ass=Plugins.GetAssembly(assemblyName);
             //}
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetObject.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetObject.MethodName);
             }
             if (className == "Security" && methodName == "LogInWeb")
             {
                 parameters[2] = new DtoObject(serverMapPath, typeof(string));                     //because we can't access this variable from within OpenDentBusiness.
                 RemotingClient.RemotingRole = RemotingRole.ServerWeb;
             }
             object[] paramObjs  = DtoObject.GenerateObjects(parameters);
             Object   objResult  = methodInfo.Invoke(null, paramObjs);
             Type     returnType = methodInfo.ReturnType;
             if (returnType.IsInterface)
             {
                 objResult  = new DtoObject(objResult, objResult?.GetType() ?? returnType);
                 returnType = typeof(DtoObject);
             }
             return(XmlConverter.Serialize(returnType, objResult));
         }
         #endregion
         #region DtoGetString
         else if (type == typeof(DtoGetString))
         {
             DtoGetString dtoGetString       = (DtoGetString)dto;
             string[]     fullNameComponents = GetComponentsFromDtoMeth(dtoGetString.MethodName);
             string       assemblyName       = fullNameComponents[0];      //OpenDentBusiness or else a plugin name
             string       className          = fullNameComponents[1];
             string       methodName         = fullNameComponents[2];
             Type         classType          = null;
             Assembly     ass = Plugins.GetAssembly(assemblyName);
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetString.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetString.MethodName);
             }
             object[] paramObjs = DtoObject.GenerateObjects(parameters);
             string   strResult = (string)methodInfo.Invoke(null, paramObjs);
             strResult = XmlConverter.XmlEscape(strResult);
             return(strResult);
         }
         #endregion
         #region DtoGetBool
         else if (type == typeof(DtoGetBool))
         {
             DtoGetBool dtoGetBool         = (DtoGetBool)dto;
             string[]   fullNameComponents = GetComponentsFromDtoMeth(dtoGetBool.MethodName);
             string     assemblyName       = fullNameComponents[0];        //OpenDentBusiness or else a plugin name
             string     className          = fullNameComponents[1];
             string     methodName         = fullNameComponents[2];
             Type       classType          = null;
             Assembly   ass = Plugins.GetAssembly(assemblyName);
             if (ass == null)
             {
                 classType = Type.GetType(assemblyName                      //actually, the namespace which we require to be same as assembly by convention
                                          + "." + className + "," + assemblyName);
             }
             else                                     //plugin was found
             {
                 classType = ass.GetType(assemblyName //actually, the namespace which we require to be same as assembly by convention
                                         + "." + className);
             }
             DtoObject[] parameters = dtoGetBool.Params;
             Type[]      paramTypes = DtoObject.GenerateTypes(parameters, assemblyName);
             MethodInfo  methodInfo = classType.GetMethod(methodName, paramTypes);
             if (methodInfo == null)
             {
                 throw new ApplicationException("Method not found with " + parameters.Length.ToString() + " parameters: " + dtoGetBool.MethodName);
             }
             object[] paramObjs  = DtoObject.GenerateObjects(parameters);
             bool     boolResult = (bool)methodInfo.Invoke(null, paramObjs);
             return(boolResult.ToString());
         }
         #endregion
         else
         {
             throw new NotSupportedException("Dto type not supported: " + type.FullName);
         }
     }
     catch (Exception e) {
         DtoException exception = new DtoException();
         exception.ExceptionType = e.GetType().BaseType.Name;              //Since the exception was down converted to a regular exception, we need the BaseType.
         if (e.InnerException == null)
         {
             exception.Message = e.Message;
         }
         else
         {
             exception.Message = e.InnerException.Message;
         }
         return(exception.Serialize());
     }
 }
Exemplo n.º 8
0
        //<summary>Obsolete</summary>
        //public static void ResetPassword(){
        //FIXME:UPDATE-MULTIPLE-TABLES

        /*string command="UPDATE userod,grouppermissions SET userod.Password='' "
         +"WHERE grouppermissions.UserGroupNum=userod.UserGroupNum "
         +"AND grouppermissions.PermType=24";
         * Db.NonQ(command);
         */
        //Code updated to be compatible with Oracle as well as MySQL.

        /*
         * string command="SELECT userod.UserNum FROM userod,grouppermissions "
         +"WHERE grouppermissions.UserGroupNum=userod.UserGroupNum "
         +"AND grouppermissions.PermType=24";
         * DataTable table=Db.GetTable(command);
         * if(table.Rows.Count==0){
         *      throw new ApplicationException("No admin exists.");
         * }
         * command="UPDATE userod SET Password='' WHERE UserNum="+POut.PString(table.Rows[0][0].ToString());
         * Db.NonQ(command);
         * }*/

        ///<summary>RemotingRole has not yet been set to ClientWeb, but it will if this succeeds.  Will throw an exception if server cannot validate username and password.  configPath will be empty from a workstation and filled from the server.  If Ecw, odpass will actually be the hash.</summary>
        public static Userod LogInWeb(string oduser, string odpass, string configPath, string clientVersionStr, bool usingEcw)
        {
            //Very unusual method.  Remoting role can't be checked, but is implied by the presence of a value in configPath.
            if (configPath != "")             //RemotingRole.ServerWeb
            {
                Userods.LoadDatabaseInfoFromFile(ODFileUtils.CombinePaths(configPath, "OpenDentalServerConfig.xml"));
                //ODFileUtils.CombinePaths(
                //  ,"OpenDentalServerConfig.xml"));
                //Path.GetDirectoryName(Application.ExecutablePath),"OpenDentalServerConfig.xml"));
                //Application.StartupPath,"OpenDentalServerConfig.xml"));
                //Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"OpenDentalServerConfig.xml"));
                //Environment.CurrentDirectory,"OpenDentalServerConfig.xml"));
                //Then, check username and password
                Userod user = Userods.CheckUserAndPassword(oduser, odpass, usingEcw);
                                #if DEBUG
                //if(oduser=="Admin"){
                //	user=Userods.GetUserByName("Admin",usingEcw);//without checking password.  Makes debugging faster.
                //}
                                #endif
                if (user == null)
                {
                    throw new Exception("Invalid username or password.");
                }
                string command          = "SELECT ValueString FROM preference WHERE PrefName='ProgramVersion'";
                string dbVersionStr     = Db.GetScalar(command);
                string serverVersionStr = Assembly.GetAssembly(typeof(Db)).GetName().Version.ToString(4);
                                #if DEBUG
                if (Assembly.GetAssembly(typeof(Db)).GetName().Version.Build == 0)
                {
                    command      = "SELECT ValueString FROM preference WHERE PrefName='DataBaseVersion'";                     //Using this during debug in the head makes it open fast with less fiddling.
                    dbVersionStr = Db.GetScalar(command);
                }
                                #endif
                if (dbVersionStr != serverVersionStr)
                {
                    throw new Exception("Version mismatch.  Server:" + serverVersionStr + "  Database:" + dbVersionStr);
                }
                Version clientVersion = new Version(clientVersionStr);
                Version serverVersion = new Version(serverVersionStr);
                if (clientVersion > serverVersion)
                {
                    throw new Exception("Version mismatch.  Client:" + clientVersionStr + "  Server:" + serverVersionStr);
                }
                //if clientVersion == serverVersion, than we need do nothing.
                //if clientVersion < serverVersion, than an update will later be triggered.
                //Security.CurUser=user;//we're on the server, so this is meaningless
                return(user);
                //return 0;//meaningless
            }
            else
            {
                //Because RemotingRole has not been set, and because CurUser has not been set,
                //this particular method is more verbose than most and does not use Meth.
                //It's not a good example of the standard way of doing things.
                DtoGetObject dto = new DtoGetObject();
                dto.Credentials          = new Credentials();
                dto.Credentials.Username = oduser;
                dto.Credentials.Password = odpass;              //Userods.EncryptPassword(password);
                dto.MethodName           = "Security.LogInWeb";
                dto.ObjectType           = typeof(Userod).FullName;
                object[] parameters = new object[] { oduser, odpass, configPath, clientVersionStr, usingEcw };
                Type[]   objTypes   = new Type[] { typeof(string), typeof(string), typeof(string), typeof(string), typeof(bool) };
                dto.Params = DtoObject.ConstructArray(parameters, objTypes);
                return(RemotingClient.ProcessGetObject <Userod>(dto));              //can throw exception
            }
        }
Exemplo n.º 9
0
		public string ProcessRequest(string dtoString) {
			//The web service (xml) serializer/deserializer is removing the '\r' portion of our newlines during the data transfer. 
			//Replacing the string is not the best solution but it works for now. The replacing happens here (server side) and after result is returned on the client side.
			//It's done server side for usage purposes within the methods being called (exampe: inserting into db) and then on the client side for displaying purposes.
			dtoString=dtoString.Replace("\n","\r\n");
			#if DEBUG
				//System.Threading.Thread.Sleep(100);//to test slowness issues with web service.
			#endif
			DataTransferObject dto=DataTransferObject.Deserialize(dtoString);
			//XmlSerializer serializer;
			try {
				Type type = dto.GetType();
				if(type == typeof(DtoGetTable)) {
					DtoGetTable dtoGetTable=(DtoGetTable)dto;
					Userods.CheckCredentials(dtoGetTable.Credentials);//will throw exception if fails.
					string className=dtoGetTable.MethodName.Split('.')[0];
					string methodName=dtoGetTable.MethodName.Split('.')[1];
					string assemb=Assembly.GetAssembly(typeof(Db)).FullName;//any OpenDentBusiness class will do.
					Type classType=Type.GetType("OpenDentBusiness."+className+","+assemb);
					DtoObject[] parameters=dtoGetTable.Params;
					Type[] paramTypes=DtoObject.GenerateTypes(parameters,assemb);
					MethodInfo methodInfo=classType.GetMethod(methodName,paramTypes);
					if(methodInfo==null) {
						throw new ApplicationException("Method not found with "+parameters.Length.ToString()+" parameters: "+dtoGetTable.MethodName);
					}
					object[] paramObjs=DtoObject.GenerateObjects(parameters);
					DataTable dt=(DataTable)methodInfo.Invoke(null,paramObjs);
					String response=XmlConverter.TableToXml(dt);
					return response;
				}
				else if(type == typeof(DtoGetTableLow)) {
					DtoGetTableLow dtoGetTableLow=(DtoGetTableLow)dto;
					Userods.CheckCredentials(dtoGetTableLow.Credentials);//will throw exception if fails.
					DtoObject[] parameters=dtoGetTableLow.Params;
					object[] paramObjs=DtoObject.GenerateObjects(parameters);
					DataTable dt=Reports.GetTable((string)paramObjs[0]);
					String response=XmlConverter.TableToXml(dt);
					return response;
				}
				else if(type == typeof(DtoGetDS)) {
					DtoGetDS dtoGetDS=(DtoGetDS)dto;
					Userods.CheckCredentials(dtoGetDS.Credentials);//will throw exception if fails.
					string className=dtoGetDS.MethodName.Split('.')[0];
					string methodName=dtoGetDS.MethodName.Split('.')[1];
					string assemb=Assembly.GetAssembly(typeof(Db)).FullName;//any OpenDentBusiness class will do.
					Type classType=Type.GetType("OpenDentBusiness."+className+","+assemb);
					DtoObject[] parameters=dtoGetDS.Params;
					Type[] paramTypes=DtoObject.GenerateTypes(parameters,assemb);
					MethodInfo methodInfo=classType.GetMethod(methodName,paramTypes);
					if(methodInfo==null) {
						throw new ApplicationException("Method not found with "+parameters.Length.ToString()+" parameters: "+dtoGetDS.MethodName);
					}
					object[] paramObjs=DtoObject.GenerateObjects(parameters);
					DataSet ds=(DataSet)methodInfo.Invoke(null,paramObjs);
					String response=XmlConverter.DsToXml(ds);
					return response;
				}
				else if(type == typeof(DtoGetLong)) {
					DtoGetLong dtoGetLong=(DtoGetLong)dto;
					Userods.CheckCredentials(dtoGetLong.Credentials);//will throw exception if fails.
					string className=dtoGetLong.MethodName.Split('.')[0];
					string methodName=dtoGetLong.MethodName.Split('.')[1];
					string assemb=Assembly.GetAssembly(typeof(Db)).FullName;//any OpenDentBusiness class will do.
					Type classType=Type.GetType("OpenDentBusiness."+className+","+assemb);
					DtoObject[] parameters=dtoGetLong.Params;
					Type[] paramTypes=DtoObject.GenerateTypes(parameters,assemb);
					MethodInfo methodInfo=classType.GetMethod(methodName,paramTypes);
					if(methodInfo==null) {
						throw new ApplicationException("Method not found with "+parameters.Length.ToString()+" parameters: "+dtoGetLong.MethodName);
					}
					object[] paramObjs=DtoObject.GenerateObjects(parameters);
					long longResult=(long)methodInfo.Invoke(null,paramObjs);
					return longResult.ToString();
				}
				else if(type == typeof(DtoGetInt)) {
					DtoGetInt dtoGetInt=(DtoGetInt)dto;
					Userods.CheckCredentials(dtoGetInt.Credentials);//will throw exception if fails.
					string className=dtoGetInt.MethodName.Split('.')[0];
					string methodName=dtoGetInt.MethodName.Split('.')[1];
					string assemb=Assembly.GetAssembly(typeof(Db)).FullName;//any OpenDentBusiness class will do.
					Type classType=Type.GetType("OpenDentBusiness."+className+","+assemb);
					DtoObject[] parameters=dtoGetInt.Params;
					Type[] paramTypes=DtoObject.GenerateTypes(parameters,assemb);
					MethodInfo methodInfo=classType.GetMethod(methodName,paramTypes);
					if(methodInfo==null) {
						throw new ApplicationException("Method not found with "+parameters.Length.ToString()+" parameters: "+dtoGetInt.MethodName);
					}
					object[] paramObjs=DtoObject.GenerateObjects(parameters);
					int intResult=(int)methodInfo.Invoke(null,paramObjs);
					return intResult.ToString();
				}
				else if(type == typeof(DtoGetVoid)) {
					DtoGetVoid dtoGetVoid=(DtoGetVoid)dto;
					Userods.CheckCredentials(dtoGetVoid.Credentials);//will throw exception if fails.
					string className=dtoGetVoid.MethodName.Split('.')[0];
					string methodName=dtoGetVoid.MethodName.Split('.')[1];
					string assemb=Assembly.GetAssembly(typeof(Db)).FullName;//any OpenDentBusiness class will do.
					Type classType=Type.GetType("OpenDentBusiness."+className+","+assemb);
					DtoObject[] parameters=dtoGetVoid.Params;
					Type[] paramTypes=DtoObject.GenerateTypes(parameters,assemb);
					MethodInfo methodInfo=classType.GetMethod(methodName,paramTypes);
					if(methodInfo==null) {
						throw new ApplicationException("Method not found with "+parameters.Length.ToString()+" parameters: "+dtoGetVoid.MethodName);
					}
					object[] paramObjs=DtoObject.GenerateObjects(parameters);
					methodInfo.Invoke(null,paramObjs);
					return "0";
				}
				else if(type == typeof(DtoGetObject)) {
					DtoGetObject dtoGetObject=(DtoGetObject)dto;
					string className=dtoGetObject.MethodName.Split('.')[0];
					string methodName=dtoGetObject.MethodName.Split('.')[1];
					if(className != "Security" || methodName != "LogInWeb") {//because credentials will be checked inside that method
						Userods.CheckCredentials(dtoGetObject.Credentials);//will throw exception if fails.
					}
					string assemb=Assembly.GetAssembly(typeof(Db)).FullName;//any OpenDentBusiness class will do.
					Type classType=Type.GetType("OpenDentBusiness."+className+","+assemb);
					DtoObject[] parameters=dtoGetObject.Params;
					Type[] paramTypes=DtoObject.GenerateTypes(parameters,assemb);
					MethodInfo methodInfo=classType.GetMethod(methodName,paramTypes);
					if(methodInfo==null) {
						throw new ApplicationException("Method not found with "+parameters.Length.ToString()+" parameters: "+dtoGetObject.MethodName);
					}
					if(className=="Security" && methodName=="LogInWeb") {
						string mappedPath=Server.MapPath(".");
						parameters[2]=new DtoObject(mappedPath,typeof(string));//because we can't access this variable from within OpenDentBusiness.
						RemotingClient.RemotingRole=RemotingRole.ServerWeb;
					}
					object[] paramObjs=DtoObject.GenerateObjects(parameters);
					Object objResult=methodInfo.Invoke(null,paramObjs);
					Type returnType=methodInfo.ReturnType;
					return XmlConverter.Serialize(returnType,objResult);
				}
				else if(type == typeof(DtoGetString)) {
					DtoGetString dtoGetString=(DtoGetString)dto;
					Userods.CheckCredentials(dtoGetString.Credentials);//will throw exception if fails.
					string className=dtoGetString.MethodName.Split('.')[0];
					string methodName=dtoGetString.MethodName.Split('.')[1];
					string assemb=Assembly.GetAssembly(typeof(Db)).FullName;//any OpenDentBusiness class will do.
					Type classType=Type.GetType("OpenDentBusiness."+className+","+assemb);
					DtoObject[] parameters=dtoGetString.Params;
					Type[] paramTypes=DtoObject.GenerateTypes(parameters,assemb);
					MethodInfo methodInfo=classType.GetMethod(methodName,paramTypes);
					if(methodInfo==null) {
						throw new ApplicationException("Method not found with "+parameters.Length.ToString()+" parameters: "+dtoGetString.MethodName);
					}
					object[] paramObjs=DtoObject.GenerateObjects(parameters);
					string strResult=(string)methodInfo.Invoke(null,paramObjs);
					//strResult=strResult.Replace("\r","\\r");
					//return XmlConverter.Serialize(typeof(string),strResult);
					return strResult;
				}
				else if(type == typeof(DtoGetBool)) {
					DtoGetBool dtoGetBool=(DtoGetBool)dto;
					Userods.CheckCredentials(dtoGetBool.Credentials);//will throw exception if fails.
					string className=dtoGetBool.MethodName.Split('.')[0];
					string methodName=dtoGetBool.MethodName.Split('.')[1];
					string assemb=Assembly.GetAssembly(typeof(Db)).FullName;//any OpenDentBusiness class will do.
					Type classType=Type.GetType("OpenDentBusiness."+className+","+assemb);
					DtoObject[] parameters=dtoGetBool.Params;
					Type[] paramTypes=DtoObject.GenerateTypes(parameters,assemb);
					MethodInfo methodInfo=classType.GetMethod(methodName,paramTypes);
					if(methodInfo==null) {
						throw new ApplicationException("Method not found with "+parameters.Length.ToString()+" parameters: "+dtoGetBool.MethodName);
					}
					object[] paramObjs=DtoObject.GenerateObjects(parameters);
					bool boolResult=(bool)methodInfo.Invoke(null,paramObjs);
					return boolResult.ToString();
				}
				else {
					throw new NotSupportedException("Dto type not supported: "+type.FullName);
				}
			}
			catch(Exception e) {
				DtoException exception = new DtoException();
				if(e.InnerException==null) {
					exception.Message = e.Message;
				}
				else {
					exception.Message = e.InnerException.Message;
				}
				return exception.Serialize();
			}
		}