zoukankan      html  css  js  c++  java
  • 万物云平台数据转发 c# 控制台程序

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Net;
    using System.IO;
    using System.Timers;
    using System.Data;
    using Newtonsoft;
    using System.Threading.Tasks;
    using System.Net.Sockets;
    
    namespace Tlink_Send
    {
        class Program
        {static void Main(string[] args)
            {
                Console.WriteLine("江苏xx电气公司OPC-万物云转发工具");
                //Console.ReadKey();
                System.Timers.Timer maxTimer = new System.Timers.Timer();
                maxTimer.Elapsed += new ElapsedEventHandler(Tmr_Elapsed);
                // 设置引发时间的时间间隔 此处设置为1秒(1000毫秒)
                maxTimer.Interval = 1000;
                maxTimer.Enabled = true;
    
    
                //Console.WriteLine(album.ToString());
                System.Threading.Thread.Sleep(3000);
                Console.ReadKey();
                
    
            }
    
            public static string Post(string url)
            {
                string result = "";
                HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
                req.Method = "POST";
                HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
                Stream stream = resp.GetResponseStream();
                //获取内容
                using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                {
                    result = reader.ReadToEnd();
                }
                return result;
            }
    
    
    
            static void Tmr_Elapsed(object sender, ElapsedEventArgs e)
            {
                string value = (System.DateTime.Now.Millisecond - 100).ToString();
                string message="";
                if (Post("http://www.wanwuyun.com/api/hardput?seckey=你自己的&row={'DEV_ID':'meter','VALUE':'" + value + "','NAME':'转发测试'}") == "{"code":"0"}")
                {
                    message = "上传到云平台成功" + "上传值为:" + value;
                }
                else
                {
                    message = "上传失败";
                }
                Console.WriteLine(message);
                Console.ReadKey();
            }
            }
    
    }

     2020年3月10日

    做些别的接口对接,本地数据保存。

  • 相关阅读:
    java 数组声明方法
    python 什么叫迭代
    Golang生成区间随机整数
    Golang字符串格式化
    Golang中map的三种声明方式和简单实现增删改查
    Golang实现二分查找法
    Golang实现冒泡排序法
    Golang切片的三种简单使用方式及区别
    Golang获取int数组里的最大值和下标
    Golang数组注意细节
  • 原文地址:https://www.cnblogs.com/dXIOT/p/9999883.html
Copyright © 2011-2022 走看看