0

我在手术后有一个插件,需要通过 web 服务在 sharepoint 上创建一个文件夹,为此,我的插件调用 web 服务来执行 FechXML 以从实体获取信息,但问题是该实体仍然不存在,它给了我Null。

如何强制插件将数据提交/保存到我的 FechXml 才能工作?

插件代码:

try
    {
        Entity entity;
        if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
        {
            entity = (Entity)context.InputParameters["Target"];
            if (entity.LogicalName != "fcg_processos")
            {

                throw new InvalidPluginExecutionException("Ocorreu um erro no PlugIn Create Folder.");
            }
        }
        else
        {

            throw new InvalidPluginExecutionException("Ocorreu um erro no PlugIn Create Folder.");
        }

        processosid = (Guid)((Entity)context.InputParameters["Target"])["fcg_processosid"];
        string processoid2 = processosid.ToString();


        PluginSharepointProcessos.ServiceReference.PrxActivityResult result = log.CreateFolderSP("Processo", processoid2);

        string resultado = result.xmlContent;

        if (result.retCode > 0)
        {
            throw new InvalidPluginExecutionException("Ocorreu um erro na criação do Folder do Processo.");

        }

网络服务代码:

 {          
            //WEBSERVICE TO CALL XML FROM ENTITY
            PrxActivityResult Processo = ProcessoFetch2("", "", guid);
            string stxml;
            stxml = Processo.XmlContent;
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(stxml);
            XmlNodeList nodeList = xmlDoc.SelectNodes("resultset/result");
            List<string[]> lista = new List<string[]>();
            string[] strs = new string[7];
            if (nodeList.Count != 0)//verificar o numero de registos
            {

                foreach (XmlNode xmlnode in nodeList)
                {
                    if (xmlnode.SelectSingleNode("//fcg_numero") != null)
                        strs[2] = xmlnode.SelectSingleNode("//fcg_numero").InnerText;
                    else
                        strs[2] = "";

                    if (xmlnode.SelectSingleNode("//Concurso.fcg_numero") != null)
                        strs[3] = xmlnode.SelectSingleNode("//Concurso.fcg_numero").InnerText;
                    else
                        strs[3] = "";
                }

            }

        IwsspClient FmwSharepoint = new IwsspClient();
        PrxActivityResult folderresult = new PrxActivityResult();

        List<ws.fcg.sipp.svc.ServiceReferenceSharePoint.PareChave> arrayfields = new List<ws.fcg.sipp.svc.ServiceReferenceSharePoint.PareChave>();

        ws.fcg.sipp.svc.ServiceReferenceSharePoint.PareChave nprocesso = new ws.fcg.sipp.svc.ServiceReferenceSharePoint.PareChave();
        nprocesso.Key = "FCG_Numero_Processo";
        nprocesso.value = strs[2];
        arrayfields.Add(nprocesso);

        ws.fcg.sipp.svc.ServiceReferenceSharePoint.PareChave npconcurso = new ws.fcg.sipp.svc.ServiceReferenceSharePoint.PareChave();
        npconcurso.Key = "FCG_Numero_Concurso";
        npconcurso.value = strs[3];
        arrayfields.Add(npconcurso);

        ws.fcg.sipp.svc.ServiceReferenceSharePoint.PareChave npguid = new ws.fcg.sipp.svc.ServiceReferenceSharePoint.PareChave();
        npguid.Key = "FCG_Guid_CRM";
        npguid.value = guid;
        arrayfields.Add(npguid);

        folderresult = FmwSharepoint.CreateFolder("http://localhost/folder", "Processos", strs[2], arrayfields.ToArray());

        res = folderresult;
        }
4

2 回答 2

2

当插件在 Post-Operation 上运行时,它仍然在数据库事务中,实际上并没有提交到数据库。使用作为插件上下文的一部分传入的服务引用完成的任何调用都将在数据库事务的上下文中执行,您将能够检索新创建/更新的值。如果您创建一个全新的 OrganizationServiceProxy (我猜这就是您正在做的事情),它将在数据库事务之外执行,并且不会看到新创建/更新的值。

正如@AndyMeyers 在他的评论中建议的那样(这真的应该是一个答案恕我直言),通过前/后图像或目标从插件上下文中获取数据是理想的,因为它消除了另一个数据库调用。如果您必须查找可能由之前触发的另一个插件创建的记录,则需要使用插件上下文中包含的 IOrganizationService。

于 2013-04-23T13:06:53.423 回答
0

我别无选择,我使用此代码基于图像运行 web 服务并忘记了 FecthXml,如前所述,我在后期操作中从图像中获取所有信息并发送回 Web 服务。谢谢,代码如下:

 entity = (Entity)context.InputParameters["Target"];

            concursid = (Guid)entity.Attributes["fcg_concursid"];
            guid = concursid.ToString();

            string npconcurs = (string)entity.Attributes["fcg_numer"];
            nconcurs= npconcurs;

            EntityReference nprograma = (EntityReference)entity.Attributes["fcg_unidadeorganica"];

            program = nprogram.Name;

            if (entity.LogicalName != "fcg_concurs")
于 2013-04-23T22:00:26.853 回答