service in c# to connect to sql , [closed] - c#

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I have a database, and I need to write in c# a script to execute some statements and save the result of these statements to another database, and each statement has a condition like run daily or weekly.
Then I need to save this script like a service in the window server to run it automatically.
so 1 service, for many statements, and each statement has condition inside the service.
any suggestions, or examples for this scenario?
thank you

There are multiple options:
Write your code in a console application and convert it to a windows server. If you write the code perfectly and create some timer or or function to handle the jobs they whould be run exactly at the desired time. Manual here
Using windows task scheduler for each job and create a scheduler for them. For example if you have 3 jobs (hourly,daily and weekly) you can create three separated console application and create 3 scheduled jobs in windows task scheduler. Here you have a log of last execution time, the result, the erorr etc... More info here

Related

ASP.NET Routine to make a Select everyday at midnight [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 4 years ago.
Improve this question
So, I'm creating a system in ASP.NET using SQL Server that sends email notification to people about their expiring documents. The user inputs the date of the document and it will warn the user about it's due time 5 days before.
I thought about creating some routine that runs everyday at midnight and (SELECT *) comparing the actual date and the due date. Should I create a Stored Procedure on SQL? Or something in my .CS file that runs with Microsoft Task Scheduler?
As far as I can see it, you don't need an ASP.NET app for this. You can simply have a SQL job running on your SQL Server that runs at midnight, runs your SP (stored procedure) which sends the appropriate email as required. SQL Server has facilities to send emails via SMTP.
If however you want to create something more sophisticated in ASP.NET I would definitely look into using Hangfire, which allows you to have jobs running in background in an ASP.NET application (or not). Hangfire can handle pretty complex job scenarios, have a look here: http://hangfire.io

Alternative way for Background Process [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've created a simple application in C# which purpose is to have a Windows Service running on Background in the whole time the computer is alive and which I know is a non-GUI process.
I want the Service to execute some command like, programmatically lock the computer, send data to one of my Windows Form Application, show Windows Form Application etc. which will not work because it is Windows Service. I found it really hard for me to work with this.
Now, my question is, is there any alternative way for what I want to achieve?
I mean other solution for running background process in the whole time and do the GUI job?
I am really out of ideas, anyone can suggest/help will be very appreciated!
You can always write a winforms application that will run a background thread listening for commands and executing tasks. Then all you need to do is register this executable to be started when a session is started. The application could be minimized to the tray so that the user could still manipulate it.

How can I make my application run faster [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I'm building a windows forms application, and I'm processing a huge database, so I have to use many loops to work with my tables.
I'm using C# language, the problem is when the program process data the application lag during the processing and the time require to process my data is not acceptable.
Well if you are using C# language,
First to prevent the lag issue; use a Task:
Task task = Task.Factory.StartNew(() =>
{
//put your code here
});
and for loops you can use Parallel class it has for and foreach.
if you need to modify something in the GUI you can use the following code:
this.Invoke((MethodInvoker)delegate
{
//your code
});
and there are other ways by creating threads or backgroud workers...
Try to process your Data in Sql server using stored procedure, views.
Try to use multithreading.
get your data filterd and paged from data base.
Optimize your tables using indexes.

asp.net c# website form actions after 24 hrs [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have an asp.net c# website which members complete a form which is stored in sql server. After 24 hrs, I would like to send a notification to a specific group of users if the form status has NOT changed. Is this achievable from within asp.net?? Any help is appreciated
I have done it several times and there are many ways to do it. One simple way is to check every X minutes if you need to send any notifications. If so, you send them.
For example: every 60 minutes you check if there are any forms that have been on the same status for 24hs. If so, you send a notification.
If you have full control of the server, I would recommend you to create a Windows Service to perform this job. ASP.NET was not built for long running tasks so that's why I'm suggesting to create a Windows Service.
One more thing, create a log table for this task so every time you send a notification, you add a row on that table. That's gonna help you debug any issues you might have. Also, remember to mark the rows where you have already notified the customer to avoid sending a notification twice. I always like to add a double check before sending the notification.

asp.net MVC automatic sending mail every day (without windows service) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I am searching for the best way to create a automatic mail system which fires every day (e.g. 00:00:00) and sends a list of mails.
Which is the best option to perform this task without slow down my application or harm to the server.
I don't want to use windows service to achieve this task. because i am using a shared windows hosting and they don't allow me to run it on the server
Thank you.
Which database do you use ? If its MS Sql Server You can use
THE sp_send_dbmail as a part of a stored procedure to send email.
http://technet.microsoft.com/en-us/library/ms190307.aspx
You can then set up the stored procedure as a Sql Server Agent job to run at regular intervals as shown below
http://www.c-sharpcorner.com/UploadFile/raj1979/create-and-schedule-a-job-in-sql-server-2008/
You could put WCF service with Quartz.NET http://quartznet.sourceforge.net/ aboard on the same IIS or on another machine.
This approach also allows you to have API to control your scheduler.
Regrads.

Categories