コード例 #1
0
ファイル: GraphController.cs プロジェクト: Error503/Capstone
        private List<TimelineDisplayViewModel> GetTimelineElements(DateTime start, DateTime end)
        {
            List<TimelineDisplayViewModel> result = new List<TimelineDisplayViewModel>();

            List<BasicNodeModel> nodes;
            using (NeoDriver driver = new NeoDriver())
            {
                nodes = driver.GetNodesBetweenDates(start, end);
            }

            // Convert the nodes to TimelineDisplayViewModel objects
            foreach (BasicNodeModel n in nodes)
            {
                result.Add(new TimelineDisplayViewModel
                {
                    Id = n.Id.ToString(),
                    DataType = n.ContentType,
                    CommonName = n.CommonName,
                    ReleaseDate = n.ReleaseDate.HasValue ? n.ReleaseDate.Value : -1,
                    DeathDate = n.DeathDate.HasValue ? n.DeathDate.Value : -1
                });
            }

            return result;
        }
コード例 #2
0
ファイル: GraphController.cs プロジェクト: Error503/Capstone
        public ActionResult GetNodeInformation(Guid id)
        {
            BasicNodeModel model = new BasicNodeModel();
            if(id != Guid.Empty)
            {
                using (NeoDriver driver = new NeoDriver())
                {
                    model = driver.GetNode(id);
                }
            }

            return Json(model, JsonRequestBehavior.AllowGet);
        }
コード例 #3
0
ファイル: EditController.cs プロジェクト: Error503/Capstone
        public ActionResult FlagDeletion(Guid id)
        {
            string message = "An error occurred. The node was not flagged";

            Response.StatusCode = (int)HttpStatusCode.InternalServerError;
            BasicNodeModel toDelete = null;

            using (NeoDriver driver = new NeoDriver())
            {
                toDelete = driver.GetNode(id);
            }

            // If the node with the given id is not null,
            if (toDelete != null)
            {
                DatabaseRequest request = new DatabaseRequest
                {
                    Id             = Guid.NewGuid(),
                    RequestType    = DatabaseRequestType.Delete,
                    SubmissionDate = DateTime.Now,
                    NodeDataType   = toDelete.ContentType,
                    NodeData       = JsonConvert.SerializeObject(BasicNodeViewModel.FromModel(toDelete)),
                    Approved       = false,
                    ApprovalDate   = null,
                    Notes          = null,
                    Reviewed       = false,
                    ReviewedDate   = null,
                    Reviewer       = null,
                    ReviewerRefId  = null
                };

                // Add a deletion request,
                using (ApplicationDbContext context = ApplicationDbContext.Create())
                {
                    request.Submitter = context.Users.Single(u => u.UserName == User.Identity.Name);
                    context.Requests.Add(request);
                    context.SaveChanges();
                }

                message             = "Node flagged for deletion";
                Response.StatusCode = (int)HttpStatusCode.Accepted;
            }
            else
            {
                message             = "Could not find the specified node.";
                Response.StatusCode = (int)HttpStatusCode.NotFound;
            }

            return(Json(new { message = message }));
        }
コード例 #4
0
ファイル: MeadowApp.cs プロジェクト: jpearsonduluth/Hello-F7
        public MeadowApp()
        {
            Console.WriteLine("starting neo");
            var neo = new NeoDriver(20, Device.Pins.D01);

            byte intensity            = 0x10;
            byte halfIntensity        = (byte)(intensity / 2);
            byte quarterIntensity     = (byte)(halfIntensity / 2);
            byte quarterHalfIntensity = (byte)(halfIntensity + quarterIntensity);

            Console.WriteLine("VARS SET");
            //Color[] background =
            //{
            //    new Color(0,intensity,0),
            //    new Color(0,quarterHalfIntensity,quarterIntensity),
            //    new Color(0,0,intensity),
            //    new Color(quarterIntensity,0,quarterHalfIntensity),
            //    new Color(intensity,0,0),
            //    new Color(quarterHalfIntensity,quarterIntensity,0),
            //    new Color(quarterIntensity,quarterHalfIntensity,0),
            //};



            neo.ChangeAllColor((byte)100, (byte)0, (byte)200);
            neo.Off();
            neo.Show();
            Console.WriteLine("neo started");

            //int r = 10;
            //int g = 50;
            //int b = 100;

            //while (r <= 256 && g <= 256 && b <= 256)
            //{
            //    r += 30; g += 20; b += 10;
            //    Console.WriteLine($"R: {r}; G: {g}; B: {b};");
            //    neo.ChangeAllColor((byte)r, (byte)g, (byte)b);
            //    neo.Off();
            //    Console.WriteLine("showing pixels");
            //    neo.Show();
            //    Console.WriteLine("nappy time");
            //    Thread.Sleep(200);
            //}
        }
コード例 #5
0
ファイル: GraphController.cs プロジェクト: Error503/Capstone
        public ActionResult TimelineData(Guid? id, string text)
        {
            BasicNodeModel model = null;

            using (NeoDriver driver = new NeoDriver())
            {
                if(!id.HasValue || id == Guid.Empty)
                {
                    model = driver.GetNode(text);
                }
                else
                {
                    model = driver.GetNode(id.Value);
                }
            }

            return Json(new { success = model != null,  ReleaseDate = model?.ReleaseDate, DeathDate = model?.DeathDate }, JsonRequestBehavior.AllowGet);
        }
コード例 #6
0
ファイル: EditController.cs プロジェクト: Error503/Capstone
        // GET: Edit/Index/
        public ActionResult Index(string id)
        {
            ActionResult result = View("Error");

            if (!string.IsNullOrWhiteSpace(id))
            {
                // Try to parse the Guid string
                Guid parsedId;
                if (Guid.TryParse(id, out parsedId))
                {
                    // The string was parsed, find the node
                    // We have been given an id of a node to edit
                    ViewBag.Title = "Edit Node Data";
                    BasicNodeViewModel viewModel = null;
                    // Get the node to edit
                    using (NeoDriver driver = new NeoDriver())
                    {
                        BasicNodeModel model = driver.GetNodeAndRelationships(parsedId);
                        viewModel = BasicNodeViewModel.FromModel(model);
                    }
                    // Return a view
                    if (viewModel != null)
                    {
                        result = View(model: viewModel);
                    }
                }
                else
                {
                    Response.StatusCode        = (int)HttpStatusCode.BadRequest;
                    Response.StatusDescription = $"Invalid id value: {id}";
                }
            }
            else
            {
                // We are creating a new node
                ViewBag.Title = "Create New Node";
                result        = View(model: new BasicNodeViewModel {
                    Id = Guid.NewGuid(), ContentType = 0
                });
            }
            return(result);
        }
コード例 #7
0
ファイル: EditController.cs プロジェクト: Error503/Capstone
        private ActionResult CheckModelAndMakeRequest(BasicNodeViewModel model)
        {
            ActionResult result = View("Index", model);

            // If the model state is valid,
            if (ModelState.IsValid)
            {
                DatabaseRequestType requestType = 0;
                using (NeoDriver driver = new NeoDriver())
                {
                    // TODO: This will no longer work to check if this is an update or creation request
                    requestType = driver.GetNode(model.Id) != null ? DatabaseRequestType.Update : DatabaseRequestType.Create;
                }
                // Create the database request
                CreateDatabaseRequest(model, requestType);
                // Redirect to the accepted page
                result = RedirectToAction("Accepted", "Edit");
            }

            return(result);
        }
コード例 #8
0
ファイル: GraphController.cs プロジェクト: Error503/Capstone
        private GraphDataViewModel GetPaths(Guid? id, string searchText)
        {
            GraphDataViewModel result = null;
            // Get the paths from the database
            List<IPath> paths = new List<IPath>();
            using (NeoDriver driver = new NeoDriver())
            {
                if(id == null || id == Guid.Empty)
                {
                    paths = driver.GetPaths(searchText.ToLower());
                }
                else
                {
                    paths = driver.GetPaths(id.Value);
                }

                if(paths.Count == 0)
                {
                    BasicNodeModel model = id == null || id == Guid.Empty ? driver.GetNode(searchText) : driver.GetNode(id.Value);

                    if(model != null)
                    {
                        result.Source = new GraphNodeViewModel
                        {
                            Id = model.Id.ToString(),
                            CommonName = model.CommonName,
                            DataType = model.ContentType
                        };
                        result.RelatedNodes = new List<GraphNodeViewModel>();
                    }
                }
                else
                {
                    result = ConvertFromPaths(paths);
                }
            }

            return result;
        }
コード例 #9
0
ファイル: GraphController.cs プロジェクト: Error503/Capstone
        public ActionResult GetEdgeInformation(Guid source, Guid target)
        {
            GraphEdgeViewModel viewModel = new GraphEdgeViewModel();
            if(source != Guid.Empty && target != Guid.Empty)
            {
                using (NeoDriver driver = new NeoDriver())
                {
                    IRecord record = driver.GetRelationship(source, target);

                    if(record != null)
                    {
                        viewModel = new GraphEdgeViewModel
                        {
                            SourceName = record[0].As<string>(),
                            TargetName = record[2].As<string>(),
                            Roles = record[1].As<List<string>>()
                        };
                    }
                }
            }

            return Json(viewModel, JsonRequestBehavior.AllowGet);
        }