Example #1
0
        static void Main(string[] args)
        {
            Connection         con         = new Connection("neo4j", "bwe319tu");
            TransactionManager transaction = new TransactionManager(con);



            var logicelementsender = new LogicElement(LogicType.ValueSender);

            logicelementsender.Value = 1;
            logicelementsender.Activate();

            var logicelementacceptor = new LogicElement(LogicType.ValueMoreThan);

            logicelementacceptor.Value = 2;

            var logicelementdummy = new LogicElement(LogicType.Dummy);


            var dictionary1 = new Dictionary <string, object>()
            {
                { "Name", "Entity1" },
                { "Property 1", "Property 1 value" },
                { "Property 2", "Property 2 value" }
            };

            var dictionary2 = new Dictionary <string, object>()
            {
                { "Name", "Entity2" },
                { "Property 1", "Property 1 value" },
                { "Property 2", "Property 2 value" },
                { "Property 3", "Property 3 value" }
            };

            var dictionary3 = new Dictionary <string, object>()
            {
                { "Name", "Entity3" },
                { "Property 1", "Property 1 value" },
                { "Property 2", "Property 2 value" },
                { "Property 3", "Property 3 value" }
            };

            var dictionary4 = new Dictionary <string, object>()
            {
                { "Name", "Link1" },
                { "Property 1", "Property 1 value" },
                { "Property 2", "Property 2 value" },
                { "Property 3", "Property 3 value" }
            };

            var dictionary5 = new Dictionary <string, object>()
            {
                { "Name", "Link2" },
                { "Property 1", "Property 1 value" },
                { "Property 2", "Property 2 value" },
                { "Property 3", "Property 3 value" }
            };

            var neo4jresults = new List <Neo4jUnwrapedResult>();

            var entity1 = new Entity(new string[] { "Test", "Sender" });

            entity1.AddLogic(logicelementsender);
            entity1.AddProperty(dictionary1);

            var rlt = transaction.CreateEntity(entity1);

            entity1 = rlt.AgregatedNodes[0];
            neo4jresults.Add(rlt);


            var entity2 = new Entity(new string[] { "Test", "Sender" });

            entity2.AddLogic(logicelementsender);
            entity2.AddProperty(dictionary2);

            rlt     = transaction.CreateEntity(entity2);
            entity2 = rlt.AgregatedNodes[0];
            neo4jresults.Add(rlt);

            logicelementacceptor.AddTarget(entity1);
            logicelementacceptor.AddTarget(entity2);
            var entity3 = new Entity(new string[] { "Test", "Acceptor", "Concentrator" });

            entity3.AddLogic(logicelementacceptor);
            entity3.AddProperty(dictionary3);

            rlt     = transaction.CreateEntity(entity3);
            entity3 = rlt.AgregatedNodes[0];
            neo4jresults.Add(rlt);



            var link1 = new Link("SEND_VALUE");

            link1.AddProperty(dictionary4);
            link1.AddLogic(logicelementdummy);
            link1.AddConnection(entity1, entity3);

            rlt   = transaction.CreateLink(link1);
            link1 = rlt.AgregatedLinks[0];
            neo4jresults.Add(rlt);

            var link2 = new Link("SEND_VALUE");

            link2.AddProperty(dictionary5);
            link2.AddLogic(logicelementdummy);
            link2.AddConnection(entity2, entity3);

            rlt   = transaction.CreateLink(link2);
            link1 = rlt.AgregatedLinks[0];
            neo4jresults.Add(rlt);


            Console.WriteLine(new LogicHandler(transaction).Handle(entity3.LogicElement));



            rlt = transaction.CountQuery(new[] { "Test" });
            neo4jresults.Add(rlt);


            rlt = transaction.FindEntity(new Entity("Test"));
            neo4jresults.Add(rlt);


            rlt = transaction.FindLink(new Link("SEND_VALUE"));
            neo4jresults.Add(rlt);


            var entity4 = new Entity();

            entity4.AddProperty(dictionary2);

            rlt = transaction.FindEntity(entity4);
            neo4jresults.Add(rlt);


            var link3 = new Link();

            link3.AddProperty(dictionary4);

            rlt = transaction.FindLink(link3);
            neo4jresults.Add(rlt);

            rlt = transaction.GetLinkById(143);
            neo4jresults.Add(rlt);

            rlt = transaction.GetEntitiesByClass(new string[] { "Test" });
            neo4jresults.Add(rlt);

            rlt = transaction.GetLinksByClass("SEND_VALUE");
            neo4jresults.Add(rlt);

            entity3.AddProperty("Added", "Added atribute");
            rlt = transaction.UpdateEntity(entity3);

            Console.ReadKey(false);



            //var entity2 = new Entity()
            //{
            //    //Class = "Яблоня",
            //    Name = "Дерево",
            //    IsActive = false,
            //    Atributes = new string[]
            //    {
            //        "Тип"+":"+"Дерево",
            //        "Происхождение"+":"+ "Болгария",
            //        "Дата" +":"+ "%Дата%",
            //        "Время"+":"+ "%Дата%"
            //    },
            //    Logic = new LogicalElement()
            //    {

            //        Value = 0,
            //        Type = LogicalType.ValueActivation
            //    }
            //};

            //IStatementResult result;
            //IResultSummary res = null;
            //IRecord rec = null;


            //InsertEmptyLine("Creation 1");

            //result = transaction.CreateEntity(entity);
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);

            //InsertEmptyLine("Creation 2");

            //result = transaction.CreateEntity(entity2.GetParameters());
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);

            //InsertEmptyLine("Finding 1");

            //result = transaction.FindEntity(entity1.GetParameters());
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);

            //InsertEmptyLine("Finding 2");

            //var entity3 = new Entity(entity2.Id);
            //result = transaction.FindEntity(entity3.GetParameters());
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);

            //InsertEmptyLine("Create Link 1");

            //var link = new Link
            //{
            //    //Class = "PARENT",
            //    Name = "Род-вид",
            //    IsActive = false,
            //    AtributesDictionary = new Dictionary<string, string>
            //    {
            //        {"Комментарий", "Излишний"}
            //    },
            //    Source = entity2,
            //    Target = entity1

            //};

            //result = transaction.CreateLink(link.GetParameters(), link.Source.GetParameters(), link.Target.GetParameters());
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);

            //InsertEmptyLine("Find Link 1");

            //result = transaction.FindLink(link.GetParameters());
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);

            //InsertEmptyLine("Find Link 2");

            //var link2 = new Link(link.Id);
            //result = transaction.FindLink(link2.GetParameters());
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);

            //InsertEmptyLine("IsExist 1");

            //result = transaction.IsExist(entity1.GetParameters());
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);

            //InsertEmptyLine("IsExist 2");

            //result = transaction.IsExist(entity2.GetParameters());
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);

            //InsertEmptyLine("IsExist 3");

            //result = transaction.IsExist(entity3.GetParameters());
            ////res = result.Consume();
            ////rec = result.Peek();
            //Unwrap(res, rec, result);
        }