Example #1
0
 public BaseRequest(JsonRequestBody httpBody = null) : base()
 {
     base.BaseUri = ConfigurationManager.AppSettings["BaseUri"];
     // var Host = ConfigurationManager.AppSettings["Host"];
     // if (!string.IsNullOrWhiteSpace(Host)) base.Headers["Host"] = Host;
     base.Content = httpBody;
 }
Example #2
0
        public async Task <bool> PushAsync()
        {
            var httpData   = JArray.FromObject(this.Values);
            var httpBody   = new HttpApis.JsonRequestBody(httpData);
            var httpResult = await Task.Run(() => new HttpApis.SubmitDevices(httpBody).Send());

            return(httpResult == null ? false : httpResult.Success);
        }
Example #3
0
        public void Submit()
        {
            Tag[] tags;
            lock (this)
            {
                tags = base.ToArray();
            }
            var tagSets = new Dictionary <string, TagSet>();

            var startTime = this.startTime;
            var endTime   = this.endTime;

            this.startTime = DateTime.Now;
            this.endTime   = DateTime.Now;

            // 转换
            foreach (var tag in tags)
            {
                var uniqueId = $"{tag.device.Id}-{tag.epc}-{tag.antennas}";
                if (!tagSets.ContainsKey(uniqueId))
                {
                    tagSets[uniqueId] = new TagSet(tag);
                }
                tagSets[uniqueId].Increment(tag);
            }

            // 提交
            var httpData = new JObject()
            {
                { "start_time", startTime },
                { "end_time", endTime },
                { "data", JArray.FromObject(tagSets.Values) }
            };
            var httpBody   = new HttpApis.JsonRequestBody(httpData);
            var httpResult = new HttpApis.SubmitTags(httpBody).Send();

            if (httpResult != null && httpResult.Success)
            {
                foreach (var tag in tags)
                {
                    base.Remove(tag);
                }
            }
            else
            {
                this.startTime = startTime;
                this.endTime   = endTime;
            }
        }
Example #4
0
 public SubmitDevices(JsonRequestBody httpBody) : base(httpBody)
 {
     this.Method = HcHttp.Method.POST;
     this.Uri    = "set-equipment";
 }
Example #5
0
 public SubmitTags(JsonRequestBody httpBody) : base(httpBody)
 {
     this.Method = HcHttp.Method.POST;
     this.Uri    = "insert-record";
 }