[WinAPP] keke test 改了一些無關緊要的東西

This commit is contained in:
keke 2023-08-15 17:59:17 +08:00
parent 7313283e8c
commit 6e3bf25510
7 changed files with 454 additions and 7 deletions

View File

@ -18,7 +18,8 @@ namespace tpDomeWinAPP
Application.SetHighDpiMode(HighDpiMode.SystemAware);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new fmCheckTagName());
//Application.Run(new fmCheckTagName());
Application.Run(new fmKeke());
//Application.Run(new fmDecrypt());
}
}

View File

@ -145,9 +145,10 @@ namespace tpDomeWinAPP.Service
{
List<device_value2> result = new List<device_value2>();
//String username = "obixUser";
//String password = "Admin123456";
String username = "stanGG";
String password = "St12345678";
String username = "admin";
String password = "Admin123456";
//String username = "stanGG";
//String password = "St12345678";
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
String API_Url = urlString;
@ -234,5 +235,75 @@ namespace tpDomeWinAPP.Service
}
return result;
}
public List<device_value2> obixQuery_keke(string urlString, string post_xml)
{
//var handler = new HttpClientHandler();
//handler.ClientCertificateOptions = ClientCertificateOption.Manual;
//handler.ServerCertificateCustomValidationCallback =
// (httpRequestMessage, cert, cetChain, policyErrors) =>
// {
// return true;
// };
//var client = new HttpClient(handler);
List<device_value2> result = new List<device_value2>();
String username = "admin";
String password = "Admin123456";
String encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));
String API_Url = urlString;
HttpWebRequest Postrequest = (HttpWebRequest)WebRequest.Create(API_Url);
Postrequest.Method = "POST";
Postrequest.Headers.Add("Authorization", "Basic " + encoded);
Postrequest.PreAuthenticate = true;
using (var streamWriter = new StreamWriter(Postrequest.GetRequestStream()))
{
streamWriter.Write(post_xml);
}
HttpWebResponse response = (HttpWebResponse)Postrequest.GetResponse();
var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(responseString);
//xmlDoc.Load("N4v1021.xml");//N4v1021
//xmlDoc.Save("N4.xml");
string jsonText = JsonConvert.SerializeXmlNode(xmlDoc);
// JObject resultVal = (JObject)JsonConvert.DeserializeObject(jsonText);
var data = Welcome.FromJson(jsonText);
foreach (var item in data.Obj.Str)
{
device_value2 row = new device_value2();
row.value = item.Val;
string[] s1 = item.Val.Split(',');
string[] s2 = s1[0].Split('/');
row.tag_name = "";
for (int i = 0; i < s2.Length; i++)
{
if (i == s2.Length - 2)
{
row.point_name = s2[i];
}
else if (i == 1)
{
row.tag_name += s2[i];
}
else if (i > 1 && i < s2.Length - 2)
{
row.tag_name += "_" + s2[i].Replace("$3", "");
}
}
result.Add(row);
}
return result;
}
}
}

View File

@ -120,8 +120,6 @@ namespace tpDomeWinAPP
index++;
}
}
private void rb100_CheckedChanged(object sender, EventArgs e)
{
RadioButton rb = (sender as RadioButton);

View File

@ -1,4 +1,64 @@
<root>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">

117
z01_WinAPP/fmKeke.Designer.cs generated Normal file
View File

@ -0,0 +1,117 @@
namespace z01_WinAPP
{
partial class fmKeke
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
splitContainer1 = new System.Windows.Forms.SplitContainer();
lbMsg = new System.Windows.Forms.Label();
loadData = new System.Windows.Forms.Button();
dataGridView1 = new System.Windows.Forms.DataGridView();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// splitContainer1
//
splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
splitContainer1.Location = new System.Drawing.Point(0, 0);
splitContainer1.Name = "splitContainer1";
splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer1.Panel1
//
splitContainer1.Panel1.Controls.Add(lbMsg);
splitContainer1.Panel1.Controls.Add(loadData);
//
// splitContainer1.Panel2
//
splitContainer1.Panel2.Controls.Add(dataGridView1);
splitContainer1.Size = new System.Drawing.Size(1169, 658);
splitContainer1.SplitterDistance = 121;
splitContainer1.TabIndex = 0;
//
// lbMsg
//
lbMsg.AutoSize = true;
lbMsg.Location = new System.Drawing.Point(474, 76);
lbMsg.Name = "lbMsg";
lbMsg.Size = new System.Drawing.Size(219, 19);
lbMsg.TabIndex = 0;
lbMsg.Text = "Please Click \"loadData\" button";
//
// loadData
//
loadData.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
loadData.Location = new System.Drawing.Point(463, 12);
loadData.Name = "loadData";
loadData.Size = new System.Drawing.Size(236, 42);
loadData.TabIndex = 0;
loadData.Text = "loadData";
loadData.UseVisualStyleBackColor = true;
loadData.Click += button1_Click;
//
// dataGridView1
//
dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new System.Drawing.Point(177, 13);
dataGridView1.Name = "dataGridView1";
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.Size = new System.Drawing.Size(819, 508);
dataGridView1.TabIndex = 0;
dataGridView1.CellContentClick += dataGridView1_CellContentClick;
//
// fmKeke
//
AutoScaleDimensions = new System.Drawing.SizeF(9F, 19F);
AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new System.Drawing.Size(1169, 658);
Controls.Add(splitContainer1);
Name = "fmKeke";
Text = "fmKeke";
Load += fmKeke_Load;
splitContainer1.Panel1.ResumeLayout(false);
splitContainer1.Panel1.PerformLayout();
splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
splitContainer1.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private System.Windows.Forms.SplitContainer splitContainer1;
private System.Windows.Forms.Button loadData;
private System.Windows.Forms.Label lbMsg;
private System.Windows.Forms.DataGridView dataGridView1;
}
}

77
z01_WinAPP/fmKeke.cs Normal file
View File

@ -0,0 +1,77 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
using tpDomeWinAPP.Service;
using tpDomeWinAPP.Models;
using System.Linq;
using System.Collections;
using NPOI.SS.Formula.Functions;
namespace z01_WinAPP
{
public partial class fmKeke : Form
{
List<device_value2> ds;
public fmKeke()
{
InitializeComponent();
}
private void fmKeke_Load(object sender, EventArgs e)
{
}
private void splitContainer1_Panel2_Paint(object sender, PaintEventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
loadData_fic();
}
private void loadData_fic()
{
lbMsg.Text = "Loading ...";
// https://green.fic.com.tw:8443/obix/config/
// ObixUser
// Admin123456
webRequestSvc svc = new webRequestSvc();
//local:|foxs:|history:/S02102000101/Inv|view:history:HistoryTable
string url_slot = "history:/S02102000101/Inv|";
string bql = url_slot + "bql:select *";
string obix_url = "https://green.fic.com.tw:8443/obix/histories/S03203000101/Inv/~historyQuery/";
string post_xml = "<obj is=\"obix:HistoryFilter\"><abstime name=\"start\" val=\"2023-06-02T00:00:00.000+08:00\"/><abstime name=\"end\" val=\"2023-06-06T23:59:59.000+08:00\"/><reltime name=\"interval\" val=\"PT15M\" /></obj>";
ds = svc.obixQuery_keke(obix_url, post_xml);
//ds = svc.obixQuery("http://60.251.164.125:8080/obix/config/Arena/Program/ObixQuery/query/", bql);
//ds = svc.obixQuery("http://60.251.164.125:8080/obix/config/Program/ObixQuery/query/", bql);//三菱
//ds = svc.obixQuery("http://192.168.0.136:8081/obix/config/Program/ObixQuery/query/", bql);//wsp
//ds = svc.obixQuery("http://localhost:8080/obix/config/Program/ObixQuery/query/", bql);
//dataGridView1.DataSource = ds;
dataGridView1.Columns[0].Visible = false;
dataGridView1.Columns[1].Width = 400;
dataGridView1.Columns[2].Width = 200;
//lbMsg.Text = "共 " + ds.Count.ToString() + " 筆資料 " + Environment.NewLine + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}
}

123
z01_WinAPP/fmKeke.resx Normal file
View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>