2013-04-23 3 views
0

나는 post-operation witch에서 플러그인을 가지고 webservice를 통해 sharepoint에 폴더를 만들 필요가있다. 플러그인은 엔티티에서 정보를 얻기 위해 FechXML을 실행하기 위해 webservice를 호출하지만 문제는 엔티티가 아직 없다는 것이다. 존재하고, 그것은 나에게 널을 준다.플러그인을 사후 작업시 강제로 제출하는 방법은 무엇입니까?

플러그인이 강제로 데이터를 내 FechXml에 저장하여 작동하도록하려면 어떻게해야합니까?

플러그인 CODE :

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 코드 :

{   
      //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; 
     } 
+1

엔티티에서 사후 작업을 수행하는 경우 정의에 따라 트랜잭션이 처리됩니다. 또한 현재 엔티티에서 데이터를 가져 오는 경우 플러그인을 사용하면 컨텍스트 및 프리/포스트 이미지에서 해당 데이터를 가져 와서 추가 호출을 할 필요가 없습니다. 코드를 표시하면 다른 사람들도 쉽게 도움이 될 것입니다. –

+0

코드로 게시물을 편집하기 만하면됩니다. –

+0

FetchXml 쿼리를 실제로 수행하는 위치가 표시되지 않습니다. ProcessoFetch2에 있습니까? – Daryl

답변

2

플러그인이 사후 작업에서 실행, 그것은 데이터베이스 트랜잭션 내에서 여전히이며, 실제로하지 않은 데이터베이스에 커밋되었습니다. 플러그인 컨텍스트의 일부로 전달 된 서비스 참조로 수행 된 모든 호출은 데이터베이스 트랜잭션의 컨텍스트 내에서 실행되며 새로 생성/업데이트 된 값을 검색 할 수 있습니다. 당신이 새로운 OrganizationServiceProxy (내가하고있는 일이라고 추측합니다)를 만들면, 데이터베이스 트랜잭션 외부에서 실행되고 새로 생성/업데이트 된 값을 볼 수 없습니다.

@AndyMeyers는 자신의 의견 (실제로 IMHO 대답이어야 함)에서 이전/이후 이미지 또는 대상을 통해 플러그인 컨텍스트에서 데이터를 가져 오는 것이 다른 데이터베이스 호출을 제거하므로 이상적이라고 생각합니다. 이전에 해고 한 다른 플러그인에 의해 생성 된 레코드를 조회해야하는 경우 플러그인 컨텍스트에 포함 된 IOrganizationService를 사용해야합니다.

+0

+1 포스트 플러그인이 여전히 트랜잭션에 있음을 수정합니다. 이전 버전의 CRM (4.0)에서는 이것이 사실이 아니었고 제 전선이 섞여 있다고 생각합니다. –

0

나는 옵션이 없었고 이미지 기반의 webservice를 실행하기 위해이 코드를 사용했는데 FecthXml을 잊어 버렸습니다. 언급 한 것처럼, 나는 Post 작업의 Image에서 모든 정보를 얻었고 WebService로 다시 보냅니다. 감사합니다. 코드는 다음과 같습니다.

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") 
관련 문제