예제 #1
0
 protected virtual void OnExecuteEvent(ref WFSRESULT result)
 {
     //Task.Run(() => { L4Logger.Info("OnExecuteEvent  ServiceName => " + serviceName); });
     if (ExecuteEvent != null)
     {
         ExecuteEvent.Invoke(serviceType, result.dwCommandCodeOrEventID, result.lpBuffer);
     }
 }
예제 #2
0
 protected virtual void OnExecuteComplete(ref WFSRESULT result, int EventID)
 {
     //Task.Run(() => { L4Logger.Info("OnExecuteComplete  ServiceName => " + serviceName); });
     if (result.hResult == 0)
     {
         if (ExecuteComplete != null)
         {
             ExecuteComplete?.Invoke(serviceType, result.lpBuffer, EventID);
         }
     }
     else
     {
         if (ExecuteCompleteError != null)
         {
             ExecuteCompleteError?.Invoke(serviceType, result.hResult);
         }
     }
 }
예제 #3
0
        protected virtual bool InnerGetInfo <T>(int category, IntPtr inParam, Type type, out T value)
        {
            IntPtr pOutParam = IntPtr.Zero;

            value = (T)Activator.CreateInstance(type);
            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)((ISTATUS)value).UnMarshal(wfsResult.lpBuffer);
                    XfsApi.WFSFreeResult(pOutParam);
                    return(true);
                }
            }
            XfsApi.WFSFreeResult(pOutParam);
            return(false);
        }
예제 #4
0
 protected virtual void OnSystemEvent(ref WFSRESULT result)
 {
 }
예제 #5
0
 protected virtual void OnUserEvent(ref WFSRESULT result)
 {
 }
예제 #6
0
 protected virtual void OnServiceEvent(ref WFSRESULT result)
 {
 }
예제 #7
0
        protected override void WndProc(ref Message m)
        {
            if (m.Msg >= XFSDefinition.WFS_OPEN_COMPLETE &&
                m.Msg <= XFSDefinition.WFS_SYSTEM_EVENT)
            {
                var msg = m.Msg;
                Task.Run(() => { L4Logger.Info(string.Format("Xfs WndProc ServiceName {0} msg {1} ", ServiceName, msg)); });
                WFSRESULT result = new WFSRESULT();
                if (m.LParam != IntPtr.Zero)
                {
                    XFSUtil.PtrToStructure(m.LParam, ref result);
                }
                switch (m.Msg)
                {
                case XFSDefinition.WFS_OPEN_COMPLETE:
                {
                    Task.Run(() => { L4Logger.Info("OpenCompleted =>  " + serviceType.ToString()); });
                    OnOpenComplete();
                }
                break;

                case XFSDefinition.WFS_CLOSE_COMPLETE:
                    OnCloseComplete();
                    break;

                case XFSDefinition.WFS_REGISTER_COMPLETE:
                {
                    Task.Run(() => { L4Logger.Info("RegisterCompleted =>  " + serviceType.ToString()); });
                    OnRegisterComplete();
                }
                break;

                case XFSDefinition.WFS_EXECUTE_COMPLETE:
                    Task.Run(() => { L4Logger.Info(string.Format("ExecuteCompleted  Service => {0} CommandCode => {1} ",
                                                                 serviceType.ToString(), result.dwCommandCodeOrEventID)); });

                    if (commandHandlers.Contains(result.dwCommandCodeOrEventID))
                    {
                        OnExecuteComplete(ref result, result.dwCommandCodeOrEventID);
                    }
                    break;

                case XFSDefinition.WFS_EXECUTE_EVENT:
                case XFSDefinition.WFS_SERVICE_EVENT:
                case XFSDefinition.WFS_USER_EVENT:
                case XFSDefinition.WFS_SYSTEM_EVENT:
                    Task.Run(() => { L4Logger.Info(string.Format("WFS_SYSTEM_EVENT servicename {0}  lpBuffer {1} EventId => ",
                                                                 serviceName, result.lpBuffer, result.dwCommandCodeOrEventID)); });
                    if (eventHandlers.Contains(result.dwCommandCodeOrEventID))
                    {
                        OnExecuteEvent(ref result);
                    }
                    else
                    {
                        Task.Run(() =>
                        {
                            L4Logger.Info(string.Format("EventId = {0} AcceptsEvents = {1}",
                                                        result.dwCommandCodeOrEventID,
                                                        string.Join(",", eventHandlers.ToArray())));
                        });
                    }
                    break;
                }
                XfsApi.WFSFreeResult(ref result);
            }
            else
            {
                base.WndProc(ref m);
            }
        }
예제 #8
0
 public static extern int WFSFreeResult(ref WFSRESULT lpResult);