[英]Asp.net: using Console application call Web-form application's method
我正在尝试将Web窗体asp.net应用程序添加到Windows服务。 我在那里有一个控制台应用程序教程,用于转换exe文件,然后将其用作Windows服务。 那是在Windows的开始运行,然后继续。 我需要将Web表单(使用ASPX,CS文件)页面转换为服务,以便在Windows启动时运行。 或通过计时器使用任何方式制作网页表单页面的工作,
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会更好。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.