/// <summary> /// Build MetaTable /// </summary> /// <param name="name"></param> /// <returns></returns> public MetaTable GetMetaTable(string name) { MetaTable mt; if (ServiceFacade.UseRemoteServices) { Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = ServiceFacade.InvokeNativeMethod(nativeClient, (int)Services.Native.ServiceCodes.MobiusMetaTableService, (int)Services.Native.ServiceOpCodes.MobiusMetaTableService.GetMetaTable, new Services.Native.NativeMethodTransportObject(new object[] { name })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); if (resultObject == null || resultObject.Value == null) { return(null); } string serializedMt = resultObject.Value.ToString(); mt = MetaTable.Deserialize(serializedMt); return(mt); } else { int t0 = TimeOfDay.Milliseconds(); mt = MetaTableFactoryInstance.GetMetaTable(name); //DebugLog.TimeMessage("MetaTableFactory.GetMetaTable " + name + ", time = ", t0); return(mt); } }
/// <summary> /// GetServiceVersion /// </summary> /// <returns></returns> public string GetServiceVersion() { if (UseMobiusServices) { Services.Native.INativeSession nativeClient = CreateNativeSessionProxy(); string serviceVersion = nativeClient.GetCurrentVersionNumber(); ((System.ServiceModel.IClientChannel)nativeClient).Close(); return(serviceVersion); } else // just return version of this assembly { string version = Assembly.GetExecutingAssembly().GetName().Version.ToString(); return(version); } }
/// <summary> /// Initialize the MetaTableFactory /// </summary> public static void Initialize() { if (ServiceFacade.UseRemoteServices) { Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = nativeClient.InvokeNativeMethod( (int)Services.Native.ServiceCodes.MobiusMetaTableService, (int)Services.Native.ServiceOpCodes.MobiusMetaTableService.Initialize, new Mobius.Services.Native.NativeMethodTransportObject(new object[] { false })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); return; } else { Mfn.MetaTableFactory.Initialize(); } }
/// <summary> /// Freshen session /// </summary> /// <returns>Updated Session object</returns> public Session FreshenSession() { if (UseMobiusServices) { if (LogServiceCalls) { DebugLog.Message("Freshening session: " + Session.Id); } Services.Native.INativeSession nativeClient = CreateNativeSessionProxy(); Session session = nativeClient.FreshenSession(Session); ((System.ServiceModel.IClientChannel)nativeClient).Close(); return(session); } else { return(Session); // just return current session } }
/// <summary> /// Load/reload from specified file /// </summary> public void BuildFromFile(string fileName) { if (ServiceFacade.UseRemoteServices) { MetaTableCollection.Reset(); // reset local collection string serverFile = ServerFile.GetTempFileName(".xml", true); ServerFile.CopyToServer(fileName, serverFile); Services.Native.INativeSession nativeClient = ServiceFacade.CreateNativeSessionProxy(); Services.Native.NativeMethodTransportObject resultObject = nativeClient.InvokeNativeMethod( (int)Services.Native.ServiceCodes.MobiusMetaTableService, (int)Services.Native.ServiceOpCodes.MobiusMetaTableService.BuildFromFile, new Mobius.Services.Native.NativeMethodTransportObject(new object[] { serverFile })); ((System.ServiceModel.IClientChannel)nativeClient).Close(); } else // just do local build { Mobius.MetaFactoryNamespace.MetaTableFactory.BuildFromXmlFile(fileName); } }
/// <summary> /// DisposeSession /// </summary> public void DisposeSession() { if (Session != null) { try { if (DebugNativeSessionHost) { return; // don't exit if debugging native session to allow faster restart of the client } Services.Native.INativeSession nativeClient = CreateNativeSessionProxy(); nativeClient.DisposeSession(Session); ((System.ServiceModel.IClientChannel)nativeClient).Close(); } catch (Exception ex) { ex = ex; //no need to report failure // application should be running down, so this was the last/only chance to clean up the server-side // disposing a NATIVE session actually results in a legitimate exception // ie, the other end of the conversation dies before it can return! } } }