public SearchResults Search(SearchInfo info) { if (info == null) { throw new ArgumentNullException(); } var search = new PCDSearch(); search.SetDST(Dst); search.SetSearchObject(info.SearchObject); foreach (var pair in info.Criteria) { search.AddSearchCriteria(pair.Key, pair.Value); } foreach (var prop in info.ReturnProperties) { search.AddReturnProperty(prop); } if (info.OrderBy != null) { foreach (var pair in info.OrderBy) { search.AddOrderByProperty(pair.Key, (int)pair.Value); } } if (search.Execute() != 0 || search.ErrNumber != 0) { throw new DMApiException(string.Format("PCDSearch.Execute failed with error {0}: {1}", search.ErrNumber, search.ErrDescription)); } var results = new SearchResults(); int count = search.GetRowsFound(); if (count > 0) { results.Rows.Capacity = count; search.BeginGetBlock(); try { for (int i = 0; i < count; i++) { search.NextRow(); var row = new SearchRow(); foreach (var prop in info.ReturnProperties) { row.Add(prop, search.GetPropertyValue(prop)); } results.Rows.Add(row); } } finally { search.EndGetBlock(); search.ReleaseResults(); } } return(results); }
/// <summary> /// Questo costruttore instanzia un oggetto di ricerca sul documentale /// </summary> /// <param name="dst"></param> /// <param name="library"></param> /// <param name="searchObject"></param> public Ricerca(string dst, string library, string searchObject) { // Create a search object. search = new PCDCLIENTLib.PCDSearch(); // Set the Security Token. search.SetDST(dst); // Add the library that was passed in. search.AddSearchLib(library); // Use the versions form to access properties. search.SetSearchObject(searchObject); }