创建产品或更新产品获取错误CatalogContext.Create(catalogSiteAgent); [英] Creating product or updating product getting error CatalogContext.Create(catalogSiteAgent);

查看:109
本文介绍了创建产品或更新产品获取错误CatalogContext.Create(catalogSiteAgent);的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从sharepoint工作流程序列调用以下代码:获取以下错误位于CatalogContext catalogContext = CatalogContext.Create(catalogSiteAgent)下面:错误消息是:1)无法计算表达式,因为当前
方法的代码优化。 2)从Commerce Server管理数据库中为站点"管理"读取站点资源时出现问题。请检查该站点是否存在资源,以及该进程是否有权访问该数据库。
InnerException包含使用System的更多细节;使用System.ComponentModel;使用System.ComponentModel.Design;使用System.Collections;使用System.Drawing;使用System.Linq;使用System.Workflow.ComponentModel.Compiler;使用System.Workflow.ComponentModel.Serialization;
使用System.Workflow.ComponentModel;使用System.Workflow.ComponentModel.Design;使用System.Workflow.Runtime;使用System.Workflow.Activities;使用System.Workflow.Activities.Rules;使用Microsoft.SharePoint;使用Microsoft.SharePoint.Workflow;使用
Microsoft.SharePoint.WorkflowActions;使用System.Data;使用System.Data.Sql;使用System.Data.SqlClient;使用System.Data.SqlTypes;使用Microsoft.CommerceServer;使用Microsoft.CommerceServer.Catalog;使用Microsoft.CommerceServer.Inventory; namespace
ProductListWF.ProductUpdateWF {public sealed partial class ProductUpdateWF:SequentialWorkflowActivity {public ProductUpdateWF(){InitializeComponent(); public Guid workflowId = default(System.Guid); public SPWorkflowActivationProperties workflowProperties
= new SPWorkflowActivationProperties(); bool wfPending = true; / * false时假停止工作流程* / int step = 0; / * 0 - 产品是否存在* / bool wfProductFound = false; void wf_updateProductInfo(){switch(step){case 0:updateInventory(); //如果
存在则更新产品,否则创建新的产品中断;案例1:休息;案例2:休息;默认值:wfPending = false;打破;如果存在则更新产品,否则创建新产品void updateInventory(){string vProductID ="" ;; string vDefinition_Name ="" ;; string vDisplay_Name
="" ;; string vList_Price =" 0" ;; string vCategory_Price ="" ;; string vDescription ="" ;; string vOn_Sale ="" ;; string vBrand_Name ="" ;; string vBrand_Name_Display ="" ;; string vImage_filename ="" ;; string vImage_height ="" ;; string vImage_width ="" ;; string
vIntroduction_Date ="" ;; string vIntorVariantID ="" ;; string vSize ="" ;; string vColor ="" ;; string vCategory_Name ="" ;; string vCategory_Display ="" ;; string vCatalog_Name ="" ;; string vCatalogVariantID ="" ;; string vBack_Orderable ="" ;; string vBack_Order_Limit
="" ;; string vPreOrderable ="" ;; string vPreOrderQuantity ="" ;; string vOnHandQuantity ="" ;; string vReOrderPoint ="" ;; string vLast_Restocked ="" ;; string vExcess_Onhand_Quantity ="" ;; string vTarget_Quantity ="" ;; string vProduct_Type ="" ;; string vStatus
="" ;; if(workflowProperties.Item [" ProductID"]!= null)vProductID = workflowProperties.Item [" ProductID"]。ToString(); if(workflowProperties.Item [" Definition_Name"]!= null)vDefinition_Name = workflowProperties.Item [" Definition_Name"]。ToString(); if(workflowProperties.Item [" Display_Name"]
!= null)vDisplay_Name = workflowProperties.Item [" Display_Name"]。ToString(); if(workflowProperties.Item [" List_Price"]!= null)vList_Price = workflowProperties.Item [" List_Price"]。ToString(); if(workflowProperties.Item [" Category_Price"]!= null)vCategory_Price
= workflowProperties.Item [" Category_Price"]。ToString(); if(workflowProperties.Item [" Description"]!= null)vDescription = workflowProperties.Item [" Description"]。ToString(); if(workflowProperties.Item [" On_Sale"]!= null)vOn_Sale = workflowProperties.Item [" On_Sale"]。ToString();
if(workflowProperties.Item [" Brand_Name"]!= null)vBrand_Name = workflowProperties.Item [" Brand_Name"]。ToString(); if(workflowProperties.Item [" Brand_Name_Display"]!= null)vBrand_Name_Display = workflowProperties.Item [" Brand_Name_Display"]。ToString(); if
(workflowProperties.Item [" Image_filename"]!= null)vImage_filename = workflowProperties.Item [" Image_filename"]。ToString(); if(workflowProperties.Item [" Image_height"]!= null)vImage_height = workflowProperties.Item [" Image_height"]。ToString(); if(workflowProperties.Item [" Image_height"]
!= null)vImage_width = workflowProperties.Item [" Image_height"]。ToString(); if(workflowProperties.Item [" Introduction_Date"]!= null)vIntroduction_Date = workflowProperties.Item [" Introduction_Date"]。ToString(); if(workflowProperties.Item [" IntroVariantID"]
!= null)vIntorVariantID = workflowProperties.Item [" IntroVariantID"]。ToString(); if(workflowProperties.Item [" Size"]!= null)vSize = workflowProperties.Item [" Size"]。ToString(); if(workflowProperties.Item [" Color"]!= null)vColor = workflowProperties.Item [" Color"]。ToString();
if(workflowProperties.Item [" Category_Name"]!= null)vCategory_Name = workflowProperties.Item [" Category_Name"]。ToString(); if(workflowProperties.Item [" Category_Display"]!= null)vCategory_Display = workflowProperties.Item [" Category_Display"]。ToString();
if(workflowProperties.Item [" Catalog_Name"]!= null)vCatalog_Name = workflowProperties.Item [" Catalog_Name"]。ToString(); if(workflowProperties.Item [" CatalogVariantID"]!= null)vCatalogVariantID = workflowProperties.Item [" CatalogVariantID"]。ToString(); if
(workflowProperties.Item [" Back_Orderable"]!= null)vBack_Orderable = workflowProperties.Item [" Back_Orderable"]。ToString(); if(workflowProperties.Item [" Back_Order_Limit"]!= null)vBack_Order_Limit = workflowProperties.Item [" Back_Order_Limit"]。ToString();
if(workflowProperties.Item [" PreOrderable"]!= null)vPreOrderable = workflowProperties.Item [" PreOrderable"]。ToString(); if(workflowProperties.Item [" PreOrderQuantity"]!= null)vPreOrderQuantity = workflowProperties.Item [" PreOrderQuantity"]。ToString(); if
(workflowProperties.Item [" OnHandQuantity"]!= null)vOnHandQuantity = workflowProperties.Item [" OnHandQuantity"]。ToString(); if(workflowProperties.Item [" ReOrderPoint"]!= null)vReOrderPoint = workflowProperties.Item [" ReOrderPoint"]。ToString(); if(workflowProperties.Item [" Last_Restocked"]
!= null)vLast_Restocked = workflowProperties.Item [" Last_Restocked"]。ToString(); if(workflowProperties.Item [" Excess_Onhand_Quantity"]!= null)vExcess_Onhand_Quantity = workflowProperties.Item [" Excess_Onhand_Quantity"]。ToString(); if(workflowProperties.Item [" Target_Quantity"]
!= null)vTarget_Quantity = workflowProperties.Item [" Target_Quantity"]。ToString(); if(workflowProperties.Item [" Product_Type"]!= null)vProduct_Type = workflowProperties.Item [" Product_Type"]。ToString(); if(workflowProperties.Item [" Status"]!= null)vStatus
= workflowProperties.Item [" Status"]。ToString(); decimal dList_Price = System.Convert.ToDecimal(vList_Price); //创建CatalogSiteAgent以连接到数据库。 CatalogSiteAgent catalogSiteAgent = new CatalogSiteAgent(); catalogSiteAgent.SiteName =" Management" ;;
catalogSiteAgent.AuthorizationMode = Microsoft.CommerceServer.AuthorizationMode.HttpContext; catalogSiteAgent.AuthorizationPolicyPath = @" C:\inetpub \ WildernessNorthWebServices\WildernessNorth_CatalogWebService\CatalogAuthorizationStore.xml" ;; //创建
CatalogContext对象。 CatalogContext catalogContext = CatalogContext.Create(catalogSiteAgent); //获取目录BaseCatalog baseCatalog =(BaseCatalog)catalogContext.GetCatalog(" Adventure Works Catalog"); //检查产品是否已存在//
获取要搜索的类别。 CatalogSearch search = catalogContext.GetCatalogSearch(); search.CatalogNames = baseCatalog.Name; search.SqlWhereClause = vCategory_Name; // CatalogItemsDataSetSchema.CategoryName = baseCatalog.GetCategory(vCategory_Name); CatalogItemsDataSet
dataSet = search.Search(); //遍历类别中的项目,搜索产品名称foreach(dataSet.CatalogItems中的CatalogItemsDataSet.CatalogItem catalogItem){//如果找到产品,请将wfProductFound设置为if if(catalogItem.DisplayName ==
vDisplay_Name.ToString ()){wfProductFound = true; //catalogItem.ListPrice + = 5; //更新catelog项目catalogItem [" ProductID"] = workflowProperties.Item [" ProductID"]。ToString(); catalogItem [" Definition_Name"] = workflowProperties.Item [" Definition_Name"]。ToString();
catalogItem [" Display_Name"] = workflowProperties.Item [" Display_Name"]。ToString(); catalogItem [" List_Price"] = workflowProperties.Item [" List_Price"]。ToString(); catalogItem [" Category_Price"] = workflowProperties.Item [" Category_Price"]。ToString(); catalogItem [" Description"]
= workflowProperties.Item [" Description"]。ToString(); catalogItem [" On_Sale"] = workflowProperties.Item [" On_Sale"]。ToString(); catalogItem [" Brand_Name"] = workflowProperties.Item [" Brand_Name"]。ToString(); catalogItem [" Brand_Name_Display"] = workflowProperties.Item [" Brand_Name_Display"]。ToString();
catalogItem [" Image_filename"] = workflowProperties.Item [" Image_filename"]。ToString(); catalogItem [" Image_height"] = workflowProperties.Item [" Image_height"]。ToString(); catalogItem [" Image_width"] = workflowProperties.Item [" Image_width"]。ToString(); catalogItem [" Introduction_Date"]
= workflowProperties.Item [" Introduction_Date"]。ToString(); catalogItem [" IntroVariantID"] = workflowProperties.Item [" IntroVariantID"]。ToString(); catalogItem [" Size"] = workflowProperties.Item [" Size"]。ToString(); catalogItem [" Color"] = workflowProperties.Item [" Color"]。ToString();
catalogItem [" Category_Name"] = workflowProperties.Item [" Category_Name"]。ToString(); catalogItem [" Category_Display"] = workflowProperties.Item [" Category_Display"]。ToString(); catalogItem [" Catalog_Name"] = workflowProperties.Item [" Catalog_Name"]。ToString();
catalogItem [" CatalogVariantID"] = workflowProperties.Item [" CatalogVariantID"]。ToString(); catalogItem [" Back_Orderable"] = workflowProperties.Item [" Back_Orderable"]。ToString(); catalogItem [" Back_Order_Limit"] = workflowProperties.Item [" Back_Order_Limit"]。ToString();
catalogItem [" PreOrderable"] = workflowProperties.Item [" PreOrderable"]。ToString(); catalogItem [" PreOrderQuantity"] = workflowProperties.Item [" PreOrderQuantity"]。ToString(); catalogItem [" OnHandQuantity"] = workflowProperties.Item [" OnHandQuantity"]。ToString();
catalogItem [" ReOrderPoint"] = workflowProperties.Item [" ReOrderPoint"]。ToString(); catalogItem [" Last_Restocked"] = workflowProperties.Item [" Last_Restocked"]。ToString(); catalogItem [" Excess_OnHand_Quantity"] = workflowProperties.Item [" Excess_OnHand_Quantity"]。ToString();
catalogItem [" Target_Quantity"] = workflowProperties.Item [" Target_Quantity"]。ToString(); catalogItem [" Product_Type"] = workflowProperties.Item [" Product_Type"]。ToString(); catalogItem [" Status"] = workflowProperties.Item [" Status"]。ToString(); if(wfProductFound
== true){//更新项目。 baseCatalog.UpdateItems(数据集); } else {try {//为产品创建自定义属性。 CatalogProperty size = catalogContext.CreateProperty(" Size",CatalogDataType.String,250); CatalogProperty solePattern = catalogContext.CreateProperty(" Sole
Pattern",CatalogDataType.String,250); //为目录中的ProductID创建产品定义。 CatalogDefinition productDefinition = catalogContext.CreateDefinition(vProductID.ToString(),CatalogDefinitionType.ProductDefinition); //将属性
添加到产品定义并保存定义。 productDefinition.AddProperty(size.Name,DefinitionPropertyType.NormalProperty); productDefinition.AddProperty(solePattern.Name,DefinitionPropertyType.NormalProperty); productDefinition.Save(); //将
产品添加到目录中的Footwear类别。 Product newproduct = baseCatalog.CreateProduct(productDefinition.Name,vDefinition_Name.ToString(),dList_Price,vCategory_Name.ToString()); //定义产品的属性并保存。 newproduct [" ProductID"]
= workflowProperties.Item [" ProductID"]。ToString(); newproduct [" Definition_Name"] = workflowProperties.Item [" Definition_Name"]。ToString(); newproduct [" Display_Name"] = workflowProperties.Item [" Display_Name"]。ToString(); newproduct [" List_Price"] = workflowProperties.Item [" List_Price"]。ToString();
newproduct [" Category_Price"] = workflowProperties.Item [" Category_Price"]。ToString(); newproduct [" Description"] = workflowProperties.Item [" Description"]。ToString(); newproduct [" On_Sale"] = workflowProperties.Item [" On_Sale"]。ToString(); newproduct [" Brand_Name"]
= workflowProperties.Item [" Brand_Name"]。ToString(); newproduct [" Brand_Name_Display"] = workflowProperties.Item [" Brand_Name_Display"]。ToString(); newproduct [" Image_filename"] = workflowProperties.Item [" Image_filename"]。ToString(); newproduct [" Image_height"]
= workflowProperties.Item [" Image_height"]。ToString(); newproduct [" Image_width"] = workflowProperties.Item [" Image_width"]。ToString(); newproduct [" Introduction_Date"] = workflowProperties.Item [" Introduction_Date"]。ToString(); newproduct [" IntroVariantID"] = workflowProperties.Item [" IntroVariantID"]。ToString();
newproduct [" Size"] = workflowProperties.Item [" Size"]。ToString(); newproduct [" Color"] = workflowProperties.Item [" Color"]。ToString(); newproduct [" Category_Name"] = workflowProperties.Item [" Category_Name"]。ToString(); newproduct [" Category_Display"] = workflowProperties.Item [" Category_Display"]。ToString();
newproduct [" Catalog_Name"] = workflowProperties.Item [" Catalog_Name"]。ToString(); newproduct [" CatalogVariantID"] = workflowProperties.Item [" CatalogVariantID"]。ToString(); newproduct [" Back_Orderable"] = workflowProperties.Item [" Back_Orderable"]。ToString(); newproduct [" Back_Order_Limit"]
= workflowProperties.Item [" Back_Order_Limit"]。ToString(); newproduct [" PreOrderable"] = workflowProperties.Item [" PreOrderable"]。ToString(); newproduct [" PreOrderQuantity"] = workflowProperties.Item [" PreOrderQuantity"]。ToString(); newproduct [" OnHandQuantity"]
= workflowProperties.Item [" OnHandQuantity"]。ToString(); newproduct [" ReOrderPoint"] = workflowProperties.Item [" ReOrderPoint"]。ToString(); newproduct [" Last_Restocked"] = workflowProperties.Item [" Last_Restocked"]。ToString(); newproduct [" Excess_OnHand_Quantity"]
= workflowProperties.Item [" Excess_OnHand_Quantity"]。ToString(); newproduct [" Target_Quantity"] = workflowProperties.Item [" Target_Quantity"]。ToString(); newproduct [" Product_Type"] = workflowProperties.Item [" Product_Type"]。ToString(); newproduct [" Status"] = workflowProperties.Item [" Status"]。ToString();
newproduct.Save(); } catch(Exception e){Console.WriteLine(string.Format(" Exception:{0}",e.Message)); private void onWorkflowActivated(object sender,ExternalDataEventArgs e){wf_updateProductInfo(); private void isWorkflowPending(object sender,
ConditionalEventArgs e){e.Result = wfPending;步骤++; private void onWorkflowItemChanged(object sender,ExternalDataEventArgs e){wf_updateProductInfo();



Robert Ware电子邮件:robert.ware@peakuptime.com |网站:http://www.peakuptime.com

The following code is called from sharepoint workflow sequencial: Get the following error located at CatalogContext catalogContext = CatalogContext.Create(catalogSiteAgent) below: Error message is: 1)Cannot evaluate expression because the code of the current method is optimized. 2)There was a problem reading the site resources from the Commerce Server administration database for the site 'Management'. Please check that resources exist for the site and that the process has permission to access the database. The InnerException contains more details using System; using System.ComponentModel; using System.ComponentModel.Design; using System.Collections; using System.Drawing; using System.Linq; using System.Workflow.ComponentModel.Compiler; using System.Workflow.ComponentModel.Serialization; using System.Workflow.ComponentModel; using System.Workflow.ComponentModel.Design; using System.Workflow.Runtime; using System.Workflow.Activities; using System.Workflow.Activities.Rules; using Microsoft.SharePoint; using Microsoft.SharePoint.Workflow; using Microsoft.SharePoint.WorkflowActions; using System.Data; using System.Data.Sql; using System.Data.SqlClient; using System.Data.SqlTypes; using Microsoft.CommerceServer; using Microsoft.CommerceServer.Catalog; using Microsoft.CommerceServer.Inventory; namespace ProductListWF.ProductUpdateWF { public sealed partial class ProductUpdateWF : SequentialWorkflowActivity { public ProductUpdateWF() { InitializeComponent(); } public Guid workflowId = default(System.Guid); public SPWorkflowActivationProperties workflowProperties = new SPWorkflowActivationProperties(); bool wfPending = true;/* Stop workflow when false */ int step = 0;/* 0-Does Product Exists */ bool wfProductFound = false; void wf_updateProductInfo() { switch (step) { case 0: updateInventory(); // Update product if exists, else create new product break; case 1: break; case 2: break; default: wfPending = false; break; } } // Update product if exists, else create new product void updateInventory() { string vProductID = ""; string vDefinition_Name = ""; string vDisplay_Name = ""; string vList_Price = "0"; string vCategory_Price = ""; string vDescription = ""; string vOn_Sale = ""; string vBrand_Name = ""; string vBrand_Name_Display = ""; string vImage_filename = ""; string vImage_height = ""; string vImage_width = ""; string vIntroduction_Date = ""; string vIntorVariantID = ""; string vSize = ""; string vColor = ""; string vCategory_Name = ""; string vCategory_Display = ""; string vCatalog_Name = ""; string vCatalogVariantID = ""; string vBack_Orderable = ""; string vBack_Order_Limit = ""; string vPreOrderable = ""; string vPreOrderQuantity = ""; string vOnHandQuantity = ""; string vReOrderPoint = ""; string vLast_Restocked = ""; string vExcess_Onhand_Quantity = ""; string vTarget_Quantity = ""; string vProduct_Type = ""; string vStatus = ""; if( workflowProperties.Item["ProductID"] != null) vProductID = workflowProperties.Item["ProductID"].ToString(); if( workflowProperties.Item["Definition_Name"] != null) vDefinition_Name = workflowProperties.Item["Definition_Name"].ToString(); if( workflowProperties.Item["Display_Name"] != null) vDisplay_Name = workflowProperties.Item["Display_Name"].ToString(); if( workflowProperties.Item["List_Price"] != null) vList_Price = workflowProperties.Item["List_Price"].ToString(); if( workflowProperties.Item["Category_Price"] != null) vCategory_Price = workflowProperties.Item["Category_Price"].ToString(); if (workflowProperties.Item["Description"] != null) vDescription = workflowProperties.Item["Description"].ToString(); if (workflowProperties.Item["On_Sale"] != null) vOn_Sale = workflowProperties.Item["On_Sale"].ToString(); if (workflowProperties.Item["Brand_Name"] != null) vBrand_Name = workflowProperties.Item["Brand_Name"].ToString(); if (workflowProperties.Item["Brand_Name_Display"] != null) vBrand_Name_Display = workflowProperties.Item["Brand_Name_Display"].ToString(); if (workflowProperties.Item["Image_filename"] != null) vImage_filename = workflowProperties.Item["Image_filename"].ToString(); if (workflowProperties.Item["Image_height"] != null) vImage_height = workflowProperties.Item["Image_height"].ToString(); if (workflowProperties.Item["Image_height"] != null) vImage_width = workflowProperties.Item["Image_height"].ToString(); if (workflowProperties.Item["Introduction_Date"] != null) vIntroduction_Date = workflowProperties.Item["Introduction_Date"].ToString(); if (workflowProperties.Item["IntroVariantID"] != null) vIntorVariantID = workflowProperties.Item["IntroVariantID"].ToString(); if( workflowProperties.Item["Size"] != null) vSize = workflowProperties.Item["Size"].ToString(); if (workflowProperties.Item["Color"] != null) vColor = workflowProperties.Item["Color"].ToString(); if (workflowProperties.Item["Category_Name"] != null) vCategory_Name = workflowProperties.Item["Category_Name"].ToString(); if (workflowProperties.Item["Category_Display"] != null) vCategory_Display = workflowProperties.Item["Category_Display"].ToString(); if (workflowProperties.Item["Catalog_Name"] != null) vCatalog_Name = workflowProperties.Item["Catalog_Name"].ToString(); if (workflowProperties.Item["CatalogVariantID"] != null) vCatalogVariantID = workflowProperties.Item["CatalogVariantID"].ToString(); if (workflowProperties.Item["Back_Orderable"] != null) vBack_Orderable = workflowProperties.Item["Back_Orderable"].ToString(); if (workflowProperties.Item["Back_Order_Limit"] != null) vBack_Order_Limit = workflowProperties.Item["Back_Order_Limit"].ToString(); if (workflowProperties.Item["PreOrderable"] != null) vPreOrderable = workflowProperties.Item["PreOrderable"].ToString(); if (workflowProperties.Item["PreOrderQuantity"] != null) vPreOrderQuantity = workflowProperties.Item["PreOrderQuantity"].ToString(); if (workflowProperties.Item["OnHandQuantity"] != null) vOnHandQuantity = workflowProperties.Item["OnHandQuantity"].ToString(); if (workflowProperties.Item["ReOrderPoint"] != null) vReOrderPoint = workflowProperties.Item["ReOrderPoint"].ToString(); if (workflowProperties.Item["Last_Restocked"] != null) vLast_Restocked = workflowProperties.Item["Last_Restocked"].ToString(); if (workflowProperties.Item["Excess_Onhand_Quantity"] != null) vExcess_Onhand_Quantity = workflowProperties.Item["Excess_Onhand_Quantity"].ToString(); if (workflowProperties.Item["Target_Quantity"] != null) vTarget_Quantity = workflowProperties.Item["Target_Quantity"].ToString(); if (workflowProperties.Item["Product_Type"] != null) vProduct_Type = workflowProperties.Item["Product_Type"].ToString(); if (workflowProperties.Item["Status"] != null) vStatus = workflowProperties.Item["Status"].ToString(); decimal dList_Price = System.Convert.ToDecimal(vList_Price); // Create a CatalogSiteAgent to connect to the database. CatalogSiteAgent catalogSiteAgent = new CatalogSiteAgent(); catalogSiteAgent.SiteName = "Management"; catalogSiteAgent.AuthorizationMode = Microsoft.CommerceServer.AuthorizationMode.HttpContext; catalogSiteAgent.AuthorizationPolicyPath = @"C:\inetpub\WildernessNorthWebServices\WildernessNorth_CatalogWebService\CatalogAuthorizationStore.xml"; // Create the CatalogContext object. CatalogContext catalogContext = CatalogContext.Create(catalogSiteAgent); // Get the catalog. BaseCatalog baseCatalog = (BaseCatalog)catalogContext.GetCatalog("Adventure Works Catalog"); // Check to see if the product already exists // Get a category to search. CatalogSearch search = catalogContext.GetCatalogSearch(); search.CatalogNames = baseCatalog.Name; search.SqlWhereClause = vCategory_Name;//CatalogItemsDataSetSchema.CategoryName = baseCatalog.GetCategory(vCategory_Name); CatalogItemsDataSet dataSet = search.Search(); // Iterate through the items in the category, search for product name foreach (CatalogItemsDataSet.CatalogItem catalogItem in dataSet.CatalogItems) { // If product found, set wfProductFound to found if (catalogItem.DisplayName == vDisplay_Name.ToString()) { wfProductFound = true; //catalogItem.ListPrice += 5;//Update the catelog items catalogItem["ProductID"] = workflowProperties.Item["ProductID"].ToString(); catalogItem["Definition_Name"] = workflowProperties.Item["Definition_Name"].ToString(); catalogItem["Display_Name"] = workflowProperties.Item["Display_Name"].ToString(); catalogItem["List_Price"] = workflowProperties.Item["List_Price"].ToString(); catalogItem["Category_Price"] = workflowProperties.Item["Category_Price"].ToString(); catalogItem["Description"] = workflowProperties.Item["Description"].ToString(); catalogItem["On_Sale"] = workflowProperties.Item["On_Sale"].ToString(); catalogItem["Brand_Name"] = workflowProperties.Item["Brand_Name"].ToString(); catalogItem["Brand_Name_Display"] = workflowProperties.Item["Brand_Name_Display"].ToString(); catalogItem["Image_filename"] = workflowProperties.Item["Image_filename"].ToString(); catalogItem["Image_height"] = workflowProperties.Item["Image_height"].ToString(); catalogItem["Image_width"] = workflowProperties.Item["Image_width"].ToString(); catalogItem["Introduction_Date"] = workflowProperties.Item["Introduction_Date"].ToString(); catalogItem["IntroVariantID"] = workflowProperties.Item["IntroVariantID"].ToString(); catalogItem["Size"] = workflowProperties.Item["Size"].ToString(); catalogItem["Color"] = workflowProperties.Item["Color"].ToString(); catalogItem["Category_Name"] = workflowProperties.Item["Category_Name"].ToString(); catalogItem["Category_Display"] = workflowProperties.Item["Category_Display"].ToString(); catalogItem["Catalog_Name"] = workflowProperties.Item["Catalog_Name"].ToString(); catalogItem["CatalogVariantID"] = workflowProperties.Item["CatalogVariantID"].ToString(); catalogItem["Back_Orderable"] = workflowProperties.Item["Back_Orderable"].ToString(); catalogItem["Back_Order_Limit"] = workflowProperties.Item["Back_Order_Limit"].ToString(); catalogItem["PreOrderable"] = workflowProperties.Item["PreOrderable"].ToString(); catalogItem["PreOrderQuantity"] = workflowProperties.Item["PreOrderQuantity"].ToString(); catalogItem["OnHandQuantity"] = workflowProperties.Item["OnHandQuantity"].ToString(); catalogItem["ReOrderPoint"] = workflowProperties.Item["ReOrderPoint"].ToString(); catalogItem["Last_Restocked"] = workflowProperties.Item["Last_Restocked"].ToString(); catalogItem["Excess_OnHand_Quantity"] = workflowProperties.Item["Excess_OnHand_Quantity"].ToString(); catalogItem["Target_Quantity"] = workflowProperties.Item["Target_Quantity"].ToString(); catalogItem["Product_Type"] = workflowProperties.Item["Product_Type"].ToString(); catalogItem["Status"] = workflowProperties.Item["Status"].ToString(); } } if (wfProductFound == true) { // Update the items. baseCatalog.UpdateItems(dataSet); }else{ try { // Create the custom properties for the product. CatalogProperty size = catalogContext.CreateProperty("Size", CatalogDataType.String, 250); CatalogProperty solePattern = catalogContext.CreateProperty("Sole Pattern", CatalogDataType.String, 250); // Create a product definition for the ProductID in the catalog. CatalogDefinition productDefinition = catalogContext.CreateDefinition(vProductID.ToString(), CatalogDefinitionType.ProductDefinition); // Add the properties to the product definition and save the definition. productDefinition.AddProperty(size.Name, DefinitionPropertyType.NormalProperty); productDefinition.AddProperty(solePattern.Name, DefinitionPropertyType.NormalProperty); productDefinition.Save(); // Add the product to the Footwear category in the catalog. Product newproduct = baseCatalog.CreateProduct(productDefinition.Name, vDefinition_Name.ToString(), dList_Price, vCategory_Name.ToString()); // Define the properties of the product and save. newproduct["ProductID"] = workflowProperties.Item["ProductID"].ToString(); newproduct["Definition_Name"] = workflowProperties.Item["Definition_Name"].ToString(); newproduct["Display_Name"] = workflowProperties.Item["Display_Name"].ToString(); newproduct["List_Price"] = workflowProperties.Item["List_Price"].ToString(); newproduct["Category_Price"] = workflowProperties.Item["Category_Price"].ToString(); newproduct["Description"] = workflowProperties.Item["Description"].ToString(); newproduct["On_Sale"] = workflowProperties.Item["On_Sale"].ToString(); newproduct["Brand_Name"] = workflowProperties.Item["Brand_Name"].ToString(); newproduct["Brand_Name_Display"] = workflowProperties.Item["Brand_Name_Display"].ToString(); newproduct["Image_filename"] = workflowProperties.Item["Image_filename"].ToString(); newproduct["Image_height"] = workflowProperties.Item["Image_height"].ToString(); newproduct["Image_width"] = workflowProperties.Item["Image_width"].ToString(); newproduct["Introduction_Date"] = workflowProperties.Item["Introduction_Date"].ToString(); newproduct["IntroVariantID"] = workflowProperties.Item["IntroVariantID"].ToString(); newproduct["Size"] = workflowProperties.Item["Size"].ToString(); newproduct["Color"] = workflowProperties.Item["Color"].ToString(); newproduct["Category_Name"] = workflowProperties.Item["Category_Name"].ToString(); newproduct["Category_Display"] = workflowProperties.Item["Category_Display"].ToString(); newproduct["Catalog_Name"] = workflowProperties.Item["Catalog_Name"].ToString(); newproduct["CatalogVariantID"] = workflowProperties.Item["CatalogVariantID"].ToString(); newproduct["Back_Orderable"] = workflowProperties.Item["Back_Orderable"].ToString(); newproduct["Back_Order_Limit"] = workflowProperties.Item["Back_Order_Limit"].ToString(); newproduct["PreOrderable"] = workflowProperties.Item["PreOrderable"].ToString(); newproduct["PreOrderQuantity"] = workflowProperties.Item["PreOrderQuantity"].ToString(); newproduct["OnHandQuantity"] = workflowProperties.Item["OnHandQuantity"].ToString(); newproduct["ReOrderPoint"] = workflowProperties.Item["ReOrderPoint"].ToString(); newproduct["Last_Restocked"] = workflowProperties.Item["Last_Restocked"].ToString(); newproduct["Excess_OnHand_Quantity"] = workflowProperties.Item["Excess_OnHand_Quantity"].ToString(); newproduct["Target_Quantity"] = workflowProperties.Item["Target_Quantity"].ToString(); newproduct["Product_Type"] = workflowProperties.Item["Product_Type"].ToString(); newproduct["Status"] = workflowProperties.Item["Status"].ToString(); newproduct.Save(); } catch (Exception e) { Console.WriteLine(string.Format("Exception: {0}", e.Message)); } } } private void onWorkflowActivated(object sender, ExternalDataEventArgs e) { wf_updateProductInfo(); } private void isWorkflowPending(object sender, ConditionalEventArgs e) { e.Result = wfPending; step++; } private void onWorkflowItemChanged(object sender, ExternalDataEventArgs e) { wf_updateProductInfo(); } } }


Robert Ware E-Mail: robert.ware@peakuptime.com | Website: http://www.peakuptime.com

推荐答案

您的网站名称是什么? '管理'或 或'WildernessNorth'


这篇关于创建产品或更新产品获取错误CatalogContext.Create(catalogSiteAgent);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆