public ADEPTNodeDTO ToNodeDTO() { ADEPTNodeDTO targetNode = new ADEPTNodeDTO(); targetNode.Symbol = Symbol; targetNode.Thing = Thing; return(targetNode); }
public ADEPTNodeDTO Upsert(ADEPTNodeDTO targetNode) { ADEPTNodeDTO result = new ADEPTNodeDTO(); if (myManager != null && string.Compare(db_connectionstatus, "active") == 0) { result = myManager.UpsertNode(targetNode); } return(result); }
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); } } }
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); }