Using system;
Using system. collections;
Using system. componentmodel;
Using system. Data;
Using system. drawing;
Using system. Web;
Using system. Web. sessionstate;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. htmlcontrols;
Using henwry. model;
Using henwry. BLL;
Using system. configuration;
Using system. xml;
Public void read ()
{
String filename = server. mappath ("../") + @ "Web. config ";
Xmldocument xmldoc = new xmldocument ();
Xmldoc. Load (filename );
Xmlnodelist topm = xmldoc. documentelement. childnodes;
Foreach (xmlelement element in topm)
{
If (element. Name = "etettings ")
{
Xmlnodelist node = element. childnodes;
If (node. Count> 0)
{
Foreach (xmlelement El in node)
{
Switch (El. attributes ["key"]. value)
{
Case "day ":
This.txt day. Text = El. attributes ["value"]. value;
Break;
Case "Hour ":
This.txt hour. Text = El. attributes ["value"]. value;
Break;
Case "min ":
This.txt Mim. Text = El. attributes ["value"]. value;
Break;
}
}
}
}
}
}
Public void write ()
{
String filename = server. mappath ("../") + @ "Web. config ";
Xmldocument xmldoc = new xmldocument ();
Xmldoc. Load (filename );
Xmlnodelist topm = xmldoc. documentelement. childnodes;
Foreach (xmlelement element in topm)
{
If (element. Name = "etettings ")
{
Xmlnodelist node = element. childnodes;
If (node. Count> 0)
{
Foreach (xmlelement El in node)
{
Switch (El. attributes ["key"]. value)
{
Case "day ":
El. attributes ["value"]. value = this.txt day. text;
Break;
Case "Hour ":
El. attributes ["value"]. Value implements this.txt hour. text;
Break;
Case "min ":
El. attributes ["value"]. Value implements this.txt Mim. text;
Break;
}
}
}
}
}
Xmldoc. Save (filename );
}
Public void resert ()
{
String filename = server. mappath ("../") + @ "Web. config ";
Xmldocument xmldoc = new xmldocument ();
Xmldoc. Load (filename );
Xmlnodelist topm = xmldoc. documentelement. childnodes;
Foreach (xmlelement element in topm)
{
If (element. Name = "etettings ")
{
Xmlnodelist node = element. childnodes;
If (node. Count> 0)
{
Foreach (xmlelement El in node)
{
Switch (El. attributes ["key"]. value)
{
Case "day ":
El. attributes ["value"]. value = "0 ";
Break;
Case "Hour ":
El. attributes ["value"]. value = "6 ";
Break;
Case "min ":
El. attributes ["value"]. value = "10 ";
Break;
}
}
}
}
}
Xmldoc. Save (filename );
}
Public static string gettime ()
{
String day = "";
String hour = "";
String min = "";
Page dd = new page ();
String filename = dd. server. mappath ("/") + @ "Web. config ";
Xmldocument xmldoc = new xmldocument ();
Xmldoc. Load (filename );
Xmlnodelist topm = xmldoc. documentelement. childnodes;
Foreach (xmlelement element in topm)
{
If (element. Name = "etettings ")
{
Xmlnodelist node = element. childnodes;
If (node. Count> 0)
{
Foreach (xmlelement El in node)
{
Switch (El. attributes ["key"]. value)
{
Case "day ":
Day = El. attributes ["value"]. value;
Break;
Case "Hour ":
Hour = El. attributes ["value"]. value;
Break;
Case "min ":
Min = El. attributes ["value"]. value;
Break;
}
}
}
}
}
String
Nowtime = datetime. now. adddays (Int. parse ("-" + day )). addhours (Int. parse ("-" + hour )). addminutes (Int. parse ("-" + min )). tostring ();
Return nowtime;
}
//
Web. config
<Deleetask>
<Add key = "day" value = "0"/>
<Add key = "Hour" value = "6"/>
<Add key = "min" value = "10"/>
</Appsettings>