09-20-06 06:22 PM
Hi,
do it with the Serviceagents search:
*** SAMPLE Searchs for an User ... an in a Comment one which gets all Users
.. then binding to a Datagrid - use at own risk ***
String searchstring="Mr. Fokker";
String searchkey = "SoldToName";
//This creates the OrderManagementContext in an Out-of-proc mode and
all the APIs go over the web service - so this is more flexible and portable
/*OrderServiceAgent orderAgent = new
OrderServiceAgent(settings.OrdersWebServiceURL);
OrderManagementContext outOfProcOrderMgtContext =
OrderManagementContext.Create(orderAgent);
*/
//This creates the OrderManagementContext in an in-proc mode (Commerce
Server has to be installed locally) and is therefore faster
OrderSiteAgent orderSiteAgent = new
OrderSiteAgent(CommerceContext.Current.SiteName); //Or whatever your site
name is
OrderManagementContext inProcOrderMgtContext =
OrderManagementContext.Create(orderSiteAgent);
//Now you can access the particular manager object you are interested in
//depending on what you want to do and you can use one of the
management context objects created above - you would have created either one
or the other
/*BasketManager basketMgr = outOfProcOrderMgtContext.BasketManager;
PurchaseOrderManager poMgr =
outOfProcOrderMgtContext.PurchaseOrderManager;
PaymentMethodManager pmtMethodMgr =
outOfProcOrderMgtContext.PaymentMethodManager;
ShippingMethodManager shipMethodMgr =
outOfProcOrderMgtContext.ShippingMethodManager;*/
PurchaseOrderManager poMgr = inProcOrderMgtContext.PurchaseOrderManager;
// Clause gets all Users
//SearchClause clause =
poMgr.GetSearchClauseFactory(poMgr.GetSearchableProperties(CultureInfo.Curre
ntUICulture.ToString()),
"PurchaseOrder").CreateClause(ExplicitComparisonOperator.NotEqual, "Status",
"");
//poMgr.GetSearchableProperties("en").Tables[0].Select(searchstring);
// Clause looking for 1 User
SearchClause clause =
poMgr.GetSearchClauseFactory(poMgr.GetSearchableProperties("en"),
"PurchaseOrder").CreateClause(ExplicitComparisonOperator.Contains, searchkey
,
searchstring);
DataSet searchResults = poMgr.SearchPurchaseOrders(clause);
List<Guid> purchaseOrderIds = new List<Guid>();
DataTable dt = searchResults.Tables[0];
foreach (DataRow dr in dt.Rows)
{
purchaseOrderIds.Add(new Guid(dr[0].ToString()));
}
String xmlString =
poMgr.GetPurchaseOrdersAsXml(purchaseOrderIds.ToArray()).OuterXml;
System.IO.StringReader sr = new System.IO.StringReader(xmlString);
DataSet ds2 = new DataSet();
ds2.ReadXml(sr);
Gridview1.DataSource=ds2;
Gridview1.DataBind();
"briguy" wrote:
> I need to write an administration tool that will allow me to access all
> new orders (regardless of the user) for a Commerce Server site. I know
> that Business Desk already has this but I need to write a custom one
> that reads all the order information (including line information) and
> call a custom web service to pass the information to a 3rd party
> business system. Is there a way to get all the orders without setting
> a user ID? I tried using OrderGroupSearch but that requires that I set
> a UserID which I don't want to do since I won't know which users have
> created the new orders.
>
>
[ Post a follow-up to this message ]
|