Exemplo n.º 1
0
        public ActionResult Create()
        {
            AcrCallback item;
            CloudTable  table = getTable();

            try {
                item = new AcrCallback()
                {
                    StreamId  = "streamid1",
                    StreamUrl = "streal_url1",
                    Data      = "data1",
                };
                AcrCallback acrData = new AcrCallback(item.StreamId, DateTime.Now.ToString("yyyyMMddHHmmss"))
                {
                    Data      = item.Data,
                    StreamUrl = item.StreamUrl,
                };
                TableOperation insertOperation = TableOperation.Insert(acrData);
                TableResult    result          = table.Execute(insertOperation);
                ViewBag.TableName     = table.Name;
                ViewBag.Result        = result.HttpStatusCode;
                ViewBag.ResultDetails = result.HttpStatusCode.ToString();
                return(View());
            } catch (Exception ex) {
                ViewBag.Result        = (int)HttpStatusCode.InternalServerError;;
                ViewBag.ResultDetails = ex.ToString();
                return(View());
            }
        }
Exemplo n.º 2
0
        public ActionResult Create(FormCollection collection)
        {
            StringBuilder msg   = new StringBuilder();
            CloudTable    table = getTable();

            try {
                AcrCallback acrData = new AcrCallback(
                    collection["stream_id"],
                    getRowKeyFromTimeString(DateTime.Now.ToString("yyyyMMddHHmmss")))
                {
                    StreamId  = collection["stream_id"],
                    StreamUrl = collection["stream_url"],
                    Data      = collection["data"],
                    Timestamp = DateTime.Now,
                };
                _lastCallback = acrData;
                TableOperation insertOperation = TableOperation.Insert(acrData);
                TableResult    result          = table.Execute(insertOperation);

                Response.StatusCode = result.HttpStatusCode;
                return(Content(msg.ToString()));
            } catch (Exception ex) {
                return(Content(ex.ToString()));
            }
        }
Exemplo n.º 3
0
        public ActionResult ConvertOldRowKey()
        {
            var msg   = new StringBuilder("Átírtam:");
            var item  = getLast()[0];
            var table = getTable();

            while (item.RowKey.StartsWith("2019"))
            {
                var delete  = TableOperation.Delete(item);
                var newItem = new AcrCallback(item.PartitionKey, getRowKeyFromTimeString(item.RowKey))
                {
                    Data      = item.Data,
                    ETag      = item.ETag,
                    StreamId  = item.StreamId,
                    StreamUrl = item.StreamUrl,
                    Timestamp = item.Timestamp,
                };
                var insert = TableOperation.Insert(newItem);
                table.Execute(delete);
                table.Execute(insert);
                msg.AppendLine($"{item.RowKey} -> {newItem.RowKey}");

                item = getLast()[0];
            }
            return(Content(msg.ToString()));
        }