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日

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

  • 相关阅读:
    [转]Lucene 性能优化带数据
    Lucene Document getBoost(float) 和 setBoost(float)
    几种Lucene.Net打开IndexReader的方式
    JSON 省市数据包括港澳
    Lucene Boost 精度表
    Dot NET 内存泄漏
    对《LINQ能不能用系列(一)数组筛选效率对比》中测试的几个问题
    售前工程师的成长一个老员工的经验之谈(三)(转载)
    yum使用简介
    Hadoop源代码分析 HDFS(转载)
  • 原文地址:https://www.cnblogs.com/dXIOT/p/9999883.html
Copyright © 2011-2022 走看看