Windows Service Printing PDFs - c#

Have the need to nightly startup a process that creates PDF based Reports (Financial Charts). A past developer produced a component that uses System.Drawing and System.Printing to create and save the reports to a directory as a PDF using Amyuni. Now we would like to use that component to produce PDF off hours for analysts to use the next day. The actual graphs are custom drawn using GDI+ with DrawLine, DrawString, etc. Using the PrintPageEventArgs Graphics property as the canvas for the drawing.
Using the component works just fine from a Windows Forms application works just fine. When using the component running under a user account (not LocalSystem) so service has access to printers doesnt fail with any exceptions, but no files are created.
I know that System.Drawing and System.Printing not really supported from Windows Service, but supported doesnt mean doesnt work. Just means MS wont help you through issues.
Any idea what we can do to get this to work? This is not a high volume process. Currently they do it with a command line program and the Windows Task Scheduler, but that requires the user to be left logged in.
UPDATE:
So I tried this as a .NET console application and started it with the Windows Task Scheduler and the same problem occurs. Run the console application from the desktop and it works. Run it from Task Scheduler it runs, but no files are created. I do have extensive logging going on an no exceptions are occurring and it sure looks like the process is creating the charts. They just arent showing up in the output directory. I setup the task to run under the same account that I am logged in as. The previous task that did work was a Visual Basic 6 solution not a .NET solution.

For future readers of this post, the issue described on this question was caused by licensing restrictions of Amyuni libraries on Windows Server operating systems (Amyuni Technologies provides several licensing models according to the applications being developed). For this particular case, new licensing information was provided after contacting Amyuni Support and the issue was resolved.
Disclaimer: I work for Amyuni Technologies.

Related

how to fix "Not enough memory resources are available to complete this operation" asp.net c#?

I am using loop for my images so I can get multiple images at a time and extract the written data from those images, I am using MODI for my OCR in Visual studio to extract the written data but my problem is ...
after one loop "Not enough memory resources are available to complete this operation" this error appears and only one image is saved in my database, I have tried taking, string builder, string list, and many other helps from internet but still not able to solve my problem. I am stuck at this code for past week
Please help!! if anyone can..
I want to download images in loop to my database and at the same time do Optical Character Recognition.
Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.
If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution. Read more about that in the Considerations for server-side Automation of Office article.
Instead, consider using any components designed for the server-side execution and that don't required Office on the system.

Packaging multiple programs into one installer C# (visual 2010 basic)

I am currently finishing a project that uses multiple programs, and I am trying to get ideas of how to package them all into one installer, probably through the publishing option in visual basic, but I am sure there are multiple ways this can be done.
First, the main program is done using windows forms. That program, on the server side, keeps track of information that is going on in the warehouse. Users are able to manipulate that info on the client side as needed from multiple points: receiving, work orders, and shipping.
The external program was done in Unity and uses the same information to show how the warehouse is staged, what work is being done, and gives a 3D view of where people and inventory are located in snap shots of time.
So what I am trying to do, is package the Unity project into the installer. It's okay that it's a stand alone program, since I can just open it via the system controls in the main windows form project.
What isn't okay, is that right now it takes two installs to get everything running. Given that I have to deal with individuals that can barely use Google chat, I need this process to be seamless.
I am personally a fan of WiX. I have used it for small, single application distributions and large composite applications that involve many parts. It is capable of producing MSI( MSU, MSM, etc.), EXE installers and has Visual Studio integration.

Time-based trial for an application - how to check when app was downloaded

Is there any way to access the time the app was downloaded (or first launched, etc) as this would be of great help in implementing my trial run feature on my app.
I don't remember how does it stand on the Win8 platform, but for WinPhone7.0/7.5 there's a clear warning/guideline in the official documents from Microsoft, saying:
Do not rely on usage time limited trials to protect your app’s value.
Typically, it is best to protect the value of your full mode app by limiting trial access to key code paths. A user may uninstall and retry an app without restriction so a trial design that offers full mode behavior for a limited time provides only inconvenience as a barrier to reuse.
Source: Creating trial apps for Windows Phone
The problem in time-based trials is very simple: when you uninstall the application, the Phone's operating system will erase it completely. This means, that nothing will be left, not a byte. If you write any data to isostorage, it will be purged upon deletion.
So, if you make a time-base trial and store a "installed date", then the user will simply uninstall the application and install it again, and will be happy to get next free-trial period. If it is OK for you, well, then just be aware of that.
To make a true time-trial you'd need to create some internet service that your application will register to with the phone's/user's UUID, and then the app would need to check at the service to determine whether the trial has passed or have been used up by a previous installation..
What's more, Microsoft Phone Appp guidelines state that generally you should not create an application that "turns off some of its features" at some point of time. This irritates end-users and the makes the whole phone/platform "bad" from the user's point of view, because people don't like to lose what they once had.
IIRC, at some early point of time Microsoft even advised to create two separate applications: one free and without the extra features at all, and one paid with all extra features. Later, TrialModes were included in the Market's workflow and Microsoft's App Licensing API introduced a very easy way to determine if an app works in "free trial" or "fully paid" mode, depending on whether it was downloaded from the market for free or not.
I truly don't know which one is most-recent, so let me paste three:
XNA: http://msdn.microsoft.com/en-us/library/dd282459(v=xnagamestudio.30).aspx
SL: http://msdn.microsoft.com/en-us/library/windowsphone/develop/microsoft.phone.marketplace.licenseinformation.istrial
W8: http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.store.licenseinformation.istrial
If you are trying to implement a trial function within your phone application, why not latch onto the libraries that MS provides?
MSDN Creating a trial application
MSDN Sample code for integrating a trial applicaiton
This is only available for WP7.1, WP7.1+ and WP8 (when written for WP7.1)
Microsoft recommends using the WP8 LicenseInformation class, to do
MSDN LicenseInformation class, WP8
Hope this helps!

Windows embedded 2009 service

I'm developing an application that will be executed in a ThinClient with Windows Embedded 2009. It's written in C# 3.5. But, when I played for the first time with the ThinClient, I noticed that it has a lot of features disabled.
For example, there is no MyPc, or I can't have access to it.
So, my app needs to run when the client is turned on, but I can't find a service manager in embedded 2009.
Is there a way to make my app run every time the client is turned on?, I thought about a service, with automatic start. Can this be done like a windows service with no problems?
And another thing. My app also has to shut down the client. I've found a way to make it, but, I'd like to know if is different in Wndows Embedded.
Btw, the device has no hard disk.
Any other suggestion, will be very appreciated.
Have a nice day.
In the older Embedded there is a "startup"-folder (located on the flash-card containing the win-image)

Monitoring Framework needed

I'm building a big application with a lot of modules, i want to monitor them. Every module has its own different parameters that I'm interested in, ranging from performance, to logical statuses of components.
Eventually i need to concentrate all this information, and to be able to display it. Is there a framework i can use to achieve this? im using .net 3.5
You could try Munin. Once you install it - you simply write some plugins - small programs that will grab values from your application. And print them to command line in the form of values and labels. For example:
NoRDNS.value 10
Breakin.value 1
LogPassPAM.value 0
NoID.value 0
LogPass.value 100
InvUsr.value 23
LogKey.value 0
RootAttempt.value 0
Floats are OK too.
Munin will call the plugins periodically (every 10 minutes by default) and plot beautiful PNG graphs over time, track the min/max/average info, and organize everything in static HTML pages.
For you, probably the biggest problem with Munin would be setting it up on Windows. I never tried it on Windows - for me it works on Linux. Fortunately official website does have some options for Windows - in particular the munin-node-win32 program. You would need it.
Unfortunately, munin-node-win32 will only collect the data. To store (as RDD) and render the graphs (as PNG) you would need the Munin server. That can run locally or remotely. For running it locally, Cygwing may be and option but a sure way it to setups a virtual machine (see QUEMU or VirtualBox) running a simple setup of Ubuntu or Debian. In there, setting-up the Munin server is very easy - simply, run:
sudo aptitude install munin
and edit /etc/munin/munin.conf - placing the local IP address of the host where your application and munin-node are running. You don't even need to restart anything - Munin will be already configured in CRON so it will read the config file and do its job every 10 minutes as long as the VM is running. Just in case something goes wrong - the logs will be in the usual /var/log folder.
It looks pretty involved but it's easier than writing your own monitoring and graphing framework. I have a close relative who re-invented the wheel and wrote a monitoring/plotting system from scratch in .NET but I would trust Munin much more than his code.
At the end of the day you would point your web-browser to a private network IP address of the VM and get a nice performance report that looks like this.
Try wolfpack.codeplex.com - .net windows service based monitoring framework - fully extensible & ships with loads of plugins!
Provides passive monitoring (polling for data) and active - you app can pump data/kpis/stats into wolfpack. It also provides a geckoboard data api so you can get rich business dashboards in an instant.
PS: I wrote wolfpack!
You can use appfirst product. They have a way of discovering network flow and display what you described. This might solve your question.

Categories

Resources