public async Task DownloadTeamsSolutionAsStreamByIdTest() { //TestCommon.Instance.Mocking = false; using (var context = await TestCommon.Instance.GetContextAsync(TestCommon.TestSite)) { var appManager = context.GetTenantAppManager(); var app = appManager.Add(packagePath, true); app.Deploy(false); var appCatalogUrl = await appManager.GetTenantAppCatalogUriAsync(); using (var appCatalogContext = await context.CloneAsync(appCatalogUrl)) { var list = await appCatalogContext.Web.Lists.GetByServerRelativeUrlAsync($"{appCatalogContext.Uri.LocalPath}/appcatalog").ConfigureAwait(false); var query = new CamlQueryOptions { ViewXml = $"<View><Query><Where><Contains><FieldRef Name='UniqueId'/><Value Type='Text'>{app.Id}</Value></Contains></Where></Query></View>" }; await list.LoadItemsByCamlQueryAsync(query).ConfigureAwait(false); var item = list.Items.AsRequested().Single(); var stream = appManager.DownloadTeamsSolution(item.Id); Assert.IsTrue(stream != null); } } }
public CamlQueryOptions GetQueryOptions() { CamlQueryOptions queryOptions = new CamlQueryOptions() { IncludeMandatoryColumns = false }; return(queryOptions); }
public static XmlNode GetQueryOptionsXmlNode(CamlQueryOptions queryOptions) { XmlDocument xmlDoc = new XmlDocument(); XmlNode queryOptionsNode = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", ""); XmlNode includeMandatoryColumnsNode = xmlDoc.CreateNode(XmlNodeType.Element, "IncludeMandatoryColumns", String.Empty); includeMandatoryColumnsNode.InnerText = queryOptions.IncludeMandatoryColumns == true ? "TRUE" : "FALSE"; queryOptionsNode.AppendChild(includeMandatoryColumnsNode); XmlNode dateInUtcNode = xmlDoc.CreateNode(XmlNodeType.Element, "DateInUtc", String.Empty); dateInUtcNode.InnerText = queryOptions.DateInUtc == true ? "TRUE" : "FALSE"; queryOptionsNode.AppendChild(dateInUtcNode); if (string.IsNullOrEmpty(queryOptions.Folder) == false) { XmlNode folderNode = xmlDoc.CreateNode(XmlNodeType.Element, "Folder", String.Empty); folderNode.InnerText = queryOptions.Folder; queryOptionsNode.AppendChild(folderNode); } if (string.IsNullOrEmpty(queryOptions.Scope) == false) { XmlNode viewAttributesNode = xmlDoc.CreateNode(XmlNodeType.Element, "ViewAttributes", String.Empty); XmlAttribute scopeAttribute = xmlDoc.CreateAttribute(string.Empty, "Scope", String.Empty); scopeAttribute.InnerText = queryOptions.Scope; viewAttributesNode.Attributes.Append(scopeAttribute); queryOptionsNode.AppendChild(viewAttributesNode); } if (queryOptions.RowLimit.HasValue == true) { XmlNode rowLimitNode = xmlDoc.CreateNode(XmlNodeType.Element, "RowLimit", String.Empty); rowLimitNode.InnerText = queryOptions.RowLimit.Value.ToString(); queryOptionsNode.AppendChild(rowLimitNode); } if (string.IsNullOrEmpty(queryOptions.ListItemCollectionPositionNext) == false) { XmlNode pagingNode = xmlDoc.CreateNode(XmlNodeType.Element, "Paging", String.Empty); XmlAttribute positionNextAttribute = xmlDoc.CreateAttribute("ListItemCollectionPositionNext"); positionNextAttribute.Value = queryOptions.ListItemCollectionPositionNext.ToString(); pagingNode.Attributes.Append(positionNextAttribute); queryOptionsNode.AppendChild(pagingNode); } return(queryOptionsNode); }
private void ExecuteQueryButton_Click(object sender, RoutedEventArgs e) { Folder selectedFolder = ApplicationContext.Current.SPCamlStudio.QueriesPanel.ActiveQueryPanel.AttachedObject; ISiteSetting siteSetting = ApplicationContext.Current.GetSiteSetting(selectedFolder.SiteSettingID); List <CamlFieldRef> viewFields = ApplicationContext.Current.SPCamlStudio.QueriesPanel.ActiveQueryPanel.GetViewFields(); CamlQueryOptions queryOptions = ApplicationContext.Current.SPCamlStudio.QueriesPanel.ActiveQueryPanel.GetQueryOptions(); CamlFilters filters = ApplicationContext.Current.SPCamlStudio.QueriesPanel.ActiveQueryPanel.GetFilters(); List <CamlOrderBy> orderBys = ApplicationContext.Current.SPCamlStudio.QueriesPanel.ActiveQueryPanel.GetOrderBys(); string folderServerRelativePath = string.Empty; if (selectedFolder as SPFolder != null) { folderServerRelativePath = ((SPFolder)selectedFolder).ServerRelativePath; } ApplicationContext.Current.SPCamlStudio.QueriesPanel.ActiveQueryPanel.PopulateResults(siteSetting, selectedFolder.GetWebUrl(), selectedFolder.GetListName(), filters, viewFields, orderBys, queryOptions, folderServerRelativePath); }
public async Task <bool> IsAppUpgradeAvailableAsync(Guid id) { var pnpContext = await GetTenantAppCatalogContextAsync().ConfigureAwait(false); return(await ExecuteWithDisposeAsync(pnpContext, async() => { var list = await pnpContext.Web.Lists.GetByServerRelativeUrlAsync($"{pnpContext.Uri.LocalPath}/appcatalog").ConfigureAwait(false); var query = new CamlQueryOptions { ViewXml = $"<View><Query><Where><Contains><FieldRef Name='UniqueId'/><Value Type='Text'>{id}</Value></Contains></Where></Query></View>" }; await list.LoadItemsByCamlQueryAsync(query).ConfigureAwait(false); var item = list.Items.AsRequested().Single(); return await IsAppUpgradeAvailableAsync(item.Id).ConfigureAwait(false); }).ConfigureAwait(false)); }
void _CriteriaPane_After_CriteriaChange() { Folder selectedFolder = this.AttachedObject; ISiteSetting siteSetting = this.SiteSetting; List <CamlFieldRef> viewFields = this.GetViewFields(); CamlQueryOptions queryOptions = this.GetQueryOptions(); CamlFilters filters = this.GetFilters(); List <CamlOrderBy> orderBys = this.GetOrderBys(); if (selectedFolder as Entities.SharePoint.SPFolder != null) { _CamlTextEditorPane.PopulateCamlTextEditor(filters, viewFields, orderBys, queryOptions); } else { _CamlTextEditorPane.PopulateSQLServerTextEditor(selectedFolder.Title, filters, viewFields, orderBys, queryOptions); } }
public async Task <ITenantApp> AddAndDeployStoreAppAsync(string storeAssetId, string cultureName, bool skipFeatureDeployment = true, bool overwrite = true) { var apiCall = new ApiCall($"_api/web/{Scope}appcatalog/AddAndDeployStoreAppById(storeAssetId='{storeAssetId}',overwrite='{overwrite}',cmu='{cultureName}',skipFeatureDeployment='{skipFeatureDeployment}')", ApiType.SPORest); var pnpContext = await GetTenantAppCatalogContextAsync().ConfigureAwait(false); return(await ExecuteWithDisposeAsync(pnpContext, async() => { await(pnpContext.Web as Web).RawRequestAsync(apiCall, HttpMethod.Post).ConfigureAwait(false); var list = await pnpContext.Web.Lists.GetByServerRelativeUrlAsync($"{pnpContext.Uri.LocalPath}/appcatalog").ConfigureAwait(false); var query = new CamlQueryOptions { ViewXml = $"<View><Query><Where><Contains><FieldRef Name='FileLeafRef'/><Value Type='Text'>{storeAssetId}</Value></Contains></Where></Query></View>" }; await list.LoadItemsByCamlQueryAsync(query).ConfigureAwait(false); var item = list.Items.AsRequested().Single(); return await GetAvailableAsync(item.Title).ConfigureAwait(false); }).ConfigureAwait(false)); }
public void PopulateResults(ISiteSetting _siteSetting, string webUrl, string listName, CamlFilters _filters, List<CamlFieldRef> _viewFields, List<CamlOrderBy> _orderBys, CamlQueryOptions _queryOptions, string folderServerRelativePath) { this.FolderServerRelativePath = folderServerRelativePath; siteSetting = _siteSetting; filters = _filters; viewFields = _viewFields; orderBys= _orderBys; queryOptions = _queryOptions; string listItemCollectionPositionNext; int itemCount; List<IItem> items = ApplicationContext.Current.GetListItems(siteSetting, orderBys, filters, viewFields, queryOptions, webUrl, listName, out listItemCollectionPositionNext, out itemCount); DataTable dataTable = new DataTable(); ResultGrid.Columns.Clear(); foreach (CamlFieldRef fieldRef in _viewFields) { DataGridTextColumn column = new DataGridTextColumn(); column.IsReadOnly = true; column.Binding = new Binding(fieldRef.Name); column.Header = fieldRef.DisplayName; ResultGrid.Columns.Add(column); dataTable.Columns.Add(fieldRef.Name); } foreach (IItem item in items) { DataRow row = dataTable.NewRow(); foreach (CamlFieldRef fieldRef in _viewFields) { string key = fieldRef.Name; if(item.Properties.ContainsKey(key) == true) row[fieldRef.Name] = item.Properties[fieldRef.Name]; } dataTable.Rows.Add(row); } ResultGrid.ItemsSource = dataTable.AsDataView(); AttachContextMenu(); }
public List <IItem> GetListItems(ISiteSetting siteSetting, List <CamlOrderBy> orderBys, CamlFilters filters, List <CamlFieldRef> viewFields, CamlQueryOptions queryOptions, string webUrl, string listName, out string listItemCollectionPositionNext, out int itemCount) { try { List <IItem> results = new List <IItem>(); IOrganizationService organizationService = GetClientContext(siteSetting); var query = new QueryExpression(listName); query.ColumnSet.AddColumns(viewFields.Select(t => t.Name).ToArray()); query.Criteria = GetFilterExpression(filters); //query.Criteria.Filters[0].FilterOperator = LogicalOperator. EntityCollection entities = organizationService.RetrieveMultiple(query); itemCount = entities.TotalRecordCount; listItemCollectionPositionNext = string.Empty; foreach (Entity entity in entities.Entities) { CRMRecord record = new CRMRecord(siteSetting.ID); foreach (CamlFieldRef viewField in viewFields) { string viewFieldName = viewField.Name; if (entity.Attributes.ContainsKey(viewFieldName) == true) { string value = string.Empty; object objValue = entity.Attributes[viewFieldName]; if (objValue != null) { if (objValue is EntityReference) { EntityReference entityReference = (EntityReference)objValue; value = entityReference.Id.ToString() + ";#" + entityReference.Name; } else if (objValue is EntityReferenceCollection) { EntityReferenceCollection entityReferences = (EntityReferenceCollection)objValue; for (int i = 0; i < entityReferences.Count; i++) { EntityReference entityReference = entityReferences[i]; if (i > 0) { value += ";#"; } value += entityReference.Id.ToString() + ";#" + entityReference.Name; } } else if (objValue is DateTime) { value = ((DateTime)objValue).ToString("yyyy-MM-ddTHH:mm:ssZ"); } else { value = entity.Attributes[viewFieldName].ToString(); } } record.Properties.Add(viewFieldName, value); } } results.Add(record); } return(results); } catch (Exception ex) { string errorMessage = errorMessage = ex.Message; errorMessage += Environment.NewLine + ex.StackTrace; Logger.Info(errorMessage, "Service"); string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; //LogManager.LogAndShowException(methodName, ex); throw ex; } }
public static string GetSQLString(string tableName, CamlFilters filters, List <CamlFieldRef> viewFields, List <CamlOrderBy> orderBys, CamlQueryOptions queryOptions) { StringBuilder sb = new StringBuilder(); sb.Append("SELECT "); foreach (CamlFieldRef fieldRef in viewFields) { sb.Append(fieldRef.Name + " ,"); } sb.Remove(sb.Length - 1, 1); sb.Append(" FROM " + tableName + " "); sb.Append(GetSQLWhereString(filters)); sb.Append(GetSQLOrderByString(orderBys)); return(sb.ToString()); }
public void PopulateSQLServerTextEditor(string tableName, CamlFilters filters, List <CamlFieldRef> viewFields, List <CamlOrderBy> orderBys, CamlQueryOptions queryOptions) { string sqlString = SQLManager.GetSQLString(tableName, filters, viewFields, orderBys, queryOptions); QueryCamlTextBox.Text = sqlString; ViewFieldsTabItem.Visibility = Visibility.Hidden; QueryOptionsTabItem.Visibility = Visibility.Hidden; }
public void PopulateCamlTextEditor(CamlFilters filters, List <CamlFieldRef> viewFields, List <CamlOrderBy> orderBys, CamlQueryOptions queryOptions) { XmlDocument xmlDoc = new XmlDocument(); XmlNode query = xmlDoc.CreateNode(XmlNodeType.Element, "Query", ""); query.InnerXml = SPCamlManager.GetCamlString(filters, orderBys); XmlNode viewFieldsNode = SPCamlManager.GetViewFieldsXmlNode(viewFields); XmlNode queryOptionsNode = SPCamlManager.GetQueryOptionsXmlNode(queryOptions); QueryCamlTextBox.Text = query.OuterXml; ViewFieldsCamlTextBox.Text = viewFieldsNode.OuterXml; QueryOptionsCamlTextBox.Text = queryOptionsNode.OuterXml; }
public List <IItem> GetListItems(ISiteSetting siteSetting, List <CamlOrderBy> orderBys, CamlFilters filters, List <CamlFieldRef> viewFields, CamlQueryOptions queryOptions, string webUrl, string listName, out string listItemCollectionPositionNext, out int itemCount) { throw new NotImplementedException(); }
/// <summary> /// The GetListItemChangesSinceToken operation is used to return changes made to a specified list after the event /// expressed by the change token, if specified, or to return all the list items in the list. /// </summary> /// <param name="listName">The name of the list from which version collection will be got</param> /// <param name="viewName">The GUID refers to a view of the list</param> /// <param name="query">The query to determine which records from the list are to be /// returned and the order in which they will be returned</param> /// <param name="viewFields">Specifies which fields of the list item will be returned</param> /// <param name="rowLimit">Indicate the maximum number of rows of data to return</param> /// <param name="queryOptions">Specifies various options for modifying the query</param> /// <param name="changeToken">Assigned a string comprising a token returned by a previous /// call to this operation.</param> /// <param name="contains">Specifies a value to search for</param> /// <returns>A return value represent the list item changes since the specified token</returns> public GetListItemChangesSinceTokenResponseGetListItemChangesSinceTokenResult GetListItemChangesSinceToken(string listName, string viewName, GetListItemChangesSinceTokenQuery query, CamlViewFields viewFields, string rowLimit, CamlQueryOptions queryOptions, string changeToken, CamlContains contains) { if (null == this.listsProxy) { throw new InvalidOperationException("The Proxy instance is NULL, need to initialize the adapter"); } GetListItemChangesSinceTokenResponseGetListItemChangesSinceTokenResult result = null; result = this.listsProxy.GetListItemChangesSinceToken(listName, viewName, query, viewFields, rowLimit, queryOptions, changeToken, contains); this.VerifyTransportRequirement(); this.VerifyGetListItemChangesSinceTokenResponse(result); return(result); }
public override List <IItem> GetListItems(ISiteSetting siteSetting, List <CamlOrderBy> orderBys, CamlFilters filters, List <CamlFieldRef> viewFields, CamlQueryOptions queryOptions, string webUrl, string listName, out string listItemCollectionPositionNext, out int itemCount) { IServiceManager serviceManager = ServiceManagerFactory.GetServiceManager(siteSetting.SiteSettingType); return(serviceManager.GetListItems(siteSetting, orderBys, filters, viewFields, queryOptions, webUrl, listName, out listItemCollectionPositionNext, out itemCount)); }
public void Initialize(Folder selectedObject, List <CamlFieldRef> viewFields, CamlQueryOptions queryOptions, List <CamlOrderBy> orderBys, CamlFilters filters) { }
public void PopulateResults(ISiteSetting siteSetting, string webUrl, string listName, CamlFilters _filters, List <CamlFieldRef> _viewFields, List <CamlOrderBy> _orderBys, CamlQueryOptions _queryOptions, string folderServerRelativePath) { _ResultPane.PopulateResults(siteSetting, webUrl, listName, _filters, _viewFields, _orderBys, _queryOptions, folderServerRelativePath); }
public void MSOUTSPS_S01_TC01_OperateAttachment_AppointmentTemplateType() { #region Add a list item // Add one list into SUT. string listId = this.AddListToSUT(TemplateType.Events); // Add one list item List <string> addedListitems = this.AddItemsToList(listId, 1); string addedListitemId = addedListitems[0]; byte[] attachmentContent = this.GenerateUniqueAttachmentContents(5); string attachmentName = this.GetUniqueAttachmentName(); #endregion #region AddAttachment operation // Call AddAttachment operation. string fileUrl = OutspsAdapter.AddAttachment( listId, addedListitemId, attachmentName, attachmentContent); #endregion #region HTTPGET operation // Get full URL of an attachment string fullUrlOfAttachment = this.GetAttachmentFullUrl(listId, addedListitemId, attachmentName); Uri fullUrlOfAttachmentPath; if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath)) { this.Site.Assert.Fail("The full url of attachment should be valid Uri format string."); } // Call HTTPGET operation. byte[] getContentsOfAttachment = OutspsAdapter.HTTPGET(fullUrlOfAttachmentPath, "f"); #endregion #region Capture R1062, R1070, R1073, R1075 // If the length of attachment content in protocol SUT equal to added by AddAttachment operation, then capture R1062, R1070, R1073 Site.CaptureRequirementIfAreEqual( attachmentContent.Length, getContentsOfAttachment.Length, 1062, "[In Message Processing Events and Sequencing Rules][The operation]AddAttachment Adds an attachment to an item."); // Verify MS-OUTSPS requirement: MS-OUTSPS_R1070 Site.CaptureRequirementIfAreEqual( attachmentContent.Length, getContentsOfAttachment.Length, 1070, "[In AddAttachment]AddAttachment is used by protocol clients to create a new attachment on an item on the protocol server."); // Verify MS-OUTSPS requirement: MS-OUTSPS_R10730 Site.CaptureRequirementIfAreEqual( attachmentContent.Length, getContentsOfAttachment.Length, 10730, "[In Messages]AddAttachmentResponse specified the response to a request to create a new attachment on an item on the protocol server."); // If the AddAttachment operation return valid attachment url, then Capture R1075 Site.CaptureRequirementIfIsNotNull( fileUrl, 1075, "[In AddAttachmentResponse]If an AddAttachmentResponse is received, then the upload was successful."); #endregion #region GetAttachmentCollection operation byte[] attachmentContentSecond = this.GenerateUniqueAttachmentContents(5); string attachmentNameSecond = this.GetUniqueAttachmentName(); // Call the AddAttachment operation. OutspsAdapter.AddAttachment( listId, addedListitemId, attachmentNameSecond, attachmentContentSecond); // Call GetAttachmentCollection operation. GetAttachmentCollectionResponseGetAttachmentCollectionResult getAttachementCollectionResult = OutspsAdapter.GetAttachmentCollection(listId, addedListitemId); #endregion #region Capture R1065, R11000 // If add new attachment successfully, total attachment number is 2, Capture R1065, R11000 bool isContainExpectedAttachment = this.VerifyWhetherContainExpectedNumberAttachment(getAttachementCollectionResult, 2); this.Site.CaptureRequirementIfIsTrue( isContainExpectedAttachment, 1065, "[In Message Processing Events and Sequencing Rules][The operation]GetAttachmentCollection Gets a list of the attachments on an item."); this.Site.CaptureRequirementIfIsTrue( isContainExpectedAttachment, 11000, "[In Messages]GetAttachmentCollectionResponse specified the response to a request to get the list of all attachments on a single item in one list."); #endregion if (Common.IsRequirementEnabled(106802, this.Site)) { #region GetListItemChangesSinceToken operation // Set CamlQueryOptions and view fields make the "attachment" field present in response. CamlQueryOptions camloptions = new CamlQueryOptions(); camloptions.QueryOptions = new CamlQueryOptionsQueryOptions(); camloptions.QueryOptions.IncludeAttachmentUrls = bool.TrueString; camloptions.QueryOptions.IncludeAttachmentVersion = bool.TrueString; CamlViewFields viewfieds = this.GenerateViewFields(false, new List <string> { "Attachments" }); // Call GetListItemChangesSinceToken operation. GetListItemChangesSinceTokenResponseGetListItemChangesSinceTokenResult getListItemChangesRes = null; getListItemChangesRes = OutspsAdapter.GetListItemChangesSinceToken( listId, null, null, viewfieds, null, camloptions, null, null); this.Site.Assert.IsNotNull(getListItemChangesRes, "SUT should return a response contain data."); string headerValue = this.GetIfMatchHeaderValueFromResponse(getListItemChangesRes, fullUrlOfAttachment, int.Parse(addedListitemId)); #endregion #region Capture R1241 // If the header is returned, then R1241 should be covered. this.Site.CaptureRequirementIfIsNotNull( headerValue, 1241, "[In HTTP PUT]The Attachments property MUST contain a file version if protocol clients have included the IncludeAttachmentUrls and IncludeAttachmentVersion elements specified in [MS-LISTSWS]."); #endregion #region HTTPPUT operation // Call HTTPPUT operation to update the attachment contents for the first attachment. fullUrlOfAttachmentPath = null; if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath)) { this.Site.Assert.Fail("The full url of attachment should be valid Uri format string."); } byte[] newattachmentContents = this.GenerateUniqueAttachmentContents(6); OutspsAdapter.HTTPPUT(fullUrlOfAttachmentPath, headerValue, newattachmentContents); // Verify the updated attachment contents' length this.VerifyAttachmentContentsLength(fullUrlOfAttachment, newattachmentContents.Length); #endregion } OutspsAdapter.DeleteAttachment(listId, addedListitemId, fullUrlOfAttachment); #region Capture R10930 // If the operation does not return SoapException, capture R10930 directly. Because the schema of the DeleteAttachmentResponse define in [MS-LISTSWS]: <s:element name="DeleteAttachmentResponse"><s:complexType/></s:element>, does not contain any complex type definition, so the proxy class marked this operation as void type return. this.Site.CaptureRequirement( 10930, "[In Messages]DeleteAttachmentResponse specified the response to a request to delete attachments from an item on the protocol server."); #endregion // Verify whether the attachment was deleted. bool isDeleteSucceed = this.VerifyDeleteAttachmentSucceed(fullUrlOfAttachment); #region Capture R1064, R1091 // Because the specified attachment was deleted, the HTTPGET operation could not find it, so there will have a soap exception. this.Site.CaptureRequirementIfIsTrue( isDeleteSucceed, 1064, @"[In Message Processing Events and Sequencing Rules][The operation]DeleteAttachment Deletes an attachment from an item on a list."); this.Site.CaptureRequirementIfIsTrue( isDeleteSucceed, 1091, @"[In DeleteAttachment]Protocol clients use DeleteAttachment to delete attachments from an item on the protocol server."); #endregion }
public List <IItem> GetListItems(ISiteSetting siteSetting, List <CamlOrderBy> orderBys, CamlFilters filters, List <CamlFieldRef> viewFields, CamlQueryOptions queryOptions, string webUrl, string listName, out string listItemCollectionPositionNext, out int itemCount) { ISharePointService spService = new SharePointService(); return(spService.GetListItems(siteSetting, orderBys, filters, viewFields, queryOptions, webUrl, listName, out listItemCollectionPositionNext, out itemCount)); }
public abstract List <IItem> GetListItems(ISiteSetting siteSetting, List <CamlOrderBy> orderBys, CamlFilters filters, List <CamlFieldRef> viewFields, CamlQueryOptions queryOptions, string webUrl, string listName, out string listItemCollectionPositionNext, out int itemCount);
public void MSOUTSPS_S01_TC04_OperateAttachment_TasksTemplateType() { #region Add a list item // Add one list into SUT. string listId = this.AddListToSUT(TemplateType.Tasks); // Add one list item List <string> addedListitems = this.AddItemsToList(listId, 1); string addedListitemId = addedListitems[0]; byte[] attachmentContent = this.GenerateUniqueAttachmentContents(5); string attachmentName = this.GetUniqueAttachmentName(); #endregion #region AddAttachment operation // Call AddAttachment operation. OutspsAdapter.AddAttachment( listId, addedListitemId, attachmentName, attachmentContent); #endregion #region HTTPGET operation // Get full URL of an attachment string fullUrlOfAttachment = this.GetAttachmentFullUrl(listId, addedListitemId, attachmentName); // Call HTTPGET operation. Uri fullUrlOfAttachmentPath; if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath)) { this.Site.Assert.Fail("The full url of attachment should be valid Uri format string."); } byte[] getContentsOfAttachment = OutspsAdapter.HTTPGET(fullUrlOfAttachmentPath, "f"); this.Site.Assert.AreEqual <int>( attachmentContent.Length, getContentsOfAttachment.Length, "The attachment content's length should equal to added by AddAttachment operation."); #endregion #region GetAttachmentCollection operation byte[] attachmentContentSecond = this.GenerateUniqueAttachmentContents(5); string attachmentNameSecond = this.GetUniqueAttachmentName(); // Call the AddAttachment operation. OutspsAdapter.AddAttachment( listId, addedListitemId, attachmentNameSecond, attachmentContentSecond); // Call GetAttachmentCollection operation. GetAttachmentCollectionResponseGetAttachmentCollectionResult getAttachementCollectionResult = OutspsAdapter.GetAttachmentCollection(listId, addedListitemId); // If add new attachment successfully, total attachment number is 2 this.VerifyWhetherContainExpectedNumberAttachment(getAttachementCollectionResult, 2); #endregion if (Common.IsRequirementEnabled(106802, this.Site)) { #region GetListItemChangesSinceToken operation // Set CamlQueryOptions and view fields make the "attachment" field present in response. CamlQueryOptions camloptions = new CamlQueryOptions(); camloptions.QueryOptions = new CamlQueryOptionsQueryOptions(); camloptions.QueryOptions.IncludeAttachmentUrls = bool.TrueString; camloptions.QueryOptions.IncludeAttachmentVersion = bool.TrueString; CamlViewFields viewfieds = this.GenerateViewFields(false, new List <string> { "Attachments" }); // Call GetListItemChangesSinceToken operation. GetListItemChangesSinceTokenResponseGetListItemChangesSinceTokenResult getlistItemChangesRes = null; getlistItemChangesRes = OutspsAdapter.GetListItemChangesSinceToken( listId, null, null, viewfieds, null, camloptions, null, null); this.Site.Assert.IsNotNull(getlistItemChangesRes, "SUT should return a response contain data."); string headerValue = this.GetIfMatchHeaderValueFromResponse(getlistItemChangesRes, fullUrlOfAttachment, int.Parse(addedListitemId)); #endregion #region HTTPPUT operation // Call HTTPPUT operation. fullUrlOfAttachmentPath = null; if (!Uri.TryCreate(fullUrlOfAttachment, UriKind.RelativeOrAbsolute, out fullUrlOfAttachmentPath)) { this.Site.Assert.Fail("The full url of attachment should be valid Uri format string."); } byte[] newattachmentContents = this.GenerateUniqueAttachmentContents(6); OutspsAdapter.HTTPPUT(fullUrlOfAttachmentPath, headerValue, newattachmentContents); // Verify updated attachment. this.VerifyAttachmentContentsLength(fullUrlOfAttachment, newattachmentContents.Length); #endregion } OutspsAdapter.DeleteAttachment(listId, addedListitemId, fullUrlOfAttachment); // Verify whether delete attachment succeed. this.VerifyDeleteAttachmentSucceed(fullUrlOfAttachment); }
public List <IItem> GetListItems(ISiteSetting siteSetting, List <CamlOrderBy> orderBys, CamlFilters filters, List <CamlFieldRef> viewFields, CamlQueryOptions queryOptions, string webUrl, string listName, out string listItemCollectionPositionNext, out int itemCount) { try { List <IItem> items = new List <IItem>(); listItemCollectionPositionNext = string.Empty; itemCount = 100; string sqlString = SQLManager.GetSQLString(listName, filters, viewFields, orderBys, queryOptions); string dbName = webUrl; DataSet ds = new DataSet(); using (SqlConnection con = new SqlConnection(this.GetConnectionString(siteSetting, dbName))) { con.Open(); SqlDataAdapter da = new SqlDataAdapter(); SqlCommand cmd = con.CreateCommand(); cmd.CommandText = sqlString; da.SelectCommand = cmd; da.Fill(ds); } DataTable table = ds.Tables[0]; foreach (DataRow row in table.Rows) { SQLTableRecord record = new SQLTableRecord(siteSetting.ID); foreach (CamlFieldRef viewField in viewFields) { string value = string.Empty; if (row[viewField.Name] != null) { value = row[viewField.Name].ToString(); } record.Properties.Add(viewField.Name, value); } items.Add(record); } /* * SPView view = selectedView as SPView; * string orderBy = String.Empty; * if (sortField == String.Empty) * { * if (view != null) * { * orderBy = view.GetOrderByXML(); * } * } * else * { * orderBy = "<OrderBy><FieldRef Name=\"" + sortField + "\" " + (isAsc == false ? "Ascending=\"FALSE\"" : "") + " /></OrderBy>"; * } * SharePointListsWS.Lists ws = GetListsWebService(siteSetting, webUrl); * XmlDocument xmlDoc = new XmlDocument(); * * XmlNode query = xmlDoc.CreateNode(XmlNodeType.Element, "Query", ""); * XmlNode viewFields = SPCamlManager.GetViewFieldsXmlNode(new List<CamlFieldRef>()); * //XmlNode queryOptionsNode = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", ""); * * int? rowLimit = null; * if (view != null && view.RowLimit > 0) * rowLimit = view.RowLimit; * * CamlQueryOptions queryOptions = new CamlQueryOptions() * { * IncludeMandatoryColumns = true, * DateInUtc = true, * Folder = folderName, * Scope = (isRecursive == true ? "RecursiveAll" : string.Empty), * RowLimit = rowLimit, * ListItemCollectionPositionNext = currentListItemCollectionPositionNext * }; * XmlNode queryOptionsNode = SPCamlManager.GetQueryOptionsXmlNode(queryOptions); * * CamlFilters filters = new CamlFilters(); * filters.Add(@"<Eq><FieldRef Name='FSObjType' /><Value Type='Lookup'>0</Value></Eq>"); * if (view != null && view.WhereXML != String.Empty) * { * filters.Add(view.WhereXML); * } * if (customFilters != null && customFilters.Filters.Count > 0) * { * filters.Add(customFilters); * } * * query.InnerXml = orderBy + "<Where>" + filters.ToCaml() + "</Where>"; * XmlNode ndListItems = ws.GetListItems(listName, null, query, viewFields, null, queryOptionsNode, null); * string message = string.Format("SharePointService GetListItems method returned ListName:{0} queryOptions:{1} \n query:{2} \n xml:{3}", listName, queryOptionsNode.OuterXml, query.OuterXml, ndListItems.OuterXml); * Logger.Info(message, "Service"); * * xmlDoc.LoadXml(ndListItems.OuterXml); * * itemCount = int.Parse(xmlDoc.GetElementsByTagName("rs:data")[0].Attributes["ItemCount"].Value); * XmlAttribute listItemCollectionPositionNextAttribute = xmlDoc.GetElementsByTagName("rs:data")[0].Attributes["ListItemCollectionPositionNext"]; * listItemCollectionPositionNext = String.Empty; * if (listItemCollectionPositionNextAttribute != null) * listItemCollectionPositionNext = listItemCollectionPositionNextAttribute.Value; * XmlNodeList _items = xmlDoc.GetElementsByTagName("z:row"); * string titleFieldName = "Title"; * if (isDocumentLibrary == true) * titleFieldName = "LinkFilename"; * foreach (XmlNode item in _items) * { * SPListItem listItem = ParseSPListItem(item, siteSetting.ID, folderName, webUrl, listName, titleFieldName); * items.Add(listItem); * }*/ return(items); } catch (Exception ex) { string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name; //LogManager.LogAndShowException(methodName, ex); throw ex; } }