예제 #1
0
        /// <summary>
        /// Read database header for a database id
        /// </summary>
        /// <param name="databaseId"></param>
        /// <returns></returns>

        public UcdbDatabase SelectDatabaseHeader(
            long databaseId)
        {
            if (ServiceFacade.UseRemoteServices)
            {
                Mobius.Services.Native.INativeSession       nativeClient = ServiceFacade.CreateNativeSessionProxy();
                Services.Native.NativeMethodTransportObject resultObject =
                    ServiceFacade.InvokeNativeMethod(nativeClient,
                                                     (int)Services.Native.ServiceCodes.MobiusUserCmpndDbService,
                                                     (int)Services.Native.ServiceOpCodes.MobiusUserCmpndDbService.SelectDatabaseHeaderByDatabaseId,
                                                     new Services.Native.NativeMethodTransportObject(new object[] { databaseId }));
                ((System.ServiceModel.IClientChannel)nativeClient).Close();
                if (resultObject == null)
                {
                    return(null);
                }
                ServiceTypes.UcdbDatabase serviceUcdbDatabase =
                    (ServiceTypes.UcdbDatabase)resultObject.Value;
                UcdbDatabase ucdbDatabase =
                    ServiceFacade.TypeConversionHelper.Convert <ServiceTypes.UcdbDatabase, UcdbDatabase>(serviceUcdbDatabase);
                return(ucdbDatabase);
            }
            else
            {
                return(Instance.SelectDatabaseHeader(databaseId));
            }
        }
예제 #2
0
        /// <summary>
        /// Update the local copy of the Ucdb object with returned values keeping compounds & models if returned as null
        /// </summary>
        /// <param name="resultObject"></param>
        /// <param name="ucdb"></param>

        void UpdateUcdb(
            Services.Native.NativeMethodTransportObject resultObject,
            UcdbDatabase ucdb)
        {
            if (resultObject == null || resultObject.Value == null || ucdb == null)
            {
                return;
            }

            ServiceTypes.UcdbDatabase serviceUcdbDatabase =
                (ServiceTypes.UcdbDatabase)resultObject.Value;
            UcdbDatabase ucdbDatabase =
                ServiceFacade.TypeConversionHelper.Convert <ServiceTypes.UcdbDatabase, UcdbDatabase>(serviceUcdbDatabase);

            UcdbCompound[] compounds = ucdb.Compounds;
            UcdbModel[]    models    = ucdb.Models;
            ObjectEx.MemberwiseCopy(ucdbDatabase, ucdb);             // copy values back
            if (ucdb.Compounds == null)
            {
                ucdb.Compounds = compounds;
            }
            if (ucdb.Models == null)
            {
                ucdb.Models = models;
            }
            return;
        }
예제 #3
0
        /// <summary>
        /// Update the compounds for a database
        /// </summary>
        /// <param name="ucdb"></param>
        /// <param name="cpds"></param>
        /// <returns>New number of compounds in database</returns>

        public void UpdateDatabaseCompounds(
            UcdbDatabase ucdb,
            UcdbCompound[] cpds)
        {
            if (ServiceFacade.UseRemoteServices)
            {
                ServiceTypes.UcdbDatabase serviceUcdbDatabase =
                    ServiceFacade.TypeConversionHelper.Convert <UcdbDatabase, ServiceTypes.UcdbDatabase>(ucdb);
                ServiceTypes.UcdbCompound[] serviceUcdbCompounds =
                    ServiceFacade.TypeConversionHelper.Convert <UcdbCompound[], ServiceTypes.UcdbCompound[]>(cpds);

                Mobius.Services.Native.INativeSession       nativeClient = ServiceFacade.CreateNativeSessionProxy();
                Services.Native.NativeMethodTransportObject resultObject =
                    ServiceFacade.InvokeNativeMethod(nativeClient,
                                                     (int)Services.Native.ServiceCodes.MobiusUserCmpndDbService,
                                                     (int)Services.Native.ServiceOpCodes.MobiusUserCmpndDbService.UpdateDatabaseCompounds,
                                                     new Services.Native.NativeMethodTransportObject(new object[] { serviceUcdbDatabase, serviceUcdbCompounds }));
                ((System.ServiceModel.IClientChannel)nativeClient).Close();
                UpdateUcdb(resultObject, ucdb);
            }

            else
            {
                Instance.UpdateDatabaseCompounds(ucdb, cpds);
            }
        }