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.
Related
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.
We have a ssis pkg that takes 20 mins to complete. (generates a xl report). Users had requested ability to control this pkg via params so we have winforms/c# gui that runs the pkg. (Direct from sql server. We basically call a stored proc that starts a sql job that runs the ssis pkg). So far so good. Now users want to log off after submitting the report request since it does not make sense to wait for 20 mins. (we use citrix vdi. Users loginto specific vdi depending on the apps they want to use, do their tasks and logoff). We are 90% there and just for this functionality service broker seems to be an overkill. I checked with our dba and we have never used service broker till now. Is there someway I can get the ssis pkg to run even if the user closed the winforms app and logged off. (basically sql connection is lost but the fired ssis pkg on sql server must continue to run to completion). thanks
we can do like this add package in job call proc and leave it will run
CREATE proc startjob
AS
begin
EXEC dbo.sp_start_job N'Weekly Sales Data Backup'
END
I'm working on program which rergisters and processes service calls. I'm working in asp.net c# and my data base is on SqL Server. Each call has a status, at first 'NEW' and when work has started on it becomes 'UNDER CARE' and when work is finished 'CLOSED'. After the day is finished in the middle of the night when the application is not running, I want an automatic summing up to be made of the number of calls of the different types of status. How can this be done thru the application or thru the server or any other way even though the application isn't running?
What you described is a SQL Server Agent job scheduled to run at midnight.
I am building an ASP.Net website, I have a db table which I want to reset a column in it for all rows. column type: byte
I want to do this every day at midnight, in an automatically way. I know I can set a job in SQL Server Management Studio but I want to do this in a programmatic way and my website will be the trigger for it.
I'm using C#.Net 2008 and MS SQL Server 2005
i.e. (Pseudo code)
if(new_day)// can we be accurate that time here will be around 12:00:05 at maximum?
// call sql stored procedure to reset that column
You could make a simple Windows service in C# that would run in the background but considering all you want to do is make database updates, it's best to keep it in the DB....I'd suggest going with the scheduled job in SQL
Your website only executes when a page is requested making it unable to act as a service that executes a task at regular intervals. The best solution is to use SQL Server directly to schedule the task, create your own service or execute an application at regular intervals using Windows task scheduler.
However, if you for are in hosted environment you may not be able to do any of this. In that case you can use the cache to simulate a service. Omar Al Zabir has an article on CodeProject that explains how you can do that: Simulate a Windows Service using ASP.NET to run scheduled jobs.
If you really want to: create a Scheduled Task that calls your website every day at midnight. The website itself cannot trigger itself, but a task can do this.
But really: just set up a SQL job.
SQL Agent job, scheduled to run at the specified time.
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.