示例#1
0
        /// <summary>
        /// Reload all NFT Hashes.
        /// NFT Hash is shorten version of the NFT hash, just to save space if you have just smaller amount of the NFTs.
        /// </summary>
        /// <returns></returns>
        public static async Task <bool> ReloadNFTHashes()
        {
            try
            {
                var nhs = new ConcurrentDictionary <string, NFTHash>();
                VEDLDataContext.Accounts.Values.ToList()
                .ForEach(a => a.NFTs
                         .ForEach(n => nhs.TryAdd(NFTHash.GetShortHash(n.Utxo, n.UtxoIndex), new NFTHash()
                {
                    TxId              = n.Utxo,
                    Index             = n.UtxoIndex,
                    Type              = n.Type,
                    MainAddress       = a.Address,
                    SubAccountAddress = string.Empty,
                    Description       = n.Description,
                    Name              = n.Name,
                    Image             = n.ImageLink,
                    Link              = n.Link,
                    Price             = n.Price,
                    DogePrice         = n.DogePrice,
                    AuthorDogeAddress = n.DogeAddress,
                    DogeftInfo        = n.DogeftInfo
                })));

                VEDLDataContext.Accounts.Values.ToList()
                .ForEach(a => a.SubAccounts.Values.ToList()
                         .ForEach(s => s.NFTs
                                  .ForEach(n => nhs.TryAdd(NFTHash.GetShortHash(n.Utxo, n.UtxoIndex), new NFTHash()
                {
                    TxId              = n.Utxo,
                    Index             = n.UtxoIndex,
                    Type              = n.Type,
                    MainAddress       = a.Address,
                    SubAccountAddress = s.Address,
                    Description       = n.Description,
                    Name              = n.Name,
                    Image             = n.ImageLink,
                    Link              = n.Link,
                    Price             = n.Price,
                    DogePrice         = n.DogePrice,
                    AuthorDogeAddress = n.DogeAddress,
                    DogeftInfo        = n.DogeftInfo
                }))));

                if (nhs != null)
                {
                    VEDLDataContext.NFTHashs.Clear();
                    VEDLDataContext.NFTHashs = nhs;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot refresh NFTHashes." + ex.Message);
            }
            return(false);
        }
 public async Task <string> GetShortenHash(string txid, int index)
 {
     return(NFTHash.GetShortHash(txid, index));
 }