Exemplo n.º 1
0
        public void Open(string logicName, bool paramAutoRegister = true,
                         string appID       = "XFS.NET", string lowVersion = "3.0",
                         string highVersion = "3.0")
        {
            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);
                if (hResult != XFSDefinition.WFS_SUCCESS &&
                    hResult != XFSDefinition.WFS_ERR_ALREADY_STARTED)
                {
                    OnOpenError(hResult);
                    return;
                }
            }
            hResult = XfsApi.WFSAsyncOpen(logicName, IntPtr.Zero, appID, 0,
                                          XFSConstants.WFS_INDEFINITE_WAIT, ref hService,
                                          MessageHandle, requestVersion, ref srvcVersion, ref spVersion,
                                          ref requestID);
            if (hResult != XFSDefinition.WFS_SUCCESS)
            {
                OnOpenError(hResult);
            }
        }
Exemplo n.º 2
0
        protected void ExecuteCommand(int commandCode, IntPtr ptrParam, Action <string, int, string> errorHandler = null)
        {
            int hResult = XfsApi.WFSAsyncExecute(hService, commandCode, ptrParam, TimeOut, MessageHandle, ref requestID);

            if (hResult != XFSDefinition.WFS_SUCCESS && errorHandler != null)
            {
                errorHandler(serviceName, hResult, string.Empty);
            }
        }
Exemplo n.º 3
0
        protected void InnerRegister(int eventClasses)
        {
            int hResult = XfsApi.WFSAsyncRegister(hService, eventClasses, MessageHandle
                                                  , MessageHandle, ref requestID);

            if (hResult != XFSDefinition.WFS_SUCCESS)
            {
                OnRegisterError(hResult);
            }
        }
Exemplo n.º 4
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg >= XFSDefinition.WFS_OPEN_COMPLETE &&
                m.Msg <= XFSDefinition.WFS_SYSTEM_EVENT)
            {
                WFSRESULT result = new WFSRESULT();
                if (m.LParam != IntPtr.Zero)
                {
                    XFSUtil.PtrToStructure(m.LParam, ref result);
                }
                switch (m.Msg)
                {
                case XFSDefinition.WFS_OPEN_COMPLETE:
                    OnOpenComplete();
                    break;

                case XFSDefinition.WFS_CLOSE_COMPLETE:
                    OnCloseComplete();
                    break;

                case XFSDefinition.WFS_REGISTER_COMPLETE:
                    OnRegisterComplete();
                    break;

                case XFSDefinition.WFS_EXECUTE_COMPLETE:
                    OnExecuteComplete(ref result);
                    break;

                case XFSDefinition.WFS_EXECUTE_EVENT:
                case XFSDefinition.WFS_SERVICE_EVENT:
                case XFSDefinition.WFS_USER_EVENT:
                case XFSDefinition.WFS_SYSTEM_EVENT:
                    if (eventHandlers.ContainsKey(result.dwCommandCodeOrEventID))
                    {
                        var temp = eventHandlers[result.dwCommandCodeOrEventID];
                        if (temp.EventHandler != null)
                        {
                            temp.EventHandler();
                        }
                        else if (temp.SubRoutine != null)
                        {
                            temp.SubRoutine(result.lpBuffer);
                        }
                    }
                    break;
                }
                XfsApi.WFSFreeResult(ref result);
            }
            else
            {
                base.WndProc(ref m);
            }
        }
Exemplo n.º 5
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg >= XFSDefinition.WFS_OPEN_COMPLETE &&
                m.Msg <= XFSDefinition.WFS_TIMER_EVENT)
            {
                WFSRESULT result = new WFSRESULT();
                if (m.LParam != IntPtr.Zero)
                {
                    XFSUtil.PtrToStructure(m.LParam, ref result);
                }
                switch (m.Msg)
                {
                case XFSDefinition.WFS_OPEN_COMPLETE:
                    OnOpenComplete();
                    break;

                case XFSDefinition.WFS_CLOSE_COMPLETE:
                    OnCloseComplete();
                    break;

                case XFSDefinition.WFS_REGISTER_COMPLETE:
                    OnRegisterComplete();
                    break;

                case XFSDefinition.WFS_EXECUTE_COMPLETE:
                    OnExecuteComplete(ref result);
                    break;

                case XFSDefinition.WFS_EXECUTE_EVENT:
                    OnExecuteEvent(ref result);
                    break;

                case XFSDefinition.WFS_SERVICE_EVENT:
                    OnServiceEvent(ref result);
                    break;

                case XFSDefinition.WFS_USER_EVENT:
                    OnUserEvent(ref result);
                    break;

                case XFSDefinition.WFS_SYSTEM_EVENT:
                    OnSystemEvent(ref result);
                    break;
                }
                XfsApi.WFSFreeResult(ref result);
            }
            else
            {
                base.WndProc(ref m);
            }
        }
Exemplo n.º 6
0
        protected virtual bool InnerGetInfo <T>(int category, IntPtr inParam, out T value)
        {
            IntPtr pOutParam = IntPtr.Zero;

            value = default(T);
            int hResult = XfsApi.WFSGetInfo(hService, category, inParam, TimeOut, ref pOutParam);

            if (hResult == XFSDefinition.WFS_SUCCESS)
            {
                WFSRESULT wfsResult = (WFSRESULT)Marshal.PtrToStructure(pOutParam, typeof(WFSRESULT));
                if (wfsResult.hResult == XFSDefinition.WFS_SUCCESS)
                {
                    value = (T)Marshal.PtrToStructure(wfsResult.lpBuffer, typeof(T));
                    return(true);
                }
            }
            XfsApi.WFSFreeResult(pOutParam);
            return(false);
        }
Exemplo n.º 7
0
 public void Cancel()
 {
     XfsApi.WFSCancelAsyncRequest(hService, requestID);
 }