Hi everybody
I am trying to show remainder to user who logged in the site.Whatever task he have to do is just shown in the alert box or popup window in a particular time.I used atlas timercontrol.The coding is
<form id="form1" runat="server">
<input type='text' id='myText' runat="server" visible="false" />
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>s</asp:ListItem>
<asp:ListItem>g</asp:ListItem>
</asp:DropDownList>
<cc1:ScriptManager ID="ScriptManager1" runat="server">
</cc1:ScriptManager>
</div>
<cc2:TimerControl ID="TimerControl1" runat="server" Interval="1000" OnTick="TimerControl1_Tick">
</cc2:TimerControl>
</form>
protected void TimerControl1_Tick(object sender, EventArgs e)
{
string qry = "select * from Task_det where alertstatus='y'";
DataSet ds = new DataSet();
ds = Newway.getTable(qry);
if (ds.Tables[0].Rows.Count != 0)
{
if (DateTime.Parse(ds.Tables[0].Rows[0]["AlertDt"].ToString()) == DateTime.Parse(System.DateTime.Now.Date.ToString()))
{
if (DateTime.Parse(ds.Tables[0].Rows[0]["AlertTime"].ToString()).Hour == DateTime.Parse(System.DateTime.Now.TimeOfDay.ToString()).Hour)
{
if (DateTime.Parse(ds.Tables[0].Rows[0]["AlertTime"].ToString()).Minute == DateTime.Parse(System.DateTime.Now.TimeOfDay.ToString()).Minute)
{
TimerControl1.Enabled = true;
// Response.Write("<script language='javascript'>alert('hai');</script>");
myText.Value = "Task:" + ds.Tables[0].Rows[0]["TaskTitle"].ToString();
//Response.Write("<script language='javascript'>var myTextField = document.getElementById('myText');alert(myTextField .value);</script>");
Response.Write("<script language='javascript'>window.open('showtask.aspx?Task="+ ds.Tables[0].Rows[0]["TaskTitle"].ToString().Trim() + "','REMAINDER','height=100,width=200');</script>");
TimerControl1.Interval = 60000;
}
else
{
TimerControl1.Interval = 30000;
}
}
}
}
Here i want to hide this page from the user timercontrol will start checking after the login process.But it should be behind the screen.Only alert popupwindow (showtask.aspx) is shown in particular.Is there any alternative sollution or extend this code..Please help.
Thanks& Regards
Jhanani.R
Hi Jhanani,
What do you mean by hiding the page from the user?
I can't get your point very well.
Looking forward to your reply.
Hello,
What you can do is, use WebService. For example, the user logs in and goes straight to mypage.aspx; once he/she is at the page, you can have a javascript function running behind the background; the function checks the webservice, which check the database to see if the user has any remainder (task), if the webservice returns true (meaning there are remainders (tasks)), then cancel the loop and use window.open to open showtasks.aspx page of yours. If there's none, then continue looping and checking every 20 seconds or so.
I would use SetTimeOut, don't use for loop or while loop, or any loop... =)
I mean to say i dont want a separate page for clock tick it will be common for all the pages am using in project.Any pages i can navigate but the clock should
tick and check the matching time and give alert.I have completed this using atlas control.But my friends are suggesting to do it with thread and log file.log file to hold the clock tick time.
Do u have any idea please tell
Jhanani
So here is your situation:
You have a page will continualy check if there is an event for the current user, if so, a remider will show. And you intend to hide this page from the user because it actually doesn't have any visual component.
I think you can use amaster page. It works as the template of all pages in your application.
Move the code above into it so that all pages will have this function.
JananiSharma:
my friends are suggesting to do it with thread and log file.log file to hold the clock tick time.
The customer will use a browser to visit your application, but you can't start a thread on the client via the customer's browser. If you application is windows based, it's a good idea, but not for a web based application.
ya i used atlas timer control in master page and call alert popup if event occurs in the particular time.But my team leader asked me to try in windows service.Is it possible
Yes, it's a feasible solution.
You can start a thread in the windows service to monitor if there is any reminder to show. But it's necessory to install the windows service on each machine.
Will you give one example.
And in timer control when it shows alert message that time the page which is running get changes in styles .For me font size is changing when the alert message appears.But for the next clock tick it again come to previous state.Please tell me solution for this.
Thanks&Regards,
Jhanani.R
Please follow this tutorial for how to create a windows service: http://msdn2.microsoft.com/en-us/library/aa984464(VS.71).aspx
Also note that now your application isn't a web/browser based application, you are doing windows programming now.
For more information about Windows service, please read this: http://msdn2.microsoft.com/en-us/library/d56de412(VS.80).aspx
Raymond,
If the poster uses a windows service to track the tasks from the database, how does the windows service communicate with the user(s) from the web app? Does the web app have to start the communcation with the windows service first?
I am asking because I don't know; and also i have a feeling that using windows service will create more works. May be the poster (forgot what the name is) should talk with the team leader again.
And installing the service on each system is not a good idea either. What if it's a public system? Plus, you need to program to when the windows service should run and when it should not. This is when you need to use ActiveX. Or is there an easier way, or am I over thinking? I just give my opinion so that the poster should not use windows service if i'm correct ...
Raymond, clear me up if i'm talking nonsense, thanks ... =)
WishStar99:
Raymond,
If the poster uses a windows service to track the tasks from the database, how does the windows service communicate with the user(s) from the web app? Does the web app have to start the communcation with the windows service first?
I am asking because I don't know; and also i have a feeling that using windows service will create more works. May be the poster (forgot what the name is) should talk with the team leader again.
And installing the service on each system is not a good idea either. What if it's a public system? Plus, you need to program to when the windows service should run and when it should not. This is when you need to use ActiveX. Or is there an easier way, or am I over thinking? I just give my opinion so that the poster should not use windows service if i'm correct ...
Raymond, clear me up if i'm talking nonsense, thanks ... =)
Hi,
Yes, as you've mentioned, those problems do exist.
To implement the reminder with Timer on the web page is a solution, but not good enough. The thing is that if I want to receive reminder, I have to keep the browser open. While windows service can keep running without any UI.
For the windows service here, it doesn't need to communicate with the web app. It's a separate application.
Sorry i forgot to say that am developing project in web application.I want to know timer control in windows service.Thats y i asked.Will you please tell y the styles are changing after the alert message
Thanks& Regards,
Jhanani.R
Sorry i forgot to say that am doing project in web application.But i wanna know the windows service .Thats y i asked.Please tell y font changes during alert message.
Thanks&Regards,
Jhanani.R
Raymond,
I know it's a seperate application. My concern is, how does the user from the web application knows that there's a new task for him or her? Does the web app page have to communicate with the windows service somehow? Here's what I understand so far:
You have a windows service timer which detects if there's any tasks for a certain user or not, if yes, then what will happen? How does the windows service notify the user from the web application?
Raymond, again, i'm not debating with you, but i want to know so i can learn from it =) thanks ....
Okay, forget it ... i'll leave you alone. LOL.
I'll check back when the problem is solved.
JananiSharma ... let us know what's the solution is ... thanks ...
No comments:
Post a Comment