/// <summary> /// Get an element of an array of entities from Storage based on a NeoStorageKey (NPC Level 4) /// </summary> /// <param name="vau">vau</param> /// <param name="index">index</param> /// <returns>NPCNEP5Requisition</returns> public static NPCNEP5Requisition GetElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex) { if (NeoVersionedAppUser.IsNull(vau)) { return(Null()); } Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext; NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName); NPCNEP5Requisition e; //byte[] bkey; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA)); if (NeoTrace.RUNTIME) { TraceRuntime("Get(bkey).NPCNEP5Requisition.bsta", bsta.Length, bsta); } if (bsta.Length == 0) { e = NPCNEP5Requisition.Missing(); } else // not MISSING { int ista = (int)bsta.AsBigInteger(); NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista; if (sta == NeoEntityModel.EntityState.TOMBSTONED) { e = NPCNEP5Requisition.Tombstone(); } else // not MISSING && not TOMBSTONED { e = new NPCNEP5Requisition(); byte[] FromScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bFromScriptHash)); // Template: NPCLevel4CGetElement_cs.txt byte[] ToScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bToScriptHash)); // Template: NPCLevel4CGetElement_cs.txt string EncryptedBlobURI = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bEncryptedBlobURI)).AsString(); // Template: NPCLevel4CGetElement_cs.txt Int32 WorkflowState = (Int32)Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bWorkflowState)).AsBigInteger(); // Template: NPCLevel4CGetElement_cs.txt e._fromScriptHash = FromScriptHash; e._toScriptHash = ToScriptHash; e._encryptedBlobURI = EncryptedBlobURI; e._workflowState = WorkflowState; // NPCLevel4DBuryElement_cs.txt e._state = sta; e._state = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */ } } if (NeoTrace.RUNTIME) { LogExt("Get(bkey).NPCNEP5Requisition.e", e); } return(e); }
public static NPCNEP5Requisition Get(string key) { if (key.Length == 0) { return(Null()); } Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext; string _skeyTag = key + _classKeyTag; NPCNEP5Requisition e; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sSTA); if (NeoTrace.RUNTIME) { TraceRuntime("Get(skey).NPCNEP5Requisition.bsta", bsta.Length, bsta); } if (bsta.Length == 0) { e = NPCNEP5Requisition.Missing(); } else // not MISSING { int ista = (int)bsta.AsBigInteger(); NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista; e = new NPCNEP5Requisition(); byte[] FromScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sFromScriptHash); //NPCLevel2IGet_cs.txt byte[] ToScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sToScriptHash); //NPCLevel2IGet_cs.txt string EncryptedBlobURI = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sEncryptedBlobURI).AsString(); //NPCLevel2IGet_cs.txt Int32 WorkflowState = (Int32)Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sWorkflowState).AsBigInteger(); //NPCLevel2IGet_cs.txt if (NeoTrace.RUNTIME) { TraceRuntime("Get(skey).e._fromScriptHash, e._toScriptHash, e._encryptedBlobURI, e._workflowState", e._fromScriptHash, e._toScriptHash, e._encryptedBlobURI, e._workflowState); // Template: NPCLevel2Part2_cs.txt } e._fromScriptHash = FromScriptHash; e._toScriptHash = ToScriptHash; e._encryptedBlobURI = EncryptedBlobURI; e._workflowState = WorkflowState; e._state = sta; e._state = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */ } if (NeoTrace.RUNTIME) { LogExt("Get(skey).NPCNEP5Requisition", e); } return(e); }
/// <summary> /// Bury an element of an array of entities in Storage based on a NeoStorageKey (NPC Level 4) /// </summary> /// <param name="vau">vau</param> /// <param name="index">index</param> /// <returns>NPCNEP5Requisition</returns> public static NPCNEP5Requisition BuryElement(NeoVersionedAppUser vau, byte[] domain, byte[] bindex) { if (NeoVersionedAppUser.IsNull(vau)) // TODO - create NeoEntityModel.EntityState.BADKEY? { return(NPCNEP5Requisition.Null()); } Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext; NeoStorageKey nsk = NeoStorageKey.New(vau, domain, _bClassName); //byte[] bkey; NPCNEP5Requisition e; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA)); if (NeoTrace.RUNTIME) { TraceRuntime("Bury(vau,index).NPCNEP5Requisition.bsta", bsta.Length, bsta); } if (bsta.Length == 0) { e = NPCNEP5Requisition.Missing(); } else // not MISSING - bury it { e = NPCNEP5Requisition.Tombstone(); // TODO - should Bury() preserve the exist field values or re-initialize them? Preserve is cheaper but not as private Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bSTA), e._state.AsBigInteger()); Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bFromScriptHash), e._fromScriptHash); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bToScriptHash), e._toScriptHash); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bEncryptedBlobURI), e._encryptedBlobURI); // NPCLevel4EBuryElement_cs.txt Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, NeoStorageKey.StorageKey(nsk, bindex, _bWorkflowState), e._workflowState); // NPCLevel4EBuryElement_cs.txt } // Template: NPCLevel4Part2_cs.txt if (NeoTrace.RUNTIME) { LogExt("Bury(vau,i).NPCNEP5Requisition", e); } return(e); }
public static NPCNEP5Requisition Get(byte[] key) { if (key.Length == 0) { return(Null()); } Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext; byte[] _bkeyTag = Helper.Concat(key, _bclassKeyTag); NPCNEP5Requisition e; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bSTA)); if (NeoTrace.RUNTIME) { TraceRuntime("Get(bkey).bsta", bsta.Length, bsta); } if (bsta.Length == 0) { e = NPCNEP5Requisition.Missing(); } else // not MISSING { int ista = (int)bsta.AsBigInteger(); NeoEntityModel.EntityState sta = (NeoEntityModel.EntityState)ista; e = new NPCNEP5Requisition(); byte[] FromScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bFromScriptHash)); //NPCLevel2GGet_cs.txt byte[] ToScriptHash = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bToScriptHash)); //NPCLevel2GGet_cs.txt string EncryptedBlobURI = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bEncryptedBlobURI)).AsString(); //NPCLevel2GGet_cs.txt Int32 WorkflowState = (Int32)Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, Helper.Concat(_bkeyTag, _bWorkflowState)).AsBigInteger(); //NPCLevel2GGet_cs.txt e._fromScriptHash = FromScriptHash; e._toScriptHash = ToScriptHash; e._encryptedBlobURI = EncryptedBlobURI; e._workflowState = WorkflowState; // Template: NPCLevel2HGet_cs.txt e._state = sta; e._state = NeoEntityModel.EntityState.GETTED; /* OVERRIDE */ } if (NeoTrace.RUNTIME) { LogExt("Get(bkey).NPCNEP5Requisition", e); } return(e); }
public static NPCNEP5Requisition Bury(string key) { if (key.Length == 0) { return(Null()); } Neo.SmartContract.Framework.Services.Neo.StorageContext ctx = Neo.SmartContract.Framework.Services.Neo.Storage.CurrentContext; string _skeyTag = key + _classKeyTag; NPCNEP5Requisition e; byte[] bsta = Neo.SmartContract.Framework.Services.Neo.Storage.Get(ctx, _skeyTag + _sSTA); if (NeoTrace.RUNTIME) { TraceRuntime("Bury(skey).NPCNEP5Requisition.bsta", bsta.Length, bsta); } if (bsta.Length == 0) { e = NPCNEP5Requisition.Missing(); } else // not MISSING - bury it { e = NPCNEP5Requisition.Tombstone(); // but don't overwrite existing field values - just tombstone it Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sSTA, e._state.AsBigInteger()); //Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sFromScriptHash, e._fromScriptHash); // Template: NPCLevel3CBury_cs.txt //Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sToScriptHash, e._toScriptHash); // Template: NPCLevel3CBury_cs.txt //Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sEncryptedBlobURI, e._encryptedBlobURI); // Template: NPCLevel3CBury_cs.txt //Neo.SmartContract.Framework.Services.Neo.Storage.Put(ctx, _skeyTag + _sWorkflowState, e._workflowState); // Template: NPCLevel3CBury_cs.txt } // Template: NPCLevel3Part2_cs.txt if (NeoTrace.RUNTIME) { LogExt("Bury(skey).NPCNEP5Requisition", e); } return(e); // return Entity e to signal if key is Missing or bad key }