2009-12-16 12 views
5

Sto tentando di caricare un documento dal mio computer locale utilizzando il servizio web Copy.asmx, il metodo CopyIntoItems. Posso caricare correttamente il documento e una proprietà DateTime ma non riesco ad aggiornare una proprietà di ricerca della raccolta documenti. Sto usando MOSS 2007 con SP2non può aggiornare il campo di ricerca durante il caricamento del documento utilizzando CopyIntoItems

Il codice che sto usando è la seguente:

string[] destinationUrls = { Uri.EscapeUriString(destinationUrl) }; 

CopySharepointService.FieldInformation dateInformation = new CopySharepointService.FieldInformation(); 
dateInformation.DisplayName = "Date"; 
dateInformation.Type = CopySharepointService.FieldType.DateTime; 
dateInformation.Value = DateTime.Today.ToString(); 

CopySharepointService.FieldInformation fundInformation = new CopySharepointService.FieldInformation(); 
fundInformation.DisplayName = "Fund"; 
fundInformation.Type = CopySharepointService.FieldType.Lookup; 
fundInformation.Id = new Guid(fundGuidItem); // This is the GUID of the field being updated in the document library 
fundInformation.Value = "1"; 

CopySharepointService.FieldInformation[] info = { dateInformation, fundInformation };    
CopySharepointService.CopyResult[] result;  
CopySharepointService.CopySoapClient CopyService2007 = new CopySoapClient("CopySoap"); 

CopyService2007.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials; 
CopyService2007.CopyIntoItems(destinationUrl, destinationUrls, info, fileData, out result); 

Il documento è caricato con successo, ma il campo di ricerca non viene aggiornato

Qualcuno può aiutarmi?

risposta

4

Ho appena trovato questa discussione:.

"Purtroppo, i CopyIntoItems volontà non mettere le informazioni in campi di 'File', 'computerizzata' o 'tipi di ricerca diretta' Il servizio web utilizza CopyIntoItem della classe SPCopy che fa un chiamare un metodo privato chiamato FieldShouldBeCopiedTo. Questo metodo contiene la logica che impedisce la copia dei campi di ricerca. "

http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/2fdc9933-ddb8-446f-80ad-6c8e17dfdb6f

Odio SharePoint volte.

1

Non c'è modo di farlo ragazzi; l'unica alternativa è riconnettersi, ottenere l'elemento della lista stessa e aggiornare i metadati in questo modo. Ricorda: campi di ricerca hanno bisogno di utilizzare il formato di number;# - quindi se se fosse, se i dati sono stati:

12;#Some Option 

Usa 12;# in Xml Batch Update.

0

Sfortunatamente, è necessario eseguire una chiamata UpdateListItems per impostare tutti i metadati "divertenti".

Dall'esempio nel link:

Web_Reference_Folder.Lists listService = new Web_Reference_Folder.Lists(); 
listService.Credentials= System.Net.CredentialCache.DefaultCredentials; 

string strBatch = "<Method ID='1' Cmd='Update'>" + 
    "<Field Name='ID'>4</Field>" + 
    "<Field Name='Field_Number'>999</Field></Method>" + 
    "<Method ID='2' Cmd='Update'><Field Name='ID' >6</Field>" + 
    "<Field Name='Field_DateTime'> 
     2003-11-11T09:15:30Z</Field></Method>"; 

XmlDocument xmlDoc = new System.Xml.XmlDocument(); 

System.Xml.XmlElement elBatch = xmlDoc.CreateElement("Batch"); 

elBatch.SetAttribute("OnError","Continue"); 
elBatch.SetAttribute("ListVersion","1"); 
elBatch.SetAttribute("ViewName", 
    "0d7fcacd-1d7c-45bc-bcfc-6d7f7d2eeb40"); 

elBatch.InnerXml = strBatch; 

XmlNode ndReturn = listService.UpdateListItems("List_Name", elBatch); 

MessageBox.Show(ndReturn.OuterXml); 
+0

Avete un link ad un esempio, forse? – mydoghasworms

Problemi correlati