public async Task Update(PosDTO posDto)
        {
            BasicCheck(posDto ?? throw new ArgumentNullException());
            var updatePos = await DbContext.Pos
                            .Where(p => p.PosId == posDto.PosId)
                            .Include(p => p.PosShift)
                            .SingleOrDefaultAsync();

            if (updatePos == null)
            {
                throw new BussinessException($"Cant find POS: {posDto.PosId}");
            }
            //If changes BDS then check BDS
            if (posDto.BDS.UserId != updatePos.UserId)
            {
                await CheckUser(posDto.BDS?.UserId, RoleEnum.BDS, true);
            }
            updatePos.PosCode = posDto.PosCode;
            updatePos.PosName = posDto.PosName;
            updatePos.Address = posDto.Address;
            updatePos.UserId  = posDto.BDS.UserId;
            updatePos.Phone   = posDto.Phone;
            //Replace with updated shifts
            updatePos.PosShift.Clear();
            updatePos.PosShift.AddRange(posDto.Shifts.Select(s => new PosShift()
            {
                ShiftId = s.ShiftId
            }));
            await DbContext.SaveChangesAsync();
        }
        public async Task <int> Create(PosDTO pos)
        {
            BasicCheck(pos ?? throw new ArgumentNullException());
            //Check Manager
            await CheckUser(pos.BDS?.UserId, RoleEnum.BDS, true);

            var newPos = new Pos()
            {
                PosCode = pos.PosCode.ToUpper(),
                PosName = pos.PosName,
                Address = pos.Address,
                UserId  = pos.BDS.UserId,
                Phone   = pos.Phone
            };

            newPos.PosShift.AddRange(pos.Shifts.Select(s => new PosShift()
            {
                ShiftId = s.ShiftId
            }));
            await DbContext.Pos.AddAsync(newPos);

            await DbContext.SaveChangesAsync();

            return(newPos.PosId);
        }
 private void BasicCheck(PosDTO pos)
 {
     if (pos == null)
     {
         throw new ArgumentNullException();
     }
     //Check for null
     if (string.IsNullOrEmpty(pos.PosName))
     {
         throw new BussinessException($"Missing value: {nameof(Pos.PosName)}");
     }
     if (string.IsNullOrEmpty(pos.PosCode))
     {
         throw new BussinessException($"Missing value: {nameof(Pos.PosCode)}");
     }
     if (pos.Shifts == null || !pos.Shifts.Any())
     {
         throw new BussinessException("POS must have at least 1 shift");
     }
     if (string.IsNullOrEmpty(pos.Address))
     {
         throw new BussinessException($"Missing value: {nameof(Pos.Address)}");
     }
     if (string.IsNullOrEmpty(pos.Phone))
     {
         throw new BussinessException($"Missing value: {nameof(Pos.Phone)}");
     }
     if (pos.BDS == null)
     {
         throw new BussinessException("Pos must have BDS");
     }
 }
示例#4
0
        public List <PosDTO> GetRegistersDropDownList(PosDTO dto)
        {
            var lista = ObtePostosVendas(dto);

            lista.Insert(0, new PosDTO(-1, "-SELECCIONE-"));
            return(lista);
        }
示例#5
0
        public List <PosDTO> ObterCaixaFechadas(PosDTO dto)
        {
            List <PosDTO> lista = new List <PosDTO>();

            try
            {
                BaseDados.ComandText = "stp_COM_POS_OBTER_CAIXA_FECHADA";
                BaseDados.AddParameter("DATA_HOJE", dto.DataHoje);
                BaseDados.AddParameter("FILIAL", dto.Filial);
                BaseDados.AddParameter("UTILIZADOR", dto.Utilizador);
                BaseDados.AddParameter("ACCAO", dto.Accao);
                MySqlDataReader dr = BaseDados.ExecuteReader();
                while (dr.Read())
                {
                    dto           = new PosDTO();
                    dto.Codigo    = int.Parse(dr[0].ToString());
                    dto.Descricao = dr[1].ToString();
                    lista.Add(dto);
                }
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
                lista            = new List <PosDTO>(); lista.Add(dto);
            }
            finally
            {
                BaseDados.FecharConexao();
            }
            return(lista);
        }
示例#6
0
        private FightRoomDTO fightRoomDTO = null;//缓存战斗房间信息

        /// <summary>
        /// 处理网络消息
        /// </summary>
        /// <param name="sm"></param>
        public override void OnMessageReceived(SocketModel sm)
        {
            switch (sm.command)
            {
            case FightProtocol.START_BRO:
                fightRoomDTO = sm.GetMessage <FightRoomDTO>();
                CreateBattelField(fightRoomDTO);
                Debug.LogError("收到创建战场信息");
                break;

            case FightProtocol.ATK_TO_POS_SCMD:
                PosDTO atkToPosDTO = sm.GetMessage <PosDTO>();
                MgrCenter.Instance.SendMsg(Msgs.GetMsgPos((ushort)SoilderFightEvent.SoilderAtkToPosServerCmd, atkToPosDTO));
                break;

            case FightProtocol.MOVE_TARGET_SRES:
                PosDTO moveToTargetDTO = sm.GetMessage <PosDTO>();
                MgrCenter.Instance.SendMsg(Msgs.GetMsgPos((ushort)MoveEvent.MoveServerRes, moveToTargetDTO));
                break;

            case FightProtocol.SKILL_UP_SRES:

                break;

            case FightProtocol.POS_SYNC_BRO:
                PosSyncDTO posSyncDTO = sm.GetMessage <PosSyncDTO>();
                //得到的PosSync是服务器处理时认可的服务器时间
                //这里将它转化成client认可的时间
                //floating = client - server
                //client = server + floating
                long timeStampClient = GetTimeStampClient(posSyncDTO.timeStamp);
                MgrCenter.Instance.SendMsg(Msgs.GetMsgPosSync((ushort)MoveEvent.PosSync, posSyncDTO.instanceId, new Vector3(posSyncDTO.x, posSyncDTO.y, posSyncDTO.z), new Vector3(posSyncDTO.dirX, posSyncDTO.dirY, posSyncDTO.dirZ), timeStampClient));
                break;

            case FightProtocol.SKILL_BRO:

                break;

            case FightProtocol.ATTACK_BRO:


                break;

            case FightProtocol.DAMAGE_BRO:
                Damage(sm.GetMessage <DamageDTO>());

                break;

            case FightProtocol.IDLE_BRO:
                int idleEntityId = sm.GetMessage <int>();
                MgrCenter.Instance.SendMsg(Msgs.GetMsgInt((ushort)SoilderFightEvent.SoilderIdleServerAllow, idleEntityId));
                break;
            }
        }
示例#7
0
        private void CreatePOS(UtilizadorDTO dto)
        {
            PosDTO oPOS = new PosDTO
            {
                Descricao = dto.Utilizador,
                Estado    = 1,
                Sigla     = "",
                PinCode   = dto.CurrentPassword
            };

            PosRN.GetInstance().CreateNewPOS(oPOS);
        }
示例#8
0
        public IHttpActionResult Activation(PosDTO pos)
        {
            if (!ModelState.IsValid)
            {
                return(GetErrorMsg(1, "Activation Code Missing"));
            }

            PosDTO posDetails = utility.GetPos(pos);

            if (posDetails == null)
            {
                return(GetErrorMsg(2, "Invalid Activation Code"));
            }

            return(Ok(posDetails));
        }
示例#9
0
        public PosDTO ObterPorPK(PosDTO dto)
        {
            try
            {
                dto = ObterPorFiltro(dto).Where(t => t.Codigo == dto.Codigo).SingleOrDefault();
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                BaseDados.FecharConexao();
            }

            return(dto);
        }
示例#10
0
        //return pos details
        public PosDTO GetPos(PosDTO Pos)
        {
            PosDTO posActivation = new PosDTO();
            var    Posdetails    = _db.pos.Where(c => c.ActivationCode == Pos.ActivationCode)
                                   .SingleOrDefault();

            if (Posdetails == null)
            {
                return(posActivation);
            }

            Posdetails.Activation = true;

            _db.SaveChanges();

            posActivation = Mapper.Map <pos, PosDTO>(Posdetails);

            return(posActivation);
        }
 public async Task <IActionResult> Create([FromBody] PosDTO pos)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest());
     }
     try
     {
         return(Ok(await _service.Create(pos)));
     }
     catch (BussinessException ex)
     {
         Helper.Utility.LogException(ex, _logger);
         return(BadRequest(ex.Message));
     }
     catch (DbUpdateException ex)
     {
         Helper.Utility.LogException(ex, _logger);
         return(BadRequest(ex.Message));
     }
 }
示例#12
0
        public PosDTO Adicionar(PosDTO dto)
        {
            try
            {
                BaseDados.ComandText = "stp_COM_POS_ADICIONAR";

                BaseDados.AddParameter("DESCRICAO", dto.Descricao);
                BaseDados.AddParameter("SIGLA", dto.Sigla);
                BaseDados.AddParameter("SITUACAO", dto.Situacao);
                BaseDados.AddParameter("DESIGNACAO", dto.DesignacaoEntidade);
                BaseDados.AddParameter("ARMAZEM_ID", dto.WarehouseID <= 0 ? (object)DBNull.Value : dto.WarehouseID);
                BaseDados.AddParameter("DOCUMENT_ID", dto.DocumentSerieID <= 0 ? (object)DBNull.Value : dto.DocumentSerieID);
                BaseDados.AddParameter("CUSTOMER_ID", dto.CustomerDefault <= 0 ? (object)DBNull.Value : dto.CustomerDefault);
                BaseDados.AddParameter("UTILIZADOR", dto.Utilizador);
                BaseDados.AddParameter("CODIGO", dto.Codigo);
                BaseDados.AddParameter("PAYMENT_ID", dto.PaymentCondition <= 0 ? (object)DBNull.Value : dto.PaymentCondition);
                BaseDados.AddParameter("VENDEDOR_ID", dto.FuncionarioID == null || dto.FuncionarioID == "" ? (object)DBNull.Value : dto.FuncionarioID);
                BaseDados.AddParameter("PRICE_TABLE_ID", dto.PriceTableID <= 0 ? (object)DBNull.Value : dto.PriceTableID);
                BaseDados.AddParameter("FUNDO", dto.FundoManeio);
                BaseDados.AddParameter("CALENDARIO", dto.AllowCalendar != true ? 0 : 1);
                BaseDados.AddParameter("PREVENT_CLOSE", dto.PreventCloseWithSuspendSale != true ? 0 : 1);
                BaseDados.AddParameter("CASH_SERIE_ID", dto.CashRefundSerieID <= 0 ? (object)DBNull.Value : dto.CashRefundSerieID);
                BaseDados.AddParameter("CREDIT_SERIE_ID", dto.CreditRefundSerieID <= 0 ? (object)DBNull.Value : dto.CreditRefundSerieID);
                BaseDados.AddParameter("PAYMENT_METHOD_ID", dto.PaymentMethodID <= 0 ? (object)DBNull.Value : dto.PaymentMethodID);
                BaseDados.ExecuteNonQuery();

                dto.Sucesso = true;
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                BaseDados.FecharConexao();
            }

            return(dto);
        }
        public List <string> GetPOSbyWord(string word)
        {
            List <string> results = new List <string>();

            try
            {
                using (SqlCommand cmd = new SqlCommand("SELECT PartOfSpeech.PartOfSpeech FROM Word w INNER JOIN PartOfSpeech ON w.PartOfSpeechID = PartOfSpeech.PartOfSpeechID where word = '" + word + "'", con))
                {
                    cmd.CommandType = CommandType.Text;

                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    SqlDataReader rdr = cmd.ExecuteReader();
                    if (rdr.Read())
                    {
                        PosDTO tmp = new PosDTO();

                        string[] poss = rdr[0].ToString().Split('-');
                        foreach (string pos in poss)
                        {
                            results.Add(pos);
                        }
                    }
                    rdr.Close();
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                throw;
            }
            finally
            {
                con.Close();
            }
            return(results);
        }
示例#14
0
        public void ChangePosPinCode(PosDTO dto)
        {
            try
            {
                BaseDados.ComandText = "stp_COM_POS_CHANGE_PINCODE";


                BaseDados.AddParameter("PINCODE", dto.PinCode);
                BaseDados.AddParameter("POS_ID", dto.Codigo);

                BaseDados.ExecuteNonQuery();
                dto.Sucesso = true;
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                BaseDados.FecharConexao();
            }
        }
        public List <PosDTO> GetPOSAndIds()
        {
            List <PosDTO> results = new List <PosDTO>();

            try
            {
                using (SqlCommand cmd = new SqlCommand("SELECT  PartOfSpeechID, PartOfSpeech, lastUpdated FROM   PartOfSpeech", con))
                {
                    cmd.CommandType = CommandType.Text;

                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    SqlDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        PosDTO tmp = new PosDTO();

                        tmp.ID  = (int)rdr[0];
                        tmp.pos = rdr[1].ToString();
                        results.Add(tmp);
                    }
                    rdr.Close();
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
                throw;
            }
            finally
            {
                con.Close();
            }
            return(results);
        }
示例#16
0
        public bool Eliminar(PosDTO dto)
        {
            try
            {
                BaseDados.ComandText = "stp_COM_POS_EXCLUIR";


                BaseDados.AddParameter("CODIGO", dto.Codigo);

                BaseDados.ExecuteNonQuery();
                dto.Sucesso = true;
            }
            catch (Exception ex)
            {
                dto.Sucesso      = false;
                dto.MensagemErro = ex.Message.Replace("'", "");
            }
            finally
            {
                BaseDados.FecharConexao();
            }

            return(dto.Sucesso);
        }
示例#17
0
        public void OnMessageReceived(UserToken token, SocketModel sm)
        {
            switch (sm.command)
            {
            case FightProtocol.ENTER_CREQ:
                EnterBattle(token);
                break;

            case FightProtocol.POS_SYNC_CREQ:
                Move(token, sm.GetMessage <PosSyncDTO>());
                break;

            case FightProtocol.MOVE_CREQ:
                ReturnNextTargetToClient(token, sm.GetMessage <PathRequestDTO>());
                break;

            case FightProtocol.ATTACK_CREQ:
                Attack(sm.GetMessage <AttackDTO>());

                break;

            case FightProtocol.DAMAGE_CREQ:
                Damage(token, sm.GetMessage <DamageDTO>());

                break;

            case FightProtocol.SKILL_UP_CREQ:
                SkillUp(token, sm.GetMessage <int>());
                break;

            case FightProtocol.SKILL_CREQ:
                Skill(token, sm.GetMessage <SkillAttackDTO>());
                break;

            case FightProtocol.REQ_ATTACK_POS_CREQ:
                PosDTO  posDTO = sm.GetMessage <PosDTO>();
                int     teamId = instances[posDTO.instanceId].teamId;
                Vector3 atkPos = AtkTreeMgr.Instance.GetAtkTree(teamId).GetNearestAttackablePos(new Vector3(posDTO.posX, posDTO.posY, posDTO.posZ));
                posDTO.posX      = atkPos.x;
                posDTO.posY      = atkPos.y;
                posDTO.posZ      = atkPos.z;
                posDTO.timeStamp = DateTime.Now.Ticks;
                Send(token, FightProtocol.ATK_TO_POS_SRES, posDTO);

                break;

            case FightProtocol.SMALL_TARGET_ARRIVE_CREQ:
                ReturnNextSmallTarget(token, sm.GetMessage <int>());
                break;

            case FightProtocol.IDLE_CREQ:
                int instanceId = sm.GetMessage <int>();
                if (instancePos.ContainsKey(instanceId))
                {
                    instancePos[instanceId].moveStatus = MoveStatus.Still;
                }
                else
                {
                    instancePos.Add(instanceId, new EntityMoveInfo(new Vector3(0, 0, 0), false));
                }
                brocast(FightProtocol.IDLE_BRO, instanceId, token);

                break;
            }
        }
示例#18
0
 public PosDTO GetPostOfSalesDetails(PosDTO dto)
 {
     return(dao.ObterPorPK(dto));
 }
示例#19
0
 public List <PosDTO> ObtePostosVendas(PosDTO dto)
 {
     return(dao.ObterPorFiltro(dto));
 }
示例#20
0
        public List <PosDTO> ObterPorFiltro(PosDTO dto)
        {
            List <PosDTO> lista;

            try
            {
                BaseDados.ComandText = "stp_COM_POS_OBTERPORFILTRO";

                BaseDados.AddParameter("@FILIAL", dto.Filial == null ? "-1" : dto.Filial);
                MySqlDataReader dr = BaseDados.ExecuteReader();
                lista = new List <PosDTO>();
                while (dr.Read())
                {
                    dto = new PosDTO
                    {
                        Codigo                      = int.Parse(dr[0].ToString()),
                        Descricao                   = dr[1].ToString(),
                        Sigla                       = dr[2].ToString(),
                        Estado                      = int.Parse(dr[3].ToString()),
                        FuncionarioID               = dr[4].ToString(),
                        WarehouseID                 = dr[5].ToString() != "" ? int.Parse(dr[5].ToString()) : -1,
                        DocumentSerieID             = dr[6].ToString() != "" ? int.Parse(dr[6].ToString()) : -1,
                        CustomerDefault             = dr[7].ToString() != "" ? int.Parse(dr[7].ToString()) : -1,
                        DesignacaoEntidade          = dr[8].ToString(),
                        SocialName                  = dr[9].ToString(),
                        Utilizador                  = dr[10].ToString(),
                        DefaultDocument             = dr[11].ToString() != "" ? int.Parse(dr[11].ToString()) : -1,
                        TituloDocumento             = dr[12].ToString(),
                        Filial                      = dr[13].ToString(),
                        LookupField2                = dr[14].ToString() == string.Empty ? "TODOS" : dr[14].ToString(),
                        PaymentCondition            = dr[15].ToString() != "" ? int.Parse(dr[15].ToString()) : -1,
                        PaymentMethodID             = dr[16].ToString() != "" ? int.Parse(dr[16].ToString()) : -1,
                        PriceTableID                = dr[18].ToString() != "" ? int.Parse(dr[1].ToString()) : -1,
                        FundoManeio                 = dr[19].ToString() != "" ? decimal.Parse(dr[19].ToString()) : 0,
                        AllowCalendar               = dr[20].ToString() == "1" ? true : false,
                        PreventCloseWithSuspendSale = dr[21].ToString() == "1" ? true : false,
                        CashRefundSerieID           = dr[22].ToString() != "" ? int.Parse(dr[22].ToString()) : -1,
                        CreditRefundSerieID         = dr[23].ToString() != "" ? int.Parse(dr[23].ToString()) : -1,
                        CashRefundDocumentID        = dr[24].ToString() != "" ? int.Parse(dr[24].ToString()) : -1,
                        CreditRefundDocumentID      = dr[25].ToString() != "" ? int.Parse(dr[25].ToString()) : -1,
                        PinCode                     = dr[26].ToString(),
                    };

                    dto.ForRest = dr[27].ToString() == "1" || dto.WarehouseID <= 0 ? true : false;

                    if (dto.Sigla == "")
                    {
                        dto.Sigla = "POS00_" + dto.Codigo.ToString();
                    }

                    if (dto.DesignacaoEntidade == "")
                    {
                        dto.DesignacaoEntidade = "POSTO DE VENDA 00_" + dto.Codigo.ToString();
                    }
                    lista.Add(dto);
                }
            }
            catch (Exception ex)
            {
                dto = new PosDTO
                {
                    Sucesso      = false,
                    MensagemErro = ex.Message.Replace("'", "")
                };
                lista = new List <PosDTO>
                {
                    dto
                };
            }
            finally
            {
                BaseDados.FecharConexao();
            }

            return(lista);
        }
示例#21
0
 public List <PosDTO> ObterCaixaFechadas(PosDTO dto)
 {
     return(dao.ObterCaixaFechadas(dto));
 }
示例#22
0
 public PosDTO CreateNewPOS(PosDTO dto)
 {
     return(dto = dao.Adicionar(dto));
 }
示例#23
0
 public static MsgT <PosDTO> GetMsgPos(ushort msgId, PosDTO posDTO)
 {
     msgPos.SetMsgT(msgId, posDTO);
     return(msgPos);
 }