Unwrapping objects

  • Thread starter Mattia Saccotelli
  • Start date
M

Mattia Saccotelli

How to unwrap SemiTrust's objects?
An MSDN's tutorial did the following:

private Microsoft.Office.Core.CommandBars UnwrapCommandbarsObject(
Microsoft.Office.Interop.InfoPath.SemiTrust.ObjectWrapper
commandBarsWrapper ) {
Type t = commandBarsWrapper.GetType().BaseType;

Microsoft.Office.Core.CommandBars objCommandBars =
(Microsoft.Office.Core.CommandBars)t.InvokeMember( "InnerObject",
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty,
null, commandBarsWrapper, null);

return objCommandBars;
}

to access the CommandBar. I need to access the thisXDocument.DataObjects
to modify query parameters as in JavaScript. In JS it would be:

strSqlCommand =
XDocument.DataObjects.Item("SalesSummary").QueryAdapter.Command;

strSqlCommand = strSqlCommand.replace(/@Ending_Date='[^']+'/,
"@Ending_Date='" + SqlDateTime(dtEnd) + "'");


How to access the Command property?? It's not there in the C# object!
Ms experts????

thanks!
 
M

Mattia Saccotelli

How could I know to which type perform the cast?
Make sure you have the right type of object. E.g. ADOAdapter, not just
QueryAdapter. Cast as needed.

--Matthew Blain
http://tips.serriform.com/
http://www.developingsolutionswithinfopath.com/

How to unwrap SemiTrust's objects?
An MSDN's tutorial did the following:

private Microsoft.Office.Core.CommandBars UnwrapCommandbarsObject(
Microsoft.Office.Interop.InfoPath.SemiTrust.ObjectWrapper
commandBarsWrapper ) {
Type t = commandBarsWrapper.GetType().BaseType;

Microsoft.Office.Core.CommandBars objCommandBars =
(Microsoft.Office.Core.CommandBars)t.InvokeMember( "InnerObject",
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty,
null, commandBarsWrapper, null);

return objCommandBars;
}

to access the CommandBar. I need to access the thisXDocument.DataObjects
to modify query parameters as in JavaScript. In JS it would be:

strSqlCommand =
XDocument.DataObjects.Item("SalesSummary").QueryAdapter.Command;

strSqlCommand = strSqlCommand.replace(/@Ending_Date='[^']+'/,
"@Ending_Date='" + SqlDateTime(dtEnd) + "'");


How to access the Command property?? It's not there in the C# object!
Ms experts????

thanks!
 
M

Matthew Blain \(Serriform\)

One way is to use the InfoPath help integrated into Visual Studio. Go to
Help, Search, filter on Microsoft Office InfoPath2003, and search for
Command.

This is also covered in Chapter 6 of the book below.

--Matthew Blain
http://tips.serriform.com/
http://www.developingsolutionswithinfopath.com/

Mattia Saccotelli said:
How could I know to which type perform the cast?
Make sure you have the right type of object. E.g. ADOAdapter, not just
QueryAdapter. Cast as needed.

--Matthew Blain
http://tips.serriform.com/
http://www.developingsolutionswithinfopath.com/

"Mattia Saccotelli" <"m.saccotelli [AT] gruppostratos [DOT] com"> wrote in
message
How to unwrap SemiTrust's objects?
An MSDN's tutorial did the following:

private Microsoft.Office.Core.CommandBars UnwrapCommandbarsObject(
Microsoft.Office.Interop.InfoPath.SemiTrust.ObjectWrapper
commandBarsWrapper ) {
Type t = commandBarsWrapper.GetType().BaseType;

Microsoft.Office.Core.CommandBars objCommandBars =
(Microsoft.Office.Core.CommandBars)t.InvokeMember( "InnerObject",
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty,
null, commandBarsWrapper, null);

return objCommandBars;
}

to access the CommandBar. I need to access the thisXDocument.DataObjects
to modify query parameters as in JavaScript. In JS it would be:

strSqlCommand =
XDocument.DataObjects.Item("SalesSummary").QueryAdapter.Command;

strSqlCommand = strSqlCommand.replace(/@Ending_Date='[^']+'/,
"@Ending_Date='" + SqlDateTime(dtEnd) + "'");


How to access the Command property?? It's not there in the C# object!
Ms experts????

thanks!
 
M

Mattia Saccotelli

Thanks Matthew, I found the help very useful.
Btw I'm working with a web service so I used:

WebServiceAdapter2 wsA =
(WebServiceAdapter2)thisXDocument.DataAdapters["ElencoSchede"];

What I have to do is change a parameter of the WebMethod, to refresh the
query. I didn't find any property/method to do so.

I did it using a DOMDocument50Class object, I copied into it the

thisXDocument.DataObjects["ElencoSchede"].DOM

to replace the query value: I wasn't able to selectSingleNode directly
on the original DOM because of namespace's issues, actually I had to set
the needed namespace on the new object.

It's quite a long way to perform a simple task, I wonder if I'm missing
something about the WebServiceAdapter2 capabilities.

thanks


One way is to use the InfoPath help integrated into Visual Studio. Go to
Help, Search, filter on Microsoft Office InfoPath2003, and search for
Command.

This is also covered in Chapter 6 of the book below.

--Matthew Blain
http://tips.serriform.com/
http://www.developingsolutionswithinfopath.com/

How could I know to which type perform the cast?
Make sure you have the right type of object. E.g. ADOAdapter, not just
QueryAdapter. Cast as needed.

--Matthew Blain
http://tips.serriform.com/
http://www.developingsolutionswithinfopath.com/

"Mattia Saccotelli" <"m.saccotelli [AT] gruppostratos [DOT] com"> wrote
in
message

How to unwrap SemiTrust's objects?
An MSDN's tutorial did the following:

private Microsoft.Office.Core.CommandBars UnwrapCommandbarsObject(
Microsoft.Office.Interop.InfoPath.SemiTrust.ObjectWrapper
commandBarsWrapper ) {
Type t = commandBarsWrapper.GetType().BaseType;

Microsoft.Office.Core.CommandBars objCommandBars =
(Microsoft.Office.Core.CommandBars)t.InvokeMember( "InnerObject",
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty,
null, commandBarsWrapper, null);

return objCommandBars;
}

to access the CommandBar. I need to access the thisXDocument.DataObjects
to modify query parameters as in JavaScript. In JS it would be:

strSqlCommand =
XDocument.DataObjects.Item("SalesSummary").QueryAdapter.Command;

strSqlCommand = strSqlCommand.replace(/@Ending_Date='[^']+'/,
"@Ending_Date='" + SqlDateTime(dtEnd) + "'");


How to access the Command property?? It's not there in the C# object!
Ms experts????

thanks!
 
M

Matthew Blain \(Serriform\)

The adapter doesn't do anything special with the DOM (you can also call
GetDOM("elencoschede")). You will always have to deal with namespace issues
when using xpath. Typically I set namespace prefixes early in the process
(e.g. in the onload event, or immediately after calling Query).

You can also use rules or default values to set parameters in the web
service.

--Matthew

Mattia Saccotelli said:
Thanks Matthew, I found the help very useful.
Btw I'm working with a web service so I used:

WebServiceAdapter2 wsA =
(WebServiceAdapter2)thisXDocument.DataAdapters["ElencoSchede"];

What I have to do is change a parameter of the WebMethod, to refresh the
query. I didn't find any property/method to do so.

I did it using a DOMDocument50Class object, I copied into it the

thisXDocument.DataObjects["ElencoSchede"].DOM

to replace the query value: I wasn't able to selectSingleNode directly
on the original DOM because of namespace's issues, actually I had to set
the needed namespace on the new object.

It's quite a long way to perform a simple task, I wonder if I'm missing
something about the WebServiceAdapter2 capabilities.

thanks


One way is to use the InfoPath help integrated into Visual Studio. Go to
Help, Search, filter on Microsoft Office InfoPath2003, and search for
Command.

This is also covered in Chapter 6 of the book below.

--Matthew Blain
http://tips.serriform.com/
http://www.developingsolutionswithinfopath.com/

"Mattia Saccotelli" <"m.saccotelli [AT] gruppostratos [DOT] com"> wrote in
message
How could I know to which type perform the cast?

Matthew Blain (Serriform) wrote:

Make sure you have the right type of object. E.g. ADOAdapter, not just
QueryAdapter. Cast as needed.

--Matthew Blain
http://tips.serriform.com/
http://www.developingsolutionswithinfopath.com/

"Mattia Saccotelli" <"m.saccotelli [AT] gruppostratos [DOT] com"> wrote
in

message

How to unwrap SemiTrust's objects?
An MSDN's tutorial did the following:

private Microsoft.Office.Core.CommandBars UnwrapCommandbarsObject(
Microsoft.Office.Interop.InfoPath.SemiTrust.ObjectWrapper
commandBarsWrapper ) {
Type t = commandBarsWrapper.GetType().BaseType;

Microsoft.Office.Core.CommandBars objCommandBars =
(Microsoft.Office.Core.CommandBars)t.InvokeMember( "InnerObject",
BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.GetProperty,
null, commandBarsWrapper, null);

return objCommandBars;
}

to access the CommandBar. I need to access the thisXDocument.DataObjects
to modify query parameters as in JavaScript. In JS it would be:

strSqlCommand =
XDocument.DataObjects.Item("SalesSummary").QueryAdapter.Command;

strSqlCommand = strSqlCommand.replace(/@Ending_Date='[^']+'/,
"@Ending_Date='" + SqlDateTime(dtEnd) + "'");


How to access the Command property?? It's not there in the C# object!
Ms experts????

thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

thisXDocument object 1

Top