Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Microsoft.SharePoint;
- using Microsoft.SharePoint.Administration;
- namespace SharePoint_Info
- {
- public class Servers
- {
- public event EventHandler TableDataChanged;
- private List<Server> tableData;
- public List<Server> TableData
- {
- get { return tableData; }
- set
- {
- tableData = value;
- if (TableDataChanged != null)
- {
- TableDataChanged(this, EventArgs.Empty);
- }
- }
- }
- public Servers()
- {
- }
- public class GetFarm
- {
- public static Servers GetServerList(string caurl)
- {
- Servers table = new Servers();
- table.tableData = new List<Server>();
- Server item = new Server();
- SPWebApplication oWebApplication = SPWebApplication.Lookup(new Uri(caurl));
- SPFarm farm = oWebApplication.Farm;
- foreach (SPServer server in farm.Servers)
- {
- item.ServerName = server.DisplayName;
- item.ServerIP = server.Address;
- table.TableData.Add(item);
- };
- return table;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement