If the C# server is offline then Windows Service will storage the data in SQLite and when the server is back online it will process the data. I can use a trimmer to check the server is online in every 5-10 sec. I wonder is there any better approach to deal with this kind of scenario?
The right solution for scheduling simple processes is the Windows Task Scheduler.
If you're writing a Windows Service that runs a timer, you should re-evaluate your solution. ..
–Jon Galloway, ASP.NET MVC community program manager, author, part time superhero
//TODONT: Use a Windows Service just to run a scheduled process
I stumbled with a legacy application in C# that creates an item, saves it, fetches the creation date and deletes it right after, using ExchangeService api. All this to simply get the current server time.
There's gotta be a better way of doing this, but I went through all the online docs and did a few searches about it and couldn't find anything.
So, simple question: how to fetch Exchange server current datetime using C#?
Thanks in advance.
Where is the application running ? eg if its running on the server or any domain connected machine then querying the time from the Exchange server should be redundant. Eg Windows servers within a Domain should sync there time via Windows time service https://learn.microsoft.com/en-us/windows-server/networking/windows-time-service/how-the-windows-time-service-works. And usually you would setup a DC to sync the time from NTP so every machine should have same time (in theory).
The Exchange API's don't have an time methods but any request to an Exchange server should return the Date Header in the Response headers as it a mandatory property in Http https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18
I have a Azure process that stores some .png files in Azure File storage or Blob storage every 2 hrs. I want to create a service which will run from my machine and pull the latest files every 2 hrs . Please suggest if we can do this by Windows service or if there is any other better solution to Automate this.
Please suggest if we can do this by Windows service or if there is any
other better solution to Automate this.
Yes, you could do it with windows service ,this is the official doc, it also shows how to add Timer Event then you could handle Azure-Storage like normal program.
Or you could choose to use console app, this also could satisfy your requirement. You could use a Timer to handle Azure-Storage , however you need to keep this app running all the time.
If you still have questions, please let me know.
Users will be able to configure the printer/scanner on a web application.
So I've a windows service running on client machine that communicate to cloud db through API and get the printer/scanner details and configure them accordingly in local network.
The service is configured to run every 30 minutes. So when a user modifies a printer/scanner property using the web application, the update will be available in client machine only after windows service run once. So the maximum time delay will be 30 minutes as the windows service is configure to run every 30 minutes.
Windows service cannot invoke API frequently as there will be too much load on the web server and also the update doesn't happen often but when it happens, customer expects their local network printer/scanner to be updated immediately with new configuration.
So, the question here is how effectively I could update the cloud data to the local service so that they will be in sync as soon as possible.
Please share if there is any other way to achieve this.
I've heard about message queue/clickone but I am not sure how it could suit here
I want to develop an Online Reminder service in ASP.NET 2.0 (C#) and SQL2005. But I am not getting the concept of reminder service. What I know is using an online reminder service I can schedule a reminder for future dates, which is sent to me (who schedule reminder) via email or SMS on that date. But in asp.net how to do this, caz anyone can schedule a reminder for any date, how we'll know that when to send that mail to the person. We have to put some loop or what.
So please guide me, what is the concept of an online reminder service and how I can easily develop this application using ASP.NET and SQL
Edited
I am on Shared hosting server, so that solution must be able to work on shared hosting.
Or
Please tell me if anyone knows about any FREE and open-source reminder service CMS which I can download and study it.
Microsoft SQL Server 2005 have scheduling (sql jobs) and email features. You may even donot need to use ASP.NET.
Ideally, you would have a windows service that would periodically (every few minutes) check if any new reminders need to be sent out. Since you are on shared hosting, you probably can't install a service though.
I'm not very familiar with windows shared hosting, but if you have the option of creating scheduled/cron job type tasks you could probably do it that way.
If you can't create a scheduled task on your server, another option would be to create a scheduled task on your home PC with a program/script that runs every few minutes and simply hits a special web page on your site. That page could then have the code that checks for reminders and sends them out. It's a bit of a hack, but it should work.
Have a look at Quartz.Net (http://quartznet.sourceforge.net/). You can create an instance of the quartz scheduler in your Application_Start event and as long as the ASP.Net application is running, it will poll the database and trigger any functions you have registered with it. Since you are on a shared host environment, this is probably your best bet unless your hosting provider has a scheduler that can trigger a WebForm (or ASP.Net MVC Controller) periodically.
First you will obviously need to create a user interface and database to store the reminders. That part you got. The next step is to create a service which periodically queries the database for reminders that are due for notification.
The best way to do this is to write a lightweight Windows Service which, as you suggest, uses a loop and a reasonable sleep time (so as not to monopolize the CPU) to continually check the database for reminders and dispatches notifications. It then processes each reminder based on your requirements.
But since you are on shared hosting, you can't deploy a Windows Service, so the next best thing is to run a background thread on Application_Start of your global.asax. There are many examples of how to do this, e.g.:
http://www.west-wind.com/WebLog/posts/67557.aspx
What are some best practices for managing background threads in IIS?
Shared hosting will not work well with what you are trying to do. You could create a background polling thread on Application start, but it will get shut down at some point and may actually be prohibited by your hosting company. An infinite loop will most likely be detected by your hoster and result in your account being automatically shut down, especially if it is using a fair bit of CPU. As John suggests, there may be a scheduled tasks or hosted cron option with your ISP, but generally, those are just for doing things like nightly backups, not really having the level of granularity you need.
Simple answer is, you most likely need something other than a hosted account. You may need to look into a VPS shared hosting service or you may wish to consider looking into MS Azure or Amazon EC2. To do this right, you need to create an application, or better, a service that runs constantly, something a shared hosting account will not provide.
There also a few services out there who can call a specific web page on your service periodically. You could use that to make the page check if there are any reminders that need to be sent.
However since you're then relying on an external site you can't control this might not be the ideal solution if it is very important that the reminders are always being sent.
1) Create a database for storing messages, with a datestamp
2) Create an SQL job, that selects all messages in a time period
3) From the SQL job, you can initialize an .net based SQL Function, that would send out the emails with the System.Net.Mail namespace.
You might consider a 'hack' using the Cache expiration in for triggering events. Create new cache keys that expire at specific Date-Times to run the reminder or make it recur at defined intervals, checking a queue to see if anything new should be sent.
See:
Easy Background Tasks in ASPNET