Exemple #1
0
        public ADEPTNodeDTO ToNodeDTO()
        {
            ADEPTNodeDTO targetNode = new ADEPTNodeDTO();

            targetNode.Symbol = Symbol;
            targetNode.Thing  = Thing;

            return(targetNode);
        }
Exemple #2
0
        public ADEPTNodeDTO Upsert(ADEPTNodeDTO targetNode)
        {
            ADEPTNodeDTO result = new ADEPTNodeDTO();

            if (myManager != null && string.Compare(db_connectionstatus, "active") == 0)
            {
                result = myManager.UpsertNode(targetNode);
            }

            return(result);
        }
Exemple #3
0
        private void btnUpsert_Click(object sender, EventArgs e)
        {
            ADEPTNodeDTO resultNode = new ADEPTNodeDTO();

            if (myManager != null && string.Compare(myManager.db_connectionstatus, "active") == 0)
            {
                ADEPTFormInputs myInputs   = GetFormInputs();
                ADEPTNodeDTO    targetNode = myInputs != null?myInputs.ToNodeDTO() : null;

                if (targetNode != null)
                {
                    resultNode = myManager.Upsert(targetNode);
                }
            }
        }
Exemple #4
0
        public ADEPTNodeDTO UpsertNode(ADEPTNodeDTO targetNode)
        {
            ADEPTNodeDTO resultNode = new ADEPTNodeDTO();

            using (var session = myDriver.Session())
            {
                var symbol = session.WriteTransaction(tx =>
                {
                    string baseQuery         = "MERGE(n: ADEPTNode {{symbol:'{0}'}}) ON CREATE SET n.counter = 0, n.created = timestamp() ON MATCH SET n.counter = coalesce(n.counter, 0) + 1, n.accessTime = timestamp()";
                    string targetInsertQuery = string.Format(baseQuery, targetNode.Symbol);
                    var result = tx.Run(targetInsertQuery);
                    return((result != null && result.Count() > 0) ? result.Single()[0].As <string>() : null);
                });
                resultNode.Symbol = symbol;
                Console.WriteLine(symbol);
            }

            return(resultNode);
        }