public Result UndoCheckOutFile(ISiteSetting siteSetting, IItem item) { SPListItem spLListItem = (SPListItem)item; ISharePointService spService = new SharePointService(); return(spService.UndoCheckOutFile(siteSetting, spLListItem.WebURL, spLListItem.URL)); }
public Result CheckInFile(ISiteSetting siteSetting, IItem item, string comment, CheckinTypes checkinType) { SPListItem spLListItem = (SPListItem)item; ISharePointService spService = new SharePointService(); return(spService.CheckInFile(siteSetting, spLListItem.WebURL, spLListItem.URL, comment, checkinType)); }
/// <summary> /// Return Parent Folder with object /// </summary> /// <param name="siteSetting">Site Setting</param> /// <param name="folder">Folder to retreive</param> /// <returns></returns> public Folder GetParentFolder(ISiteSetting siteSetting, Folder folder) { SPBaseFolder spFolder = folder as SPBaseFolder; string folderPath = spFolder.WebUrl.CombineUrl(spFolder.FolderPath).TrimEnd(new char[] { '/' }); if (folderPath.Equals(siteSetting.Url, StringComparison.OrdinalIgnoreCase) == true) { return(null); } //folderPath = folderPath.Substring(0, folderPath.LastIndexOf('/'));//JD folderPath = folderPath.TrimEnd('/'); ISharePointService spService = new SharePointService(); if (folder as SPList != null) { //return spService.GetWeb(siteSetting, folderPath); return(spService.GetList(siteSetting, folderPath)); } else if (folder as SPWeb != null) { return(spService.GetWeb(siteSetting, folderPath)); } else { if (folder.GetRoot() == folder.GetUrl()) { return(spService.GetList(siteSetting, folderPath)); } return(spService.GetList(siteSetting, folderPath)); //return spService.GetFolder(siteSetting, folderPath); } }
public ActionResult Delete(Product product) { var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); SharePointService.DeleteProduct(spContext, product); return(RedirectToAction("Index", new { SPHostUrl = SharePointContext.GetSPHostUrl(HttpContext.Request).AbsoluteUri })); }
public Folder GetRootFolder(ISiteSetting siteSetting) { ISharePointService spService = new SharePointService(); return(spService.GetWeb(siteSetting, siteSetting.Url)); //return new SPWeb(siteSetting.Url, siteSetting.Url, siteSetting.ID, siteSetting.Url, siteSetting.Url, siteSetting.Url); }
public ActionResult Deploy(string spHostUrl) { var context = SharePointContextProvider.Current.GetSharePointContext(HttpContext); var service = new SharePointService(context); TempData["Message"] = service.Deploy(); return(RedirectToAction("Home", new { SPHostUrl = spHostUrl })); }
public List <IItem> GetListItems(ISiteSetting siteSetting, string webUrl, string listName, bool isRecursive) { ISharePointService spService = new SharePointService(); string next; int count; return(spService.GetListItems(siteSetting, null, String.Empty, true, false, webUrl, listName, null, String.Empty, null, isRecursive, out next, out count)); }
public ActionResult FillHostWebSupportCasesToThreshold(string spHostUrl) { var context = SharePointContextProvider.Current.GetSharePointContext(HttpContext); var service = new SharePointService(context); TempData["Message"] = service.FillHostWebSupportCasesToThreshold(); return(RedirectToAction("Home", new { SPHostUrl = spHostUrl })); }
public List <ItemVersion> GetListItemVersions(ISiteSetting siteSetting, IItem item) { string webUrl = ((SPListItem)item).WebURL; string fileURL = ((SPListItem)item).URL; ISharePointService spService = new SharePointService(); return(spService.GetListItemVersions(siteSetting, webUrl, fileURL)); }
public ActionResult Delete(int id) { var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); Product product = SharePointService.GetProductDetails(spContext, id); return(View(product)); }
public Result CopyItem(ISiteSetting siteSetting, Folder targetFolder, IItem copySource, string newFileName) { SPFolder spFolder = (SPFolder)targetFolder; SPListItem spListItem = (SPListItem)copySource; ISharePointService spService = new SharePointService(); return(spService.CopyFile(siteSetting, spFolder.WebUrl, spFolder.ListName, spFolder.FolderPath + "/" + newFileName)); }
public ActionResult UninstallTheApp(string spHostUrl) { var context = SharePointContextProvider.Current.GetSharePointContext(HttpContext); var service = new SharePointService(context); service.UninstallTheApp(); TempData["Message"] = "The App has been uninstalled successfully."; return(RedirectToAction("Home", new { SPHostUrl = spHostUrl })); }
public ActionResult FillAppWebNotesWith1G(string spHostUrl) { var context = SharePointContextProvider.Current.GetSharePointContext(HttpContext); var service = new SharePointService(context); var count = service.FillAppWebNotesWith1G(); TempData["Message"] = count + " items have been added to the App Web Notes list, and every item size is more than 1MB."; return(RedirectToAction("Home", new { SPHostUrl = spHostUrl })); }
private async Task LoadData() { IsLoading = true; throw new NotImplementedException("Load Data From SharePoint!"); SharePointService.GetStringFromSharePointUrl(new Uri("....")); IsLoading = false; }
private void UserControl_Loaded(object sender, RoutedEventArgs e) { SharePointService sharePointService = new SharePointService(); List <SPWebpart> webparts = sharePointService.GetWebparts(this.SiteSetting, this.FileLeafRef); foreach (SPWebpart wp in webparts) { AddNode(WebpartsTreeView.Items, wp.Title, wp, Brushes.Black); } }
private void InternalExecute() { _packages.Clear(); if (string.IsNullOrEmpty(Url)) { throw new ArgumentException("Url"); } if (IsSharePointOnline) { if (string.IsNullOrEmpty(UserName)) { throw new ArgumentException("UserName"); } if (string.IsNullOrEmpty(UserPassword)) { throw new ArgumentException("UserPassword"); } } var spService = new SharePointService(); spService.WithSharePointContext(Url, UserName, UserPassword, IsSharePointOnline, context => { var repoFolder = AppDomain.CurrentDomain.BaseDirectory; var repo = PackageRepositoryFactory.Default.CreateRepository(repoFolder); // create manager with empty repo to avoid connectivity var packageManager = new DefaultMetaPackSolutionPackageManager(repo, context); //var packages = packageManager.LocalRepository.GetPackages(); var packages = packageManager.LocalRepository.Search( string.Empty, Enumerable.Empty <string>(), this.PreRelease); packages = packages.GroupBy(p => p.Id) .Select(g => g.OrderByDescending(p => p.Version).FirstOrDefault()); packages = packages.Where(p => p != null); foreach (var package in packages) { _packages.Add(package); Out.WriteLine(package.GetFullName()); } }); }
public override void TestInitialize() { base.TestInitialize(); ShimClientContext.AllInstances.ExecuteQuery = (a) => { }; ShimClientContext.AllInstances.WebGet = (a) => new ShimWeb(); ShimWeb.AllInstances.ListsGet = (a) => new ShimListCollection(); var spContextHelper = Substitute.For <ISharePointContextHelper>(); spContextHelper.ClientContext.Returns(new ShimClientContext()); fakeColumnMapping = Substitute.For <IColumnMappingResolver>(); sharePointSerivce = new SharePointService(spContextHelper, fakeColumnMapping); }
public void it_should_remove_all_illegal_characters() { // Arrange var fakeName = "? f|<a>\\ke *\\\\:<>?/|\"#%' /n%a$m#e:"; string[] illegalChars = { "*", "\\", ":", "<", ">", "?", "/", "|", "\"", "#", "%", "'" }; // Act fakeName = SharePointService.GetValidDocumentName(fakeName, ""); // Assert fakeName.Should().NotContainAny(illegalChars); }
public ActionResult Home() { var context = SharePointContextProvider.Current.GetSharePointContext(HttpContext); var sharePointService = new SharePointService(context); var currentUser = sharePointService.GetCurrentUser(); ViewBag.UserName = currentUser.Title; var surveyRatingsService = new SurveyRatingsService(); ViewBag.Score = surveyRatingsService.GetUserScore(currentUser.UserId.NameId); return(View()); }
public bool CheckConnection(ISiteSetting siteSetting) { SharePointService spService = new SharePointService(); SPWeb web = null; try { web = spService.GetWeb(siteSetting, siteSetting.Url); } catch { } return(web == null ? false : true); }
public List <IItem> GetListItems(Folder folder, IView view, string sortField, bool isAsc, int currentPageIndex, string currentListItemCollectionPositionNext, CamlFilters filters, bool isRecursive, out string listItemCollectionPositionNext, out int itemCount) { SPFolder _folder = folder as SPFolder; string folderPath = string.Empty; if (folder as SPList == null) { folderPath = _folder.GetPath(); } ISharePointService spService = new SharePointService(); return(spService.GetListItems((SiteSetting)this.SiteSetting, (SPView)view, sortField, isAsc, _folder.IsDocumentLibrary, _folder.WebUrl, _folder.ListName, folderPath, currentListItemCollectionPositionNext, filters, isRecursive, out listItemCollectionPositionNext, out itemCount)); }
private void SaveWebpartPropertyButton_Click(object sender, RoutedEventArgs e) { string key = PropertiesLabel.Content.ToString(); string value = ValueTextBox.Text; SPWebpart webpart = ((TreeViewItem)WebpartsTreeView.SelectedItem).Tag as SPWebpart; SharePointService sharePointService = new SharePointService(); sharePointService.SaveWebpartProperty(this.SiteSetting, this.FileLeafRef, webpart.ID, key, value); DataRowView selectedRow = (DataRowView)ResultGrid.SelectedItem; selectedRow["Value"] = value; webpart.Properties[key] = value; }
public bool CheckItemCanBeCopied(ISiteSetting siteSetting, Folder targetFolder, IItem copyItem, string fileName) { SPFolder spFolder = (SPFolder)targetFolder; // list item does not anything unique like document has unique file name if (copyItem as SPListItem == null) { return(true); } SPDocument spDocument = (SPDocument)copyItem; ISharePointService spService = new SharePointService(); return(spService.CheckFileExistency(siteSetting, spFolder.WebUrl, spFolder.ListName, spFolder.FolderPath, null, fileName)); }
static void Main() { try { using (var client = new SharePointService(@"https://snconceptohg.sharepoint.com/Testumgebung", "_USER_", "_PASSWORD_")) { // Write var entry = new TestListEntry { Title = "Herr", Erstellt_Am = DateTime.Now, Name = "Mustermann" }; var id = client.AddItemToSharePointList(entry, "TestListe"); // Update var uentry = new TestListEntry { ID = id, Title = "Herr", Erstellt_Am = DateTime.Now, Name = "Meier" }; client.UpdateExistingItemOnSharePointList(uentry, "TestListe"); // Read var testList = client.ReadListFromSharePoint <TestListEntry>("TestListe"); foreach (var item in testList) { Console.WriteLine(item.ToString()); } // Delete client.DeleteEntryFromSharePointListById(id, "TestListe"); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } finally { Console.ReadLine(); } }
public ActionResult Index() { var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); ViewBag.Username = SharePointService.GetUserName(spContext); CamlQuery queryProducts = new CamlQuery(); queryProducts.ViewXml = @"<View><ViewFields><FieldRef Name='Title'/> <FieldRef Name='ProductDescription'/> <FieldRef Name='Price'/></ViewFields></View>"; List <Product> products = SharePointService.GetProducts(spContext, queryProducts); return(View(products)); }
public void UpdateListItem(ISiteSetting siteSetting, string webUrl, string listName, int listItemID, System.Collections.Generic.Dictionary <object, object> fields, System.Collections.Generic.Dictionary <string, object> auditInformation) { Hashtable changedProperties = SharePointService.getChangedProperties(null, fields); if (auditInformation["Editor"] != null && auditInformation["Editor"] != string.Empty) { changedProperties.Add("Editor", auditInformation["Editor"]); } if (auditInformation["Modified"] != null && auditInformation["Modified"] != string.Empty) { changedProperties.Add("Modified", auditInformation["Modified"]); } SharePointService.UpdateListItem(siteSetting, webUrl, listName, listItemID, changedProperties, true); }
public Folder GetFolder(ISiteSetting siteSetting, BasicFolderDefinition folderDefinition) { ISharePointService spService = new SharePointService(); if (typeof(SPList).FullName.Equals(folderDefinition.FolderType, StringComparison.OrdinalIgnoreCase) == true) { return(spService.GetList(siteSetting, folderDefinition.FolderUrl)); } else if (typeof(SPWeb).FullName.Equals(folderDefinition.FolderType, StringComparison.OrdinalIgnoreCase) == true) { return(spService.GetWeb(siteSetting, folderDefinition.FolderUrl)); } else { return(spService.GetFolder(siteSetting, folderDefinition.FolderUrl)); } }
public ActionResult AddProduct(string title, string description, string price) { HttpStatusCodeResult httpCode = new HttpStatusCodeResult(HttpStatusCode.MethodNotAllowed); var spContext = SharePointContextProvider.Current.GetSharePointContext(HttpContext); Product newProduct = new Product(); newProduct.Title = title; newProduct.Description = description; newProduct.Price = price; if (SharePointService.AddProduct(spContext, newProduct)) { httpCode = new HttpStatusCodeResult(HttpStatusCode.Created); } return(httpCode); }
/// <summary> /// ファイルの処理 /// </summary> /// <param name="file">ファイル</param> private async void HandleFile(File file) { spservice = new SharePointService(); // ファイルを SharePointOnline より取得 var filedata = await spservice.GetContent(file.ServerRelativeUrl); // ファイルが編集対象とマーク file.InEdit = true; // 後で比較するため、現在のファイルサイズを保存 file.Size = filedata.Length; var path = await Xamarin.Forms.DependencyService.Get <IFileService>().SaveFile(file.Name, filedata); string type = ""; // 拡張子からタイプを設定 string extension = file.Name.Split('.').Count() > 1 ? file.Name.Split('.').Last() : "application/*"; if (extension == "pptx") { type = "application/vnd.openxmlformats-officedocument.presentationml.presentation"; } else if (extension == "ppt") { type = "application/vnd.ms-powerpoint"; } else if (extension == "docx") { type = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; } else if (extension == "xlsx") { type = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; } else if (extension == "txt") { type = "application/txt"; } Xamarin.Forms.DependencyService.Get <IOpenUriService>().OpenFile(path, type); }
public List <Folder> GetSubFolders(Folder folder) { ISharePointService spService = new SharePointService(); List <Folder> subFolders = new List <Folder>(); /* * if (folder as SPWeb != null) * { * SPWeb web = (SPWeb)folder; * List<SPWeb> webs = spService.GetWebs(web.Url, (SiteSetting)this.SiteSetting); * foreach (SPWeb _web in webs) * { * _web.ParentFolder = web; * subFolders.Add(_web); * } * List<SPList> lists = spService.GetLists(web.Url, (SiteSetting)this.SiteSetting); * foreach (SPList list in lists) * { * if ( * (list.ServerTemplate == 101 || list.ServerTemplate == 100 || list.BaseType == 1) //or BaseType == 1 * && list.Hidden == false * ) * { * list.ParentFolder = web; * subFolders.Add(list); * } * } * } * else if (folder as SPFolder != null) * { * SPFolder _folder = (SPFolder)folder; * List<Folder> folders = spService.GetFolders(_folder, (SiteSetting)this.SiteSetting); * foreach (SPFolder __folder in folders) * { * __folder.ParentFolder = _folder; * subFolders.Add(__folder); * } * } */ return(subFolders); }