Exemplo n.º 1
0
 public void OnRegisterError(PushwooshError error)
 {
     RegisterError?.Invoke(this, error);
 }
 protected virtual void OnRegisterError(PrinterEventArgs e)
 {
     RegisterError?.Invoke(this, e);
 }
Exemplo n.º 3
0
        private void ParsCommand(XfsCommandBase <object> commandBase)
        {
            switch (commandBase.CommandType)
            {
            case CommandType.Execute:
            {
                blockingQueue.Clear();
                var cmnd = JsonConvert.DeserializeObject <ExecuteCommand>(JsonConvert.SerializeObject(commandBase.XfsCommand));
                if (commandBase.IsExecuteSuccessfully)
                {
                    if (cmnd.CommandCode == BCRDefinition.WFS_CMD_BCR_READ)
                    {
                        blockingQueue.Clear();
                        try
                        {
                            var data = XFSUtil.Cast <BarcodeData[]>(cmnd.ResultModel)[0].Value;
                            ReadDataCompleted?.Invoke(data);
                        }
                        catch (Exception ex)
                        {
                            L4Logger.Error(ex);
                            //MediaError.Invoke();
                        }
                    }
                }
                else
                {
                    if (commandBase.ErrorCode == XFSDefinition.WFS_ERR_CANCELED)
                    {
                        return;
                    }
                    if (cmnd.CommandCode == BCRDefinition.WFS_CMD_BCR_READ)
                    {
                        ReadDataError?.Invoke("BCR", commandBase.ErrorCode, commandBase.ErrorCode.ToString());
                        //if (workingMode == WorkingMode.None || workingMode == WorkingMode.EjectCard)
                        //    return;
                        //else
                        //    ReadRawDataError?.Invoke("IDC", commandBase.ErrorCode, commandBase.ErrorCode.ToString());

                        //workingMode = WorkingMode.None;
                    }
                }
                break;
            }

            case CommandType.Open:
            {
                var cmnd = JsonConvert.DeserializeObject <OpenCommand>(JsonConvert.SerializeObject(commandBase.XfsCommand));
                if (commandBase.IsExecuteSuccessfully)
                {
                    if (commandBase.Detail.Equals("XFSDevice_OpenComplete"))
                    {
                        IsOpenned = true;
                        OpenCompleted?.Invoke();
                    }
                    if (commandBase.Detail.Equals("XFSDevice_RegisterComplete"))
                    {
                        RegisterCompleted?.Invoke();
                    }
                }
                else
                {
                    if (commandBase.Detail.Equals("XFSDevice_OpenError"))
                    {
                        IsOpenned = false;
                        OpenError?.Invoke(commandBase.ErrorCode);
                    }
                    if (commandBase.Detail.Equals("XFSDevice_RegisterError"))
                    {
                        RegisterError?.Invoke(commandBase.ErrorCode);
                    }
                }
                break;
            }

            case CommandType.Getinfo:
            {
                var cmnd = JsonConvert.DeserializeObject <GetInfoCommand>(JsonConvert.SerializeObject(commandBase.XfsCommand));
                GetInfoResponse?.Invoke(XFSUtil.Cast <WFSBCRSTATUS>(cmnd.Status), null);
                break;
            }
            }
        }