Adding a Schedule Task Module for WPF Window Application - c#

I have a small program which converts doc file from specified folder to pdf and XPS format using the printer driver available in the local PC.
Now I need to add a scheduler to this program which runs as per scheduled by the user taking parameters like folder_where_doc_files, Destination_Folder, Date_Time to schedule, whether daily, etc, etc.. in the background.
It's a WPF C# window application. The user is requesting to use the command line to schedule the task.
I am unable to analyze how to proceed further.
I checked a few links where "schtaks" command can be used to create a task. How to send my desired parameters to it.
even if I do then my application will start in the background. How to initiate a conversion process like any events on form load, etc, etc..
I am really confused, Please clarify this confusion

One of the possible design would be
1- Create a console application which takes input from the user and store it either locally or on the server
2- Create a windows service that will check through your storage (Local/Server) periodically for the next run.
3- After each run save the last run time in local / server to calculate the next schedule.
The scheduled task requires a user/pwd to be stored in the scheduled task itself and needs to be updated each time the user changes the system password.

Related

How can I run windows service to schedule a job which will pick time from database to execute?

I have created a process for sending email which will send the email automatically at a specific time using windows services and time is fixed in code. But I want this process to take the time from database. Is it possible??
I had tried to make the window service take time from database but didn't find anything for this. Now I want to make this window service to connect with ms sql and take the time from table in database.
Perhaps you can set up your service to always run and read the time from the database at startup, then trigger an event at the scheduled time and get the job done.

Looking to run automated jobs in .NET application

Within a .NET application (.NET Framework 4.5), the following is occurring:
A single record in a table in an SQL Server database is referred to as a job
When the job is run, C# code is called
Briefly to explain what it is doing, the job, when run, converts PDFs in a folder directory location, to images in SQL Server
Currently, these jobs run successfully, when the user manually runs them
Does anyone have a recommendation on how these jobs may be run as automated, and not require user intervention? I'm trying to find a process similar to the following:
A daily process will look for all jobs that have a 'next run date' of the current date (the 'next run date' will be stored in a table/column in SQL Server)
When a job is run, the C# code is to be called and run, without user intervention
If you can insert the first part of your requirement (to look for all jobs that have a 'next run date' of the current date (the 'next run date' will be stored in a table/column in SQL Server)) in the C# application that is already executed manually then you only need a Task Scheduler to Execute this C# Application on a daily basis.
you basically need to set up a CRON job. If your "job" can operate on a URL, you could use a service like "easycron.com" to set up a call to this URL at regular intervals.
Alternatively, the same thing might be possible with your hosting if they allow CRON jobs to be set up.
If this isn't a web-facing app - maybe a scheduled task calling the app (if it is a console based EXE) directly on the server. You'll obviously need access to the server at an admin level for that.

Create a windows like screen saver to open an application

I want to open an url in a browser after no activity in windows , and that using windows services
Any idea how that will be in c#
You would need thread that checks for activity, Make a class with a method in it, Make a timespan that checks time since the last key was pressed and use an if statement to launch a browser if the time passes a certain amount.

File System watcher in Windows Service or Console Application?

I am implementing a file system watcher, my requirement is to watch for a given local folder on a machine and then do a small task (for example open a certain page in web browser). The file(s) in the given directory would be generated randomly sometimes every two hours or four etc. This tool should be automated in the sense that a user does not have to start it. So my question is, Should I implement this in a windows service which always will be running or in a console application.Preference is to do it in a console application but then it would need to started by a user right? Please advice
You can automatically call any type of application (Console, Windows, etc.). What it gets down to with a Windows Service is whether you want it to be running before anyone logs in.
Only a Windows service runs while no one is logged in. A console application (while it can be set to run on login) must have someone log in in order to run.

SharePoint Timer Job not working properly when run on schedule but fine when running manually

I've got a SharePoint timer job that takes a document library and puts the documents, converts them to PDF and puts them into a SQL server every night. Problem is, the timer job doesn't seem to work when it's called on the schedule. If I install it and then using a little console app I wrote, call execute on the job it works properly. When it runs on schedule it doesn't.
The reasons I know the job is running:
The timer job status says that it completed at ~12 minutes past midnight (starts on midnight)
The target database table has been truncated (the job is ment to do this before an export)
The reasons I know something is wrong:
The database is empty and contains no documents. Running it manually fills it with documents
The very first line of code should output to the event log but it doesn't do this once. Running the job manually logs correctly several times. Another timer job to test writing to the log works correctly on this server.
Now I was thinking it's something weird to do with permissions when running under owstimer opposed to a console app. But the fact is, first thing it does is log to the windows event log and this isn't happening but in a timer job that only does this, it does work. And the truncate code is being hit which is after the event logging which doesn't seem to happen.
When you run the job via the console app, it is running in the security context of your user.
When the job is run via the timer it is running in the security context of the user running that process.
Check which user is running the timer job, check the rights of that user.
There should be an error in the event log or the sharepoint log files.

Categories

Resources