Żid il-webreference għall-Lists.asmx fis-sit SharePoint.
http://localhost / _vti_bin / Lists.asmx
(SharePoint Direttorju virtwali ikteb / _vti_bin / Lists.asmx
jiktbu l-metodi li ġejjin fil-webservice tiegħek.
privati data.DataTable GetDataTableFromWSS(onlySchema bool)
{
sekwenza WssSiteUrl = http://192.168.111.21;
sekwenza WssSiteUrl = ConfigurationSettings.AppSettings[“WssSiteUrl”];
WssSite.Lists listi = WssSite.Lists ġodda();
lists.Url = WssSiteUrl + “_vti_bin / Lists.asmx”;
lists.Credentials = System.Net.CredentialCache.DefaultCredentials;
lists.PreAuthenticate = veru;
//trid tgħaddi l-Isem Lista hawn
sekwenza CommandText = “Informazzjoni impjegat”;
XmlNode = lists.GetListCollection ListCollectionNode();
Lista XmlElement = (XmlElement)ListCollectionNode.SelectSingleNode(String.Format(“WSS:Lista[@ Titolu = "{0}"]”, CommandText), NameSpaceMgr);
jekk (Lista == null)
{
tarmi ArgumentException ġodda(String.Format(“Il-lista {0} ma tista 'tinstab fis-sit {1}”, CommandText, WssSiteUrl));
}
TechListName string = List.GetAttribute(“Isem”);
riżultat data.DataTable = ġdid data.DataTable(“lista”);
Node XmlNode lists.GetList listinfo =(TechListName);
FieldRefs System.Text.StringBuilder = ġdid System.Text.StringBuilder();
DisplayNames System.Collections.Hashtable = ġdid System.Collections.Hashtable();
foreach (Qasam XmlElement fil ListInfoNode.SelectNodes(“WSS:Oqsma / WSS:Qasam”, NameSpaceMgr))
{
jekk (Field.HasChildNodes)
{
foreach (FLD XmlElement fil Field.SelectNodes(“WSS:Oqsma / WSS:Qasam”, NameSpaceMgr))
{
FieldName string = Fld.GetAttribute(“Isem”);
FieldDisplayName string = Fld.GetAttribute(“DisplayName”);
jekk (result.Columns.Contains(FieldDisplayName))
{
FieldDisplayName = FieldDisplayName + ” (” + FieldName + “)”;
}
result.Columns.Add(FieldDisplayName, TypeFromField(Qasam));
fieldRefs.AppendFormat(“”, FieldName);
DisplayNames.Add(FieldDisplayName, FieldName);
}
}
inkella
{
FieldName string = Field.GetAttribute(“Isem”);
FieldDisplayName string = Field.GetAttribute(“DisplayName”);
jekk (result.Columns.Contains(FieldDisplayName))
{
FieldDisplayName = FieldDisplayName + ” (” + FieldName + “)”;
}
result.Columns.Add(FieldDisplayName, TypeFromField(Qasam));
fieldRefs.AppendFormat(“”, FieldName);
DisplayNames.Add(FieldDisplayName, FieldName);
}
}
jekk (onlySchema) ritorn riżultat;
Oqsma XmlElement = ListInfoNode.OwnerDocument.CreateElement(“ViewFields”);
fields.InnerXml = fieldRefs.ToString();
XmlNode = ItemsNode lists.GetListItems(TechListName, “”, null, oqsma, “1000000”, null);
// Reverse oqsma dejjem tibda bil-identità numeriku, imbagħad ;# u allura l-rappreżentazzjoni sekwenza.
// Aħna normalment huma biss interessati fl-isem, hekk aħna strixxa l-ID.
CheckLookup System.Text.RegularExpressions.Regex = ġdid System.Text.RegularExpressions.Regex(“^ D ;#”);
foreach (Punt XmlElement fil ItemsNode.SelectNodes(“rs:data / z:ringiela”, NameSpaceMgr))
{
data.DataRow newRow = result.NewRow();
foreach (result.Columns data.DataColumn col)
{
jekk (Item.HasAttribute(“ows_” + (sekwenza)DisplayNames[col.ColumnName]))
{
string val Item.GetAttribute =(“ows_” + (sekwenza)DisplayNames[col.ColumnName]);
jekk (CheckLookup.IsMatch((sekwenza)elezzjoni))
{
sekwenza valString = val bħala String;
= għażla valString.Substring(valString.IndexOf(“#”) + 1);
}
// Assenjar string ma 'qasam li tistenna numri jew
// valuri datetime se impliċitament jaqilbuhom
newRow[ma '] = Għażla;
}
}
result.Rows.Add(newRow);
}
ritorn riżultat;
}
// Il-Funzjoni li ġej huwa użat biex tikseb namespaces
privati _nsmgr statiku XmlNamespaceManager;
privati NameSpaceMgr statiku XmlNamespaceManager
{
tikseb
{
jekk (_nsmgr == null)
{
_nsmgr = ġdid XmlNamespaceManager(ġodda NameTable());
_nsmgr.AddNamespace(“WSS”, “http://schemas.microsoft.com / SharePoint / sapun /”);
_nsmgr.AddNamespace(“ma”, “UUID:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882”);
_nsmgr.AddNamespace(“dt”, “UUID:C2F41010-65B3-11D1-A29F-00AA00C14882”);
_nsmgr.AddNamespace(“rs”, “urn:iskemi-Microsoft-com:rowset”);
_nsmgr.AddNamespace(“ta '”, “#RowsetSchema”);
}
ritorn _nsmgr;
}
}
privati Tip TypeFromField(Qasam XmlElement)
{
swiċċ (field.GetAttribute(“Tip”))
{
każ “DateTime”:
ritorn typeof(DateTime);
każ “Numru sħiħ”:
ritorn typeof(int);
każ “Numru”:
ritorn typeof(float);
inadempjenza:
ritorn typeof(sekwenza);
}
}
Oġġett WssSite dwar dan il-kodiċi, I am jkollna żball dwar dan, “inti nieqes ta 'direttiva bl-użu jew assemblaġġ ta' referenza?” ebda idea
Hi Bala,
WssSite huwa Webreference għall-lists.asmx
Evviva,
Uday
Eċċellenti. Grazzi Uday. Your post saved me lot of time in my migration project 🙂
You are welcome Jaya