I am at a loss and could use some direction. I have a windows service that performs an Audit on customers. For new customers, I need to create a profile for each one. I already have a ASP.net C# web page that displays a single customer profile for the user:
http://webserver/showprofile.aspx?id=CustomerID
I would like to run some type of loop in the service that would render each new customer's profile and output all of those profiles into a PDF, Word Document, etc. Is there an easy way to do this using the existing Show Profile webpage?
If not, what is the best way to do this in C#? If it requires a component, I would prefer something free to very inexpensive. I currently have licenses for Telerik's complete line of tools if there is something there that can help. The bottom line, this has to be done programmatically as the user will have nothing to do with the generation/export to PDF. They will only access the resulting exported file.
Thanks in advance for your help.
You can use PdfCreator using the following command:
private PDFCreator.clsPDFCreator printer;
printer = new PDFCreator.clsPDFCreator();
printer.cDefaultPrinter = "PDFCreator";
printer.cOptions.UseAutosave = 0;
// Format in which file is to be saved. 0 if for pdf.
printer.cOptions.AutosaveFormat = 0;
printer.cClearCache();
printer.cStart();
foreach(int CustomerId in CustomerIDs)//array of customer ids as an example
{
printer.cPrintURL("http://webserver/showprofile.aspx?id=" + CustomerID.ToString());
}
You can download the software and necessary dll at the following link and look at the examples in the .net folder.
http://sourceforge.net/projects/pdfcreator/
Related
Im trying to follow this Microsoft tutorial to display the names of a distribution list in c#
https://learn.microsoft.com/en-us/office/client-developer/outlook/pia/how-to-get-members-of-an-exchange-distribution-list
This example prompts the user to select an Exchange distribution list from the Select Names dialog box and expands the distribution list to display its members.
except when I get an error here
I have this in a console app project. How can I fix this?
You can fix this by creating an Application instance, as per suggestion made by the prompt in your screenshot. Like so:
Application app = new Application();
Outlook.SelectNamesDialog snd = app.Session.GetSelectNamesDialog();
Sources:
How to invoke a method with (Outlook.Application application) as parameter in C#?
So I'm tasked to build a file upload for our application, which is using Visual WebGUI and therefore mostly looks like WinForms codewise.
The problem is, I don't have any clues as to where to start. I tried looking through our Download class, but it just takes a file and puts it into the response.
I tried google, but there's nothing on uploading something.
I don't understand enough of how websites work to even ask myself or google the right question. I have no Idea how a website tells the browser to get a file. And if I find out how that works, I still need to somehow get VWG to do that. I can't directly interact with the browser (except when I write javascript, but I'm not sure I can get a response from js).
Ideas and clues to where to start would be great too, I just need somewhere to start.
Let me know if you need any more information or clarification, as I'm not sure which kind of information you need for this.
Visual WebGUI has a built in Upload mechanism, called the UploadControl.
Since you're using VWG, you should check out the Companion Kit which is one of few remaining resources out there for Visual Web Gui. It gives an example of the upload control. It also gives example code, which you can download.
In short, what happens is that VWG will handle the JS components of getting the file. You don't have to worry about JavaScript, that's the point of VWG. In C#, you'll code the UploadControl, and what you "get" is the information about the file like Name, Size, MIME type, etc. Refer to the companion kit for info on this.
Steps:
1) Add the UploadControl to a form
this.mobjUploadControl = new Gizmox.WebGUI.Forms.UploadControl();
2) Wire up the UploadControl
this.mobjUploadControl.UploadFileCompleted += new Gizmox.WebGUI.Forms.UploadFileCompletedHandler(this.mobjUploadControl_UploadFileCompleted);
3) Handle the actual upload.
private void mobjUploadControl_UploadFileCompleted(object sender, UploadCompletedEventArgs e)
{
UploadFileResult uploadedFile = e.Result;
// binary data for file, can be used to store to filesystem, db, etc
byte[] fileData = File.ReadAllBytes(uploadedFile.TempFileFullName);
// filename of what was uploaded
string fileName = uploadedFile.Name;
}
I have an application that writes SSRS reports as a PDF to a file directory and I would like each time a report is added to the folder for it to be printed to a specific network printer. The reports are generated using the SQL SSRS web service.
This folder and application is on a server and I cannot use Adobes silent printing to accomplish this. Does anyone have any advice?
Thanks.
You could try sending your document as raw or you might be able to convert your file to a stream and send it to your printer using TcpClient.
Realized I left this question unanswered and wanted to give a followup in case anyone else encounters this problem. I ended up using the code from the answer found here...
Print a ReportViewer Without Preview
I was able to create the reports using my web service and put them into a report viewer and then simply pass the report and the printer I wanted to print to as parameters to the code above and it handled the printing for me. The only thing I did was extend the functionality to accept a printer name as a parameter and use assign that as the specified printer that I wanted to print to.
Here is some sample code in case anyone wants to see the general flow I used.
List<ReportParameter> reportparms = new List<ReportParameter>();
ServerReport rpt = new ServerReport();
reportparms.Add(new ReportParameter("param1", param1));
rpt.ReportServerUrl = reportserver;
rpt.ReportPath = myReportPath;
rpt.SetParameters(reportparms);
//I created a class "ReportPrintDocument" for the code from the question linked above.
ReportPrintDocument rdp = new ReportPrintDocument(rpt, myPrinter);
rdp.PrinterSettings.PrinterName = ps.Printer;
if (p.PrinterSettings.IsValid)
{
rdp.Print();
}
There is some other logic here and there but that is the basic idea that will get the job done.
I am working on a WPF app (written in C#) that searches and serves data from the active directory. Searching for a user will fetch all phone numbers for the user and display on the app window.
How can I open the outlook contact card by the click of some icon or the username or something?
The Outlook Contact Card is part of Microsoft Outlook and (as far as I know) not a public control, so you can not simply 'open' it unless you are creating an Outlook add-in.
Using the Active Directory's information you could recreate it.
By Outlook Contact Card I assume you mean a vCard (*.VCF file). It is actually nothing more than a text file. You can easily recreate it. For example:
Create a StringBuilder instance and write the contents of the .VCF file to it.
var vcf = new StringBuilder();
vcf.Append("TITLE:" + contact.Title + System.Environment.NewLine);
//...
Afterwards you can save it to a file.
var filename = #"C:\mycontact.vcf";
File.WriteAllText(filename, vcf.ToString());
Most properties are easy to figure out.
A small example:
BEGIN:VCARD
FN:Mr. John Smith
TITLE:Developer
ORG:Microsoft
BDAY:1979-12-10
VERSION:2.1
END:VCARD
If you want to include an image you have to base 64 encode it.
If you open this newly created file:
Process.Start(#"C:\mycontact.vcf");
Then it should be opened by the application that is configured by default to handle this file extension.
Wikipedia contains more information about the contents of a vCard:
http://en.wikipedia.org/wiki/VCard
It seems that outlook is using a Lync Feature.
Even if not exactly the Same you can use the Lync SDK in your wpf app if you use Lync.
http://msdn.microsoft.com/en-us/uc14trainingcourse_2l_topic2#_Toc273951814
I did implement a web application(asp.net,c#) where it has couple of pages .Each page has the ability to read the values from an xml file and passes into couple of text boxes in each page.User has the ability to edit the values and save,which inturn saves the xml file.I did use the linq to xml .
I have to move to the silverlight now.so i am trying to implement the same logic in a new silverlight project.I m trying to use the linq to xml in silverlight also.But some how i am unable to read the xml file which is not in the xap file.Here is my code
XDocument doc = Document.Load("C:\Data\Data.exe.config");
var applicationSettings = (from x in doc.Descendants("applicationSettings")
from kvpair in .Element("Data.Properties.Settings").Elements("setting")
select new
{
Name = kvpair.Attribute("name").Value,
Node = kvpair.Element("value")
}).ToDictionary(x => x.Name, y => y);
string Account = applicationSettings["Account no"].Node.Value.ToString();
txtAccountno.Text = AttendanceWindow;
string Details=applicationSettings["Details"].Node.Value.ToString();
txtDetails.Text = Details;
I am assuming that "C:\Data\Data.exe.config" is a file that sits on the server? Keep in mind that Silverlight is executing on the client-side. Not only would you have to give Silverlight permission to access that directory (see this link for some details), but you'd be accessing the client's hard disk, not the server's. In order to get that file's contents, you'd be better off parsing the XML server-side and sending whatever settings you require from it to Silverlight via web services.
If the file really does sit on the client's computer, then you need to create an out-of-browser Silverlight project: http://msdn.microsoft.com/en-us/library/ee721082(VS.95).aspx
EDIT:
Ah, I think I see what's going on now. The Document.Load method by default assumes the URI points to a resource within the XAP: http://msdn.microsoft.com/en-us/library/bb538371(v=vs.95).aspx
What you'll probably need to do is described in this MSDN article, which will use a stream approach to loading the XML: http://msdn.microsoft.com/en-us/library/cc645034(v=vs.95).aspx#Y0
Your problem is related to which areas on the disk you are allowed to access.
You need ensure that Silverlight can access the file, that it has rights to the files location, and that silverlight is configured to be able to access local files. Either the file must be moved to local storage or you must run with elevated privilages out of the browser.
See also: http://www.codeproject.com/KB/silverlight/FileExplorerInSilverlight.aspx for an example of accessing files from Silverlight
In Silverlight 5 it is possible to run the Silverlight application in-browser with elevated permissions, enabling you to access the entire file system. Otherwise you are restricted to the isolated storage area.