Пример #1
0
        /// <summary>
        /// Contains uses Azure Table services (one at a time, threaded, no batching here)
        /// </summary>
        /// <param name="table"></param>
        /// <param name="check"></param>
        /// <returns></returns>
        private bool Contains(CloudTable table, HashEntity check)
        {
            bool        KeepTrying = false;
            int         retryCount = 10;
            TableResult result     = null;
            HashEntity  entry      = null;

            TableOperation retrieveOperation = TableOperation.Retrieve <HashEntity>(check.PartitionKey, check.RowKey);

            do
            {
                try
                {
                    result = table.Execute(retrieveOperation);
                }
                catch (SocketException se)
                {
                    KeepTrying = true;
                    retryCount--;
                    if (retryCount <= 0)
                    {
                        KeepTrying = false;
                    }
                }
            } while (KeepTrying == true);

            entry = result.Result as HashEntity;
            if (entry != null)
            {
                return(true);
            }
            return(false);
        }
Пример #2
0
        private List <HashEntity> BatchBatch(CloudTable table, List <HashRec> recs, Func <CloudTable, HashEntity[], IList <TableResult> > BatchOp)
        {
            List <HashEntity> all = new List <HashEntity>();
            // if were still loading keep waiting till the buckets are all full
            List <HashEntity> entities = new List <HashEntity>();

            for (int h = 0; h < recs.Count; h++)
            {
                var e = new HashEntity(recs[h]);
                e.MetaInfo = $"{recs[h].RID}";
                entities.Add(e);

                if (entities.Count == 100)
                {
                    BatchOp(table, entities.ToArray());

                    all.AddRange(entities);
                    entities = new List <HashEntity>();
                }
            }
            if (entities.Count > 0)
            {
                BatchOp(table, entities.ToArray());
            }

            return(all);
        }