I am trying to make web form asp.net application to windows service. I got a tutorial there console application used to convert exe file, then it is used as a windows service. That is run in starting of windows and do continue. I need web form (aspx, cs files used) page convert to service what will run in starting of windows. or any way to make cron-job of web form page where used timer,
aspx::
<asp:Timer ID="Timer1" runat="server" Interval="" ontick="Timer1_Tick">
</asp:Timer>
cs::
public void CallMethod()//-------------------3
{
conCondition.GetConnectedConn();//con test from diff class
CopyLocalDir();
InsertAtmLogToDB();
ParsedDataInsert();//
}
protected void Timer1_Tick(object sender, EventArgs e)//Ontick method-------defined in input----2
{
CallMethod();
}
public void getInterval()/// Called in page load-----to call::: Timer1_Tick-----------1
{
string selectTime = "select time from timer";
con.Open();
SqlCommand select = new SqlCommand(selectTime, con);
SqlDataReader sdr = select.ExecuteReader();
int setTime = 0;
if (sdr.Read())
{
setTime = int.Parse(sdr["time"].ToString());
}
con.Close();
Timer1.Interval = setTime;//set time to id(named Timer1) of input field(of aspx file)
}
将逻辑代码解耦到dll,从Web窗体和控制台引用dll会更好。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.