Esempio n. 1
0
        protected void btnSolicitar_Click(object sender, EventArgs e)
        {
            Localizacao localizacao = Geolocation.ObterLocalizacao(txtEndereco.Text);

            if (localizacao != null)
            {
                try
                {
                    OFMS ofms = OFMS.GetInstance();
                    ofms.IniciarRequisicao(Base.SessaoUsuario.ID, localizacao.Latitude, localizacao.Longitude);

                    multiview.ActiveViewIndex = VIEW_AGUARDE_PROCESSAMENTO;
                }
                catch (NenhumTaxiParaAtenderRequisicaoException)
                {
                    PageBase.CaixaMensagens.Exibir(App_LocalResources.MensagensResource.NENHUM_TAXI_DISPONIVEL);
                    multiview.ActiveViewIndex = VIEW_TAXI_INDISPONIVEL;
                }
                catch (Exception)
                {
                    PageBase.CaixaMensagens.Exibir(App_LocalResources.MensagensResource.GEOLOCALIZACAO_INDISPONIVEL);
                }
            }
            else
            {
                PageBase.CaixaMensagens.Exibir(App_LocalResources.MensagensResource.GEOLOCALIZACAO_NAO_ENCONTRADA);
            }
        }
Esempio n. 2
0
        protected void btnAtender_Click(object sender, EventArgs e)
        {
            OFMS ofms = OFMS.GetInstance();

            ofms.AceitarRequisicao(Base.SessaoUsuario.ID);
            multiview.ActiveViewIndex = VIEW_AGUARDANDO_CONFIRMACAO;
        }
Esempio n. 3
0
        public DirectionsPoco RequisitarTaxi(Guid codigoCliente, double latitude, double longitude, MetodoBuscaTaxi metodo)
        {
            try
            {
                TimeSpan processTime = new TimeSpan();

                OFMS ofms = OFMS.GetInstance();
                ofms.IniciarRequisicao(codigoCliente, latitude, longitude, metodo, out processTime);

                DirectionsPoco poco = ofms.ObterPrevisaoAtendimento(codigoCliente);
                ofms.CancelarRequisicao(codigoCliente);

                if (poco != null)
                {
                    poco.ProcessTime = processTime;
                }

                return(poco);
            }
            catch (GoogleMapsApiException gmaex)
            {
                return(new DirectionsPoco()
                {
                    STATUS_CODE = gmaex.Message
                });
            }
        }
Esempio n. 4
0
        private void AtualizarGrid()
        {
            OFMS ofms = OFMS.GetInstance();

            gvTaxistas.DataSource = ofms.Taxistas.OrderByDescending(taxi => taxi.PosicaoAtual.Data);
            gvTaxistas.DataBind();
        }
Esempio n. 5
0
        protected void btnIniciarAtendimento_Click(object sender, EventArgs e)
        {
            OFMS ofms = OFMS.GetInstance();

            ofms.IniciarAtendimento(Base.SessaoUsuario.ID);

            multiview.ActiveViewIndex = VIEW_EM_ATENDIMENTO;
        }
Esempio n. 6
0
        protected void btnFinalizarAtendimento_Click(object sender, EventArgs e)
        {
            OFMS ofms = OFMS.GetInstance();

            ofms.ConcluirRequisicao(Base.SessaoUsuario.ID);

            multiview.ActiveViewIndex = VIEW_LOCATION;
        }
Esempio n. 7
0
        protected void btnConfirmarSolicitacao_Click(object sender, EventArgs e)
        {
            OFMS ofms = OFMS.GetInstance();

            ofms.ConfirmarRequisicao(Base.SessaoUsuario.ID);

            multiview.ActiveViewIndex = VIEW_AGUARDE_ATENDIMENTO;
        }
Esempio n. 8
0
        protected void btnCancelarTaxiIndisponivel_Click(object sender, EventArgs e)
        {
            OFMS ofms = OFMS.GetInstance();

            ofms.CancelarRequisicao(Base.SessaoUsuario.ID);

            PageBase.CaixaMensagens.Exibir(App_LocalResources.MensagensResource.REQUISICAO_CANCELADA);
            multiview.ActiveViewIndex = VIEW_POSICAO;
        }
Esempio n. 9
0
        protected void timerEmAtendimento_Tick(object sender, EventArgs e)
        {
            OFMS ofms            = OFMS.GetInstance();
            bool existe_requisao = ofms.ExistsRequisicao(Base.SessaoUsuario.ID);

            if (!existe_requisao)
            {
                PageBase.CaixaMensagens.Exibir(App_LocalResources.MensagensResource.REQUISICAO_CONCLUIDA);
                multiview.ActiveViewIndex = VIEW_POSICAO;
            }
        }
Esempio n. 10
0
        protected void timerLocation_Tick(object sender, EventArgs e)
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "GetLocation()", true);

            OFMS       ofms        = OFMS.GetInstance();
            Requisicao atendimento = ofms.GetRequisicaoRealizada(Base.SessaoUsuario.ID);

            if (atendimento != null)
            {
                multiview.ActiveViewIndex = VIEW_RESPOSTA_ATENDIMENTO;
            }
        }
Esempio n. 11
0
        protected void timerAguardeAtendimento_Tick(object sender, EventArgs e)
        {
            OFMS ofms          = OFMS.GetInstance();
            bool em_atedimento = ofms.ExistsRequisicaoEmAtendimento(Base.SessaoUsuario.ID);

            if (em_atedimento)
            {
                multiview.ActiveViewIndex = VIEW_EM_ATENDIMENTO;
            }

            ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "GetAtendimento()", true);
        }
Esempio n. 12
0
        public void IniciarPosicaoComStatusAleatorio(Guid ID, double latitude, double longitude)
        {
            double value = new Random().NextDouble();

            if (value > 0.5)
            {
                OFMS.AtualizaPosicaoTaxista(ID, latitude, longitude, StatusTaxista.TaxiLivre);
            }
            else
            {
                OFMS.AtualizaPosicaoTaxista(ID, latitude, longitude, StatusTaxista.EmAtendimento);
            }
        }
Esempio n. 13
0
        protected void btnRecusar_Click(object sender, EventArgs e)
        {
            try
            {
                OFMS ofms = OFMS.GetInstance();
                ofms.RecusarAtendimento(Base.SessaoUsuario.ID);
            }
            catch (NenhumTaxiParaAtenderRequisicaoException) { }

            PageBase.CaixaMensagens.ExibirRedirecionar(App_LocalResources.LabelsResource.REQUISICAO,
                                                       App_LocalResources.MensagensResource.REQUISICAO_RECUSADA, Request.AppRelativeCurrentExecutionFilePath);

            multiview.ActiveViewIndex = VIEW_LOCATION;
        }
Esempio n. 14
0
        protected void timerAguardeProcessamento_Tick(object sender, EventArgs e)
        {
            OFMS ofms = OFMS.GetInstance();
            bool taxista_confirmou = ofms.ExistsRequisicaoAguardandoConfirmacao(Base.SessaoUsuario.ID);

            if (taxista_confirmou)
            {
                multiview.ActiveViewIndex = VIEW_CONFIRMACAO;
            }
            else
            {
                //verifica se a requisição foi recusada e agora está na fila de espera
                if (ofms.ExistsRequisicaoEmProcessamento(Base.SessaoUsuario.ID))
                {
                    //PageBase.CaixaMensagens.ExibirRedirecionar(App_LocalResources.LabelsResource.REQUISICAO,
                    //    App_LocalResources.MensagensResource.NENHUM_TAXI_DISPONIVEL, Request.AppRelativeCurrentExecutionFilePath);
                    multiview.ActiveViewIndex = VIEW_TAXI_INDISPONIVEL;
                }
            }
        }
Esempio n. 15
0
        protected void timerAguardandoConfirmacao_Tick(object sender, EventArgs e)
        {
            OFMS ofms = OFMS.GetInstance();
            bool cliente_confirmou = ofms.ExistsRequisicaoAguardandoAtendimento(Base.SessaoUsuario.ID);

            if (cliente_confirmou)
            {
                multiview.ActiveViewIndex = VIEW_AGUARDANDO_ATENDIMENTO;
            }
            else
            {
                //verifica se o cliente não cancelou a requisição
                if (!ofms.ExistsRequisicaoAguardandoConfirmacao(Base.SessaoUsuario.ID))
                {
                    PageBase.CaixaMensagens.ExibirRedirecionar(App_LocalResources.LabelsResource.REQUISICAO,
                                                               App_LocalResources.MensagensResource.CLIENTE_CANCELOU_REQUISICAO, Request.AppRelativeCurrentExecutionFilePath);

                    multiview.ActiveViewIndex = VIEW_LOCATION;
                }
            }
        }
Esempio n. 16
0
        public static string Teste()
        {
            OFMS           ofms     = OFMS.GetInstance();
            List <Taxista> taxistas = ofms.Taxistas.OrderByDescending(taxi => taxi.PosicaoAtual.Data).ToList();

            List <TaxistaWeb> taxistas_web = new List <TaxistaWeb>();

            foreach (Taxista taxista in taxistas)
            {
                TaxistaWeb taxi_web = new TaxistaWeb();
                taxi_web.placa     = taxista.Pessoa.NomeOuRazaoSocial;
                taxi_web.latitude  = taxista.PosicaoAtual.Latitude;
                taxi_web.longitude = taxista.PosicaoAtual.Longitude;
                taxi_web.status    = (int)taxista.Status;

                taxistas_web.Add(taxi_web);
            }

            int livres = taxistas.Count(tx => tx.Status == StatusTaxista.TaxiLivre);

            System.Web.Script.Serialization.JavaScriptSerializer oSerializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            return("{\"Taxista\":" + oSerializer.Serialize(taxistas_web) + "}");
        }
Esempio n. 17
0
        protected void viewAguardandoAtendimento_Activate(object sender, EventArgs e)
        {
            lblTitulo.Text = App_LocalResources.MensagensResource.ATENDIMENTO_REQUISICAO;

            OFMS       ofms       = OFMS.GetInstance();
            Requisicao requisicao = ofms.ObterRequisicao(Base.SessaoUsuario.ID);

            if (requisicao != null && requisicao.Taxista != null && requisicao.Taxista.PosicaoAtual != null)
            {
                DirectionsRequest request = new DirectionsRequest();
                request.Origin      = Localizacao.ObterEndereco(requisicao.Taxista.PosicaoAtual.Latitude, requisicao.Taxista.PosicaoAtual.Longitude);
                request.Destination = Localizacao.ObterEndereco(requisicao.Cliente.PosicaoAtual.Latitude, requisicao.Cliente.PosicaoAtual.Longitude);

                try
                {
                    DirectionsResponse response = GoogleMapsApi.GoogleMaps.Directions.Query(request);
                    Leg leg = response.Routes.First().Legs.First();
                    lblPrevisao.Text  = leg.Duration.Text.ToString();
                    lblDistancia.Text = leg.Distance.Text.ToString();

                    StringBuilder rota = new StringBuilder();
                    foreach (Step step in leg.Steps)
                    {
                        rota.Append("&#8226; " + step.HtmlInstructions.Replace("<b>", "").Replace("<b />", "") + "<br />");
                    }
                    lblRota.Text = rota.ToString();

                    if (requisicao.Cliente != null)
                    {
                        lblCliente.Text = requisicao.Cliente.Pessoa.NomeOuRazaoSocial;
                    }
                }
                catch { }
            }

            ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "GetAtendimento()", true);
        }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                OFMS       ofms       = OFMS.GetInstance();
                Requisicao requisicao = ofms.ObterRequisicao(Base.SessaoUsuario.ID);
                if (requisicao != null)
                {
                    switch (requisicao.Status)
                    {
                    case StatusRequisicao.RequisicaoRealizada:
                        multiview.ActiveViewIndex = VIEW_RESPOSTA_ATENDIMENTO;
                        break;

                    case StatusRequisicao.AguardandoResposta:
                        multiview.ActiveViewIndex = VIEW_AGUARDANDO_CONFIRMACAO;
                        break;

                    case StatusRequisicao.AguardandoAtendimento:
                        multiview.ActiveViewIndex = VIEW_AGUARDANDO_ATENDIMENTO;
                        break;

                    case StatusRequisicao.EmProcessamento:
                        multiview.ActiveViewIndex = VIEW_EM_ATENDIMENTO;
                        break;

                    default:
                        multiview.ActiveViewIndex = VIEW_LOCATION;
                        break;
                    }
                }
                else
                {
                    multiview.ActiveViewIndex = VIEW_LOCATION;
                }
            }
        }
Esempio n. 19
0
        protected void viewAguardeAtendimento_Activate(object sender, EventArgs e)
        {
            OFMS       ofms       = OFMS.GetInstance();
            Requisicao requisicao = ofms.ObterRequisicao(Base.SessaoUsuario.ID);

            if (requisicao != null && requisicao.Taxista != null && requisicao.Taxista.PosicaoAtual != null)
            {
                DirectionsRequest request = new DirectionsRequest();
                request.Origin      = Localizacao.ObterEndereco(requisicao.Taxista.PosicaoAtual.Latitude, requisicao.Taxista.PosicaoAtual.Longitude);
                request.Destination = Localizacao.ObterEndereco(requisicao.Cliente.PosicaoAtual.Latitude, requisicao.Cliente.PosicaoAtual.Longitude);

                try
                {
                    DirectionsResponse response = GoogleMapsApi.GoogleMaps.Directions.Query(request);
                    Leg leg = response.Routes.First().Legs.First();
                    lblPrevisao.Text    = leg.Duration.Text.ToString();
                    lblPlaca.Text       = requisicao.Taxista.Veiculo.Placa;
                    lblResponsavel.Text = requisicao.Taxista.Pessoa.NomeOuRazaoSocial;
                }
                catch { }
            }

            ScriptManager.RegisterStartupScript(this, this.GetType(), Guid.NewGuid().ToString(), "GetAtendimento()", true);
        }
Esempio n. 20
0
        //public TimeSpan RequisitarTaxiPorBroadcasting(Guid codigoCliente, double latitude, double longitude)
        //{
        //    OFMS ofms = OFMS.GetInstance();
        //    ofms.IniciarRequisicao(codigoCliente, latitude, longitude);

        //    return ofms.ObterPrevisaoAtendimento(codigoCliente);
        //}

        public void AlterarStatusTaxistaAleatorio()
        {
            OFMS ofms = OFMS.GetInstance();

            ofms.AlterarStatusTaxistaAleatorio();
        }
Esempio n. 21
0
        public void MovimentarTaxistas()
        {
            OFMS ofms = OFMS.GetInstance();

            ofms.MovimentarTaxistasAleatorio();
        }
Esempio n. 22
0
 public void AtualizarPosicao(Guid ID, double latitude, double longitude)
 {
     OFMS.AtualizaPosicaoTaxista(ID, latitude, longitude);
 }
Esempio n. 23
0
        private void CancelarRequisicao()
        {
            OFMS ofms = OFMS.GetInstance();

            ofms.CancelarRequisicao(Base.SessaoUsuario.ID);
        }