public void OnRestaurantObjectRemoved(object sender, RestaurantObject restaurantObject) { Logged(this, $"Из ресторана {sender} удален объект типа {restaurantObject.GetType()}. " + $"Иформация по объекту:{Environment.NewLine}{restaurantObject}"); switch (restaurantObject.RestaurantObjectType) { case RestaurantObjectType.None: throw new ArgumentException("Unknown restaurant object.", nameof(restaurantObject)); case RestaurantObjectType.Cashier: (restaurantObject as AbstractCashier).OrderAccepted -= OnOrderAccepted; break; case RestaurantObjectType.Cook: (restaurantObject as AbstractCook).OrderCompleted -= OnOrderCompleted; break; case RestaurantObjectType.ProductDeliveryWindow: (restaurantObject as AbstractProductDeliveryWindow).CompletedOrderTaken -= OnCompletedOrderTaken; break; case RestaurantObjectType.Table: (restaurantObject as AbstractTable).OrderMarkedCompleted -= OnOrderMarkedCompleted; break; default: throw new ArgumentException("Unknown restaurant object type.", nameof(restaurantObject.RestaurantObjectType)); } }
protected void btnAddRestaurantMakeReview_Click(object sender, EventArgs e) { UserFunctions uf = new UserFunctions(); string name = txtnewRestName.Text; string phone = txtNewRestPhone.Text; string address = txtnewRestAddress.Text; string cuisinetype = ddlNewRestCuisine.Text; RestaurantObject newRestaurant = new RestaurantObject(name, address, phone, cuisinetype, 1, 1); uf.AddNewRestaurantDB(name, address, phone, cuisinetype); //Adds record to the Restaurant Database Session["Restaurant"] = newRestaurant; Response.Redirect("AddReview.aspx"); }
protected void btnAddRestaurantReturnHome_Click(object sender, EventArgs e) { UserFunctions uf = new UserFunctions(); string name = txtnewRestName.Text; string phone = txtNewRestPhone.Text; string address = txtnewRestAddress.Text; string cuisinetype = ddlNewRestCuisine.Text; if (name == "") { lblErrorMessage.Text = "Please fill out all fields before submitting."; return; } if (phone == "") { lblErrorMessage.Text = "Please fill out all fields before submitting."; return; } if (address == "") { lblErrorMessage.Text = "Please fill out all fields before submitting."; return; } if (cuisinetype == "") { lblErrorMessage.Text = "Please fill out all fields before submitting."; return; } RestaurantObject newRestaurant = new RestaurantObject(name, address, phone, cuisinetype, 1, 1); uf.AddNewRestaurantDB(name, address, phone, cuisinetype); //Adds record to the Restaurant Database Session["Restaurant"] = newRestaurant; Response.Redirect("UserHome.aspx"); }
// Update is called once per frame void Update() { try { UpdateLineChartPositions(); if (curBarGraph != null) { curBarGraph.transform.position = BarGraph.transform.position; curBarGraph.transform.rotation = new Quaternion(0, 0, 0, 0); } if (curLineChart != null) { curLineChart.transform.position = LineChart.transform.position; curLineChart.transform.rotation = new Quaternion(0, 0, 0, 0); } if (ModeSelection) { if (Input.touchCount > 0) { if (EventSystem.current.IsPointerOverGameObject(0)) // is the touch on the GUI { return; } Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit Hit; if (Physics.Raycast(ray, out Hit, 20.0f)) { if ((Hit.transform.name.StartsWith("BrooklynCollider") || (Hit.transform.name.StartsWith("StatenIslandCollider")) || (Hit.transform.name.StartsWith("ManhattanCollider")) || (Hit.transform.name.StartsWith("QueensCollider")) || (Hit.transform.name.StartsWith("BronxCollider")))) { currentObject = Hit.transform.gameObject; } if (Hit.transform.name.StartsWith("BrooklynCollider")) { currentBoro = BrooklynPlane; curBoroRestaurantDict = BoroWiseDict["BROOKLYN"]; } else if (Hit.transform.name.StartsWith("StatenIslandCollider")) { currentBoro = StatenIslandPlane; curBoroRestaurantDict = BoroWiseDict["STATEN ISLAND"]; } else if (Hit.transform.name.StartsWith("BronxCollider")) { currentBoro = BronxPlane; curBoroRestaurantDict = BoroWiseDict["BRONX"]; } else if (Hit.transform.name.StartsWith("ManhattanCollider")) { currentBoro = ManhattanPlane; curBoroRestaurantDict = BoroWiseDict["MANHATTAN"]; } else if (Hit.transform.name.StartsWith("QueensCollider")) { currentBoro = QueensPlane; curBoroRestaurantDict = BoroWiseDict["QUEENS"]; } } } } else if (InTransitionZoomIn) { TransitionMapTowardsCamera(); } else if (InTransitionZoomOut) { ZoomOut(); } else if (ModeBuild) { if (currentObject == null) { ARText.GetComponent <TextMesh>().text = "Select a restaurant!"; } if (Input.touchCount > 0) { if (EventSystem.current.IsPointerOverGameObject(0)) // is the touch on the GUI { // GUI Action //ARText.GetComponent<TextMesh>().text = "UI TOUCH!"; return; } Ray ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position); RaycastHit Hit; if (Physics.Raycast(ray, out Hit, 20.0f)) { currentObject = Hit.transform.gameObject; if (Hit.transform.name.StartsWith("RES:")) { //ARAreaText.GetComponent<TextMesh>().text = "Selected Area: " + Hit.transform.name; RestaurantObject restaurantObject = null; if (currentBoro == BrooklynPlane) { restaurantObject = BoroWiseDict["BROOKLYN"][Hit.transform.name]; } else if (currentBoro == StatenIslandPlane) { restaurantObject = BoroWiseDict["STATEN ISLAND"][Hit.transform.name]; } else if (currentBoro == BronxPlane) { restaurantObject = BoroWiseDict["BRONX"][Hit.transform.name]; } else if (currentBoro == QueensPlane) { restaurantObject = BoroWiseDict["QUEENS"][Hit.transform.name]; } else if (currentBoro == ManhattanPlane) { restaurantObject = BoroWiseDict["MANHATTAN"][Hit.transform.name]; } restaurantObject.restaurantGameObject.GetComponent <Light>().enabled = true; restaurantObject.restaurantGameObject.GetComponent <Light>().range = restaurantObject.restaurantGameObject.GetComponent <Light>().range + HaloChange; restaurantObject.restaurantGameObject.GetComponent <Light>().intensity = restaurantObject.restaurantGameObject.GetComponent <Light>().intensity + HaloChange; //if ((restaurantObject.restaurantGameObject.GetComponent<Light>().range > 0.1) || (restaurantObject.restaurantGameObject.GetComponent<Light>().range < 0.01)) //{ // HaloChange = HaloChange * -1; //} ARText.GetComponent <TextMesh>().text = "Restaurant Details: "; ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nName: " + restaurantObject.restaurantDetails.features["DBA"]; ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nPhone: " + restaurantObject.restaurantDetails.features["PHONE"]; ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nCriticality: " + restaurantObject.restaurantDetails.features["CRITICALFLAG"]; ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nGrade: " + restaurantObject.restaurantDetails.features["GRADE"]; ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nScore: " + restaurantObject.restaurantDetails.features["SCORE"]; ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nCuisines: " + restaurantObject.restaurantDetails.features["CUISINEDESCRIPTION"]; } } } } float newX = BiggestPlane.transform.position.x + LeftJoystick.Horizontal / 50; float newZ = BiggestPlane.transform.position.z + LeftJoystick.Vertical / 50; BiggestPlane.transform.position = new Vector3(newX, BiggestPlane.transform.position.y, newZ); BiggestPlane.transform.Rotate(new Vector3(0, RightJoystick.Horizontal, 0)); if (currentObject != null) { ARAreaText.GetComponent <TextMesh>().text = "Selected Area: " + selectedBoro; } } catch (Exception ex) { ExceptionOccured = true; UnityEngine.Debug.Log("EXCEPTION!"); var st = new StackTrace(ex, true); // Get the top stack frame var frame = st.GetFrame(0); // Get the line number from the stack frame var line = frame.GetFileLineNumber(); LastExceptionString = line.ToString(); } //if (ExceptionOccured) // ARText.GetComponent<TextMesh>().text = "Exception update!: " + LastExceptionString; }
void CreateAndPlaceCubesOnMap() { try { System.Random rand = new System.Random(); #region Deleting previously visible cubes that don't fit the query. List <RestaurantObject> toBeRemoved = new List <RestaurantObject>(); foreach (RestaurantObject curCubeObject in allVisibleCubes) { if ((Int32.Parse(curCubeObject.restaurantDetails.features["SCORE"]) < selectedThreshold) || !(curCubeObject.restaurantDetails.features["BORO"].Equals(selectedBoro))) { Destroy(curCubeObject.restaurantGameObject); toBeRemoved.Add(curCubeObject); //allVisibleCubes.Remove(curCubeObject); } } foreach (RestaurantObject curCubeObject in toBeRemoved) { allVisibleCubes.Remove(curCubeObject); } #endregion #region Restaurant 3D code foreach (KeyValuePair <string, RestaurantObject> curPair in BoroWiseDict[selectedBoro]) { RestaurantObject curRestaurantObject = curPair.Value; Restaurant curRestaurant = curRestaurantObject.restaurantDetails; if (Int32.Parse(curRestaurant.features["SCORE"]) > selectedThreshold) { if (!allVisibleCubes.Contains(curRestaurantObject)) { curRestaurantObject.restaurantGameObject = Instantiate(Restaurant3DGameObject); curRestaurantObject.restaurantGameObject.transform.parent = ImagePlane.transform; curRestaurantObject.restaurantGameObject.transform.localScale = new Vector3( Restaurant3DGameObject.transform.localScale.x, Restaurant3DGameObject.transform.localScale.y + 0.1f, Restaurant3DGameObject.transform.localScale.z); curRestaurantObject.restaurantGameObject.SetActive(true); GameObject targetPlane = BrooklynPlane; if (curRestaurant.features["BORO"].Equals("BROOKLYN")) { targetPlane = BrooklynPlane; } else if (curRestaurant.features["BORO"].Equals("MANHATTAN")) { targetPlane = ManhattanPlane; } else if (curRestaurant.features["BORO"].Equals("BRONX")) { targetPlane = BronxPlane; } else if (curRestaurant.features["BORO"].Equals("STATEN ISLAND")) { targetPlane = StatenIslandPlane; } else if (curRestaurant.features["BORO"].Equals("QUEENS")) { targetPlane = QueensPlane; } float randomFactor = 0.2f; if (targetPlane == ManhattanPlane) { randomFactor = 0.05f; } if (targetPlane == BronxPlane) { randomFactor = 0.1f; } if (ZoomedIn) { randomFactor = 3f; } float X_Offset = (float)(rand.NextDouble()) * randomFactor; float Z_Offset = (float)(rand.NextDouble()) * randomFactor; curRestaurantObject.restaurantGameObject.transform.position = new Vector3( targetPlane.transform.position.x + X_Offset, targetPlane.transform.position.y, targetPlane.transform.position.z + Z_Offset ); if (curRestaurant.features["CRITICALFLAG"].Equals("Critical")) { curRestaurantObject.restaurantGameObject.transform.Find("3DModel").gameObject.GetComponent <Renderer>().material.color = new Color(100, 0, 0, 0.5f); } else { curRestaurantObject.restaurantGameObject.transform.Find("3DModel").gameObject.GetComponent <Renderer>().material.color = new Color(0, 100, 0, 50f); } curRestaurantObject.restaurantGameObject.transform.Find("3DModel").name = "RES:" + curRestaurant.features["ID"]; curRestaurantObject.restaurantGameObject.transform.Find("RestaurantLabel").GetComponent <TextMesh>().text = curRestaurant.features["DBA"]; allVisibleCubes.Add(curRestaurantObject); } } } #endregion #region Graph Updation Calculations int criticalYes = 0; int criticalNo = 0; Dictionary <int, int> monthCriticalCount = new Dictionary <int, int>(); Dictionary <int, int> monthInspectionCount = new Dictionary <int, int>(); Dictionary <string, int> cuisineCount = new Dictionary <string, int>(); for (int i = 1; i <= 12; i++) { monthCriticalCount[i] = 0; monthInspectionCount[i] = 0; } foreach (RestaurantObject curCubeObject in allVisibleCubes) { if (curCubeObject.restaurantDetails.features["CRITICALFLAG"].Equals("Critical")) { criticalYes++; monthCriticalCount[Int32.Parse(curCubeObject.restaurantDetails.features["MONTH"])]++; } else { criticalNo++; } //Debug.Log("1"); monthInspectionCount[Int32.Parse(curCubeObject.restaurantDetails.features["MONTH"])]++; //Debug.Log("2"); if (cuisineCount.ContainsKey(curCubeObject.restaurantDetails.features["CUISINEDESCRIPTION"])) { //Debug.Log("3"); cuisineCount[curCubeObject.restaurantDetails.features["CUISINEDESCRIPTION"]]++; //Debug.Log("4"); } else { cuisineCount[curCubeObject.restaurantDetails.features["CUISINEDESCRIPTION"]] = 1; } } List <CuisineCount> CuisineCountList = new List <CuisineCount>(); foreach (KeyValuePair <string, int> curCuisine in cuisineCount) { CuisineCount curCuisineCount = new CuisineCount(); curCuisineCount.Count = curCuisine.Value; curCuisineCount.Name = curCuisine.Key; CuisineCountList.Add(curCuisineCount); } //Debug.Log("5"); CuisineCountList.Sort((x, y) => y.Count - x.Count); int CuisineGraphCount = 15; string[] CuisineXLabels = new string[CuisineGraphCount]; float[] CuisineYLabels = new float[CuisineGraphCount]; if (CuisineCountList.Count < 15) { CuisineGraphCount = CuisineCountList.Count; } int labelCount = 0; for (int i = 0; i < CuisineGraphCount - 1; i++) { if (CuisineCountList[i].Count == 0) { continue; } CuisineXLabels[labelCount] = CuisineCountList[i].Name; CuisineYLabels[labelCount] = CuisineCountList[i].Count; labelCount++; } CuisineXLabels[CuisineGraphCount - 1] = "Others"; CuisineYLabels[CuisineGraphCount - 1] = 0f; for (int i = CuisineGraphCount - 1; i < CuisineCountList.Count; i++) { CuisineYLabels[CuisineGraphCount - 1] = CuisineYLabels[CuisineGraphCount - 1] + CuisineCountList[i].Count; } //Removing zero count cuisines string[] CuisineXLabelsCleaned = new string[labelCount]; float[] CuisineYLabelsCleaned = new float[labelCount]; for (int i = 0; i < labelCount; i++) { CuisineXLabelsCleaned[i] = CuisineXLabels[i]; CuisineYLabelsCleaned[i] = CuisineYLabels[i]; } //Debug.Log("8"); CreateBarGraph(CuisineXLabelsCleaned, CuisineYLabelsCleaned, CuisineYLabelsCleaned[0], "Cuisines", "Restaurant Count"); //CreateBarGraph(new string[] { "Critical", "Not Critical"}, new float[] { criticalYes, criticalNo }, criticalYes + criticalNo); string[] monthsLabels = new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; float[] InspectionTrend = new float[12]; float[] CriticalTrend = new float[12]; for (int i = 1; i <= 12; i++) { if (monthInspectionCount.ContainsKey(i)) { InspectionTrend[i - 1] = monthInspectionCount[i]; } if (monthCriticalCount.ContainsKey(i)) { CriticalTrend[i - 1] = monthCriticalCount[i]; } } CreateLineChart(monthsLabels, InspectionTrend, CriticalTrend, "Months", "Count"); #endregion } catch (Exception ex) { var st = new StackTrace(ex, true); // Get the top stack frame var frame = st.GetFrame(0); // Get the line number from the stack frame var line = frame.GetFileLineNumber(); LastExceptionString = "ex! cube function!"; ExceptionOccured = true; } }
// Start is called before the first frame update void Start() { try { #region Setting colors for bar graph barColors = new List <Color>(); barColors.Add(Color.red); barColors.Add(Color.blue); barColors.Add(Color.yellow); barColors.Add(Color.gray); barColors.Add(Color.green); barColors.Add(Color.cyan); barColors.Add(Color.white); barColors.Add(Color.magenta); barColors.Add(Color.grey); barColors.Add(Color.black); barColors.Add(Color.clear); barColors.Add(Color.cyan); barColors.Add(new Color(30, 60, 90)); barColors.Add(Color.red); barColors.Add(Color.cyan); barColors.Add(Color.yellow); #endregion selectedThreshold = 50; selectedBoro = "QUEENS"; allVisibleCubes = new List <RestaurantObject>(); System.Random rand = new System.Random(); BoroWiseDict = new Dictionary <string, Dictionary <string, RestaurantObject> >(); BoroWiseDict["MANHATTAN"] = new Dictionary <string, RestaurantObject>(); BoroWiseDict["BRONX"] = new Dictionary <string, RestaurantObject>(); BoroWiseDict["STATEN ISLAND"] = new Dictionary <string, RestaurantObject>(); BoroWiseDict["BROOKLYN"] = new Dictionary <string, RestaurantObject>(); BoroWiseDict["QUEENS"] = new Dictionary <string, RestaurantObject>(); BiggestPlane = ImagePlane; //test.csv //Features = new string[] { "ID", "CAMIS", "DBA", "BORO", "BUILDING", "STREET", "ZIPCODE", "PHONE", "INSPECTIONDATE", "ACTION", "VIOLATIONCODE", "CRITICALFLAG", "SCORE", "GRADE", "GRADEDATE", "RECORDDATE", "INSPECTIONTYPE" }; //valid_data.csv //Features = new string[] { "ID", "CAMIS", "DBA", "BORO", "BUILDING", "STREET", "ZIPCODE", "PHONE", "CUISINEDESCRIPTION", "INSPECTIONDATE", "ACTION", "VIOLATIONCODE", "VIOLATIONDESCRIPTION", "CRITICALFLAG", "SCORE", "GRADE", "GRADEDATE", "RECORDDATE", "INSPECTIONTYPE", "MONTH" }; //testnkTruncated.csv Features = new string[] { "ID", "DBA", "BORO", "STREET", "ZIPCODE", "PHONE", "CUISINEDESCRIPTION", "INSPECTIONDATE", "VIOLATIONDESCRIPTION", "CRITICALFLAG", "SCORE", "GRADE", "MONTH" }; //dict = new Dictionary<string, List<Restaurant>>(); //PlacedGameObjects = new List<GameObject>(); Button btn = FinalizePlaneButton.GetComponent <Button>(); btn.onClick.AddListener(FinalizePlane); Button btn2 = SelectAreaButton.GetComponent <Button>(); btn2.onClick.AddListener(MoveToSelectedArea); Button btn3 = ButtonZoomOut.GetComponent <Button>(); btn3.onClick.AddListener(SwitchToZoomOutMode); Button btn4 = ButtonManhattan.GetComponent <Button>(); btn4.onClick.AddListener(ApplyManhattanFilter); Button btn5 = ButtonBronx.GetComponent <Button>(); btn5.onClick.AddListener(ApplyBronxFilter); Button btn6 = ButtonBrooklyn.GetComponent <Button>(); btn6.onClick.AddListener(ApplyBrooklynFilter); Button btn7 = ButtonQueens.GetComponent <Button>(); btn7.onClick.AddListener(ApplyQueensFilter); Button btn8 = ButtonStatenIsland.GetComponent <Button>(); btn8.onClick.AddListener(ApplyStatenIslandFilter); slider.onValueChanged.AddListener(ChangeThreshold); using (var reader = new StreamReader(new MemoryStream((Resources.Load("test10kTruncated") as TextAsset).bytes))) { int rowCount = 0; while (!reader.EndOfStream) { //Processing row string[] fields = reader.ReadLine().Split(','); if (rowCount == 0) { rowCount++; continue; } Restaurant curRestaurant = new Restaurant(); int curFeatureIndex = 0; foreach (string field in fields) { curRestaurant.features[Features[curFeatureIndex++]] = field; } RestaurantObject curRestaurantObject = new RestaurantObject(); curRestaurantObject.restaurantDetails = curRestaurant; BoroWiseDict[curRestaurant.features["BORO"]]["RES:" + curRestaurant.features["ID"]] = curRestaurantObject; rowCount++; } ARText.GetComponent <TextMesh>().text = "RESTAURANT COUNT:"; ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nManhattan: " + BoroWiseDict["MANHATTAN"].Count.ToString(); ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nBronx: " + BoroWiseDict["BRONX"].Count.ToString(); ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nQueens: " + BoroWiseDict["QUEENS"].Count.ToString(); ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nBrooklyn: " + BoroWiseDict["BROOKLYN"].Count.ToString(); ARText.GetComponent <TextMesh>().text = ARText.GetComponent <TextMesh>().text + "\nStaten Island: " + BoroWiseDict["STATEN ISLAND"].Count.ToString(); } CreateAndPlaceCubesOnMap(); } catch (Exception ex) { ExceptionOccured = true; var st = new StackTrace(ex, true); // Get the top stack frame var frame = st.GetFrame(0); // Get the line number from the stack frame var line = frame.GetFileLineNumber(); LastExceptionString = "??"; } }