コード例 #1
0
ファイル: TypeService.cs プロジェクト: SiliconHoller/sysgraph
        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);
        }
コード例 #2
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);
        }
コード例 #3
0
ファイル: TypeService.cs プロジェクト: SiliconHoller/sysgraph
        /// <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);
        }
コード例 #4
0
        public IEnumerable <Documentation> GetProcessDocs(int procid)
        {
            List <Documentation> docList = new List <Documentation>();

            using (SystemMapEntities db = new SystemMapEntities())
            {
                docList = db.process_docs
                          .Where(pd => pd.processid == procid)
                          .OrderBy(pd => pd.name)
                          .Select(pd => new Documentation
                {
                    documentationId = pd.process_docid,
                    name            = pd.name,
                    description     = pd.descr,
                    url             = pd.docurl,
                    docTypeId       = pd.doctypeid
                })
                          .ToList <Documentation>();
                TypeService           tsvc     = new TypeService();
                IEnumerable <DocType> typelist = tsvc.GetDocTypes();
                foreach (Documentation doc in docList)
                {
                    doc.documentType = typelist.Where(t => t.typeId == doc.docTypeId).FirstOrDefault();
                }
            }
            return(docList);
        }
コード例 #5
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);
        }
コード例 #6
0
ファイル: EdgeService.cs プロジェクト: SiliconHoller/sysgraph
        /// <summary>
        /// Given a list of edges (from another filter selection), return Edge data for each in a collection
        /// </summary>
        /// <param name="eidList">Collection of edge identity values</param>
        /// <returns>Collection of edge model data for each record, if it exists; otherwise, an empty collection.</returns>
        public IEnumerable <Edge> GetListedEdges(IEnumerable <int> eidList)
        {
            List <Edge> edgeList = new List <Edge>();

            using (SystemMapEntities db = new SystemMapEntities())
            {
                edgeList = db.edges.Where(e => eidList.Contains(e.edgeid))
                           .OrderBy(e => e.name)
                           .Select(e => new Edge
                {
                    id          = e.edgeid,
                    name        = e.name,
                    description = e.descr,
                    fromNodeId  = e.from_node,
                    toNodeId    = e.to_node,
                    type        = new EdgeType
                    {
                        typeId  = e.edgetypeid,
                        name    = e.edgetype.name,
                        iconUrl = e.edgetype.iconurl
                    }
                })
                           .ToList <Edge>();
            }
            return(edgeList);
        }
コード例 #7
0
        public IEnumerable <NodeAttribute> GetNodeAttributes(int nodeid)
        {
            List <NodeAttribute> attList = new List <NodeAttribute>();

            using (SystemMapEntities db = new SystemMapEntities())
            {
                attList = db.node_attributes
                          .Where(natt => natt.nodeid == nodeid)
                          .Select(natt => new NodeAttribute
                {
                    id          = natt.attributeid,
                    name        = natt.name,
                    description = natt.descr,
                    nodeVal     = natt.nodeval,
                    type        = new AttributeType
                    {
                        typeId      = natt.attribute_types.attrtypeid,
                        name        = natt.attribute_types.name,
                        description = natt.attribute_types.descr,
                        iconUrl     = natt.attribute_types.iconurl
                    }
                })
                          .ToList <NodeAttribute>();
            }
            return(attList);
        }
コード例 #8
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);
        }
コード例 #9
0
ファイル: TypeService.cs プロジェクト: SiliconHoller/sysgraph
        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);
        }
コード例 #10
0
ファイル: EdgeService.cs プロジェクト: SiliconHoller/sysgraph
        /// <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);
        }
コード例 #11
0
ファイル: TypeService.cs プロジェクト: SiliconHoller/sysgraph
        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);
        }
コード例 #12
0
        public void TestConnectivity()
        {
            SystemMapEntities db = new SystemMapEntities();

            db.Dispose();
            Assert.IsTrue(true);
        }
コード例 #13
0
        /// <summary>
        /// Return a collection of nodes which are part of the membership group as the given node id.
        /// </summary>
        /// <param name="nodeid">Identifier for node of interest</param>
        /// <returns>Collection of sibling nodes, if they exist; otherwise, an empty list</returns>
        public IEnumerable <Node> GetNodeSiblings(int nodeid)
        {
            List <Node> nlist = new List <Node>();

            using (SystemMapEntities db = new SystemMapEntities())
            {
                nlist = db.node_membership
                        .Where(nm => nm.membernode_id == nodeid)
                        .Join(db.node_membership, a => a.groupnode_id, b => b.groupnode_id, (a, b) => b)
                        .Join(db.nodes, a => a.membernode_id, b => b.nodeid, (a, b) => b)
                        .OrderBy(n => n.name)
                        .Select(s => new Node
                {
                    id          = s.nodeid,
                    name        = s.name,
                    description = s.descr,
                    type        = new NodeType
                    {
                        typeId      = s.nodetype.typeid,
                        name        = s.nodetype.name,
                        iconUrl     = s.nodetype.iconurl,
                        description = s.nodetype.descr
                    }
                })
                        .ToList <Node>();
            }
            return(nlist);
        }
コード例 #14
0
ファイル: TypeService.cs プロジェクト: SiliconHoller/sysgraph
        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);
        }
コード例 #15
0
ファイル: NodeService.cs プロジェクト: SiliconHoller/sysgraph
        /// <summary>
        /// Returns a Collection of nodes on which the given node depends
        /// </summary>
        /// <param name="nodeid">Node of interest</param>
        /// <returns>Collection of nodes that provide data or reference for the node given; otherwise, an empty collection</returns>
        public IEnumerable <Node> GetParents(int nodeid)
        {
            List <Node> nlist = new List <Node>();

            using (SystemMapEntities db = new SystemMapEntities())
            {
                nlist = db.edges
                        .Where(e => e.to_node == nodeid)
                        .Join(db.nodes, a => a.from_node, b => b.nodeid, (a, b) => b)
                        .Select(p => new Node
                {
                    id          = p.nodeid,
                    name        = p.name,
                    description = p.descr,
                    type        = new NodeType
                    {
                        typeId      = p.nodetype.typeid,
                        name        = p.nodetype.name,
                        iconUrl     = p.nodetype.iconurl,
                        description = p.nodetype.descr
                    }
                })
                        .ToList <Node>();
            }
            return(nlist);
        }
コード例 #16
0
ファイル: NodeService.cs プロジェクト: SiliconHoller/sysgraph
        /// <summary>
        /// Given a list of node id values (from another filter process, for example), return a collection
        /// of the given records.
        /// </summary>
        /// <param name="nodeIdList">List of node id values</param>
        /// <returns>Collection of node models with the given identities, if they exist; if none found, and empty collection.</returns>
        public IEnumerable <Node> GetListed(IEnumerable <int> nodeIdList)
        {
            List <Node> nlist = new List <Node>();

            using (SystemMapEntities db = new SystemMapEntities())
            {
                nlist = db.nodes
                        .Where(n => nodeIdList.Contains(n.nodeid))
                        .OrderBy(n => n.name)
                        .Select(n => new Node
                {
                    id          = n.nodeid,
                    name        = n.name,
                    description = n.descr,
                    type        = new NodeType
                    {
                        typeId      = n.nodetype.typeid,
                        name        = n.nodetype.name,
                        iconUrl     = n.nodetype.iconurl,
                        description = n.nodetype.descr
                    }
                })
                        .ToList <Node>();
            }
            return(nlist);
        }
コード例 #17
0
        public IEnumerable <EdgeAttribute> GetEdgeAttributes(int edgeid)
        {
            List <EdgeAttribute> attList = new List <EdgeAttribute>();

            using (SystemMapEntities db = new SystemMapEntities())
            {
                attList = db.edge_attributes
                          .Where(eatt => eatt.edgeid == edgeid)
                          .Select(eatt => new EdgeAttribute
                {
                    id          = eatt.attributeid,
                    name        = eatt.name,
                    description = eatt.descr,
                    edgeVal     = eatt.edgeval,
                    type        = new AttributeType
                    {
                        typeId      = eatt.attribute_types.attrtypeid,
                        name        = eatt.attribute_types.name,
                        description = eatt.attribute_types.descr,
                        iconUrl     = eatt.attribute_types.iconurl
                    }
                })
                          .ToList <EdgeAttribute>();
            }
            return(attList);
        }
コード例 #18
0
ファイル: EdgeService.cs プロジェクト: SiliconHoller/sysgraph
        /// <summary>
        /// Return a list of edges to the given node
        /// </summary>
        /// <param name="nodeid">node of interest</param>
        /// <returns>Collection of edges terminating at the given node, if they exist; otherwise, an empty list.</returns>
        public IEnumerable <Edge> GetEdgesTo(int nodeid)
        {
            List <Edge> elist = new List <Edge>();

            using (SystemMapEntities db = new SystemMapEntities())
            {
                elist = db.edges
                        .Where(e => e.to_node == nodeid)
                        .Select(e => new Edge
                {
                    id          = e.edgeid,
                    name        = e.name,
                    description = e.descr,
                    fromNodeId  = e.from_node,
                    toNodeId    = e.to_node,
                    type        = new EdgeType
                    {
                        typeId  = e.edgetypeid,
                        name    = e.edgetype.name,
                        iconUrl = e.edgetype.iconurl
                    }
                })
                        .ToList <Edge>();
            }
            return(elist);
        }
コード例 #19
0
ファイル: NodeService.cs プロジェクト: SiliconHoller/sysgraph
 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();
     }
 }
コード例 #20
0
ファイル: NodeService.cs プロジェクト: SiliconHoller/sysgraph
 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();
     }
 }
コード例 #21
0
        public bool NodeMembershipExists(int contId, int memid)
        {
            bool retval = false;

            using (SystemMapEntities db = new SystemMapEntities())
            {
                int ecount = db.node_membership.Where(nm => nm.groupnode_id == contId && nm.membernode_id == memid).Count();
                retval = ecount > 0;
            }
            return(retval);
        }
コード例 #22
0
ファイル: EdgeService.cs プロジェクト: SiliconHoller/sysgraph
 /// <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();
         }
     }
 }
コード例 #23
0
ファイル: TypeService.cs プロジェクト: SiliconHoller/sysgraph
 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();
         }
     }
 }
コード例 #24
0
ファイル: NodeService.cs プロジェクト: SiliconHoller/sysgraph
 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();
         }
     }
 }
コード例 #25
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();
         }
     }
 }
コード例 #26
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();
         }
     }
 }
コード例 #27
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();
         }
     }
 }
コード例 #28
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();
         }
     }
 }
コード例 #29
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();
         }
     }
 }
コード例 #30
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();
         }
     }
 }