示例#1
0
 public static XmlDocument XmlDocumentFromHttpResponse(HttpResponse response)
 {
     var sr = new MemoryStream(response.bytes);
     XmlDocument doc = new XmlDocument();
     try
     {
         doc.Load(sr);
     }
     catch (Exception e)
     {
         GenUtils.PriorityLogMsg("exception", "XmlDocumentFromHttpResponse", e.Message + e.StackTrace);
     }
     return doc;
 }
示例#2
0
 public BlobStorageResponse(HttpResponse http_response)
 {
     this.HttpResponse = http_response;
     this.response = null;
 }
示例#3
0
 public BlobStorageResponse(HttpResponse http_response, List<Dictionary<string, string>> response)
 {
     this.HttpResponse = http_response;
     this.response = response;
 }
示例#4
0
        // read atom response, select desired elements, return enum of dict<str,str>
        public List<Dictionary<string, string>> DictsFromBlobStorageResponse(HttpResponse response, string xpath, string[] elements, ref string next_marker)
        {
            var dicts = new List<Dictionary<string, string>>();
            var doc = XmlUtils.XmlDocumentFromHttpResponse(response);
            XmlNodeList nodes = doc.SelectNodes(xpath);
            foreach (XmlNode node in nodes)
            {
                var dict = new Dictionary<string, string>();
                foreach (string element in elements)
                {
                    dict[element] = node.SelectSingleNode(element).FirstChild.Value;
                    var lm = node.SelectSingleNode("Properties/Last-Modified").FirstChild.Value;
                    dict["Last-Modified"] = lm;
                }
                dicts.Add(dict);
            }

            XmlNode next_marker_node = doc.SelectSingleNode("//NextMarker");
            if (next_marker_node != null && next_marker_node.HasChildNodes)
                next_marker = next_marker_node.FirstChild.Value;
            else
                next_marker = null;

            return dicts;
        }
示例#5
0
 // alternate for data as string
 public TableStorageStringResponse(HttpResponse http_response, string str)
     : base(http_response, null_bytes: false)
 {
     this._str = str;
 }
示例#6
0
 // encapsulate the http response from the table store, plus data as a list of dict<str,obj>
 public TableStorageListDictResponse(HttpResponse http_response, List<Dictionary<string,object>> list_dict_obj)
     : base(http_response, null_bytes: true)
 {
     this._list_dict_obj = list_dict_obj;
 }
示例#7
0
 // alternate version for int responses
 public TableStorageIntResponse(HttpResponse http_response, int i)
     : base(http_response, null_bytes:true)
 {
     this._i = i;
 }
示例#8
0
 public TableStorageHttpResponse(HttpResponse http_response, bool null_bytes)
 {
     this._http_response = http_response;
     if (null_bytes == true)
         this._http_response.bytes = null;
 }
示例#9
0
 // alternate version for boolean responses
 public TableStorageBoolResponse(HttpResponse http_response, bool boolean)
     : base(http_response, null_bytes:true)
 {
     this._boolean = boolean;
 }
示例#10
0
 // package azure table response as list of dict<str,obj>
 private static List<Dictionary<string, object>> GetTsDicts(HttpResponse http_response)
 {
     return GenUtils.GetOdataDicts(http_response.bytes);
 }
示例#11
0
 // for tracing, used everywhere
 public TableStorageHttpResponse WriteLogMessage(string type, string message, string data)
 {
     HttpResponse http_response;
     type = type ?? "";
     message = message ?? "";
     data = data ?? "";
     var entity = new Dictionary<string, object>();
     entity.Add("PartitionKey", "log");
     entity.Add("RowKey", DateTime.Now.ToUniversalTime().Ticks.ToString());
     entity.Add("type", type);
     entity.Add("message", message);
     entity.Add("data", data);
     try
     {
         http_response = this.InsertEntity(Configurator.azure_log_table, entity).http_response;
     }
     catch (Exception e)
     {
         http_response = new HttpResponse(HttpStatusCode.Unused, "unable to write log message, " + e.Message, null, null);
     }
     return new TableStorageHttpResponse(http_response, null_bytes: true);
 }
示例#12
0
 public static bool CompletedIfStatusEqualsExpected(HttpResponse r, Object o)
 {
     return r.status == (HttpStatusCode) o;
 }