public GameObject SpawnPothole()
    {
        Vector2Int  index       = GetRandomRoadIndex();
        PotholeType potholeType = GetRandomSizedPotholePrefab();

        GameObject potholeObject = placementManager.CreateRoadObject(index.x, index.y, grid, potholeType.prefab);

        placementManager.AddIndicatorToPothole(potholeObject);
        potholeObject.transform.tag = "Pothole";
        potholeObject.name          = "Pothole (" + index.x + ", " + index.y + ")";

        Pothole newPothole = potholeObject.AddComponent <Pothole>();

        newPothole.SetPothole(this, potholeType.repairTime, potholeType.GetSize());

        //Remove road from grid
        GameObject road = grid.GetRoadObjectFromGird(index.x, index.y);

        placementManager.RemoveObject(road);

        //Set new pothole to grid
        grid.PlaceRoadToGrid(index.x, index.y, potholeObject, true);

        //Change numbers
        potholeCount++;
        ChangePotholeCount(new Vector3Int(1, 0, 0));

        return(potholeObject);
    }
 public override void SetPothole(Pothole pothole, Action potholeWatcher)
 {
     this.pothole = pothole;
     this.pothole.AddCarToPothole();
     this.pothole.AddListenerOnPotholeDestructionEvent(potholeWatcher);
     this.potholeWatcherAction = potholeWatcher;
 }
Exemple #3
0
        public ActionResult ReportPotholePost(PotholeViewModel viewModel)
        {
            if (!Request.IsAuthenticated)
            {
                return(RedirectToAction("Index"));
            }
            //Pothole pothole = new Pothole();
            //pothole.UserName = userName;

            Pothole p = new Pothole();

            p.UserName      = viewModel.UserName;
            p.PotholeDesc   = viewModel.PotholeDesc;
            p.Latitude      = viewModel.Latitude;
            p.Longitude     = viewModel.Longitude;
            p.Severity      = viewModel.Severity;
            p.Street1       = viewModel.Street1;
            p.Street2       = viewModel.Street2;
            p.LocationDesc  = viewModel.LocationDesc;
            p.ReportedDate  = viewModel.ReportedDate;
            p.InspectedDate = viewModel.InspectedDate;
            p.RepairedDate  = viewModel.RepairedDate;
            p.IsValidated   = Convert.ToBoolean(viewModel.IsValidated);


            bool confirm = potholeDAL.ReportPothole(p);

            return(RedirectToAction("Index", "Home"));
        }
        public Pothole ReportApothole(Pothole pothole)
        {
            pothole.Status    = (PotholeStatus)1;
            pothole.DateAdded = DateTime.Now;
            string sqlQuery = "INSERT INTO Pothole([Location], DateAdded, [Description], Status) VALUES(@location, @dateAdded, @description, @status) SELECT @@IDENTITY";

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();

                    SqlCommand cmd = new SqlCommand(sqlQuery, conn);
                    //Add all the params
                    cmd.Parameters.AddWithValue("@location", pothole.Location);
                    //cmd.Parameters.AddWithValue("@dateAdded", pothole.DateAdded);
                    cmd.Parameters.AddWithValue("@dateAdded", pothole.DateAdded);
                    cmd.Parameters.AddWithValue("@description", pothole.Description);
                    cmd.Parameters.AddWithValue("@status", pothole.Status);

                    pothole.Id = Convert.ToInt32(cmd.ExecuteScalar());
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return(pothole);
        }
        public void UnTrigger(Pothole potehole)
        {
            if (m_triggered == false)
            {
                return;
            }
            m_triggered = false;
            switch (m_type)
            {
            default:
                break;

            case EventType.GameObject:
                m_GO.SetActive(false);
                break;

            case EventType.Function:
                break;

            case EventType.ParticleSystem:
                ParticleSystem.EmissionModule em = m_particleSystem.emission;
                em.enabled = false;
                break;

            case EventType.Collider:
                m_collider.enabled = false;
                break;
            }
        }
        public List <Pothole> GetOrderPotholes(int orderId)
        {
            List <Pothole> orderPotholes = new List <Pothole>();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();

                    string query = "SELECT PotHole.PotHole_Id, PotHole.UserId, Users.UserName, PotHole.PotHoleDesc, PotHole.Lat, PotHole.Long, PotHole.Severity, PotHole.Street1, PotHole.Street2, PotHole.LocationDesc, PotHole.DateReported, PotHole.InspectedDate, PotHole.RepairDate, PotHole.IsValidated FROM PotHole JOIN Users on Users.UserId = PotHole.UserId JOIN WorkOrderPotholeUser ON PotHole.PotHole_Id = WorkOrderPotholeUser.PotHole_Id WHERE WorkOrderPotholeUser.WorkOrderId = @workOrderId GROUP BY PotHole.PotHole_Id, PotHole.UserId, Users.UserName, PotHole.PotHoleDesc, PotHole.Lat, PotHole.Long, PotHole.Severity, PotHole.Street1, PotHole.Street2, PotHole.LocationDesc, PotHole.DateReported, PotHole.InspectedDate, PotHole.RepairDate, PotHole.IsValidated;";

                    SqlCommand cmd = new SqlCommand(query, conn);
                    cmd.Parameters.AddWithValue("@workOrderId", orderId);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        Pothole p = MapRows(reader);

                        orderPotholes.Add(p);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }

            return(orderPotholes);
        }
        public PotholeViewModel SearchValidPotHoles(PotholeViewModel viewModel)
        {
            List <Pothole> allPotholes = new List <Pothole>();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();

                    //string query = BuildSqlCommand(viewModel, conn);

                    SqlCommand cmd = BuildSqlCommand(viewModel, conn);



                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        Pothole p = MapRows(reader);

                        allPotholes.Add(p);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }

            viewModel.PotholeList = allPotholes;

            return(viewModel);
        }
Exemple #8
0
 void UnsetPothole()
 {
     m_currentPothole = null;
     m_animator.SetBool("Fixing", false);
     //ParticleSystem.EmissionModule em = m_hammerEffect.emission;
     //em.enabled = false;
     m_hammerEffect.Stop(true);
 }
Exemple #9
0
 public ActionResult DeletePothole(Pothole potholeDelete)
 {
     if (!Request.IsAuthenticated || User.IsInRole("citizen") || User.IsInRole("crew_member"))
     {
         return(RedirectToAction("Index"));
     }
     potholeDAL.DeletePothole(potholeDelete);
     return(RedirectToAction("AdminPotholeEdit"));
 }
Exemple #10
0
    void SetPothole(Collider other)
    {
        m_potholeTriggerStay = 0.0f;
        m_currentPothole     = other.transform.parent.GetComponent <Pothole>();
        m_animator.SetBool("Fixing", true);

        //ParticleSystem.EmissionModule em = m_hammerEffect.emission;
        //em.enabled = true;
        m_hammerEffect.Play(true);
    }
Exemple #11
0
    public void SetParams(Pothole pothole)
    {
        this.pothole = pothole;
        PotholeSize holeType = pothole.size;

        Image[] holes = potholeTypesPanel.GetComponentsInChildren <Image>();
        uiHelper.SetPotholeTypeIcon(holes, holeType);

        Image[] workers = workersPanel.GetComponentsInChildren <Image>();
        uiHelper.ChangeWorkerColor(0, workers);
    }
    void HandlePotholeClick(RaycastHit hit)
    {
        Pothole pothole = hit.transform.gameObject.GetComponent <Pothole>();

        if (pothole.status == PotholeStatus.ToDo)
        {
            uiController.OpenAssignPanel(pothole);
        }
        else if (pothole.status == PotholeStatus.InProgress)
        {
            uiController.OpenStatusPanel(pothole);
        }
    }
 public ActionResult DetailHole(Pothole pothole)
 {
     if (CurrentUser == "EmptyUserName" || CurrentUser != "")
     {
         int potHoleID = potholeDAL.InsertPothole(pothole);
         Session["Pothole_id"] = potHoleID;
         return(View("DetailHole", pothole));
     }
     else
     {
         return(RedirectToAction("Login", "User"));
     }
 }
Exemple #14
0
        public ActionResult AdminPotholeEdit(Pothole pothole)
        {
            if (!Request.IsAuthenticated || User.IsInRole("citizen") || User.IsInRole("crew_member"))
            {
                return(RedirectToAction("Index"));
            }

            potholeDAL.UpdatePothole(pothole);
            //PotholeViewModel returnModel = new PotholeViewModel();
            //returnModel.PotholeList = new List<Pothole>();
            //returnModel.PotholeList.Add(pothole);
            return(RedirectToAction("AdminPotholeEdit" /*, returnModel*/));
        }
Exemple #15
0
        public void InsertPotholeTest()
        {
            PotholeDAL sql     = new PotholeDAL(connectionString);
            Pothole    pothole = new Pothole
            {
                Status       = "Reported",
                Severity     = 4,
                DateReported = DateTime.UtcNow.Date,
                Longitude    = -83.045653M,
                Latitude     = 39.99753999999996M,
            };

            Assert.AreEqual(updateId + 1, sql.InsertPothole(pothole));
        }
        public void Trigger(Pothole potehole)
        {
            if (m_triggered)
            {
                return;
            }
            m_triggered = true;
            switch (m_type)
            {
            default:
                break;

            case EventType.GameObject:
                m_GO.SetActive(true);
                break;

            case EventType.Function:
                potehole.InvokeFunction(m_function);
                break;

            case EventType.ParticleSystem:
                ParticleSystem.EmissionModule em = m_particleSystem.emission;
                em.enabled = true;
                m_particleSystem.Play(true);
                break;

            case EventType.Collider:
                m_collider.enabled = true;
                break;
            }

            switch (m_sound)
            {
            default:
            case PlaySound.None:
                break;

            case PlaySound.Dig:
                MasterAudio.PlaySound3DAtTransformAndForget("Dig", potehole.transform);
                break;

            case PlaySound.Crack:
                MasterAudio.PlaySound3DAtTransformAndForget("Break", potehole.transform);
                break;

            case PlaySound.RabbitJump:
                MasterAudio.PlaySound3DAtTransformAndForget("RabbitJump", potehole.transform);
                break;
            }
        }
        public List <Pothole> GetAllPotholes()
        {
            List <Pothole> potholeList = new List <Pothole>();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand    cmd    = new SqlCommand(SQL_GetAllPotholes, conn);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        Pothole pothole = new Pothole();

                        pothole.PotholeID    = Convert.ToInt32(reader["PotHole_ID"]);
                        pothole.Status       = Convert.ToString(reader["Status"]);
                        pothole.Severity     = Convert.ToInt32(reader["Severity"]);
                        pothole.DateReported = Convert.ToDateTime(reader["Date_Reported"]);
                        if (reader["Repair_Date"] is DBNull)
                        {
                            pothole.RepairDate = null;
                        }
                        else
                        {
                            pothole.RepairDate = Convert.ToDateTime(reader["Repair_Date"]);
                        }
                        if (reader["Inspect_Date"] is DBNull)
                        {
                            pothole.InspectDate = null;
                        }
                        else
                        {
                            pothole.InspectDate = Convert.ToDateTime(reader["Inspect_Date"]);
                        }

                        pothole.Longitude = Convert.ToDecimal(reader["Longitude"]);
                        pothole.Latitude  = Convert.ToDecimal(reader["Latitude"]);

                        potholeList.Add(pothole);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(potholeList);
        }
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Pothole = await _context.Pothole.SingleOrDefaultAsync(m => m.ID == id);

            if (Pothole == null)
            {
                return(NotFound());
            }
            return(Page());
        }
 private void Next_imga2_Click(object sender, EventArgs e)
 {
     if (selected != null || selected != "")
     {
         string  a = JsonConvert.DeserializeObject <string>(Intent.GetStringExtra("objtopass"));
         Pothole p = new Pothole();
         p.IssueImage = a;
         p.waterLevel = selected;
         Control.DataOper.PutData <createissue4>(this, p);
     }
     else
     {
         Toast.MakeText(this, "Please select any option", ToastLength.Long).Show();
     }
 }
        public List <Pothole> GetAllValidPotholes()
        {
            List <Pothole> allPotholes = new List <Pothole>();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionString))
                {
                    conn.Open();

                    string query = "SELECT PotHole.PotHole_Id, PotHole.UserId, Users.UserName, PotHole.PotHoleDesc, PotHole.Lat, PotHole.Long, PotHole.Severity, PotHole.Street1, PotHole.Street2, PotHole.LocationDesc, PotHole.DateReported, PotHole.InspectedDate, PotHole.RepairDate, PotHole.IsValidated FROM PotHole JOIN Users ON PotHole.UserId = Users.UserId WHERE IsValidated = 1";

                    SqlCommand cmd = new SqlCommand(query, conn);

                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        //Pothole p = new Pothole();

                        //p.PotholeId = Convert.ToInt32(reader["PotHole_Id"]);
                        //p.UserId = (Guid)reader["UserId"];
                        //p.PotholeDesc = Convert.ToString(reader["PotHoleDesc"]);
                        //p.Latitude = Convert.ToDouble(reader["Lat"]);
                        //p.Longitude = Convert.ToDouble(reader["Long"]);
                        //p.Severity = Convert.ToInt32(reader["Severity"]);
                        //p.Street1 = Convert.ToString(reader["Street1"]);
                        //p.Street2 = Convert.ToString(reader["Street2"]);
                        //p.LocationDesc = Convert.ToString(reader["LocationDesc"]);
                        //p.ReportedDate = Convert.ToDateTime(reader["DateReported"]);
                        //p.InspectedDate = Convert.ToDateTime(reader["InspectedDate"]);
                        //p.RepairedDate = Convert.ToDateTime(reader["RepairDate"]);
                        //p.IsValidated = Convert.ToBoolean(reader["IsValidated"]);

                        Pothole p = MapRows(reader);

                        allPotholes.Add(p);
                    }
                }
            }
            catch (SqlException ex)
            {
                throw;
            }

            return(allPotholes);
        }
        public Pothole GetOnePotholes(string id)
        {
            Pothole pothole = new Pothole();

            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(SQL_GetSinglePothole, conn);
                    cmd.Parameters.AddWithValue("@id", id);
                    SqlDataReader reader = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        pothole.PotholeID    = Convert.ToInt32(reader["PotHole_ID"]);
                        pothole.Status       = Convert.ToString(reader["Status"]);
                        pothole.Severity     = Convert.ToInt32(reader["Severity"]);
                        pothole.DateReported = Convert.ToDateTime(reader["Date_Reported"]);
                        if (reader["Repair_Date"] is DBNull)
                        {
                            pothole.RepairDate = null;
                        }
                        else
                        {
                            pothole.RepairDate = Convert.ToDateTime(reader["Repair_Date"]);
                        }
                        if (reader["Inspect_Date"] is DBNull)
                        {
                            pothole.InspectDate = null;
                        }
                        else
                        {
                            pothole.InspectDate = Convert.ToDateTime(reader["Inspect_Date"]);
                        }

                        pothole.Longitude = Convert.ToDecimal(reader["Longitude"]);
                        pothole.Latitude  = Convert.ToDecimal(reader["Latitude"]);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(pothole);
        }
Exemple #22
0
        public void UpdatePotholeTest()
        {
            DateTime repair  = new DateTime(2018, 5, 30);
            DateTime inspect = new DateTime(2018, 4, 30);

            PotholeDAL sql     = new PotholeDAL(connectionString);
            Pothole    pothole = new Pothole
            {
                PotholeID   = updateId,
                Status      = "Inspected",
                Severity    = 5,
                RepairDate  = null,
                InspectDate = inspect,
            };

            Assert.AreEqual(true, sql.UpdatePothole(pothole));
        }
Exemple #23
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Pothole = await _context.Pothole.FindAsync(id);

            if (Pothole != null)
            {
                _context.Pothole.Remove(Pothole);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
 public ActionResult ReportPothole(Pothole pothole)
 {
     //Create an array to hold the address
     string[] addressSplit;
     //Split the address
     addressSplit = pothole.Location.Split(" ");
     //Check the array to make sure the info is in the format that is wanted
     if (addressSplit[0] == "" || addressSplit[1] == "" || addressSplit[2] == "" || addressSplit[3] == "" || addressSplit[4] == "" || addressSplit[5] == "" || pothole.Description == "")
     {
         return(Forbid());
     }
     else
     {
         Pothole pothole1 = potholeDAO.ReportApothole(pothole);
         return(Ok());
     }
 }
        //The method that convert the data from sql data types to C# Objects
        private Pothole PotholeData(SqlDataReader reader)
        {
            //Location location = ParseAddress(Convert.ToString(reader["Location"]));
            ParseAddressModel addressModel = ParseAddress(Convert.ToString(reader["Location"]));
            Pothole           pothole      = new Pothole();

            pothole.Id          = Convert.ToInt32(reader["Id"]);
            pothole.Location    = Convert.ToString(reader["Location"]);
            pothole.DateAdded   = Convert.ToDateTime(reader["DateAdded"]);
            pothole.Description = Convert.ToString(reader["Description"]);
            pothole.Status      = (PotholeStatus)Convert.ToInt32(reader["Status"]);
            pothole.Severity    = Convert.ToInt32(reader["Severity"]);
            pothole.Latitude    = addressModel.results[0].geometry.location.Lat;
            pothole.Longitude   = addressModel.results[0].geometry.location.Lng;



            return(pothole);
        }
    // Update is called once per frame
    void Update()
    {
        Pothole pothole = CheckForPotholes();

        if (pothole != null)
        {
            carState.TransitionToState(stoppedByPotholeState, pothole, PotholeDone);
        }

        CharacterNavigationController otherCar = CheckForOtherCars();

        if (otherCar != null)
        {
            if (otherCar.carState.StoppedByPothole())
            {
                carState.TransitionToState(stoppedByPotholeState, otherCar.carState.GetPothole(), PotholeDone);
            }
            else
            {
                carState.TransitionToState(stoppedByCarState, otherCar);
            }
        }

        if (pothole == null && otherCar == null && !carState.IsMoving())
        {
            carState.TransitionToState(movingState);
        }

        if (carState.IsMoving())
        {
            MoveTowardsDestination();
        }
        else
        {
            carState.TimeGoesBy(Time.deltaTime);
            if (carState.NeedToKillCar())
            {
                Destroy(this.gameObject);
            }
        }
    }
    public void FinishPothole(Pothole pothole, int workerCount)
    {
        Vector2Int gridIndex     = grid.GetGridIndexByPosition(pothole.transform.position);
        GameObject potholeObject = grid.GetRoadObjectFromGird(gridIndex.x, gridIndex.y);

        if (potholeObject.GetComponent <Pothole>() == pothole)
        {
            //Create road
            GameObject roadObject = placementManager.CreateRoadObject(gridIndex.x, gridIndex.y, grid, roadRepository.roadModelCollection.straightRoadPrefab.prefab);

            //Remove Pothole from grid
            placementManager.RemoveObject(potholeObject);

            //Set the road to the grid
            grid.PlaceRoadToGrid(gridIndex.x, gridIndex.y, roadObject, false);

            //Change numbers
            ChangePotholeCount(new Vector3Int(0, -1, 1));
            ChangeAvailableWorker(workerCount);
        }
    }
    public void StartRepairPothole(Pothole pothole, int workerCount)
    {
        Vector2Int gridIndex  = grid.GetGridIndexByPosition(pothole.transform.position);
        GameObject gridObject = grid.GetRoadObjectFromGird(gridIndex.x, gridIndex.y);

        if (gridObject.GetComponent <Pothole>() == pothole)
        {
            //Remove indicator
            GameObject indicator = pothole.gameObject.GetComponentInChildren <IconController>().gameObject;
            placementManager.RemoveObject(indicator);

            //Add canvas and particle system
            GameObject canvas = placementManager.AddSliderIconToPothole(pothole.gameObject);
            canvas.GetComponent <SliderController>().SetSolveTime(pothole.repairTime);

            GameObject repairParticle = placementManager.AddParticleSystemToPothole(pothole.gameObject);

            //Change numbers
            ChangePotholeCount(new Vector3Int(-1, 1, 0));
            ChangeAvailableWorker(-workerCount);
        }
    }
        public ActionResult UpdatePothole(Pothole updatedPothole, int?page)
        {
            potholeDAL.UpdatePothole(updatedPothole);
            string id        = updatedPothole.PotholeID.ToString();
            int    pageSize  = 15;
            int    pageIndex = 1;

            pageIndex = page.HasValue ? Convert.ToInt32(page) : 1;
            IPagedList <Pothole> pagedPotholes = null;
            List <Pothole>       potholeList   = potholeDAL.GetAllPotholes();

            pagedPotholes = potholeList.ToPagedList(pageIndex, pageSize);

            if (IsEmployee())
            {
                return(View("ViewPotholesForEmp", pagedPotholes));
            }
            else
            {
                return(View("ViewPotholes", pagedPotholes));
            }
        }
        public bool UpdatePothole(Pothole update)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(SQL_UpdatePothole, conn);

                    cmd.Parameters.AddWithValue("@potholeid", update.PotholeID);
                    cmd.Parameters.AddWithValue("@status", update.Status);
                    cmd.Parameters.AddWithValue("@severity", update.Severity);
                    if (update.RepairDate == null)
                    {
                        cmd.Parameters.AddWithValue("@repairDate", DBNull.Value).IsNullable = true;
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@repairDate", update.RepairDate).IsNullable = true;
                    }
                    if (update.InspectDate == null)
                    {
                        cmd.Parameters.AddWithValue("@inspectDate", DBNull.Value).IsNullable = true;
                    }
                    else
                    {
                        cmd.Parameters.AddWithValue("@inspectDate", update.InspectDate).IsNullable = true;
                    }
                    int rowsAffected = cmd.ExecuteNonQuery();


                    return(rowsAffected > 0);
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }