public void ShouldGetItemVersionContent() { var svc = new ListsSoapClient(); svc.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(_appSettings.Username, _appSettings.Password, "SSW2000"); var xx = svc.GetVersionCollection("Pages", "4", "PublishingPageContent"); xx.Should().NotBeNull(); }
private ListsSoapClient GetListServiceProxy() { ListsSoapClient proxy = new ListsSoapClient(); string hostName = App.Current.Host.Source.Host; string endPointUrl = proxy.Endpoint.Address.ToString().Replace("localhost", hostName); proxy.Endpoint.Address = new System.ServiceModel.EndpointAddress(endPointUrl); return(proxy); }
public void ShouldGetList() { var svc = new ListsSoapClient(); svc.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(_appSettings.Username, _appSettings.Password, "SSW2000"); var xx = svc.GetList("TaxonomyHiddenList"); xx.Should().NotBeNull(); }
public LiveUpdateHandler(MainPage mainPage) { _mainPage = mainPage; ListAsmx = Constants.InitParams.ListAsmx(_mainPage); ListsService = new ListsSoapClient("ListsSoap", ListAsmx); ListsService.GetListItemsCompleted += ListsService_GetListItemsCompleted; _listHelper = new ListHelper(_mainPage); _listHelper.UpdateComplete += listHelper_UpdateComplete; }
public ListSettingsServiceAgent(String asmxUrl, String listOrgAsmxUrl, string siteURL) { MethodID = 0; AsmxUrl = asmxUrl; SiteURL = siteURL; ListOrgAsmx = listOrgAsmxUrl; proxy_query = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(AsmxUrl, ServiceParamStatHelper.Actions.QUERY, "UNKNOWN")); proxy_update = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(AsmxUrl, ServiceParamStatHelper.Actions.UPDATE, "UNKNOWN")); proxy_queryorg = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(ListOrgAsmx, ServiceParamStatHelper.Actions.QUERY, "UNKNOWN")); proxy_updateorg = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(ListOrgAsmx, ServiceParamStatHelper.Actions.UPDATE, "UNKNOWN")); _client = new ClientContext(siteURL); }
public void ShouldGetItems() { var svc = new ListsSoapClient(); svc.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(_appSettings.Username, _appSettings.Password, "SSW2000"); XElement queryOptions = XElement.Parse(@"<QueryOptions/>"); var xx = svc.GetListItems("Pages", "", null, null, null, queryOptions, null); Console.Out.WriteLine(xx.ToString()); xx.Should().NotBeNull(); }
public void LoadMyLinks() { //TODO: LoadMyLinks code here XElement viewFields = new XElement("ViewFields", new XElement("FieldRef", new XAttribute("Name", "ows_URL"))); ListsSoapClient svc = new ListsSoapClient(); svc.CookieContainer = App.Cookies; svc.GetListItemsCompleted += new EventHandler <GetListItemsCompletedEventArgs> (svc_GetListItemsCompleted); svc.GetListItemsAsync("MyLinks", string.Empty, null, viewFields, null, null, null); }
private void AddLink(Link link) { //TODO: AddLink code here XElement updateQuery = new XElement("Batch", new XAttribute("OnError", "Continue"), new XAttribute("ListVersion", "1"), new XElement("Method", new XAttribute("ID", "1"), new XAttribute("Cmd", "New"), new XElement("Field", new XAttribute("Name", "ID"), "New"), new XElement("Field", new XAttribute("Name", "URL"), Link.BuildSPLink(link.Title, link.HyperLink)) )); ListsSoapClient svc = new ListsSoapClient(); svc.CookieContainer = App.Cookies; svc.UpdateListItemsCompleted += new EventHandler <UpdateListItemsCompletedEventArgs>(svc_UpdateListItemsCompleted); svc.UpdateListItemsAsync(Constants.MYLINKS_LIST_TITLE, updateQuery); }
public void GetPartSuppliers() { Suppliers.Clear(); ListsSoapClient proxy = GetListServiceProxy(); proxy.GetListItemsCompleted += proxy_GetSuppliersListItemsCompleted; var query = XElement.Parse(@"<Query> <Where> <Eq> <FieldRef Name='PartLookup' /> <Value Type='Lookup'>" + CurrentPart.Title + @"</Value> </Eq> </Where> </Query>"); var queryOptions = XElement.Parse(@"<QueryOptions></QueryOptions>"); var viewFields = XElement.Parse(@"<ViewFields></ViewFields>"); proxy.GetListItemsAsync("Part Suppliers", null, query, viewFields, null, queryOptions, null); }
public void GetParts() { Parts.Clear(); ListsSoapClient proxy = GetListServiceProxy(); proxy.GetListItemsCompleted += proxy_GetPartsListItemsCompleted; var query = XElement.Parse(@"<Query> <Where> <BeginsWith> <FieldRef Name='SKU' /> <Value Type='Text'>" + SearchSku + @"</Value> </BeginsWith> </Where> </Query>"); var queryOptions = XElement.Parse(@"<QueryOptions></QueryOptions>"); var viewFields = XElement.Parse(@"<ViewFields></ViewFields>"); proxy.GetListItemsAsync("Parts", null, query, viewFields, null, queryOptions, null); }
public ListHelper(MainPage page) { ListAsmx = Constants.InitParams.ListAsmx(page); ConfigListAsmx = Constants.InitParams.ListOrgAsmx(page); if (ListAsmx == "") throw new Exception("No list url has been specified"); if (ConfigListAsmx == "") throw new Exception("No config list url has been specified"); _service = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(ListAsmx, ServiceParamStatHelper.Actions.UPDATE, "UNKNOWN")); _service.UpdateListItemsCompleted += new EventHandler<UpdateListItemsCompletedEventArgs>(Service_UpdateListItemsCompleted); _service.UpdateListCompleted += new EventHandler<UpdateListCompletedEventArgs>(Service_UpdateListCompleted); _service.DeleteListCompleted += new EventHandler<AsyncCompletedEventArgs>(Service_DeleteListCompleted); _serviceParent = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(ConfigListAsmx, ServiceParamStatHelper.Actions.QUERY,Constants.ConfigListBCheck)); _serviceParent.GetListItemsCompleted += new EventHandler<GetListItemsCompletedEventArgs>(ServiceParent_GetListItemCompleted); _serviceParent.UpdateListItemsCompleted += new EventHandler<UpdateListItemsCompletedEventArgs>(ServiceParent_UpdateListItemsCompleted); }
public DataHandler(IExcelParams excelParams, MainPage page) { _page = page; _excelParams = excelParams; UpdateHandlerQueue = new List<RowHandler>(); _listHelper = new ListHelper(page); ListAsmx = Constants.InitParams.ListAsmx(page); ListOrgAsmx = Constants.InitParams.ListOrgAsmx(page); FrequencyAsmx = Constants.InitParams.FrequencyAsmx(page); _listHelper.UpdateComplete += listHelper_UpdateComplete; _listHelper.DeleteComplete += listHelper_DeleteComplete; _listsService = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(ListAsmx, ServiceParamStatHelper.Actions.QUERY, "UNKNOWN")); _listsOrgService = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(ListOrgAsmx, ServiceParamStatHelper.Actions.QUERY, Constants.OrgStructure)); _frequencyService = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(FrequencyAsmx, ServiceParamStatHelper.Actions.QUERY, "FrequencyValidation")); _updateTimer = new DispatcherTimer(); _updateTimer.Interval = new TimeSpan(0, 0, Constants.UpdateTimerOffset); _updateTimer.Tick += updateTimer_Tick; _updateTimer.Start(); _listsOrgService.GetListItemsCompleted += ListsOrgService_GetListItemsCompleted; _listsService.GetListCollectionCompleted += Service_GetListCollectionCompleted; _listsService.GetListItemsCompleted += Service_GetListItemsCompleted; //_listsService.GetListAndViewCompleted += Service_GetListAndViewCompleted; _frequencyService.GetListItemsCompleted += FrequencyService_GetListItemsCompleted; ListSettingsAgent = new ListSettingsServiceAgent(ListOrgAsmx); BusinessUnitAgent = new BusinessUnitServiceAgent(Constants.InitParams.SiteRootURL(page), page._sLog); HelperAgent = new HelperServiceAgent(); _dispatcher = Deployment.Current.Dispatcher; InitiateStaticData(); if (_current == null) { _current = this; } }
public List <MediaModel> MediaSearch(string name, DateTime?dateFrom, DateTime?dateTo) { var result = new List <MediaModel>(); XElement listItems; var queryXML = new StringBuilder(); queryXML.Append("<Query><Where>"); if (!string.IsNullOrEmpty(name)) { queryXML.Append("<Contains><FieldRef Name='Title'/><Value Type='Text'>"); queryXML.Append(name); queryXML.Append("</Value></Contains>"); } if (dateFrom.HasValue) { queryXML.Append("<Geq><FieldRef Name='ImageCreateDate'/><Value Type='DateTime'>"); queryXML.Append(dateFrom.ToString()); queryXML.Append("</Value></Geq>"); } if (dateTo.HasValue) { queryXML.Append("<Lt><FieldRef Name='ImageCreateDate'/><Value Type='DateTime'>"); queryXML.Append(dateTo.ToString()); queryXML.Append("</Value></Lt>"); } queryXML.Append("</Where></Query>"); var servicePath = string.Format("{0}/_vti_bin/lists.asmx", IntegrationHelper.SPOperationURL); var mediaPath = Globals.GetSetting("SPMediaPath"); string viewFieldsXml = @"<ViewFields> <FieldRef Name='Title'/> <FieldRef Name='DocIcon'/> <FieldRef Name='EncodedAbsUrl'/> <FieldRef Name='CreatedDate'/> </ViewFields>" ; string queryOptionsXml = "<QueryOptions>" + "<IncludeMandatoryColumns>TRUE</IncludeMandatoryColumns>" + "<DateInUtc>TRUE</DateInUtc>" + "</QueryOptions>"; var endPoint = new EndpointAddress(servicePath); var binding = GetSharepointBinding(); string userWebConf = ConfigurationManager.AppSettings["CyberArk:SPServiceAccount_login"]; string user = userWebConf.Split('|')[0]; string password = PasswordStorage.GetPasswordStorage().GetPassword(userWebConf); using (var factory = new ChannelFactory <ListsSoap>(binding, endPoint)) { using (var proxy = new ListsSoapClient(binding, endPoint)) { if (proxy.ClientCredentials != null) { proxy.ClientCredentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials; proxy.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation; proxy.Endpoint.Address = endPoint; proxy.ClientCredentials.UserName.UserName = user; proxy.ClientCredentials.UserName.Password = password; } listItems = proxy.GetListItems( mediaPath, null, XElement.Parse(queryXML.ToString()), XElement.Parse(viewFieldsXml), null, XElement.Parse(queryOptionsXml), null); } } var responseDocument = new XmlDocument(); responseDocument.LoadXml(listItems.ToString()); XmlNodeList elementList = responseDocument.GetElementsByTagName("z:row"); foreach (XmlNode element in elementList) { result.Add(new MediaModel() { MediaId = -1, Name = GetXMLStringValue(element.Attributes["ows_Title"]), Content = GetXMLStringValue(element.Attributes["ows__Comments"]), Year = GetXMLIntValue(element.Attributes["ows_Created_x0020_Date"]), Location = GetXMLStringValue(element.Attributes["ows_Keywords"]), MediaUrl = GetXMLStringValue(element.Attributes["ows_EncodedAbsUrl"]), }); } return(result); }
public System.Collections.Generic.List<string> GetLists(Action<List<SharepointList>> reply) { proxy_query = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(AsmxUrl, ServiceParamStatHelper.Actions.QUERY, "UNKNOWN")); proxy_query.GetListCollectionCompleted += (s, e) => { if (e.Error == null) { proxy_query.CloseAsync(); XElement list = e.Result; XNamespace ns = "http://schemas.microsoft.com/sharepoint/soap/"; var functionalfield = from field in list.Descendants(ns + "List") select new SharepointList() { ListName = field.Attribute("Title").Value, Description = field.Attribute("Description").Value, Version = field.Attribute("Version").Value, IsQuickLaunchEnabled = true, GUID = field.Attribute("ID").Value }; reply(functionalfield.ToList()); } else { reply(new List<SharepointList>()); } }; proxy_query.GetListCollectionAsync(); return new List<String>(); }
public void CreateList(SharepointList newList, Action<bool> reply) { SharepointList tempnewList = newList; proxy_update = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(AsmxUrl, ServiceParamStatHelper.Actions.UPDATE, "UNKNOWN")); EventHandler<AddListCompletedEventArgs> addlisthandler = null; addlisthandler = (s, e) => { tempnewList.GUID = e.Result.Attribute("ID").Value; if (e.Error == null) { XElement flds = XElement.Load("Data/ListDefinition2.xml"); string isEnabled = tempnewList.IsActivated == true ? "Yes" : "No"; EventHandler<UpdateListCompletedEventArgs> updatelisthandler = null; updatelisthandler = (s1, e1) => { if (e1.Error == null) { EventHandler<UpdateListItemsCompletedEventArgs> updatelistitemshandler = null; updatelistitemshandler = (s2, e2) => { if (e2.Error == null) { //Removing all existing permissions. ClientContext clientContext = new ClientContext(SiteURL); Site collSite = clientContext.Site; Web site = clientContext.Web; SecurableObject listSecurable = site.Lists.GetByTitle(tempnewList.ListName); listSecurable.BreakRoleInheritance(false, true); clientContext.ExecuteQueryAsync((sender, args) => { reply(true); }, (sender,args) => { reply(false); }); } else { reply(false); } proxy_updateorg.UpdateListItemsCompleted -= updatelistitemshandler; }; string sBatch = "<Batch><Method ID='1' Cmd='New'>"; sBatch += "<Field Name='Title'>" + tempnewList.ListName + "</Field>"; sBatch += "<Field Name='bcheck_x0020_list_x0020_name'>" + "operations checklist" + "</Field>"; sBatch += "<Field Name='bcheck_x0020_list_x0020_template'>" + tempnewList.ListName + "</Field>"; sBatch += "<Field Name='bcheck_x0020_site'>" + "/tasks/Lists/operations checklist" + "</Field>"; sBatch += "<Field Name='bcheck_x0020_email'>" + tempnewList.OwnerEmailString + "</Field>"; sBatch += "<Field Name='bcheck_x0020_Process'>" + isEnabled + "</Field>"; sBatch += "</Method></Batch>"; XElement updates = XElement.Parse(sBatch); proxy_updateorg.UpdateListItemsCompleted += updatelistitemshandler; proxy_updateorg.UpdateListItemsAsync("bcheck", updates); } else { reply(false); } proxy_update.UpdateListCompleted -= updatelisthandler; }; proxy_update.UpdateListCompleted += updatelisthandler; proxy_update.UpdateListAsync(tempnewList.GUID, null, flds, null, null, null); } else { reply(false); } proxy_update.AddListCompleted -= addlisthandler; }; proxy_update.AddListCompleted += addlisthandler; proxy_update.AddListAsync(newList.ListName, newList.Description, 100); }
private static ListsSoapClient CreateListSoapClient(Uri serverUri) { var wslist = new ListsSoapClient(basicbinding, new EndpointAddress(serverUri)); return wslist; }
public void SaveList(SharepointList selectedList, Action<bool> reply) { proxy_update = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(AsmxUrl, ServiceParamStatHelper.Actions.UPDATE, "UNKNOWN")); proxy_updateorg = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(ListOrgAsmx, ServiceParamStatHelper.Actions.UPDATE, "UNKNOWN")); XElement listprops = new XElement(new XElement("List")); listprops.SetAttributeValue("Title", selectedList.ListName); listprops.SetAttributeValue("Description", selectedList.Description); listprops.SetAttributeValue("OnQuickLaunch", selectedList.IsQuickLaunchEnabled); EventHandler<UpdateListCompletedEventArgs> updatehandler = null; updatehandler = (s, e) => { if (e.Error == null) { selectedList.Version = (Int32.Parse(selectedList.Version) + 1).ToString(); reply(true); } else { reply(false); } proxy_update.UpdateListCompleted -= updatehandler; }; proxy_update.UpdateListCompleted += updatehandler; proxy_update.UpdateListAsync(selectedList.GUID, listprops, null, null, null, selectedList.Version); XDocument xdoc = new XDocument(); XElement queryOptions = new XElement("QueryOptions"); XElement viewFields = new XElement("ViewFields"); string isEnabled = selectedList.IsActivated == true ? "Yes" : "No"; XElement updateQuery = XElement.Parse("<Batch><Method ID='1' Cmd='Update'>" + "<Field Name='ID'>" + selectedList.bCheckListItemID + "</Field>" + "<Field Name='bcheck_x0020_Process'>" + isEnabled + "</Field><Field Name='bcheck_x0020_email'>" + selectedList.OwnerEmailString + "</Field><Field Name='Title'>" + selectedList.ListName + "</Field><Field Name='bcheck_x0020_list_x0020_template'>" + selectedList.ListName + "</Field></Method></Batch>"); EventHandler<UpdateListItemsCompletedEventArgs> handler2 = null; handler2 = (s1, e1) => { proxy_updateorg.UpdateListItemsCompleted -= handler2; }; proxy_updateorg.UpdateListItemsCompleted += handler2; proxy_updateorg.UpdateListItemsAsync("bcheck", updateQuery); }
/// <summary> /// need to hit 2 different services in order to get full history: CSOM and lists.asmx /// </summary> /// <param name="contentItem"></param> /// <param name="ctx"></param> /// <param name="item"></param> private void LoadContentHistory(IHasContentHistory contentItem, ClientContext ctx, ListItem item) { _log.LogInformation("load history for item {item} ", item.Id); var introTextFieldName = (item.ContentType.Name == "RuleSummaryPage") ? "RuleSummaryIntro" : "RuleContentTop"; var file = ctx.Web.GetFileByServerRelativeUrl($"/Pages/{item["FileLeafRef"]}"); ctx.Load(file); var versions = file.Versions; ctx.Load(versions); var oldVersions = ctx.LoadQuery(versions.Where(v => v != null)); ctx.ExecuteQuery(); var svc = new ListsSoapClient(); svc.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential(_appSettings.Username, _appSettings.Password, "SSW2000"); XNamespace xmlns = "http://schemas.microsoft.com/sharepoint/soap/"; var fields = new List <string> { "Title", introTextFieldName, "PublishingPageContent" }; // we need to fetch history for each field individually - and we might not have data for every record reported by the "Version" field // build this data into a 2-level dictionary fieldName->modifiedDate->Value // use of modified date key ensures we map incomplete datasets to correct versions var fieldHistoryData = new Dictionary <string, Dictionary <string, string> >(); foreach (var field in fields) { fieldHistoryData[field] = new Dictionary <string, string>(); var fieldVersionsXml = svc.GetVersionCollection("Pages", item.Id.ToString(), field); var elements = fieldVersionsXml.Descendants(xmlns + "Version"); foreach (var element in elements) // note: I started with a ToDictionary() here but we need to handle duplicate 'modified' value in source data { var modified = element.Attribute("Modified")?.Value; if (!string.IsNullOrWhiteSpace(modified) && !fieldHistoryData[field].ContainsKey(modified)) { fieldHistoryData[field][modified] = element.Attribute(field)?.Value; } } } // now fetch all data for the "Version" field to make ContentVersion objects - adding fields from fieldHistoryData where we can var versionsXml = svc.GetVersionCollection("Pages", item.Id.ToString(), "Version"); var contentVersions = versionsXml.Descendants(xmlns + "Version") .Select(v => new ContentVersion() { VersionLabel = v.Attribute("Version")?.Value, Comment = oldVersions.FirstOrDefault(x => x.VersionLabel == v.Attribute("Version")?.Value) ?.CheckInComment, ModifiedUtc = DateTime.Parse(v.Attribute("Modified")?.Value), ModifiedBy = v.Attribute("Editor")?.Value?.Split(new char[] { ',' })[2], ModifiedByFullName = v.Attribute("Editor")?.Value?.Split(new char[] { ',' })[4], Title = fieldHistoryData.ValueOrNull("Title")?.ValueOrNull(v.Attribute("Modified")?.Value), IntroText = fieldHistoryData.ValueOrNull(introTextFieldName)?.ValueOrNull(v.Attribute("Modified")?.Value), Content = fieldHistoryData.ValueOrNull("PublishingPageContent")?.ValueOrNull(v.Attribute("Modified")?.Value), }).ToList(); contentItem.Versions = contentVersions; }
public TaskSummaryServiceAgent(String asmxUrl, string siteURL) { AsmxUrl = asmxUrl; proxy_query = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(AsmxUrl, ServiceParamStatHelper.Actions.QUERY, "UNKNOWN")); }
public FucntionalChoicesServicesAgent(string AsmxUrl) { proxy_query = new ListsSoapClient("ListsSoap",ServiceParamStatHelper.SetParams(AsmxUrl, ServiceParamStatHelper.Actions.UPDATE, "UNKNOWN")); proxy_update = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(AsmxUrl, ServiceParamStatHelper.Actions.QUERY,"UNKNOWN")); }
public void DeleteList(SharepointList selectedList, Action<bool> reply) { proxy_update = new ListsSoapClient("ListsSoap", ServiceParamStatHelper.SetParams(AsmxUrl, ServiceParamStatHelper.Actions.UPDATE, "UNKNOWN")); EventHandler<AsyncCompletedEventArgs> deletelisthandler = null; deletelisthandler = (s, e) => { if (e.Error == null) { String strBatch = "<Batch>"; strBatch += "<Method ID='1' Cmd='Delete'>"; strBatch += "<Field Name='ID'>" + selectedList.bCheckListItemID + "</Field>"; strBatch += "</Method></Batch>"; XElement deleteItem = XElement.Parse(strBatch); EventHandler<UpdateListItemsCompletedEventArgs> deletebCheckItemhandler = null; deletebCheckItemhandler = (s1, e1) => { if (e1.Error == null) { reply(true); } else { reply(false); } proxy_updateorg.UpdateListItemsCompleted -= deletebCheckItemhandler; }; proxy_updateorg.UpdateListItemsCompleted += deletebCheckItemhandler; proxy_updateorg.UpdateListItemsAsync("bcheck", deleteItem); } else { reply(false); } proxy_update.DeleteListCompleted -= deletelisthandler; }; proxy_update.DeleteListCompleted += deletelisthandler; proxy_update.DeleteListAsync(selectedList.ListName); }
private static void EnsureSharepointListColumnsCreated(SharepointList list, Action<Exception> exceptionCallback, ListsSoapClient wslist, Action doAction) { if (list.Columns == null) { wslist.GetListCompleted += (o, args) => { if (args.Error != null) { if (exceptionCallback != null) exceptionCallback(args.Error); } else { list.ParseColumns(args.Result); doAction(); } }; wslist.GetListAsync(list.Name); } else { doAction(); } }