📄 form1.cs
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlServerCe;
using System.Xml;
using System.IO;
using System.IO.Ports;
using Microsoft.Win32;
using System.Diagnostics;
using System.Threading;
namespace DCMAutoSave
{
public partial class DCMAutoSave : Form
{
//DateTime Dateold;
//string strDOCUMENT_ROOT;
const string strversion = "DCM AutoSave\r\nVersion:1.0.4\r\nCopyright 2007 Pentadyne Power Corporation.\r\n All rights reserved.";
DateTime Datenew;
String CodePath;
private string Dbname;
private string XMLname;
private string XMLpathname;
String vpackcontent;
DateTime vpacksavelast;
int vpackdaysave;
int vpacktime;
String fipackcontent;
DateTime fipacksavelast;
int fipackdaysave;
int fipacktime;
String sipackcontent;
DateTime sipacksavelast;
int sipackdaysave;
int sipacktime;
String dipackcontent;
DateTime dipacksavelast;
int dipackdaysave;
int dipacktime;
String aipackcontent;
DateTime aipacksavelast;
int aipackdaysave;
int aipacktime;
String epackcontent;
DateTime epacksavelast;
int epackdaysave;
int epacktime;
String ippackcontent;
DateTime ippacksavelast;
int ippackdaysave;
int ippacktime;
String fpackcontent;
DateTime fpacksavelast;
int fpackdaysave;
int fpacktime;
String spackcontent;
DateTime spacksavelast;
int spackdaysave;
int spacktime;
public DCMAutoSave()
{
InitializeComponent();
}
private void DCMAutoSave_Load(object sender, EventArgs e)
{
try
{
CodePath = System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase;
CodePath = CodePath.Substring(0, CodePath.LastIndexOf(@"\"));
Dbname = "MyDatabase.SDF";
//Dateold = DateTime.Now.Date;//.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString();
XMLname = "DCM_Config.xml";
XMLname = "www\\XML\\" + XMLname;
WriteRegistry();
XMLpathname = CodePath + "\\" + XMLname;
if (!System.IO.File.Exists(XMLpathname))
{
listBox1.Items.Insert(0, "XML file is not exist.");
}
start();
}
catch
{
}
}
/*public void CreatTxt(string pack, DateTime dtdateold, DateTime dtdatenew)
{
string strfile;
string filefull = CodePath + "\\" + dtdateold.Year.ToString() + "-" + dtdateold.Month.ToString() + "-" + dtdateold.Day.ToString() + "-" + dtdatenew.Year.ToString() + "-" + dtdatenew.Month.ToString() + "-" + dtdatenew.Day.ToString() + pack + ".xml";
string filetxt = CodePath + "\\" + dtdateold.Year.ToString() + "-" + dtdateold.Month.ToString() + "-" + dtdateold.Day.ToString() + "-" + dtdatenew.Year.ToString() + "-" + dtdatenew.Month.ToString() + "-" + dtdatenew.Day.ToString() + pack + ".txt";
try
{
FileStream fs = new FileStream(filefull, FileMode.Open, FileAccess.Read);
StreamReader sr = new StreamReader(fs, Encoding.GetEncoding(950));
strfile = sr.ReadToEnd();
fs.Close();
if (strfile.IndexOf("<Table>") == -1)
{
fs.Close();
return;
}
strfile = strfile.Substring(strfile.IndexOf("<Table>\r") + 8, strfile.Length - (strfile.IndexOf("<Table>\r") + 8));
strfile = strfile.Substring(0, strfile.IndexOf("</_") - 1);
strfile = strfile.Replace("\n", "");
strfile = strfile.Insert(0, "\n");
strfile = strfile.Replace("</Table>\r", "\n");
strfile = strfile.Replace("<Table>\r", "");
if (strfile.IndexOf("<Reserved>") != -1)
{
strfile = strfile.Replace("<Reserved>", ",");
strfile = strfile.Replace("</Reserved>\r", "");
strfile = strfile.Insert(0, "Reserved,");
}
if (strfile.IndexOf("<I_cR>") != -1)
{
strfile = strfile.Replace("<I_cR>", ",");
strfile = strfile.Replace("</I_cR>\r", "");
strfile = strfile.Insert(0, "I_cR,");
}
if (strfile.IndexOf("<I_bR>") != -1)
{
strfile = strfile.Replace("<I_bR>", ",");
strfile = strfile.Replace("</I_bR>\r", "");
strfile = strfile.Insert(0, "I_bR,");
}
if (strfile.IndexOf("<I_aR>") != -1)
{
strfile = strfile.Replace("<I_aR>", ",");
strfile = strfile.Replace("</I_aR>\r", "");
strfile = strfile.Insert(0, "I_aR,");
}
if (strfile.IndexOf("<V_extR>") != -1)
{
strfile = strfile.Replace("<V_extR>", ",");
strfile = strfile.Replace("</V_extR>\r", "");
strfile = strfile.Insert(0, "V_extR,");
}
if (strfile.IndexOf("<I_busR>") != -1)
{
strfile = strfile.Replace("<I_busR>", ",");
strfile = strfile.Replace("</I_busR>\r", "");
strfile = strfile.Insert(0, "I_busR,");
}
if (strfile.IndexOf("<V_busR>") != -1)
{
strfile = strfile.Replace("<V_busR>", ",");
strfile = strfile.Replace("</V_busR>\r", "");
strfile = strfile.Insert(0, "V_busR,");
}
if (strfile.IndexOf("<t_bgloop>") != -1)
{
strfile = strfile.Replace("<t_bgloop>", ",");
strfile = strfile.Replace("</t_bgloop>\r", "");
strfile = strfile.Insert(0, "t_bgloop,");
}
if (strfile.IndexOf("<V_reg>") != -1)
{
strfile = strfile.Replace("<V_reg>", ",");
strfile = strfile.Replace("</V_reg>\r", "");
strfile = strfile.Insert(0, "V_reg,");
}
if (strfile.IndexOf("<time>") != -1)
{
strfile = strfile.Replace("<time>", ",");
strfile = strfile.Replace("</time>\r", "");
strfile = strfile.Insert(0, "time,");
}
if (strfile.IndexOf("<t_oper>") != -1)
{
strfile = strfile.Replace("<t_oper>", ",");
strfile = strfile.Replace("</t_oper>\r", "");
strfile = strfile.Insert(0, "t_oper,");
}
if (strfile.IndexOf("<V_miser>") != -1)
{
strfile = strfile.Replace("<V_miser>", ",");
strfile = strfile.Replace("</V_miser>\r", "");
strfile = strfile.Insert(0, "V_miser,");
}
if (strfile.IndexOf("<Offset>") != -1)
{
strfile = strfile.Replace("<Offset>", ",");
strfile = strfile.Replace("</Offset>\r", "");
strfile = strfile.Insert(0, "Offset,");
}
if (strfile.IndexOf("<Runout>") != -1)
{
strfile = strfile.Replace("<Runout>", ",");
strfile = strfile.Replace("</Runout>\r", "");
strfile = strfile.Insert(0, "Runout,");
}
if (strfile.IndexOf("<t_lastdrag>") != -1)
{
strfile = strfile.Replace("<t_lastdrag>", ",");
strfile = strfile.Replace("</t_lastdrag>\r", "");
strfile = strfile.Insert(0, "t_lastdrag,");
}
if (strfile.IndexOf("<P_drag>") != -1)
{
strfile = strfile.Replace("<P_drag>", ",");
strfile = strfile.Replace("</P_drag>\r", "");
strfile = strfile.Insert(0, "P_drag,");
}
if (strfile.IndexOf("<V_ps2>") != -1)
{
strfile = strfile.Replace("<V_ps2>", ",");
strfile = strfile.Replace("</V_ps2>\r", "");
strfile = strfile.Insert(0, "V_ps2,");
}
if (strfile.IndexOf("<V_ps1>") != -1)
{
strfile = strfile.Replace("<V_ps1>", ",");
strfile = strfile.Replace("</V_ps1>\r", "");
strfile = strfile.Insert(0, "V_ps1,");
}
if (strfile.IndexOf("<T_ps2>") != -1)
{
strfile = strfile.Replace("<T_ps2>", ",");
strfile = strfile.Replace("</T_ps2>\r", "");
strfile = strfile.Insert(0, "T_ps2,");
}
if (strfile.IndexOf("<T_ps1>") != -1)
{
strfile = strfile.Replace("<T_ps1>", ",");
strfile = strfile.Replace("</T_ps1>\r", "");
strfile = strfile.Insert(0, "T_ps1,");
}
if (strfile.IndexOf("<T_mlm>") != -1)
{
strfile = strfile.Replace("<T_mlm>", ",");
strfile = strfile.Replace("</T_mlm>\r", "");
strfile = strfile.Insert(0, "T_mlm,");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -