I need to write something for listen data for devices like gps and other device that can send every X seconds me data
And I will can to add device to my database from web site / (via wcf service)
Now I want after I added new device to database I want to start get from device data.
I dont want to do it in wcf service - so I want top write a little program only for get data.
What is better way for get data in background ?
Also I will need sent "push notification" from WCF to this program - for add new device to list
So what is better way ? windows service / console/wpf programm / asp.net ??
Sorry for English grammar
You can use either windows service or console application. I will suggest you to develop console application and configure it as schedule task. Schedule task is allow you to define task job to execute the console application.
Some advantages using console application over windows service:
Easy to debug/truobleshoot.
Easy to develop and configure.
No need to learn how to write Windows service.
Don't require extra permissions.
Related
I need to develop a web application in asp.net and C# that sends emails and SMS. I already have a console version of this app that i created a few years back but it relies on a windows scheduled task, and is outdated.
What is the proper or best way to do this using asp.net, considering that i'll have other applications that will feed a database with the information to send. How can i setup a background service that will monitor this database and send the messages even if there are no pages open?
Thanks.
We use Topshelf to run as a windows service and Quarts to schedule/manage the recurring job/function calls. Hangfire was another solution that looked interesting.
Hangfire
An easy way to perform background processing in .NET and .NET Core applications. No Windows Service or separate process required.
https://www.hangfire.io/
Background -
I am working on a Windows Phone RSS reader app (using C#). In addition to just reading RSS content, the app does some scraping on the articles linked by the feeds to get additional info. This is turning out to be too resource/bandwidth intensive to be done on the client and I am thinking of moving the RSS aggregation and scraping logic to the cloud.
I want to use Azure mobile services. In my simple design, I want to have-
(1) an Azure DB, which stores all the RSS data including the scraped content.
(2) Front end service which clients can call to get this data
(3) A scheduled task in the cloud that keeps the DB up to date with the latest RSS content. The processing here will be heavy weight since it will scrape thousands of webpages, process them to get additional information, and then update the DB.
* Actual question *
My question is regarding (3). I already have C# code that does this on the client and I want to be able to reuse it in developing the scheduled task in the service. I read the Azure mobile services documentation. What they seem to have is a scheduled job which runs javascript. I don't want to use java script and would prefer to reuse my C# code. What is a recommended (and non-hacky) way for me to do that?
You can use Windows Azure WebJobs:
http://www.windowsazure.com/en-us/documentation/articles/web-sites-create-web-jobs/
Just create a new (empty) website in Windows Azure, go to the "WEB JOBS" tab and add a new WebJob.
There you can upload your .NET console application which has all your logic (zipped), set a schedule according to your needs and you can use the web sites connection string setting (under the "CONFIGURE" tab) to set your connection string.
As of today, there isn't any option to run anything but javascript from your Mobile Service. HOWEVER, if you already have the C# code to perform #3, I would recommend wrapping that in a very light weight Web Service (Web API, etc). You can host this from Windows Azure Websites. You can then use the Windows Azure Scheduler to schedule a ping of that service which will kick off your job. You could use the Mobile Services scheduler to ping it as well but using the WA Scheduler would be even easier.
I'm working on a net based POS system and need to enable silent printing.
(Print without displaying the PrintDialog).
I have managed to get it working but at times when cashiers want to generate new vouchers it does not print and this is becoming a problem.
I have been instructed to create a Windows Forms app that will be installed on all of my cashiers machines, what this app needs to do is once the cashiers log onto the website and sells a voucher i need data to be sent from my ASP.NET website to the Windows form application where the silent print can take place, so as soon as the cashiers clicks on the 'Sell Voucher' button the data must be sent to the installed windows app and print automatically.
The data that will be sent to the cashiers machines is basic info like Cashier Name, Account Name, Site...etc
How would i go about achieving this result?
Thank you in advance.
The two apps will probably need to share a single data source (e.g. using SQL Server).
If the printing needs to happen silently, without user intervention, then you will need to implement a listener (typically as a Windows Service) that waits for new items to be added and are ready to print.
See: Publish-subscribe pattern or, alternatively, Observer Pattern.
Look into WCF or signalr.net
for signalR there is a .net client for easy implementation into a windows app
I'm developing a Windows Service in C#. One of my requirements is to get some user input: to present some options and let them select one; based on their choice, the service should perform an associated operation. Is it possible to get user input in a Windows Service, with C#?
No, a Windows Service is not designed for that. You would need to use a desktop or web application. If there is a good reason to use a service, you would need to create an application and have it send or communicate the input to the service.
I would write a separate application that manages the options in a database, a user can update this database in which the service also connects to, depending on these values the service should act accordingly
No, it's not possible. You should create another windows app (for example winforms or WPF) and communicate with service and send user input. You can do communication via WCF.
You can use ServiceBroker to Queue Userinput messages and dump the result in another Queue against the UserId or unique user key.
Like others have said this is not possible. A Windows service, as the name implies is a Service. If you want to send data to a Windows Service, you can either do so through the ServiceController Class (from another application) or if you're feeling particularly adventurous though WCF.
Why are you developing this as a service?
Yes, It is possible to get inputs from mouse and keyboard from windows service. This does not mean that, we can directly interact with the windows service. Service code can read the last keyboard input and mouse position and other events. for example, service can read the current mouse position using Cursor.Position property.
I am new to WCF and i am designing a project in which i want to run a crawler program (coded in c#) which crawlers some websites and it stores the crawled data in the tables of database (sql server db). I want that crawler runs repeatedly after 30 minutes and updated the database.
I want to then use the service on my hosted platform so that i can use the data from tables in web form (i.e. .aspx page)
Is it okay to use WCF for this purpose ?
Please suggest me how to move on ?
Thanks
Windows Communication Foundation (WCF) is responsible for communication between 2 points with different channel technology. you will use WCF if you want to send/receive some data between two point regardless channel technology (TCP/UDP/NetPipe/MSMQ , ...)
But you first need to design you crawler application which is configured to fetch data from your target web sites, then you need to design a schedular application using
http://quartznet.sourceforge.net/
to run your crawlers.
after running and storing your web pages you can use WCF if you need to do replication or synchronization with center server but it is optional
You could use a WCF service to do this but I would go for another setup:
I'd build a Windows application that is scheduled to run every 30 minutes by the Windows Task Scheduler. A simple console application might be fine.
I'd use a Web application (possibly ASP MVC) to query the database.
As you can see there is no need to use WCF at all.
An exception can/must be made when the server is not yours but you are using a hosting provider who doesn't allow you to schedule a Windows task. In that case you might want to run the crawling process by hand through the web application and have it repeat itself after 30 minutes.
Some hosting providers do allow the scheduling of tasks but in a different way so it might be worth to investigate.