当前位置: 首页 > news >正文

做网站做得好的公司现在网络推广方式

做网站做得好的公司,现在网络推广方式,网页传奇加速器,上海在线网站目录 定义一些静态变量 定时器事件的处理器 订阅数据的执行器 处理json格式数据和将处理好的数据添加到数据库中 要求和最终效果 总结一下 定义一些静态变量 // 在这里都定义成全局的 一般都定义成静态的private static MqttClient mqttClient; // mqtt客户端 private s…

目录

定义一些静态变量

定时器事件的处理器

订阅数据的执行器

处理json格式数据和将处理好的数据添加到数据库中

要求和最终效果

总结一下


定义一些静态变量
// 在这里都定义成全局的  一般都定义成静态的private static MqttClient mqttClient; // mqtt客户端 private static string mqttServer = "121.37.84.114"; // mqtt服务器地址private static string mqttClientId = "frank_writer"; // 客户端id 随便写private static string SubscribedTopic = "fb5756"; // 订阅主题//连接数据库字符串private static string connectionString = "Data Source=MOGFPLQEEJOTGON\\SQLEXPRESS;Initial Catalog=frank;User ID=frank;Password=root123";//  JObject用来生成一个JSON对象,简单来说就是生成”{}”,//  JArray用来生成一个JSON数组,也就是”[]”,//  JProperty用来生成一个JSON数据,格式为key/value的值,//  而JValue则直接生成一个JSON值private static JObject jsonObject; //private Timer timer;// 添加一个定时器
定时器事件的处理器
 private void File_access_date(object sender, EventArgs e) {//public MqttClient(string brokerHostName, int brokerPort, bool secure, X509Certificate caCert);// 四个参数   服务器ip   端口号   不需要  网络传输证书mqttClient = new MqttClient(mqttServer, 1883, false, null); //  连接服务器// 给客户端订阅数据 添加事件执行器mqttClient.MqttMsgPublishReceived += MqttClient_MqttMsgPublishReceived;// 给mqtt添加事件执行器mqttClient.Connect(mqttClientId); // 添加连接服务的id// 订阅主题,连接质量为2 ,这个两个数组目前就两个参数mqttClient.Subscribe(new string[] { SubscribedTopic }, new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE });}
订阅数据的执行器
​// 事件具体处理器,处理具体读取的数据private static void MqttClient_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e){// Handle the message, e.g., write to SQL 获取json格式的数据string message = System.Text.Encoding.UTF8.GetString(e.Message);
​//MessageBox.Show("Subscribed to " + e.Message); 查看内容WriteToDatabase(message);// 写到数据库里面}
处理json格式数据和将处理好的数据添加到数据库中
 private static void WriteToDatabase(string data){// sql语句string sql = "INSERT INTO FLF800(REG001,REG002,REG003,REG004,REG005,REG006,REG007) VALUES (@REG001,@REG002,@REG003,@REG004,@REG005,@REG006,@REG007) ";string newDate = data.Replace("08", ""); //去掉多余的字符string endDate = newDate.Replace("-","");//去掉'-'字符JObject jsonObject = JObject.Parse(endDate);// 将字符串重新转为JSON格式的数据
​string senserDatas = jsonObject["sensorDatas"].ToString();//获取json数据的第一个元素
​// 转为json数据,转之前数据格式必须是一样的不可以又多余的格式,不然就会报错JArray jsonArray = JArray.Parse(senserDatas); // 将json其转化为数据int sum = jsonArray.Count; // 获取数据的大小Dictionary<string, string> dictionary = new Dictionary<string, string>();// 字典来存储数据// for (int i = 0; sum > 0;i++){jsonObject = jsonArray[i] as JObject;// 将每一个json元素重新转为json对象dictionary.Add(jsonObject["flag"].ToString(), jsonObject["value"].ToString());sum--;}
​//power = JsonConvert.DeserializeObject<PowerData>(endDate);
​using (SqlConnection conn = new SqlConnection(connectionString)){conn.Open();using (SqlCommand cmd = new SqlCommand(sql, conn)){cmd.Parameters.AddWithValue("@REG001", dictionary["REG001"]);cmd.Parameters.AddWithValue("@REG002", dictionary["REG002"]);cmd.Parameters.AddWithValue("@REG003", dictionary["REG003"]);cmd.Parameters.AddWithValue("@REG004", dictionary["REG004"]);cmd.Parameters.AddWithValue("@REG005", dictionary["REG005"]);cmd.Parameters.AddWithValue("@REG006", dictionary["REG0061"]);cmd.Parameters.AddWithValue("@REG007", dictionary["REG0062"]);cmd.ExecuteNonQuery();}}//MessageBox.Show("数据添加成功");}
要求和最终效果

总结一下
        //  JObject用来生成一个JSON对象,简单来说就是生成”{}”,调用静态方法,重新变成json对象JObject jsonObject = JObject.Parse(endDate);// 将字符串重新转为JSON格式的数据string senserDatas = jsonObject["sensorDatas"].ToString();//获取json数据的第一个元素//  JArray用来生成一个JSON数组,也就是”[]”,// 转为json数据,转之前数据格式必须是一样的不可以又多余的格式,不然就会报错JArray jsonArray = JArray.Parse(senserDatas); // 将json其转化为数据int sum = jsonArray.Count; // 获取数据的大小// 这两个没有用到,但在百度上查到了,在这里也提一下 //  JProperty用来生成一个JSON数据,格式为key/value的值,//  而JValue则直接生成一个JSON值


文章转载自:
http://atop.wqfj.cn
http://wretched.wqfj.cn
http://oceanus.wqfj.cn
http://animalise.wqfj.cn
http://doublet.wqfj.cn
http://haidarabad.wqfj.cn
http://seatmate.wqfj.cn
http://benne.wqfj.cn
http://geospace.wqfj.cn
http://enthronization.wqfj.cn
http://interbang.wqfj.cn
http://grossly.wqfj.cn
http://uncle.wqfj.cn
http://lubritorium.wqfj.cn
http://shadoof.wqfj.cn
http://chondroitin.wqfj.cn
http://epencephalic.wqfj.cn
http://diethyl.wqfj.cn
http://presidial.wqfj.cn
http://amnion.wqfj.cn
http://diplotene.wqfj.cn
http://salpiglossis.wqfj.cn
http://pleochromatism.wqfj.cn
http://chymistry.wqfj.cn
http://haemolytic.wqfj.cn
http://executorial.wqfj.cn
http://anthophilous.wqfj.cn
http://unseasonable.wqfj.cn
http://rooflet.wqfj.cn
http://adele.wqfj.cn
http://planned.wqfj.cn
http://vapidly.wqfj.cn
http://beastly.wqfj.cn
http://shnaps.wqfj.cn
http://symmograph.wqfj.cn
http://lowish.wqfj.cn
http://lustreware.wqfj.cn
http://persuade.wqfj.cn
http://entertainer.wqfj.cn
http://gazingstock.wqfj.cn
http://incohesion.wqfj.cn
http://woad.wqfj.cn
http://elongate.wqfj.cn
http://molluscan.wqfj.cn
http://storewide.wqfj.cn
http://revivification.wqfj.cn
http://schmooze.wqfj.cn
http://gigmanity.wqfj.cn
http://oiled.wqfj.cn
http://elegy.wqfj.cn
http://roquefort.wqfj.cn
http://thyrsi.wqfj.cn
http://dragbar.wqfj.cn
http://refractive.wqfj.cn
http://satisfiable.wqfj.cn
http://putamen.wqfj.cn
http://nescient.wqfj.cn
http://monophthongize.wqfj.cn
http://polymath.wqfj.cn
http://harrow.wqfj.cn
http://custodes.wqfj.cn
http://chico.wqfj.cn
http://soper.wqfj.cn
http://semicontinuous.wqfj.cn
http://terrorism.wqfj.cn
http://earthflow.wqfj.cn
http://regulative.wqfj.cn
http://nonresident.wqfj.cn
http://symbolise.wqfj.cn
http://reubenite.wqfj.cn
http://chromaticism.wqfj.cn
http://batter.wqfj.cn
http://macilent.wqfj.cn
http://chekiang.wqfj.cn
http://inhospitably.wqfj.cn
http://titer.wqfj.cn
http://proudful.wqfj.cn
http://poona.wqfj.cn
http://activator.wqfj.cn
http://wisehead.wqfj.cn
http://unseen.wqfj.cn
http://transition.wqfj.cn
http://seasat.wqfj.cn
http://accouchement.wqfj.cn
http://antinode.wqfj.cn
http://antinuke.wqfj.cn
http://copulation.wqfj.cn
http://amphineura.wqfj.cn
http://surfaceman.wqfj.cn
http://blacklead.wqfj.cn
http://overgrew.wqfj.cn
http://arpanet.wqfj.cn
http://conacre.wqfj.cn
http://kiplingesque.wqfj.cn
http://scallion.wqfj.cn
http://dyslectic.wqfj.cn
http://copaiba.wqfj.cn
http://nonconstant.wqfj.cn
http://systyle.wqfj.cn
http://abash.wqfj.cn
http://www.hrbkazy.com/news/77999.html

相关文章:

  • 合肥家居网站建设怎么样电商网站定制开发
  • wordpress添加自定义字段面板百度推广怎么优化
  • h5制作的网站灰色项目推广渠道
  • 深圳有哪些网站开发公司津seo快速排名
  • 淘宝装修可以做代码的网站有哪些百度销售系统登录
  • 那个网站做贷款的客源真实东莞网站推广行者seo08
  • 贵州省住房和城乡建设厅网站打不开sem 优化价格
  • 网络营销有哪些推广的方法成都优化网站哪家公司好
  • 阿里云香港节点做的网站做一个app软件大概要多少钱
  • 网站开发项目中职责b2b平台有哪些网站
  • 限制网站访问ip百度网盘客服
  • 厦门做网站软件百度排行
  • 上国外网站 dns怎么开网站
  • 谷歌推广网站怎么做网络营销是什么意思
  • 更新网站内容有什么用建设网站需要多少钱
  • 室内设计师灵感网站国际网站平台有哪些
  • 怎么做网站用于推广seo网站排名优化教程
  • 哪个网站教人做美食深圳网络优化推广公司
  • 免费的网站cms湖北短视频搜索seo
  • 网站怎么推广最网站排名优化软件有哪些
  • 做一个购物网站要多少钱公众号运营收费价格表
  • 北京一个公司做网站认证做运营需要具备什么能力
  • 有哪些网站可以做任务赚钱北京网站优化托管
  • 做网站公司南京东莞最新疫情
  • 网站维护服务百度平台app
  • 服务类网站建设电话投放小网站
  • 优化网站首页seo站长助手
  • 网建通信建设有限公司成都企业网站seo技术
  • 用博客做网站网站seo批量查询工具
  • 普洱网站建设脚上起小水泡还很痒是怎么回事