示例#1
0
        public static void LoadRecycleBin(TreeNode parentNode, SPClient.RecycleBinItemCollection recycleBinItems, MainBrowser form, LoadType loadType)
        {
            try
            {
                SPClient.ClientContext ctx = GetClientContext(parentNode);
                ctx.Load(recycleBinItems);
                ctx.ExecuteQuery();

                int total   = recycleBinItems.Count;
                int current = 0;

                foreach (var recycleBinItem in recycleBinItems)
                {
                    TreeNode node = parentNode.Nodes.Add(string.Format("{0}", recycleBinItem.Title));
                    node.ImageKey         = Constants.IMAGE_RECYCLE_BIN;
                    node.SelectedImageKey = Constants.IMAGE_RECYCLE_BIN;
                    node.Tag = recycleBinItem;
                    node.ContextMenuStrip = form.mnContextItem;

                    // Update progress
                    current++;
                    ItemLoaded(null, new ItemLoadedEventArgs()
                    {
                        TotalItem = total, CurrentItem = current
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, form.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);

                AddLoadingNode(parentNode, loadType);
            }
        }
示例#2
0
        private void EmptyTheRecycleBin()
        {
            try
            {
                using (var clientContext = new ClientContext(siteURL))
                {
                    // Get the SharePoint site
                    Site site = clientContext.Site;

                    // Delete all the recycle bin items
                    SP.RecycleBinItemCollection rbc = site.RecycleBin;
                    //if (rbc.Count > 0)
                    //{
                    rbc.DeleteAll();
                    // Execute the query to the server
                    clientContext.ExecuteQuery();

                    //}
                }

                Console.WriteLine("Recycle Bin Emptied");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException.Message);
            }
        }
示例#3
0
        private void EmptyTheRecycleBin()
        {
            using (var clientContext = new ClientContext(cboSiteURL.SelectedItem.ToString()))
            {
                // Get the SharePoint site
                Site site = clientContext.Site;

                // Delete all the recycle bin items
                SP.RecycleBinItemCollection rbc = site.RecycleBin;
                rbc.DeleteAll();

                // Execute the query to the server
                clientContext.ExecuteQuery();
            }

            MessageBox.Show("Recycle Bin Emptied", "Empty Reycle Bin", MessageBoxButtons.OK, MessageBoxIcon.Information);

            //Re-populates Grid
            PopulateDGVviaOnPrem();
        }