コード例 #1
0
        public async Task <ICollection <IGeographicalPosition> > GetPositionsByTravelHistory(Guid taxyId, Guid travelId)
        {
            using (DataManager dataManager = new DataManager(SettingProvider.Instance.GetString(Constants.DATABASE), Provider.SqlServer))
            {
                IDataParameter[] parameters = new IDataParameter[2];

                parameters[0] = new SqlParameter("@TaxyId", taxyId);
                parameters[1] = new SqlParameter("@TravelId", travelId);

                using (IDataReader reader = dataManager.ExecuteReader("[gbm].[GetPositionsByTravelHistory]", parameters))
                {
                    var positions = new List <IGeographicalPosition>();

                    while (reader.Read())
                    {
                        var position = new GeographicalPosition();

                        position.Id               = reader["Id"] == DBNull.Value ? Guid.Empty : Guid.Parse(reader["Id"].ToString());
                        position.TaxyId           = reader["TaxyId"] == DBNull.Value ? Guid.Empty : Guid.Parse(reader["TaxyId"].ToString());
                        position.TravelId         = reader["TravelId"] == DBNull.Value ? Guid.Empty : Guid.Parse(reader["TravelId"].ToString());
                        position.DriverId         = reader["DriverId"] == DBNull.Value ? Guid.Empty : Guid.Parse(reader["DriverId"].ToString());
                        position.Latitude         = reader["Latitude"] == DBNull.Value ? "" : reader["Latitude"].ToString();
                        position.Longitude        = reader["Longitude"] == DBNull.Value ? "" : reader["Longitude"].ToString();
                        position.RegistrationDate = reader["RegistrationDate"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["RegistrationDate"]);

                        positions.Add(position);
                    }

                    return(await Task.FromResult(positions));
                }
            }
        }
コード例 #2
0
        public async Task <IGeographicalPosition> GetCurrentPosition(Guid taxyId, Guid travelId)
        {
            using (DataManager dataManager = new DataManager(SettingProvider.Instance.GetString(Constants.DATABASE), Provider.SqlServer))
            {
                IDataParameter[] parameters = new IDataParameter[2];

                parameters[0] = new SqlParameter("@TaxyId", taxyId);
                parameters[1] = new SqlParameter("@TravelId", travelId);

                using (IDataReader reader = dataManager.ExecuteReader("[gbm].[GetCurrentPosition]", parameters))
                {
                    if (reader.Read())
                    {
                        var position = new GeographicalPosition
                        {
                            Id               = reader["Id"] == DBNull.Value ? Guid.Empty : Guid.Parse(reader["Id"].ToString()),
                            TaxyId           = reader["TaxyId"] == DBNull.Value ? Guid.Empty : Guid.Parse(reader["TaxyId"].ToString()),
                            TravelId         = reader["TravelId"] == DBNull.Value ? Guid.Empty : Guid.Parse(reader["TravelId"].ToString()),
                            DriverId         = reader["DriverId"] == DBNull.Value ? Guid.Empty : Guid.Parse(reader["DriverId"].ToString()),
                            Latitude         = reader["Latitude"] == DBNull.Value ? "" : reader["Latitude"].ToString(),
                            Longitude        = reader["Longitude"] == DBNull.Value ? "" : reader["Longitude"].ToString(),
                            RegistrationDate = reader["RegistrationDate"] == DBNull.Value ? DateTime.MinValue : Convert.ToDateTime(reader["RegistrationDate"])
                        };

                        return(await Task.FromResult(position));
                    }
                    else
                    {
                        throw new LogicException("No se encontró la posición actual.");
                    }
                }
            }
        }
コード例 #3
0
        public async Task <IGeographicalPosition> GetCurrentPosition(Guid taxyId, Guid travelId)
        {
            using (AzureManager azureManager = new AzureManager(SettingProvider.Instance.GetString(Constants.STORAGE),
                                                                SettingProvider.Instance.GetInt(Constants.MAXATTEMPTS), SettingProvider.Instance.GetInt(Constants.WAITSECONDS)))
            {
                string partitionKey = travelId.ToString().ToUpperInvariant();
                string rowKey       = taxyId.ToString().ToUpperInvariant();

                var currentPositionWat = azureManager.GetEntity <GeographicalPositionEntity>(SettingProvider.Instance.GetString(Constants.WATNAME), partitionKey, rowKey);

                if (currentPositionWat != null)
                {
                    var currentPosition = new GeographicalPosition(currentPositionWat);

                    return(await Task.FromResult(currentPosition));
                }
                else
                {
                    throw new LogicException("No se encontró la posición actual.");
                }
            }
        }