Is there any way to send information from my C# MVC.NET application (that is on a server computer inside a local network) to another PC (in the same network) which has a (fiscal) printer connected in a Serial Port?
My webapp is working ok, and I have a winform app that works ok too. But I cannot connect them.
So I think in sen all the information directly from the web app to the specific IP and COM port.
Is that possible in c#?
Physical hardware are not accessible from web application. You have to create windows services for printing. For the printer it doesn't matter that printer is installed on which port it can be on USB or COM port. If you want to print webpage then simply press Ctrl + P then you get print dialog or you can page.print() javascript method.
Related
currently im developing a UWP Kiosk app. This app needs to print to a PosPrinter (EPSON TM-T20II) which is connected via ehternet to the network, The app runs in another pc connected with wifi to the same network. I have created the app using a DevicePicker class just like this example from Microsoft
PosPrinter c# configuration sample
in this example you open a poppup window that lists all your connected devices and filters the Printer. You can choose it and you will have a connection to that printer. The problem is when im using the app in Kiosk Mode in Windows 10 this windows with all the connected printers will not show up, and then i cannot stablish any connection. I have look into the set-multiple-kios apps option for windows 10, but i dont know how to stablish a path to the class known as DevicePicker to allow his functionality with my Kiosk app.
DevicePickerClass
Multiple-Kiosk-Apps
I have also tried to use PosPrinter.GetDefaultAsync() method to get the Printer directly but it always returns null, i also added the deviceCapabillities in my appxmanifest.xml
So if anyone could provideme with a hint or something i will be very grateful.
I found a solution by using the class FindAllAsync(DeviceClass), this return a collection with all connected devices belonging to that DeviceClass(in my case PosPrinter), after that i just use the Deviceinformation.id to pair the device with my program, like this: Posprinter.FromIdAsync(String deviceId), This way the device picker wont appear, so the Kiosk App will just find the Device and then will pop up a permission asking to Allow the device or not.
I am new to ASP.NET MVC, i have to develop a web page that connects to a fingerprint device using its SDK (C# SDK), captures fingerprint image and display live preview from the device.
This page is working fine if the device is connected to the server that hosts my page.
The problem is when a client opens the web page and connects the device, the code that is written to connect to the device runs on the server so it doesn't detect client devices (Device SDK is installed on the server, so it detect device only if it is connected to the server).
Can i run device code on client side using c#?
You probably won't be able to access the device directly from code running in a web page. Some device manufacturers do make certain APIs available from the web (camera, GPS, etc), but only in a limited fashion. It's highly unlikely that you'd be able to access an arbitrary third-party device from a web site unless it can act as a standard input device (keyboard or mouse) and interact with an input element. For example, if it could fill a text box with a string corresponding to the fingerprint or allow you to take a picture of the fingerprint which could then be uploaded through a file input, then you might be able to use it.
The alternative is writing a secured plugin - Java Applet or ActiveX control - that accesses the device natively and use it to interact via JavaScript with your web page. User's would have to allow the plugin to be loaded and let it have permission to access the device for it to work.
For others who need help: I implemented a custom way to connect to USB devices connected to client workstation from ASP.NET MVC web pages.
Using Web Sockets, you can create your own client desktop application (c#) to connect to the device. This desktop application will be a Server for Web Sockets and then in your web page, you can implement a Web Sockets client to connect to the desktop application.
Client Sample (JavaScript)
<script type="text/javascript">
var ws = new WebSocket("ws://127.0.0.1:8080/service");
ws.onopen = function ()
{
};
</script>
Server Sample
static void Main(string[] args)
{
var wssv = new WebSocketSharp.Server.WebSocketServer(System.Net.IPAddress.Any, 8080);
wssv.KeepClean = true;
wssv.AddWebSocketService<Service>("/service");
wssv.Start();
if (wssv.IsListening)
{
Console.WriteLine("Listening on port {0}, and providing WebSocket services:", wssv.Port);
foreach (var path in wssv.WebSocketServices.Paths)
Console.WriteLine("- {0}", path);
}
Console.WriteLine("\nPress Enter key to stop the server...");
Console.ReadLine();
wssv.Stop();
}
More about Web Sockets in JavaScript: Html 5 Web Sockets.
Also, a good c# Web Socket Library: C# Web Sockets
Silverlight is a plugin available for some browsers that allows you to run .NET (C#) code on the client. It is similar to Adobe Flash or Java Applets. The development is somewhat similar to developing a WPF app.
Things I would be concerned about are whether you can access the device or not due to security restrictions. Also, see tvanfosson's comment on his own answer. It should be relatively simple to throw together a basic "Hello, world!" app to verify if you can talk to your device from Silverlight.
Another concern is that the last Silverlight support may not be top priority for Microsoft, and it has limited support on non Microsoft platforms.
Another technology you might consider is a ClickOnce application.
I have the app for Android and another app for PC, both were written by me. Android app connects to the PC app, and the PC app sends data (in realtime) to the smartphone.
The problem is: if the PC is connected to the mobile wireless network, I can't get its address, so I can't connect my Android app to the PC.
So, is there some simple application (for Windows), that I can use as a server for data forwarding. PC and mobile App will be connected to this server (launched on the station with the static address), and the server will just forward data from one app to another?
Or maybe there are good tutorials for creating such kind of server on C#/Java?
I would use a third pc (a server) that acts as a bridge for Android and PC. I wrote a web service in .NET for a virtual server on the internet. Both Android and PC know the ip address (or the domain name) of the server.
The PC talk to server using .NET native web service call, the Android uses ksoap.
For more infomration about ksoap for android look here:
http://code.google.com/p/ksoap2-android/
EDIT:
I suppose you can have the web server in the pc but you need to configure your modem to forward specific ports to the pc. But if you have no static ip address you need to reconfigure the ip address on Android device everytime your modem is rebooted (or switched off/on). You can also try to use dynamic dns services...
Check this out:
http://whiletrue.blog.com/2013/07/11/smartphone-as-pc-controller/
I've made this with Muzzley. Basically, you already have most of the work done if you integrate with it.
(disclaimer: i work for this project)
On the PC side, you can use the lib to include in you pc app in several languages:
(java) http://www.muzzley.com/documentation/libraries/java.html
(.NET) http://www.muzzley.com/documentation/libraries/dotnet.html
(nodejs) http://www.muzzley.com/documentation/libraries/nodejs.html
On the smartphone side, you can use any of the existent widgets (virtual interfaces):
http://www.muzzley.com/documentation/widgets.html
or eventually make your own:
http://www.muzzley.com/documentation/widgets/webview.html
Example:
You can pull from github several examples here:
https://github.com/muzzley/muzzley-demos/
(check the the webview example)
I hope it helps.
I want to open an application which is developed in windowsforms using C# in PC when connecting a PDA device via USB connection.
Question is:
How do I check the particular USB device has connected (Eg:PDA)?
how do I launch the specific application when connecting a
particular USB (Eg:PDA)?
I don't understand why you tagged the question with ASP.NET. ASP.NET is a server-side technology, and ASP.NET applications are "started" by IIS in response to an HTTP request (typically from a browser).
What you're looking for is to detect a USB device insertion event, and for that you need an application that runs on the client (and have certain permissions).
Here's a thread that would get you started.
I am currently developing a web application to print data directly to the client's printer. The application works well in my pc but when I post the application to our web server, instead of retrieving the printer list in client's pc, the application is trying to look for printers that are installed in the server machine.
I developed my application using C# and I am using System.Drawing.Printing.PrinterSettings.InstalledPrinters to retrieve the printer list I realised it only trying to retrieve printer installed in the local machine. The PC is not connected to any network.
Is there any way to get the list of installed printer in the client computer?
System.Drawing.Printing.PrinterSettings.InstalledPrinters will give the list of printers where the application is hosted and i am afraid there is nothing like getting clients printer lists in ASP.Net.