public void Open(string logicName, bool paramAutoRegister = true, string appID = "CitydiXFS", string lowVersion = "3.0", string highVersion = "3.0") { try { Task.Run(() => { L4Logger.Info("xfs to open service => " + logicName); }); serviceName = logicName; autoRegister = paramAutoRegister; int requestVersion = XFSUtil.ParseVersionString(lowVersion, highVersion); WFSVERSION srvcVersion = new WFSVERSION(); WFSVERSION spVersion = new WFSVERSION(); int hResult = 0; if (!isStartup) { hResult = XfsApi.WFSStartUp(requestVersion, ref spVersion); Task.Run(() => { L4Logger.Info("xfs start result =>" + hResult); }); if (hResult != XFSDefinition.WFS_SUCCESS && hResult != XFSDefinition.WFS_ERR_ALREADY_STARTED) { OnOpenError(hResult); return; } } appID = "Citydi"; Task.Run(() => { L4Logger.Info(string.Format( "logicName {0} appID {1} hService {2} MessageHandle {3} requestVersion {4} srvcVersion {5} spVersion {6} requestID {7}", logicName, appID, hService, MessageHandle, requestVersion, srvcVersion, spVersion, requestID)); }); //hResult= XfsApi.WFSOpen(logicName, IntPtr.Zero, appID, XFSDefinition.WFS_TRACE_API, XFSConstants.WFS_INDEFINITE_WAIT, requestVersion, ref srvcVersion, ref spVersion, ref hService); //L4Logger.Info(string.Format(" service {0} WFSOpen resule {1}", logicName, hResult)); hResult = XfsApi.WFSAsyncOpen(logicName, IntPtr.Zero, appID, XFSDefinition.WFS_TRACE_ALL_API, XFSConstants.WFS_INDEFINITE_WAIT, ref hService, MessageHandle, requestVersion, ref srvcVersion, ref spVersion, ref requestID); Task.Run(() => { L4Logger.Info(string.Format(" service {0} WFSAsyncOpen resule {1}", logicName, hResult)); }); if (hResult != XFSDefinition.WFS_SUCCESS) { OnOpenError(hResult); } } catch (Win32Exception ex) { L4Logger.Info(ex); } catch (Exception ex) { L4Logger.Error(ex); OnOpenError(-10000); } }
public static extern int WFSStartUp(int dwVersionsRequired, ref WFSVERSION lpWFSVersion);
public static extern int WFSAsyncOpen(string lpszLogicalName, IntPtr hApp, string lpszAppID, int dwTraceLevel, int dwTimeOut, ref ushort lphService, IntPtr hWnd, int dwSrvcVersionsRequired, ref WFSVERSION lpSrvcVersion, ref WFSVERSION lpSPIVersion, ref int lpRequestID);