Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     rb       = GetComponent <Rigidbody>();
     settings = GetComponent <AgentsSettings>();
     flocking = new Flock(this);
     bdi      = new BDI(this);
 }
        public ActionResult DeleteConfirmed(int id)
        {
            BDI bDI = db.BDIs.Find(id);

            db.BDIs.Remove(bDI);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 3
0
 // auto-create new BDI if it doesn't exist in database
 //TODO - notify administrator that a new BDI has been reported and needs additional data.
 public void AutoCreateBDI(string bdi)
 {
     if (!db.BDIs.Any(x => x.BDINumber == bdi))
     {
         BDI newBdi = new BDI();
         newBdi.BDINumber = bdi;
         db.BDIs.Add(newBdi);
         db.SaveChanges();
     }
 }
 public ActionResult Edit([Bind(Include = "BDIID,BDINumber,DepartmentId")] BDI bDI)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bDI).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentID", "Name", bDI.DepartmentId);
     return(View(bDI));
 }
        public ActionResult Create([Bind(Include = "BDIID,BDINumber,DepartmentId")] BDI bDI)
        {
            if (ModelState.IsValid)
            {
                db.BDIs.Add(bDI);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentId = new SelectList(db.Departments, "DepartmentID", "Name", bDI.DepartmentId);
            return(View(bDI));
        }
Esempio n. 6
0
 // Use this for initialization
 void Start()
 {
     isLit        = false;
     agentManager = GetComponentInParent <AgentsPositionManager>();
     if (agentManager == null)
     {
         Debug.Log("Unable to find 'AgentPositionManager'");
     }
     rb       = GetComponent <Rigidbody>();
     settings = GetComponent <AgentsSettings>();
     flocking = new Flock(this);
     bdi      = new BDI(this);
 }
        // GET: BDIs/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BDI bDI = db.BDIs.Find(id);

            if (bDI == null)
            {
                return(HttpNotFound());
            }
            return(View(bDI));
        }
Esempio n. 8
0
    public void ResetAgent(Vector3 position)
    {
        gameObject.transform.position = position;

        isLit    = false;
        flocking = new Flock(this);
        bdi      = new BDI(this);

        if (transform.childCount > 0)
        {
            transform.Find("feeling_aura").gameObject.SetActive(true);
        }

        gameObject.GetComponent <MeshRenderer>().material = settings.StartColor;
    }
        // GET: BDIs/Edit/5
        public ActionResult Edit(int?id)
        {
            var depts = db.Departments.ToList().OrderBy(x => x.Name);

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BDI bDI = db.BDIs.Find(id);

            if (bDI == null)
            {
                return(HttpNotFound());
            }
            ViewBag.DepartmentId = new SelectList(depts, "DepartmentID", "Name", bDI.DepartmentId);
            return(View(bDI));
        }
Esempio n. 10
0
 // returns BDI from either DB or local data storage
 public BDI getBDIData(string bdiNumber)
 {
     try
     {
         BDI bdi = db.BDIs
                   .Where(x => x.BDINumber == bdiNumber)
                   .FirstOrDefault();
         return(bdi);
     }
     catch (NullReferenceException)
     {
         BDI bdi = db.BDIs.Local
                   .Where(x => x.BDINumber == bdiNumber)
                   .FirstOrDefault();
         return(bdi);
     }
 }
Esempio n. 11
0
        // calls functions to assemble billing data for connectionInfo list and adds it all to database.
        public void addBillingDataToDB(List <List <string> > connectionInfo)
        {
            foreach (List <string> item in connectionInfo)
            {
                string itemMac        = item[0];
                string itemBdi        = item[1];
                string itemDepartment = item[2];
                string itemRouter     = item[3];

                // autocreate new BDI if doesn't exist in database
                AutoCreateBDI(itemBdi);

                // Get BDI data
                BDI bdi = getBDIData(itemBdi);

                // autocreate new ConnectedDevice if doesn't exist in database
                autoCreateConnectedDevice(itemMac);

                // grab ConnectedDevice from local datasource and assign it to cd
                var cd = getConnectedDevice(itemMac);

                // get reporting device id from router name
                var reportingDevice = getReportingDevice(itemRouter);

                // create new Connection object
                createConnection(reportingDevice.ReportingDeviceID, itemMac);

                // get new connection
                Connection newestConnection = getNewestConnection();

                // add connection to connected device
                cd.Connections.Add(newestConnection);

                // add connected device to bdi
                bdi.ConnectedDevices.Add(cd);

                // Entity Framework is smart enough to track the changes above so we just save them
                db.SaveChanges();
            }
        }