public List <FavoritesEntry> GetRemoteFavorites(string SiteCollection, string Site, string List) { List <FavoritesEntry> result = new List <FavoritesEntry>(); SPWeb web = ConnectToWeb(SiteCollection, Site); SPList list = web.Lists[List]; FavoritesEntry entry; foreach (SPListItem item in list.Items) { entry = new FavoritesEntry(); SPFieldUrlValue url = new SPFieldUrlValue(item["URL"].ToString()); entry.Url = url.Url; entry.Display = url.Description; if (item["Favorites Topic"] != null) { entry.Topic = item["Favorites Topic"].ToString(); } entry.SPID = item.UniqueId; entry.Modified = DateTime.Parse(item["Modified"].ToString()); result.Add(entry); } return(result); }
public static string CreateLocalFavorite(FavoritesEntry Favorite) { string dir = GetFavoritesDirectory(Favorite); if (Directory.Exists(dir) == false) { Directory.CreateDirectory(dir); } string path = GetFavoritesPath(dir, Favorite); DeleteLocalFavorite(path); StreamWriter sw = File.CreateText(path); sw.WriteLine("[DEFAULT]"); sw.WriteLine("BASEURL=" + Favorite.Url); sw.WriteLine("[InternetShortcut]"); sw.WriteLine("URL=" + Favorite.Url); sw.WriteLine("IDList=[{000214A0-0000-0000-C000-000000000046}]"); sw.WriteLine("Prop3=19,2"); sw.Close(); return(path); }
public static List <FavoritesEntry> GetLocalFavorites() { string FavoritesPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); DirectoryInfo FavoritesDir = new DirectoryInfo(FavoritesPath); List <FavoritesEntry> result = new List <FavoritesEntry>(); FavoritesEntry item; foreach (FileInfo file in FavoritesDir.GetFiles("*.url", SearchOption.AllDirectories)) { item = new FavoritesEntry(); item.Display = file.Name.Substring(0, file.Name.Length - 4); if (FavoritesPath != file.DirectoryName) { item.Topic = file.Directory.Name; } else { item.Topic = string.Empty; } item.Url = ReadURLFromFile(file.FullName); item.Modified = file.LastWriteTime; item.LocalPath = file.FullName; result.Add(item); } return(result); }
private void DownloadFavorites(object sender, EventArgs e) { lblStatus.Text = string.Empty; string collection = txtCollection.Text; string web = cbSite.SelectedItem.ToString(); string list = cbList.SelectedItem.ToString(); InitializeWS(); List <FavoritesEntry> ClientFavs = FavoritesEntry.GetLocalFavorites(); List <FavoritesEntry> SPFavs = new List <FavoritesEntry>(); SPFavs.AddRange(FavoritesEntry.Deserialize(fws.GetRemoteFavorites(collection, web, list))); foreach (FavoritesEntry SPFav in SPFavs) { foreach (FavoritesEntry ClientFav in ClientFavs) { if (ClientFav.Url == SPFav.Url) { FavoritesEntry.DeleteLocalFavorite(ClientFav); break; } } FavoritesEntry.CreateLocalFavorite(SPFav); } lblStatus.Text = "Favorites have been downloaded"; }
private static string GetFavoritesPath(string path, FavoritesEntry item) { if (item.Topic != string.Empty) { path += @"\"; } path += item.Display + ".url"; return(path); }
private void CreateItem(SPList List, FavoritesEntry ClientEntry) { SPListItem item = List.Items.Add(); item["Title"] = ClientEntry.Display; //sp structure to store urls SPFieldUrlValue url = new SPFieldUrlValue(); url.Url = ClientEntry.Url; url.Description = ClientEntry.Display; item["URL"] = url; item["Favorites Topic"] = ClientEntry.Topic; item.Update(); }
private void UploadFavorites(object sender, EventArgs e) { lblStatus.Text = string.Empty; string collection = txtCollection.Text; string web = cbSite.SelectedItem.ToString(); string list = cbList.SelectedItem.ToString(); InitializeWS(); List <FavoritesEntry> items = FavoritesEntry.GetLocalFavorites(); fws.UploadFavorites(collection, web, list, FavoritesEntry.Serialize(items.ToArray())); lblStatus.Text = "Favorites have been uploaded"; }
private void DeleteItem(SPList List, FavoritesEntry SPEntry) { SPListItem item = List.Items[SPEntry.SPID]; item.Delete(); }
public string GetRemoteFavorites(string SiteCollection, string SharepointSite, string List) { FavoritesLogic fs = new FavoritesLogic(); return(FavoritesEntry.Serialize(fs.GetRemoteFavorites(SiteCollection, SharepointSite, List).ToArray())); }
public void UploadFavorites(string SiteCollection, string SharepointSite, string List, string Favorites) { FavoritesLogic fs = new FavoritesLogic(); fs.UploadItems(SiteCollection, SharepointSite, List, FavoritesEntry.Deserialize(Favorites)); }
private static string GetFavoritesDirectory(FavoritesEntry item) { string FavoritesPath = Environment.GetFolderPath(Environment.SpecialFolder.Favorites); return(FavoritesPath + "\\" + item.Topic); }
public static void DeleteLocalFavorite(FavoritesEntry Favorite) { string path = GetFavoritesPath(GetFavoritesDirectory(Favorite), Favorite); DeleteLocalFavorite(path); }