示例#1
0
 public void SaveSceneLocation(SceneLocation location)
 {
     using (var ctx = new GlsunViewEntities())
     {
         var loc = (from l in ctx.SceneLocation
                    where l.ID == location.ID
                    select l).FirstOrDefault();
         loc.CoordinateX = location.CoordinateX;
         loc.CoordinateY = location.CoordinateY;
         ctx.SaveChanges();
     }
 }
示例#2
0
 // GET: Subnet
 public ActionResult Index(int id)
 {
     IEnumerable<TopologyNode> nodes = null;
     IEnumerable<TopologyLine> lines = null;
     SceneLocation sceneLoc = null;
     using (var ctx = new GlsunViewEntities())
     {
         var subnet = ctx.Subnet.Find(id);
         nodes = (from d in ctx.Device
                 where d.SID == id
                 select new TopologyNode
                 {
                     ID = d.ID,
                     Name = d.DName,
                     Address = d.DAddress,
                     Icon = d.DIcon,
                     X = d.CoordinateX.Value,
                     Y = d.CoordinateY.Value
                 }).ToList();
         var nodeIds = (from n in nodes
                        select n.ID).ToList();
         lines = (from l in ctx.DeviceLine
                 where nodeIds.Contains(l.DIDA.Value) || nodeIds.Contains(l.DIDB.Value)
                 select new TopologyLine
                 {
                     ID = l.ID,
                     Name = l.DLName,
                     NodeIDA = l.DIDA.Value,
                     NodeIDZ = l.DIDB.Value
                 }).ToList();
         sceneLoc = (from l in ctx.SceneLocation
                     where l.SceneType == "device" && l.UserID == id
                     select l).FirstOrDefault();
         if (sceneLoc == null)
         {
             sceneLoc = new SceneLocation
             {
                 CoordinateX = 0,
                 CoordinateY = 0,
                 SceneType = "device",
                 UserID = id
             };
             ctx.SceneLocation.Add(sceneLoc);
             ctx.SaveChanges();
         }
     }
     ViewBag.Nodes = new JavaScriptSerializer().Serialize(nodes);
     ViewBag.Lines = new JavaScriptSerializer().Serialize(lines);
     ViewBag.SceneLocation = new JavaScriptSerializer().Serialize(sceneLoc);
     ViewBag.SubnetId = id;
     SetAuthorityData();
     return View();
 }
示例#3
0
        // GET: Topology
        public ActionResult Index()
        {
            IEnumerable <Subnet>       subnets = null;
            IEnumerable <TopologyNode> nodes   = null;
            IEnumerable <TopologyLine> lines   = null;
            SceneLocation sceneLoc             = null;
            var           nodesJSON            = string.Empty;

            using (var ctx = new GlsunViewEntities())
            {
                subnets = ctx.Subnet.ToList();
                lines   = (from l in ctx.SubnetLine
                           select new TopologyLine
                {
                    ID = l.ID,
                    Name = l.SLName,
                    NodeIDA = l.SIDA.Value,
                    NodeIDZ = l.SIDB.Value
                }).ToList();
                sceneLoc = (from l in ctx.SceneLocation
                            where l.SceneType == "subnet"
                            select l).FirstOrDefault();
                if (sceneLoc == null)
                {
                    sceneLoc = new SceneLocation
                    {
                        CoordinateX = 0,
                        CoordinateY = 0,
                        SceneType   = "subnet"
                    };
                    ctx.SceneLocation.Add(sceneLoc);
                    ctx.SaveChanges();
                }
            }
            nodes = (from n in subnets
                     select new TopologyNode
            {
                ID = n.ID,
                Name = n.SName,
                Address = n.SAddress,
                Icon = n.SIcon,
                X = n.CoordinateX.Value,
                Y = n.CoordinateY.Value
            }).ToList();
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            ViewBag.Nodes         = serializer.Serialize(nodes);
            ViewBag.Lines         = serializer.Serialize(lines);
            ViewBag.SceneLocation = serializer.Serialize(sceneLoc);
            SetAuthorityData();
            return(View());
        }
    public void UCE_OnPortal(SceneLocation targetScene)
    {
        this.transform.position = targetScene.position;
        Database.singleton.CharacterSave(this, false);
        Database.singleton.SaveCharacterScene(this.name, targetScene.mapScene.SceneName);

        // ask client to switch server
        this.connectionToClient.Send(
            new SwitchServerMsg
        {
            scenePath     = targetScene.mapScene.SceneName,
            characterName = this.name
        }
            );

        // immediately destroy so nothing messes with the new
        // position and so it's not saved again etc.
        NetworkServer.Destroy(this.gameObject);
    }