Пример #1
0
        public QRCodeNode(NodeInformation ni)
        {
            if (ni == null)
                return;

            RoomName = ni.RoomName;
            DisplayName = ni.DisplayName;

            if (ni.Node == null) return;
            NodeId = ni.Node.Id;
            FloorId = ni.Node.FloorId;
        }
Пример #2
0
        public static NodeInformation GetNodeInformationForNode(MapsEntities entities, int nodeId)
        {
            var result = new NodeInformation();
            Nodes node = entities.Nodes.Find(nodeId);
            if (node == null)
                throw new ServiceException(ResponseError.NodeIdDoesNotExist);

            result.Node = Conversions.ToNode(node);

            Data.Entities.NodeInformation queriedNodeInformation =
                entities.NodeInformation.FirstOrDefault(x => x.NodeId == nodeId);
            // Wenn keine Infos hinterlegt sind, dann leere Info zurückgegeben
            // Wichtig: Das ist kein Fehlerfall
            if (queriedNodeInformation == null)
                return result;

            return Conversions.ToNodeInformation(queriedNodeInformation);
        }
Пример #3
0
        public ObjectResponse<NodeInformation> SaveNodeInformation(NodeInformation nodeInf)
        {
            var result = new ObjectResponse<NodeInformation>();

            ExecuteMaps(entities => { result.Object = InformationService.SaveNodeInformation(entities, nodeInf); },
                        result);

            return result;
        }
Пример #4
0
 private static void CreateOrUpdateNodeInfo(MapsEntities entities, NodeInformation inputInfo,
     Data.Entities.NodeInformation nodeInformation, PoIs poi)
 {
     int? poiId = poi != null ? (int?)poi.Id : null;
     // Wenn es keine NodeInfo gibt, eine Neue anlegen
     if (nodeInformation == null)
     {
         entities.NodeInformation.Add(new Data.Entities.NodeInformation
             {
                 DisplayName = inputInfo.DisplayName,
                 RoomName = inputInfo.RoomName,
                 QRCode = inputInfo.QRCode,
                 NFCTag = inputInfo.NFCTag,
                 PoiId = poiId,
                 NodeId = inputInfo.Node.Id,
                 CreationTime = DateTime.Now
             });
     }
     // Ansonsten die bestehende NodeInfo aktualisieren
     else
     {
         nodeInformation.DisplayName = inputInfo.DisplayName;
         nodeInformation.RoomName = inputInfo.RoomName;
         nodeInformation.NFCTag = inputInfo.NFCTag;
         nodeInformation.QRCode = inputInfo.QRCode;
         nodeInformation.PoiId = poiId;
     }
     entities.SaveChanges();
 }
Пример #5
0
        public static NodeInformation SaveNodeInformation(MapsEntities entities, NodeInformation inputInfo)
        {
            if (!entities.Nodes.Any(n => n.Id == inputInfo.Node.Id))
                throw new ServiceException(ResponseError.NodeIdDoesNotExist);

            // Schon vorhandene Nodeinformationen suchen
            Data.Entities.NodeInformation nodeInformation =
                entities.NodeInformation.FirstOrDefault(x => x.NodeId == inputInfo.Node.Id);

            if (nodeInformation != null)
            {
                PoIs poi = CreateOrUpdatePoI(entities, inputInfo.PoI, nodeInformation);
                CreateOrUpdateNodeInfo(entities, inputInfo, nodeInformation, poi);

                if (!string.IsNullOrWhiteSpace(inputInfo.DisplayName) || !string.IsNullOrWhiteSpace(inputInfo.RoomName))
                    StudMapCache.Map(nodeInformation.Nodes.Floors.MapId).Nodes[inputInfo.Node.Id].HasInformation = true;
            }

            return GetNodeInformationForNode(entities, inputInfo.Node.Id);
        }
Пример #6
0
 public JsonResult SaveNodeInformation(int nodeId, string displayName, string roomName, int poiTypeId,
     string poiDescription, string qrCode, string nfcTag)
 {
     var mapsCtrl = new MapsController();
     var nodeInf = new NodeInformation(new PoI
         {
             Description = poiDescription,
             Type = new PoiType {Id = poiTypeId}
         }, displayName, roomName, qrCode, nfcTag)
         {
             Node = new Node {Id = nodeId}
         };
     ObjectResponse<NodeInformation> tmp = mapsCtrl.SaveNodeInformation(nodeInf);
     return Json(tmp, JsonRequestBehavior.AllowGet);
 }