Example #1
0
        public IActionResult Charted()
        {
            inputstate here = new inputstate();

            here.state = "USA";
            List <int> vals = new List <int>();
            var        rob  = dbContext.Robocalls.Select(x => x.Robocall).Distinct();

            foreach (var i in rob)
            {
                vals.Add(dbContext.Robocalls.Count(x => x.Robocall == i));
            }

            var val = vals;

            ViewBag.ROBO = Newtonsoft.Json.JsonConvert.SerializeObject(rob.ToList());
            ViewBag.VAL  = Newtonsoft.Json.JsonConvert.SerializeObject(vals.ToList());



            List <int> Typeval = new List <int>();
            var        typeun  = dbContext.Robocalls.Select(x => x.subject).Distinct();

            foreach (var t in typeun)
            {
                Typeval.Add(dbContext.Robocalls.Count(x => x.subject == t));
            }

            ViewBag.SUB  = Newtonsoft.Json.JsonConvert.SerializeObject(typeun.ToList());
            ViewBag.NUMS = Newtonsoft.Json.JsonConvert.SerializeObject(Typeval.ToList());

            return(View(here));
        }
Example #2
0
    private void SetStateAndType(Vector2Int hex, out uint type, out uint state)
    {
        type  = 0;
        state = 0;

        switch (tk.State)
        {
        case TerrainToolkit.state.none:
            break;

        case TerrainToolkit.state.addTile:
            type  = (uint)gridUtils.Grid.Hexagons[hex.x, hex.y].Type.ID;
            state = 1;
            break;

        case TerrainToolkit.state.removeTile:
            type  = (uint)gridUtils.Grid.Hexagons[hex.x, hex.y].Type.ID;
            state = 0;
            break;

        case TerrainToolkit.state.changeTile:
            type  = (uint)TerrainToolkit.AddTerrainID;
            state = 1;
            break;

        case TerrainToolkit.state.removeModel:
            state = 0;
            break;

        case TerrainToolkit.state.addModel:
            state = 1;
            break;

        case TerrainToolkit.state.moveModel:
            state = 2;
            break;

        default:
            break;
        }
    }
Example #3
0
    private void Update()
    {
        // DEBUG
        if (Input.GetKeyDown(KeyCode.Space))
        {
            FindObjectOfType <SerializationHandler>().SerializeData(gridUtils.Grid.SerializeData());
        }

        if (Input.GetKeyDown(KeyCode.H))
        {
            HexagonDebugInfo();
            meshUtils.MeshInit.CollectDebugVertices();
        }
        // DEBUG END


        state = GetInputState(out Vector2Int hex, out currentMousePos);

        if (state == inputstate.invalid)
        {
            if (currentSelectedModel != null)
            {
                meshUtils.ReturnToPool((int)currentSelectedModel);
            }
            return;
        }


        currentHexagon = gridUtils.Grid.Hexagons[hex.x, hex.y];

        if (TerrainToolkit.state.terrain.HasFlag(tk.State))
        {
            if (state == inputstate.interacting)
            {
                // collect information
                if (!collection.Contains(currentHexagon))
                {
                    collection.Add(currentHexagon);
                }
            }
            else if (state == inputstate.selectedCompleted)
            {
                if (collection.Count <= 0)
                {
                    return;
                }

                // submit info
                SetStateAndType(hex, out uint type, out uint state);

                uint[] types  = new uint[collection.Count];
                uint[] states = new uint[collection.Count];
                for (int i = 0; i < collection.Count; i++)
                {
                    types[i]  = type;
                    states[i] = state;
                }

                gridUtils.Grid.UpdateHexagons(collection.ToArray(), states, types);

                if (state == 0)
                {
                    // delte all models from hexagon
                    for (int i = 0; i < collection.Count; i++)
                    {
                        for (int j = 0; j < collection[i].Models.Count; j++)
                        {
                            meshUtils.ReturnToPool(collection[i].Models[j]);
                        }
                        meshUtils.ReturnToPool(collection[i].Models.ToArray());
                        collection[i].Models.Clear();
                    }
                }


                collection.Clear();
            }
        }
        else if (tk.State == TerrainToolkit.state.addModel)
        {
            if (state == inputstate.awaiting)
            {
                // collect & submit info

                if (currentSelectedModel == null || currentSelectedM.meshtype != TerrainToolkit.AddModelID)
                {
                    currentSelectedModel = meshUtils.SpawnFromPool(TerrainToolkit.AddModelID, new Vector3(currentMousePos.x, 0, currentMousePos.y), out MeshesCPUInfo model);
                    UpdateHexagons((int)currentSelectedModel, ref model);
                    currentSelectedM = model;
                    return;
                }

                meshUtils.UpdateInPool((int)currentSelectedModel, new Vector3(currentMousePos.x, 0, currentMousePos.y));

                return;
            }

            if (state == inputstate.selectedCompleted)
            {
                UpdateHexagons((int)currentSelectedModel, ref currentSelectedM);

                currentSelectedModel = null;
            }
        }
        else if (TerrainToolkit.state.selectModel.HasFlag(tk.State))
        {
            bool modelInReach = currentHexagon.GetClosestMeshFromPoint(currentMousePos, out int mid);
            bool modelValid   = meshUtils.MeshRegister.TryGetValue(mid, out MeshesCPUInfo model);

            if (state == inputstate.awaiting)
            {
                if (!modelInReach || !modelValid)
                {
                    DisableHighlights();
                    currentSelectedModel = null;
                    return;
                }

                Highlight(mid);
            }
            else if (state == inputstate.interacting)
            {
                if (modelInReach && modelValid)
                {
                    currentSelectedModel ??= mid;
                }
            }


            if (currentSelectedModel == null)
            {
                return;
            }

            if (tk.State == TerrainToolkit.state.removeModel)
            {
                if (state == inputstate.selectedCompleted)
                {
                    // collect & submit info
                    meshUtils.ReturnToPool((int)currentSelectedModel);
                    UpdateHexagons((int)currentSelectedModel, ref model);
                }
            }
            else if (tk.State == TerrainToolkit.state.moveModel)
            {
                float height = state == inputstate.interacting ? _modelMoveHeight : 0;
                if (state == inputstate.interacting || state == inputstate.selectedCompleted)
                {
                    // collect & submit info
                    meshUtils.UpdateInPool((int)currentSelectedModel, new Vector3(currentMousePos.x, height, currentMousePos.y));
                    UpdateHexagons((int)currentSelectedModel, ref model);
                }
            }

            if (state == inputstate.selectedCompleted)
            {
                DisableHighlights();
                currentSelectedModel = null;
            }
        }
    }
Example #4
0
        public IActionResult Refreshed()
        {
            inputstate newed = new inputstate();

            //dbContext.Mitigate();
            httpClient = new HttpClient();
            httpClient.DefaultRequestHeaders.Accept.Clear();
            httpClient.DefaultRequestHeaders.Accept.Add(
                new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));


            string initialData = "";

            //NoRoboComplaints Storehere = null;
            string apicall = base_url + "?api_key=" + API_key;

            httpClient.BaseAddress = new Uri(apicall);
            int c = 0;

            try
            {
                HttpResponseMessage response = httpClient.GetAsync(initial_json).GetAwaiter().GetResult();

                if (response.IsSuccessStatusCode)
                {
                    initialData = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
                }


                if (!initialData.Equals(""))
                {
                    //Console.WriteLine(initialData);

                    Console.WriteLine("Starting");
                    var Storehere = JsonConvert.DeserializeObject <List <desRobo> > (initialData);
                    Console.WriteLine("I am here");
                    Storehere.ForEach(p =>
                    {
                        dbContext.Database.EnsureCreated();
                        Console.WriteLine("I am here too");
                        var urlNameExists = dbContext.Robocalls.Any(x => x.id == p.id);
                        Console.WriteLine("I am here three");
                        if (!urlNameExists)
                        {
                            c = c + 1;
                            Console.WriteLine("I am here FOUR");
                            NoRoboComplaints Newrecord = new NoRoboComplaints()
                            {
                                id = p.id,
                                consumer_area_code   = p.attributes.consumer_area_code,
                                created_date         = p.attributes.created_date,
                                violation_date       = p.attributes.violation_date,
                                consumer_city        = p.attributes.consumer_city,
                                consumer_state       = p.attributes.consumer_state,
                                company_phone_number = p.attributes.company_phone_number,
                                subject  = p.attributes.subject,
                                Robocall = p.attributes.Robocall
                            };
                            dbContext.Robocalls.Add(Newrecord);
                            dbContext.SaveChanges();
                        }
                    });
                }
                if (c == 0)
                {
                    c = 10;
                }
                string t = c.ToString();
                newed.state = c.ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(View(newed));
        }