Exemplo n.º 1
0
        /// <summary>
        /// Check the Status of Accepter, and returns it's Error code.
        /// </summary>
        /// <returns></returns>
        public ERR_CODE CheckStatusofAccepter()
        {
            ERR_CODE result;

            if (!internalSerialPort.IsOpen)
            {
                return(ERR_CODE.CannotCheckStatus);
            }

            ChangeMode(Mode.CheckStatus);
            WriteByte(checkstatus);
            int i = 0;

            while (chkedStatus == ERR_CODE.None && i < 10)
            {
                Thread.Sleep(100);
                i++;
            }
            if (i >= 10)
            {
                Logger.Warn("Timeout");
                return(CheckStatusofAccepter());
            }

            result      = chkedStatus;
            chkedStatus = ERR_CODE.None;
            return(result);
        }
Exemplo n.º 2
0
        public BaseResponse(string body)
        {
            JSONObject ob;

            try
            {
                ob = (JSONObject)JSONObject.Parse(body);
            }
            catch (Exception x)
            {
                throw new APIReplyParseException("JSON Parse exception: " + body + "\n" + x.Message);
            }

            if (ob == null)
            {
                throw new APIReplyParseException("JSON Parse exception: " + body);
            }
            else
            {
                this.status     = (bool?)ob["status"];
                this.errCode    = new ERR_CODE((string)ob["errorCode"]);
                this.errorDescr = (string)ob["errorDescr"];
                this.returnData = (JSONAware)ob["returnData"];
                this.customTag  = (string)ob["customTag"];

                if (this.status == null)
                {
                    Console.Error.WriteLine(body);
                    throw new APIReplyParseException("JSON Parse error: " + "\"status\" is null!");
                }

                if ((this.status == null) || ((bool)!this.status))
                {
                    // If status is false check if redirect exists in given response
                    if (ob["redirect"] == null)
                    {
                        if (this.errorDescr == null)
                        {
                            this.errorDescr = ERR_CODE.getErrorDescription(this.errCode.StringValue);
                        }
                        throw new APIErrorResponse(errCode, errorDescr, body);
                    }
                }
            }
        }
Exemplo n.º 3
0
 public AddUserMessageResponse(ERR_CODE code, string token)
 {
     Code = code;
     Token = token;
 }
Exemplo n.º 4
0
        private void ReceivedData(object sender, SerialDataReceivedEventArgs e)
        {
            if (rawData != null)
            {
                List <byte> currentBuffer = rawData.ToList();
                ByteLog(currentBuffer);
                if (currentBuffer.Count > 0)
                {
                    if (mode != Mode.CheckStatus && System.Enum.IsDefined(typeof(CRITICAL_ERRORS), (int)currentBuffer[0]))
                    {
                        ChangeMode(Mode.Reset);
                        tempReset = true;
                        rawData   = null;
                    }

                    if (mode == Mode.Idle)
                    {
                        if (currentBuffer.Contains(sendBillValidated))
                        {
                            if (currentBuffer.Count > 1)
                            {
                                WriteByte(hold);
                                billType = currentBuffer[currentBuffer.IndexOf(sendBillValidated) + 1];
                                WriteByte(accept);
                            }
                            ChangeMode(Mode.Accepting);
                            rawData = null;
                        }
                    }
                    else if (mode == Mode.Accepting)
                    {
                        if (currentBuffer.Contains(stacking))
                        {
                            rawData = null;
                            AcceptBill();
                            ChangeMode(Mode.Idle);
                        }
                        else if (currentBuffer.Contains(billType1) || currentBuffer.Contains(billType2) || currentBuffer.Contains(billType3) || currentBuffer.Contains(billType4) || currentBuffer.Contains(billType5))
                        {
                            WriteByte(hold);
                            billType = currentBuffer[0];
                            rawData  = null;
                            WriteByte(accept);
                        }
                    }
                    else if (mode == Mode.Reset)
                    {
                        if (tempReset)
                        {
                            WriteByte(accept);
                            rawData = null;
                            ChangeMode(Mode.Idle);
                            Thread.Sleep(100);
                            EnableAccepter();
                            tempReset = false;
                        }
                        else
                        {
                            if (currentBuffer.Contains(powerSupplyOn1) && currentBuffer.Contains(powerSupplyOn2))
                            {
                                WriteByte(accept);
                                rawData = null;
                                ChangeMode(Mode.Idle);
                                Thread.Sleep(100);
                                DisableAccepter();
                            }
                            else if (currentBuffer.Contains(powerSupplyOn1) || currentBuffer.Contains(powerSupplyOn2))
                            {
                                if (twiceReset == false)
                                {
                                    Logger.Info("Only One PSO signal. wait again");
                                    WriteByte(accept);
                                    rawData    = null;
                                    twiceReset = true;
                                }
                                else
                                {
                                    Logger.Info("PSO signal again. Get Twice");
                                    WriteByte(accept);
                                    rawData = null;
                                    ChangeMode(Mode.Idle);
                                    Thread.Sleep(100);
                                    DisableAccepter();
                                    twiceReset = false;
                                }
                            }
                        }
                    }

                    if (mode == Mode.CheckStatus)
                    {
                        chkedStatus = (ERR_CODE)(int)currentBuffer[0];
                        rawData     = null;
                        ChangeMode(Mode.Idle);
                    }
                }
                else if (rawData != null)
                {
                    byte[] buffer = new byte[internalSerialPort.BytesToRead];
                    internalSerialPort.Read(buffer, 0, internalSerialPort.BytesToRead);
                    if (buffer != null)
                    {
                        rawData.Concat(buffer);
                    }
                    ByteLog(currentBuffer);
                }
            }
            else
            {
                byte[] buffer = new byte[internalSerialPort.BytesToRead];
                internalSerialPort.Read(buffer, 0, internalSerialPort.BytesToRead);
                rawData = (byte[])buffer.Clone();
                ReceivedData(sender, e);
            }
        }
Exemplo n.º 5
0
 public APIErrorResponse(ERR_CODE code, string errDesc, string msg) : base(msg)
 {
     this.code    = code;
     this.errDesc = errDesc;
     this.msg     = msg;
 }
Exemplo n.º 6
0
        protected void btnConfirmSale_Click(object sender, EventArgs e)
        {
            try
            {
                //#warning 代码生成警告:请检查确认真实主键的名称和类型是否正确
                string orderid  = DateTime.Now.ToString("yyyyMMddHHmmss");
                var    lstModel = new List <Jium.Model.piorecord>();

                for (int i = 0; i < gridViewBuy.Rows.Count; i++)
                {
                    var model = new Jium.Model.piorecord();
                    model.pcode      = gridViewBuy.Rows[i].Cells[0].Text;
                    model.pios3      = gridViewBuy.Rows[i].Cells[1].Text;
                    model.psaleprice = decimal.Parse(gridViewBuy.Rows[i].Cells[3].Text);
                    model.pcnt       = int.Parse(gridViewBuy.Rows[i].Cells[5].Text);
                    model.pzekou     = decimal.Parse(gridViewBuy.Rows[i].Cells[6].Text);
                    model.psalerid   = 0;
                    model.ptype      = (int)PRODUCT_IO_TYPE.SALE;;
                    model.ptime      = orderid;
                    model.pguestid   = int.Parse(txtCcode.Text);
                    var txtNum = gridViewBuy.Rows[i].Cells[4].Text.Trim();
                    model.piod1 = string.IsNullOrWhiteSpace(txtNum.Replace("&nbsp;", "")) ? 0 : int.Parse(gridViewBuy.Rows[i].Cells[4].Text); //服务
                    model.pios4 = gridViewBuy.Rows[i].Cells[2].Text.Replace("&nbsp;", "");                                                    //单位
                    model.piod5 = 5;                                                                                                          //model.pios5 = cells[i, 0].StringValue.Trim();//系列
                    model.pios1 = "销售";
                    lstModel.Add(model);
                }
                ERR_CODE iRes = ERR_CODE.SUCCESS;
                ///事务回滚机制???
                var bllCustomeService = new Jium.BLL.consumerservice();
                foreach (var model in lstModel)
                {
                    if (!Ctrl.piorecord.AddPiorecord(model))
                    {
                        iRes = ERR_CODE.FAIL;
                        break;
                    }
                    if (model.piod1 > 0)//add service for guset
                    {
                        var consumerservice = new Jium.Model.consumerservice();
                        consumerservice.ccode      = model.pguestid.ToString();
                        consumerservice.csnum      = model.piod1 ?? 0;
                        consumerservice.cstype     = model.pios3;
                        consumerservice.csleft     = model.piod1 ?? 0;
                        consumerservice.csiostatus = 0;
                        consumerservice.cstime0    = orderid;
                        consumerservice.csd5       = "5";
                        bllCustomeService.Add(consumerservice);
                    }
                }
                //update guest info
                var consumerBll = new Jium.BLL.consumer();
                var lstConsumer = consumerBll.GetModelList(string.Format("ccode='{0}' and csd5=5", txtCcode.Text.Trim()));
                if (lstConsumer.Count == 0)
                {
                    ///error
                    ///return;
                }
                lstConsumer[0].css1   = orderid;
                lstConsumer[0].csum  += decimal.Parse(txtSumReal.Text);
                lstConsumer[0].clevel = Jium.BLL.consumer.getLevelByConsume(lstConsumer[0].csum).ToString();//get from csum
                consumerBll.Update(lstConsumer[0]);

                Maticsoft.Common.MessageBox.ShowAndRedirects(this, "操作完成!", "/default.aspx");
            }
            catch (Exception ex)
            {
                Maticsoft.Common.MessageBox.Show(this, "系统错误:" + ex.Message);
                return;
            }
        }