Can I control external application using C# - c#

Currently I have a software installed on my computer. It is a time clock software whereby user scan their card and then I bring the scanner and connect to my computer and use the software to extract the information.
Is it possible for me to write a C# application to control the time clock software so that I can automate the process of extracting user's information?
The time clock software was bought from external vendor.

It depends on many things.
Does the external vendor provide an API to tap into the application or data? Maybe ask them if they do. Some developers don't give this information automatically. If so you can just look through the documentation.
Does the application save files you can open and take information from? If they save in a text format like txt or xml you can simply make a txt/xml parser that reads the file and do what-ever you want with it.
If not it gets nasty. Sniffing network to look at packages (if it sends them), hacking the software to make some changes. All in all not worth the trouble.

Related

Developing a C# reporting tool - should I use Google Analytics?

I need to develop or obtain a reporting tool that will allow us to obtain information to answer the following questions:
Frequency of use (Must)
Usage of application on a person level (Must)
Successful pages/slides (frequency of use) (Must)
Who updated the application software (Must)
Who updated the application content (Must)
Popular in which regions (Must)
Number of people who download the app vs number of people who own a device Must)
Time spent using the app (Should)
Exit pages (Should)
Number of users of share function (Should)
Number of users of search function (Should)
Time taken to update the app (software) (Should)
Time taken to update the app (content) (Should)
Use of media types (video) (Should)
Use of media types (downloads) (Should)
Average number of pages/slides visited (Could)
Number of users of feedback button (Could)
Environment app is being used (customer, office, MyCompanysOffice) (Could)
The application is a simple installer that communicates with a REST service to download and install HTML and media content, which the user browses LOCALLY. The app provides a kind of on-demand service for downloading and viewing content.
Media formats include mp4, docx, pdf, ppt which are viewed by launching media player, adobe etc.
The use of Google Analytics has been put forward as reporting tool, but I'm not sure if this would be appropriate for the following reasons:
1. GA is a tool for monitoring website traffic rather than user activity
2. GA is not really intended for tracking local pages ie ones using the file:// protocol (although I think it may be possible with one or two hacks)
My specific questions are - would Google Analytics be appropriate for generating reports of the information I described?
Would it be better/simpler to obtain this information through the logging (eg via log4net) and generate a report from that?
Is there another, better tool I could be using to generate these reports?
I can recommend Application Insights for application telemetry (performance, user activity etc). It very flexible and configurable and i think you can make it fit your needed measurements.
You can read more about Microsofts Application Insights service here: https://azure.microsoft.com/en-us/services/application-insights/

Extract gps data storage

I am using dotSpatial labrary in c#, I only can read realtime data.
but my problem is this.. how could I extract gps data storaged in my usb-gps device (it is passive gps)?
device information
brand : landairsea
Model: Gps Tracking Key
webPage: http://www.landairsea.com/gps-tracker/gps-tracking-key
From looking at their user guide:
http://www.landairsea.com/downloads/past-track-10.pdf
You could use the past-track software to save the stored data as .las format.
I believe that DotSpatial has a LIDAR plug-in that can read .las files:
Dotspatial.Plugins.LiDAR
If you are asking how to write a C# replacement for the Past-Track program that connects directly to the USB however, I don't know exactly.
DotSpatial has a positioning library that is DotSpatial.Positioning that was originally ported from http://geoframework.codeplex.com/. It is possible that this utility will have the capability to connect to your device, but I think it would probably only support a limited subset of GPS devices, and I never used it myself at all.
Hopefully that information is a little helpful though and will point you in the right direction.
Edit:
I have downloaded the Past-Track 10 software that is designed to retrieve data from the unit. This in turn installed Antaris4 and u-blox5 USB drivers. I think this is half of what you will need to write a C# app that can talk to your GPS and do things in code. You can find the drivers on the web. I think I found it here:
http://www.driverguide.com/driver/detail.php?driverid=1869444
But make sure you find a version of the driver that matches your PC configuration (32/64 and correct operating system). Incidentally, that will probably mean you will need to make x86 and x64 builds for your C# app.
The next step is to find some documentation for it and then attempt to use the drivers from C#. So far I haven't found a good document showing how to work with the drivers, but I'm sure it exits. I will update with a link when I find it.

SMS from Android device to C# application on computer

I want to make a fullscreen application that can display the latest messages received on the Android device (an SMS wall).
I've tried pulling the MMSSMS.db file from the device with ADB, but the file can't be read on my computer. It seems like it's encrypted or something, because on the phone itself you can open and view it.
Is there any library or other solution available that can accomplish that? I've searched a lot and didn't find anything on the web...
Edit: i've tried using the sqlite.dll both with SQLite Browser and in C# itself. Both showed an empty database while it was readable (and not empty) in the built-in Database Viewer of Root Explorer.
I am not specifically asking for third-party libraries or tools, only if someone has had any experience with this and/or can help me further...
Edit 2: I came here only when I didn't find a solution after searching a lot on the web.
Thanks!
I imagine that its a database file, most likely sqlite. You need to install a library to address such a file. http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki

how to secure flash file from being downloaded or extracted in c#

I'm asked to develop a secured flash viewer in C# (WinForm) where flash files will be viewable through the viewer however being securely captured within the viewer - i.e. make it not extractable nor downloadable by any sniffer tools.
I haven't got a good solution for this yet, any one help?
I will make this in a form of an answer to stop bombarding the comment section.
The task you have at hand will be extremely difficult if you don't want to make your application very user unfriendly.
The reason for that is because if your program can decrypt the information locally then play the video file then a skilled user in reversed engineering can access the method of decryption and use it to dump the video as a file.
Now in case you want to make a licence method and have the users log in before they can use the program you will have two issues.
1) It will still be possible for a person that wants to crack the program to do so, the only thing he/she will need is a valid licence in this case, which in most cases they are stolen from other users. Something that is hard to notice server side except if you have someone constantly looking at the logs banning licences and handling the calls of the users that will be calling because their (stolen) licence is no longer working.
2) Put some kind of limitations server wide as to how many people can login with the credentials which will create more issues, people won't be able to use the software on two pcs at the same time for example. Even the problem above will still be an issue but users will complain why they can't login this time (since someone else will be using their licence.
Moral of the story ? There is always a way around things. Depends how much user experience you are willing to throw away in order to make your software just a bit more safer from being cracked.

Printing from a .NET Service [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I am working on a project right now that involves receiving a message from another application, formatting the contents of that message, and sending it to a printer. The technology of choice is C# windows service. The output could be called a report, I suppose, but a reporting engine is not necessary. A simple templating engine, like StringTemplate, or even XSLT outputting HTML would be fine. The problem I'm having is finding a free way to print this kind of output from a service. Since it seems that it will work, I'm working on a prototype using Microsoft's RDLC, populating a local report and then rendering it as an image to a memory stream, which I will then print. Issues with that are:
Multi-page printing will be a big headache.
Still have to use PrintDocument to print the memory stream, which is unsupported in a Windows Service (though it may work - haven't gotten that far with the prototype yet)
If the data coming across changes, I have to change the dataset and the class that the data is being deserialized into. bad bad bad.
Has anyone had to do anything remotely like this? Any advice? I already posted a question about printing HTML without user input, and after wasting about 3 days on that, I have come to the conclusion that it cannot be done, at least not with any freely available tool.
All help is appreciated.
EDIT: We are on version 2.0 of the .NET framework.
Trust me, you will spend more money trying to search/develop a solution for this as compared to buying a third party component. Do not reinvent the wheel and go for the paid solution.
Printing is a complex problem and I would love to see the day when better framework support is added for this.
Printing from a Windows service is really painful. It seems to work... sometimes... but finally it craches or throws an exception from time to time, without any clear reason. It's really hopeless. Officially, it's even not supported, without any explanation, nor any proposal for an alternate solution.
Recently, I have been confronted to the problem and after several unsuccessful trials and experimentations, I came finally with two viable solutions:
Write your own printing DLL using the Win32 API (in C/C++ for instance), then use it from your service with P/Invoke (works fine)
Write your own printing COM+ component, then uses it from your service. I have chosen this solution with success recently (but it was third party COM+ component, not own written) It works absolutely fine too.
I've done it. It's a pain in the A*s. The problem is that printing requires that GDI engine to be in place, which normally means that you have to have the desktop, which only loads when you're logged in. If you're attempting to do this from a Service on a Server, then you normally aren't logged in.
So first you can't run as the normal service user, but instead as a real user that has interactive login rights. Then you have to tweak the service registry entries (I forget how at the moment, would have to find the code which I can do tonight if you're really interested). Finally, you have to pray.
Your biggest long term headache will be with print drivers. If you are running as a service without a logged in user, some print drivers like to pop up dialogs from time to time. What happens when your printer is out of toner? Or out of paper? The driver may pop up a dialog that will never be seen, and hold up the printer queue because nobody is logged in!
To answer your first question, this can be fairly straight forward depending on the data. We have a variety of Service-based applications that do exactly what you are asking. Typically, we parse the incoming file and wrap our own Postscript or PCL around it. If you layout is fairly simple, then there are some very basic PCL codes you can wrap it with to provide the font/print layup you want (I'd be more then happy to give you some guidance here offline).
One you have a print ready file you can send it to a UNC printer that is shared, directly to a locally installed printer, or even to the IP of the device (RAW or LPR type data).
If, however, you are going down the PDF path, the simplest method is to send the PDF output to a printer that supports direct PDF printing (many do now). In this case you just send the PDF to the device and away it prints.
The other option is to launch Ghostscript which should be free for your needs (check the licensing as they have a few different version, some GNU, some GPL etc.) and either use it's built in print function or simply convert to Postscript and send to the device. I've used Ghostscript many times in Service apps but not a huge fan as you will basically be shelling out and executing a command line app to do the conversion. That being said, it's a stable app that does tend to fail gracefully
Printing from a service is a bad idea. Network printers are connected "per-user". You can mark the service to be run as a particular user, but I'd consider that a bad security practice. You might be able to connect to a local printer, but I'd still hesitate before going this route.
The best option is to have the service store the data and have a user-launched application do the printing by asking the service for the data. Or a common location that the data is stored, like a database.
If you need to have the data printed as regular intervals, setup a Task event thru the Task Scheduler. Launching a process from a service will require knowing the user name and password, which again is bad security practice.
As for the printing itself, use a third-party tool to generate the report will be the easiest.
This may not be what you're looking for, but if I needed to do this quick&dirty, I would:
Create a separate WPF application (so I could use the built-in document handling)
Give the service the ability to interact with the desktop (note that you don't actually have to show anything on the desktop, or be logged in for this to work)
Have the service run the application, and give it the data to print.
You could probably also jigger this to print from a web browser that you run from the service (though I'd recommend building your own shell IE, rather than using a full browser).
For a more detailed (also free) solution, your best bet is probably to manually format the document yourself (using GDI+ to do the layout for you). This is tedious, error prone, time consuming, and wastes a lot of paper during development, but also gives you the most control over what's going to the printer.
If you can output to post script some printers will print anything that gets FTPed to a certain directory on them.
We used this to get past the print credits that our university exposed on us, but if your service outputs to a ps then you can just ftp the ps file to the printer.
We are using DevExpress' XtraReports to print from a service without any problems. Their report model is similar to that of Windows Forms, so you could dynamically insert text elements and then issue the print command.
I think we are going to go the third party route. I like the XSL -> HTML -> PDF -> Printer flow... Winnovative's HTML to PDF looks good for the first part, but I'm running into a block finding a good PDF printing solution... any suggestions? Ideally the license would be on a developer basis, not on a deployed runtime basis.
In answer to your question about PDF printing, I have not found an elegant solution. I was "shell" ing out to Adobe which was unreliable and required a user to be logged in at all times. To fix this specific problem, I requested that the files we process (invoices) be formatted as multi-page Tiff files instead which can be split apart and printed using native .NET printing functions. Adobe's position seems to be "get the user to view the file in Adobe Reader and they can click print". Useless.
I am still keen to find a good way of producing quality reports which can be output from the web server...
Printing using System.Drawing.Printing is not supported by MS, as per Yann Trevin's response. However, you might be able to use the new, WPF-based, System.Printing (I think)

Categories