コード例 #1
0
        public IActionResult Put(string id, [FromBody] string value)
        {
            if (id == null)
            {
                return(StatusCode(400, "Provide ID for data"));
            }
            var updateddata = _context.UpdatedData.SingleOrDefault(u => u.DataID.Equals(id));

            if (updateddata == null)
            {
                return(StatusCode(400, "Data ID not found in database"));
            }
            if (!updateddata.Active)
            {
                return(StatusCode(200, UpdatedData.GetPointers(updateddata)));
            }

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(@"http://localhost:5000/api/updates");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            HttpContent content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(updateddata));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage rm = client.PostAsync("", content).Result;

            return(StatusCode(400, rm.StatusCode.ToString() + rm.Content.ToString()));

            //
            //return StatusCode(400, "Request type not supported");
        }
コード例 #2
0
ファイル: Internal.cs プロジェクト: wj60387/akka.net
 /// <inheritdoc/>
 public override int GetHashCode()
 {
     unchecked
     {
         return(((UpdatedData != null ? UpdatedData.GetHashCode() : 0) * 397) ^ SendBack.GetHashCode());
     }
 }
コード例 #3
0
        public IActionResult Post([FromBody] dynamic value)
        {
            string      s = value.ToString();
            UpdatedData d = JsonConvert.DeserializeObject <UpdatedData>(s);

            d.DataID = Guid.NewGuid().ToString();
            d.Active = true;
            d.UpdateDateTimeTicks = DateTime.Now.Ticks.ToString();
            try
            {
                UpdatedData lastUpdatedDataInDomain = _context.UpdatedData.Where(u => u.UpdatedDomain.Equals(d.UpdatedDomain)).OrderByDescending(t => t.UpdateDateTimeTicks).FirstOrDefault();
                lastUpdatedDataInDomain.NextDataID = d.DataID;
                _context.Update(lastUpdatedDataInDomain);
            }
            catch (System.NullReferenceException)
            {
                return(StatusCode(401, "Domain does not exist"));
            }
            _context.Add(d);
            _context.SaveChanges();

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri(@"http://localhost:5000/api/updates");
            client.DefaultRequestHeaders.Accept.Clear();
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            HttpContent content = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(d));

            content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            HttpResponseMessage rm = client.PostAsync("", content).Result;

            return(StatusCode(201, d.DataID));
        }
コード例 #4
0
 public MainModel()
 {
     Device.StartTimer(TimeSpan.FromSeconds(1), () =>
     {
         UpdatedData?.Invoke(this, new DataEventArgs()
         {
             Count = _count
         });
         _count++;
         return(true);
     });
 }
コード例 #5
0
 public void StartCounter()
 {
     Device.StartTimer(TimeSpan.FromSeconds(1), () =>
     {
         UpdatedData?.Invoke(this, new DataEventArgs()
         {
             Count = count
         });
         count++;
         return(true);
     });
 }
コード例 #6
0
ファイル: Internal.cs プロジェクト: wj60387/akka.net
        /// <inheritdoc/>
        public bool Equals(Gossip other)
        {
            if (ReferenceEquals(other, null))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(other.SendBack.Equals(SendBack) && UpdatedData.SequenceEqual(other.UpdatedData));
        }
コード例 #7
0
        public IActionResult Get(string id)
        {
            if (id == null)
            {
                return(StatusCode(400, "Provide ID for data"));
            }
            var updateddata = _context.UpdatedData.SingleOrDefault(u => u.DataID.Equals(id));

            if (updateddata == null)
            {
                return(StatusCode(400, "Data ID not found in database"));
            }
            if (!updateddata.Active)
            {
                return(StatusCode(200, UpdatedData.GetPointers(updateddata)));
            }

            return(StatusCode(200, updateddata));
        }
コード例 #8
0
        // POST api/values
        public List <UpdatedData> Post([FromBody] List <ReceivedData> DataStream)
        {
            var violatedData = new List <UpdatedData>();

            foreach (var data in DataStream)
            {
                //To process the incoming Stream
                UpdatedData datareceived = new UpdatedData(data);
                datareceived.Process(data);

                //To save the incoming Stream in a Database
                _context.UpdatedDatas.Add(datareceived);
                _context.SaveChanges();

                //If signal has violated a rule then show that signal to User
                if (datareceived.CorrectSignal == false)
                {
                    violatedData.Add(datareceived);
                }
            }
            return(violatedData);
        }