예제 #1
0
        public static StoreDescription CreateStoreDescriptionNode(StoreDescription objNode)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <StoreDescription>(objNode);

            StoreRoot objRoot = new StoreRoot();


            var result = Neo4jController.m_graphClient.Cypher
                         .Merge("(A:" + objRoot.getLabel() + " { Name : { Rootname}} )")
                         .OnCreate()
                         .Set("A = { objRoot}")
                         .Merge("(A)-[R:" + Rel_StoreRoot.storeroot_store + "]->(B:" + objNode.getLabel() + "{ Name : { Name }})")
                         .OnCreate()
                         .Set("B = { objNode }")
                         .WithParams(new
            {
                Rootname = objRoot.Name,
                objRoot  = objRoot,
                objNode  = objNode,
                Name     = objNode.Name
            })
                         .Return((B, R) => new
            {
                Count         = B.Count(),
                RelationCount = R.Count(),
                retObj        = B.As <StoreDescription>()
            })
                         .Results
                         .Single();

            if (result.Count == 1)
            {
                Logger.WriteToLogFile("Successfully created Node");
                objNode = result.retObj;
            }
            else
            {
                Logger.WriteToLogFile("unable to create Node");
                objNode = null;
            }

            return(objNode);
        }
예제 #2
0
        public static void CreateStoreNode(StoreWrapper objWrap)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());
            Logger.WriteObjectToLogFile <Store>(objWrap.objStore);


            City             objCity      = objWrap.objCity;
            Store            objStore     = objWrap.objStore;
            StoreDescription objStoreDesc = new StoreDescription();

            objStoreDesc.Name = objStore.Name;
            objStore.Name     = null;

            var result = Neo4jController.m_graphClient.Cypher
                         .Match("(A:" + objCity.getLabel() + " { id : {Cityid }})")
                         .Match("(C:" + objStoreDesc.getLabel() + " { Name : { Name }})")
                         .Merge("(A)-[R:" + Rel_City.city_store + "]->(B:" + objStore.getLabel() + "{ StoreId : { storeid} })")
                         .OnCreate()
                         .Set("B = { objStore }")
                         .Merge("(B)-[:" + Rel_Store.store_storeDescription + "]->(C)")
                         .WithParams(new
            {
                Cityid   = objCity.id,
                objStore = objStore,
                storeid  = objStore.StoreId,
                Name     = objStoreDesc.Name
            })
                         .Return(B => B.As <Store>())
                         .Results;


            if (result.Count() != 0)
            {
                Logger.WriteToLogFile("Successfully created Store");
            }
            else
            {
                Logger.WriteToLogFile("Unable to create Store");
            }
        }
예제 #3
0
        public static void DeleteStoreDescription(StoreDescription objNode)
        {
            Logger.WriteToLogFile(DBInteractor.Common.Utilities.GetCurrentMethod());


            Neo4jController.m_graphClient.Cypher
            .Match("(D:" + objNode.getLabel() + "{ id : { Nodeid }})")
            .Match("(D)-[R]-()")
            .OptionalMatch("(E)-[:" + Rel_Store.store_storeDescription + "]->(D)")
            .Delete("D,R")
            .With("E")
            .Match("(E)-[R]-()")
            .OptionalMatch("(E)-[:" + Rel_Store.store_item + "]->(F)")
            .Delete("E,R")
            .With("F")
            .Match("(F)-[R]-()")
            .Delete("F,R")
            .WithParams(new
            {
                Nodeid = objNode.id
            })
            .ExecuteWithoutResults();
        }