Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static SectionClasses.Server[] GetAllActiveServers()
- {
- SectionClasses.Server[] RC = null;
- System.Collections.Hashtable ServerData = new System.Collections.Hashtable();
- using (var Context = new STDBEntities())
- {
- try
- {
- var Query = (
- from s in Context.Servers
- from c in Context.Contacts
- where s.PrimaryContactID == c.ContactID &&
- s.Active == true
- select new
- {
- s.ServerName,
- s.PrimaryContactID,
- s.ServerLocation,
- s.ServerType.ServerTypeName,
- s.IsLocked,
- c.Name,
- s.ServerID
- }
- );
- int i = 0;
- RC = new SectionClasses.Server[Query.Count()];
- foreach (var Set in Query)
- {
- ServerData.Clear();
- ServerData.Add("ServerID", Set.ServerID);
- ServerData.Add("ServerName", Set.ServerName);
- ServerData.Add("ServerLocation", Set.ServerLocation);
- ServerData.Add("ServerTypeID", Set.ServerTypeName);
- ServerData.Add("IsLocked", Set.IsLocked);
- System.Collections.Hashtable temp = new System.Collections.Hashtable();
- temp.Add("ContactID", Set.PrimaryContactID);
- temp.Add("Name", Set.Name);
- ServerData.Add("PrimaryContactID", new SectionClasses.Contact(temp));
- RC[i++] = new SectionClasses.Server(ServerData);
- }
- }
- catch (InvalidKeyException e)
- {
- Context.Connection.Close();
- Console.WriteLine(e.Message);
- }
- catch
- {
- Context.Connection.Close();
- throw new Exception("Connection to Database could not be established");
- }
- }
- return RC;
- }
Advertisement
Add Comment
Please, Sign In to add comment