Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Create a package and Porgrams from a PDF file in c#

0 views
Skip to first unread message

DaVize @discussions.microsoft.com Tony DaVize

unread,
Aug 22, 2007, 9:36:00 AM8/22/07
to
I am trying to automate the import of packages and programs from PDF files
(.sms files) using c# and the System.Management WMI classes. unfortunately I
cannot get beyond the call to "getPDFData" as this returns a
ManagementBaseObject and not a ManagementObject than can be sotred using
put(). Is there any way of taking the output from getPDFData and storing it
as SMS_package and SMS_program instances?

The code is as follows...

public bool ImportSoftware(SMSLoad mySMSLoad)
{
...
try
{
StreamReader pdfStream = new StreamReader(<PDFFilePath>);
strPDFContent = pdfStream.ReadToEnd();
pdfStream.Close();
}
catch (IOException exp)
{
...
return false;
}
try
{
ObjectGetOptions myOpts = new ObjectGetOptions();
InvokeMethodOptions myInvokeOpts = new InvokeMethodOptions();

myInvokeOpts.Timeout = new TimeSpan(0, 0, 30);

ManagementClass pdfClass = new ManagementClass
(objServ.Path.NamespacePath, "SMS_PDF_Package", myOpts);

ManagementBaseObject inParams = pdfClass.GetMethodParameters
("LoadPDF");
inParams["PDFFileName"] = <PDFFileName>;
inParams["PDFFile"] = strPDFContent;

ManagementBaseObject outParams =
pdfClass.InvokeMethod("LoadPDF", inParams, myInvokeOpts);

inParams = pdfClass.GetMethodParameters("GetPDFData");
inParams["PDFID"] = outParams["PDFID"];

ManagementBaseObject pdfReturn =
pdfClass.InvokeMethod("GetPDFData",inParams, myInvokeOpts);
....

end code.

pdfReturn contains ManagementBaseObjects. I want an SMS_package and
SMS_program(s) what do I do now (casting does not work and creating an
instance of SMS_package copying the properties and using put() does not
create the objects in SMS properly).

PS it's dead simple in VBS !

brunost

unread,
Apr 14, 2008, 9:17:32 AM4/14/08
to
Hi

I am running into the same issue.

How you found a solution for this?

Thanks in advance

Bruno Stampfli

--
Message posted using http://www.talkaboutsoftware.com/group/microsoft.public.sms.tools/
More information at http://www.talkaboutsoftware.com/faq.html


0 new messages