Esempio n. 1
0
        public Documentation AddNodeDoc(Documentation nd)
        {
            Documentation retval = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                node_docs ndoc = new node_docs {
                    name = nd.name, doctypeid = nd.docTypeId, descr = nd.description, docurl = nd.url, nodeid = nd.componentId
                };
                db.node_docs.Add(ndoc);
                db.SaveChanges();
                retval = new Documentation
                {
                    documentationId = ndoc.node_docid,
                    name            = ndoc.name,
                    description     = ndoc.descr,
                    url             = ndoc.docurl,
                    docTypeId       = ndoc.doctypeid,
                    documentType    = new DocType
                    {
                        typeId      = ndoc.doctypeid,
                        name        = ndoc.doc_type.typename,
                        description = ndoc.doc_type.descr,
                        iconUrl     = ndoc.doc_type.iconurl
                    }
                };
            }
            return(retval);
        }
Esempio n. 2
0
        /// <summary>
        /// Get the type associated with the given information.  If typeadd is true, then add those values to the node types if not found.
        /// </summary>
        /// <param name="typeid">identifier of the node type</param>
        /// <param name="typename">Name for the node type</param>
        /// <param name="typeadd">default is false.  If not found add the typename to the nodetypes.</param>
        /// <returns></returns>
        public NodeType GetNodeType(string typename, bool typeadd = false)
        {
            NodeType ntype = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                ntype = db.nodetypes
                        .Where(nt => nt.name == typename)
                        .Select(nt => new NodeType
                {
                    typeId      = nt.typeid,
                    name        = nt.name,
                    description = nt.descr,
                    iconUrl     = nt.iconurl
                })
                        .SingleOrDefault();

                if (ntype == null && typeadd && !String.IsNullOrEmpty(typename) && !String.IsNullOrWhiteSpace(typename))
                {
                    //Go ahead and add it
                    nodetype addtype = new nodetype {
                        name = typename
                    };
                    db.nodetypes.Add(addtype);
                    db.SaveChanges();
                    ntype = new NodeType {
                        name = typename, typeId = addtype.typeid
                    };
                }
            }
            return(ntype);
        }
Esempio n. 3
0
        public Documentation AddProcessDoc(Documentation pdoc)
        {
            Documentation retval = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                process_docs ndoc = new process_docs {
                    name = pdoc.name, doctypeid = pdoc.docTypeId, descr = pdoc.description, docurl = pdoc.url, processid = pdoc.componentId
                };
                db.process_docs.Add(ndoc);
                db.SaveChanges();
                retval = new Documentation
                {
                    documentationId = ndoc.process_docid,
                    name            = ndoc.name,
                    description     = ndoc.descr,
                    url             = ndoc.docurl,
                    docTypeId       = ndoc.doctypeid,
                    documentType    = new DocType
                    {
                        typeId      = ndoc.doctypeid,
                        name        = ndoc.doc_type.typename,
                        description = ndoc.doc_type.descr,
                        iconUrl     = ndoc.doc_type.iconurl
                    }
                };
            }
            return(retval);
        }
Esempio n. 4
0
        /// <summary>
        /// Add a new edge given the Connector model
        /// </summary>
        /// <param name="conn">Connector model containing edge information</param>
        /// <returns>identity value of the new edge record; otherwise, -1.</returns>
        public int AddEdge(Edge conn, bool typeadd = false)
        {
            int retval = -1;

            if (conn.type == null)
            {
                throw new Exception("Edge type data required");
            }
            TypeService tsvc  = new TypeService();
            EdgeType    etype = tsvc.GetEdgeType(conn.type.name, typeadd);

            using (SystemMapEntities db = new SystemMapEntities())
            {
                //check that an existing edge (u, v, name) is not already there)
                edge curredge = db.edges.Where(e => e.from_node == conn.fromNodeId && e.to_node == conn.toNodeId && e.name == conn.name).FirstOrDefault();
                if (curredge == null)
                {
                    curredge = new edge {
                        name = conn.name, edgetypeid = etype.typeId, descr = conn.description, from_node = conn.fromNodeId, to_node = conn.toNodeId
                    };
                    db.edges.Add(curredge);
                    db.SaveChanges();
                }
                retval = curredge.edgeid;
            }
            return(retval);
        }
Esempio n. 5
0
        public DocType GetDocType(string typename, bool typeadd = false)
        {
            DocType dtype = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                dtype = db.doc_type
                        .Where(dt => dt.typename == typename)
                        .Select(dt => new DocType
                {
                    typeId      = dt.doctypeid,
                    name        = dt.typename,
                    description = dt.descr,
                    iconUrl     = dt.iconurl
                })
                        .SingleOrDefault();
                if (dtype == null && typeadd && !String.IsNullOrEmpty(typename) && !String.IsNullOrWhiteSpace(typename))
                {
                    doc_type natype = new doc_type {
                        typename = typename
                    };
                    db.doc_type.Add(natype);
                    db.SaveChanges();
                    dtype = new DocType {
                        typeId = natype.doctypeid, name = typename
                    };
                }
            }
            return(dtype);
        }
Esempio n. 6
0
        public NodeAttribute AddNodeAttribute(NodeAttribute natt)
        {
            NodeAttribute retval = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                node_attributes nrec = new node_attributes
                {
                    nodeid     = natt.nodeId,
                    name       = natt.name,
                    descr      = natt.description,
                    attrtypeid = natt.type.typeId
                };
                db.node_attributes.Add(nrec);
                db.SaveChanges();
                retval = new NodeAttribute
                {
                    id          = nrec.attributeid,
                    name        = nrec.name,
                    description = nrec.descr
                };
                retval.type = new TypeService().GetAttributeType(nrec.attrtypeid);
            }
            return(retval);
        }
Esempio n. 7
0
        public EdgeType GetEdgeType(string typename, bool typeadd = false)
        {
            EdgeType etype = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                etype = db.edgetypes
                        .Where(et => et.name == typename)
                        .Select(et => new EdgeType
                {
                    typeId      = et.edgetypeid,
                    name        = et.name,
                    description = et.descr,
                    iconUrl     = et.iconurl
                })
                        .SingleOrDefault();
                if (etype == null && typeadd && !String.IsNullOrEmpty(typename) && !String.IsNullOrWhiteSpace(typename))
                {
                    edgetype netype = new edgetype {
                        name = typename
                    };
                    db.edgetypes.Add(netype);
                    db.SaveChanges();
                    etype = new EdgeType {
                        name = typename, typeId = netype.edgetypeid
                    };
                }
            }
            return(etype);
        }
Esempio n. 8
0
        public MembershipType GetMembershipType(string typename, bool typeadd = false)
        {
            MembershipType mtype = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                mtype = db.membership_types
                        .Where(mt => mt.typename == typename)
                        .Select(mt => new MembershipType
                {
                    typeId      = mt.memtypeid,
                    name        = mt.typename,
                    description = mt.descr,
                    iconUrl     = mt.iconurl
                })
                        .SingleOrDefault();
                if (mtype == null && typeadd && !String.IsNullOrEmpty(typename) && !String.IsNullOrWhiteSpace(typename))
                {
                    membership_types natype = new membership_types {
                        typename = typename
                    };
                    db.membership_types.Add(natype);
                    db.SaveChanges();
                    mtype = new MembershipType {
                        typeId = natype.memtypeid, name = typename
                    };
                }
            }
            return(mtype);
        }
Esempio n. 9
0
        public AttributeType GetAttributeType(string typename, bool typeadd = false)
        {
            AttributeType atype = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                atype = db.attribute_types
                        .Where(at => at.name == typename)
                        .Select(at => new AttributeType
                {
                    typeId      = at.attrtypeid,
                    name        = at.name,
                    description = at.descr,
                    iconUrl     = at.iconurl
                })
                        .SingleOrDefault();
                if (atype == null && typeadd && !String.IsNullOrEmpty(typename) && !String.IsNullOrWhiteSpace(typename))
                {
                    attribute_types natype = new attribute_types {
                        name = typename
                    };
                    db.attribute_types.Add(natype);
                    db.SaveChanges();
                    atype = new AttributeType {
                        typeId = natype.attrtypeid, name = typename
                    };
                }
            }
            return(atype);
        }
Esempio n. 10
0
 public void DeleteNode(int nodeid)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         node delnode = db.nodes.Where(n => n.nodeid == nodeid).Single();
         db.nodes.Remove(delnode);
         db.SaveChanges();
     }
 }
Esempio n. 11
0
 public void UpdateNode(Node unode)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         node update = db.nodes.Where(n => n.nodeid == unode.id).SingleOrDefault();
         update.name   = unode.name;
         update.descr  = unode.description;
         update.typeid = unode.type.typeId;
         db.SaveChanges();
     }
 }
Esempio n. 12
0
 public void DeleteAttributeType(int atypeid)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         attribute_types delrec = db.attribute_types.Where(at => at.attrtypeid == atypeid).SingleOrDefault();
         if (delrec != null)
         {
             db.attribute_types.Remove(delrec);
             db.SaveChanges();
         }
     }
 }
Esempio n. 13
0
 public void DeleteNodeDoc(int nodedocid)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         node_docs delrec = db.node_docs.Where(d => d.node_docid == nodedocid).SingleOrDefault();
         if (delrec != null)
         {
             db.node_docs.Remove(delrec);
             db.SaveChanges();
         }
     }
 }
Esempio n. 14
0
 public void DeleteProcessDoc(int pdocid)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         process_docs delrec = db.process_docs.Where(d => d.process_docid == pdocid).SingleOrDefault();
         if (delrec != null)
         {
             db.process_docs.Remove(delrec);
             db.SaveChanges();
         }
     }
 }
Esempio n. 15
0
 public void DeleteAttribute(int nattid)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         node_attributes del = db.node_attributes.Where(na => na.attributeid == nattid).SingleOrDefault();
         if (del != null)
         {
             db.node_attributes.Remove(del);
             db.SaveChanges();
         }
     }
 }
Esempio n. 16
0
 /// <summary>
 /// Remove the given edge from the system
 /// </summary>
 /// <param name="edgeid"></param>
 public void RemoveEdge(int edgeid)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         edge deledge = db.edges.Where(e => e.edgeid == edgeid).SingleOrDefault();
         if (deledge != null)
         {
             db.edges.Remove(deledge);
             db.SaveChanges();
         }
     }
 }
Esempio n. 17
0
 public void UpdateNodeMembershipType(int containerId, int memid, int mtypeid)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         node_membership nm = db.node_membership.Where(m => m.groupnode_id == containerId && m.membernode_id == memid).FirstOrDefault();
         if (nm != null)
         {
             nm.memtypeid = mtypeid;
             db.SaveChanges();
         }
     }
 }
Esempio n. 18
0
 public void DeleteEdgeAttribute(int eattid)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         edge_attributes delrec = db.edge_attributes
                                  .Where(ea => ea.attributeid == eattid)
                                  .SingleOrDefault();
         if (delrec != null)
         {
             db.edge_attributes.Remove(delrec);
             db.SaveChanges();
         }
     }
 }
Esempio n. 19
0
 public void AddNodeMembership(int containerId, int memid, int mtypeid)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         int ecount = db.node_membership.Where(nm => nm.groupnode_id == containerId && nm.membernode_id == memid).Count();
         if (ecount == 0)
         {
             node_membership nm = new node_membership {
                 groupnode_id = containerId, membernode_id = memid, memtypeid = mtypeid
             };
             db.node_membership.Add(nm);
             db.SaveChanges();
         }
     }
 }
Esempio n. 20
0
 public void UpdateNodeDoc(Documentation udata)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         node_docs urec = db.node_docs.Where(d => d.node_docid == udata.documentationId).SingleOrDefault();
         if (urec != null)
         {
             urec.name      = udata.name;
             urec.descr     = udata.description;
             urec.docurl    = udata.url;
             urec.doctypeid = udata.docTypeId;
             db.SaveChanges();
         }
     }
 }
Esempio n. 21
0
 public void UpdateNodeAttribute(NodeAttribute udata)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         node_attributes urec = db.node_attributes
                                .Where(na => na.attributeid == udata.id)
                                .SingleOrDefault();
         if (urec != null)
         {
             urec.name       = udata.name;
             urec.descr      = udata.description;
             urec.attrtypeid = udata.type.typeId;
             db.SaveChanges();
         }
     }
 }
Esempio n. 22
0
 /// <summary>
 /// Update edge information
 /// </summary>
 /// <param name="conn">Connector model containing the updated information</param>
 public void UpdateEdge(Edge conn)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         edge uedge = db.edges.Where(e => e.edgeid == conn.id).SingleOrDefault();
         if (uedge != null)
         {
             uedge.name       = conn.name;
             uedge.descr      = conn.description;
             uedge.edgetypeid = conn.type.typeId;
             uedge.from_node  = conn.fromNodeId;
             uedge.to_node    = conn.toNodeId;
             db.SaveChanges();
         }
     }
 }
Esempio n. 23
0
 public void UpdateEdgeType(EdgeType udata)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         edgetype utype = db.edgetypes
                          .Where(et => et.edgetypeid == udata.typeId)
                          .SingleOrDefault();
         if (utype != null)
         {
             utype.name    = udata.name;
             utype.descr   = udata.description;
             utype.iconurl = udata.iconUrl;
             db.SaveChanges();
         }
     }
 }
Esempio n. 24
0
 public void UpdateDocType(DocType udata)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         doc_type utype = db.doc_type
                          .Where(dt => dt.doctypeid == udata.typeId)
                          .SingleOrDefault();
         if (utype != null)
         {
             utype.typename = udata.name;
             utype.descr    = udata.description;
             utype.iconurl  = udata.iconUrl;
             db.SaveChanges();
         }
     }
 }
Esempio n. 25
0
 public void UpdateAttributeType(AttributeType udata)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         attribute_types utype = db.attribute_types
                                 .Where(at => at.attrtypeid == udata.typeId)
                                 .SingleOrDefault();
         if (utype != null)
         {
             utype.name    = udata.name;
             utype.descr   = udata.description;
             utype.iconurl = udata.iconUrl;
             db.SaveChanges();
         }
     }
 }
Esempio n. 26
0
 public void UpdateMembershipType(MembershipType udata)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         membership_types utype = db.membership_types
                                  .Where(mt => mt.memtypeid == udata.typeId)
                                  .SingleOrDefault();
         if (utype != null)
         {
             utype.typename = udata.name;
             utype.descr    = udata.description;
             utype.iconurl  = udata.iconUrl;
             db.SaveChanges();
         }
     }
 }
Esempio n. 27
0
 public void UpdateAttribute(NodeAttribute natt)
 {
     using (SystemMapEntities db = new SystemMapEntities())
     {
         node_attributes urecord = db.node_attributes
                                   .Where(na => na.attributeid == natt.id)
                                   .SingleOrDefault();
         if (urecord != null)
         {
             urecord.name       = natt.name;
             urecord.descr      = natt.description;
             urecord.attrtypeid = natt.type.typeId;
             urecord.nodeid     = natt.nodeId;
             db.SaveChanges();
         }
     }
 }
Esempio n. 28
0
        public int AddAttribute(NodeAttribute natt)
        {
            int retval = -1;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                node_attributes ndata = new node_attributes
                {
                    name       = natt.name,
                    descr      = natt.description,
                    nodeid     = natt.nodeId,
                    attrtypeid = natt.type.typeId
                };
                db.node_attributes.Add(ndata);
                db.SaveChanges();
                retval = ndata.attributeid;
            }
            return(retval);
        }
Esempio n. 29
0
        public int AddNode(Node nnode, bool typeadd = false)
        {
            int retval = -1;

            //Check for typeval--if not exists (and typeadd == false) throw exception;
            if (nnode.type == null)
            {
                throw new Exception("Node type data required");
            }
            TypeService typesvc = new TypeService();
            NodeType    ntype   = typesvc.GetNodeType(nnode.type.name, typeadd);

            using (SystemMapEntities db = new SystemMapEntities())
            {
                node addnode = new node {
                    name = nnode.name, descr = nnode.description, typeid = ntype.typeId
                };
                db.nodes.Add(addnode);
                db.SaveChanges();
                retval = addnode.nodeid;
            }
            return(retval);
        }
Esempio n. 30
0
        public EdgeAttribute AddEdgeAttribute(EdgeAttribute eatt)
        {
            EdgeAttribute retval = null;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                edge_attributes erec = new edge_attributes
                {
                    name       = eatt.name,
                    descr      = eatt.description,
                    attrtypeid = eatt.type.typeId
                };
                db.edge_attributes.Add(erec);
                db.SaveChanges();
                retval = new EdgeAttribute
                {
                    id          = erec.attributeid,
                    name        = erec.name,
                    description = erec.descr
                };
                retval.type = new TypeService().GetAttributeType(erec.attrtypeid);
            }
            return(retval);
        }