- 博客(0)
- 资源 (5)
- 收藏
- 关注
发热数据程序上报.zip
主要对XML文件进行加解密。保护重要信息(数据库连接账户和密码等配置信息)
//解密XML文件
public static XmlDocument ReadFileXML(string mFilePath)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.PreserveWhitespace = true;
xmlDoc.Load(mFilePath);
}
catch (Exception err)
{
return xmlDoc;
}
// Create a new TripleDES key.
TripleDESCryptoServiceProvider tDESkey = new TripleDESCryptoServiceProvider();
tDESkey.Key = Convert.FromBase64String(Common.customKey);
tDESkey.IV = Convert.FromBase64String(Common.customIV);
tDESkey.Mode = CipherMode.ECB;
tDESkey.Padding = PaddingMode.PKCS7;
try
{
// Encrypt the "creditcard" element.
// Common.Encrypt(xmlDoc, "Config", tDESkey);
//Console.WriteLine("Encrypted XML:");
//Console.WriteLine(xmlDoc.OuterXml);
//xmlDoc.Save(filePath);
Common.Decrypt(xmlDoc, tDESkey);
Console.WriteLine("Decrypted XML:");
Console.WriteLine(xmlDoc.OuterXml);
//xmlDoc.Save(mFilePath); //读XML文件
}
catch (Exception err)
{
//Console.WriteLine(e.Message);
}
finally
{
tDESkey.Clear();
}
return xmlDoc;
}
//加密XML
public static bool WriteFileXML(string mFilePath)
{
bool success = true;
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.PreserveWhitespace = true;
xmlDoc.Load(mFilePath);
}
catch (Exception err)
{
success = false;
return false;
}
2021-05-13
ZedGraphDemo.zip
样例代码j包括实时曲线图,多种线性图集中显示以及柱形图、饼形图、线形图等使用和介绍,并有代码注解,非常适合学习者。
public partial class Form3 : Form
{
Random ran = new Random();
PointPairList list1 = new PointPairList();
PointPairList list2 = new PointPairList();
LineItem myCurve;
public Form3()
{
InitializeComponent();
}
private void Form3_Load(object sender, EventArgs e)
{
this.zedGraphControl1.GraphPane.Title.Text = "动态折线图";
this.zedGraphControl1.GraphPane.XAxis.Title.Text = "时间";
this.zedGraphControl1.GraphPane.YAxis.Title.Text = "数量";
this.zedGraphControl1.GraphPane.XAxis.Type = ZedGraph.AxisType.DateAsOrdinal;
//开始的时候是空的,随着时间的推移才逐渐画满,可以在初始化的时候填几个Y坐标为0的点
for (int i = 0; i <= 1; i++)
{
double x = (double)new XDate(DateTime.Now.AddSeconds(-(100 - i)));
double y = 0; // ran.NextDouble();
list1.Add(x, y);
list2.Add(x, y+20);
}
DateTime dt = DateTime.Now;
myCurve = zedGraphControl1.GraphPane.AddCurve("电压1", list1, Color.DarkGreen, SymbolType.None);
zedGraphControl1.GraphPane.AddCurve("电压2", list2, Color.Red, SymbolType.None);
this.zedGraphControl1.AxisChange();
this.zedGraphControl1.Refresh();
}
private void timer1_Tick(object sender, EventArgs e)
{
//折线图内显示指定数量的点
if (list1.Count >= 100)
{
list1.RemoveAt(0);
}
if (list2.Count >= 100)
{
list2.RemoveAt(0);
}
zedGraphControl1.GraphPane.XAxis.Scale.MaxAuto = true;
double x = (double)new XDate(DateTime.Now);
double y = ran.Next(100, 120);
double y2 = ran.Next(90, 150);
// int RandKey = ran.Next(100, 999);
list1.Add(x, y);
2021-05-13
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人