- Timestamp:
- 03/23/10 10:50:26 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/UptimeCalendarDao.cs
r3022 r3203 96 96 97 97 Context.SubmitChanges(); 98 } 99 100 public IEnumerable<AppointmentDto> GetCalendarForClient(ClientDto client) { 101 Client dbc = Context.Clients.SingleOrDefault(c => c.ResourceId.Equals(client.Id)); 102 IList<AppointmentDto> appointments = new List<AppointmentDto>(); 103 if (dbc != null) { 104 ClientGroup cg = 105 Context.ClientGroups.SingleOrDefault(cgroup => cgroup.ResourceId.Equals(dbc.UseCalendarFromResourceId)); 106 //in case no plan has been set 107 if (cg == null) 108 if (dbc.Resource.ClientGroup_Resources.FirstOrDefault() != null) 109 cg = dbc.Resource.ClientGroup_Resources.FirstOrDefault().ClientGroup; 110 111 if (cg == null) 112 return appointments; 113 114 while (cg.Resource.UptimeCalendars.Count == 0) { 115 if (cg.Resource.ClientGroup_Resources.FirstOrDefault() != null) 116 cg = cg.Resource.ClientGroup_Resources.FirstOrDefault().ClientGroup; 117 else { 118 break; 119 } 120 } 121 122 foreach (UptimeCalendar appointment in cg.Resource.UptimeCalendars) { 123 appointments.Add(EntityToDto(appointment,null)); 124 } 125 126 } 127 return appointments; 128 } 129 130 public void NotifyClientsOfNewCalendar(Guid groupId, bool forcePush) { 131 132 //Get the current ClientGroup 133 ClientGroup cg = Context.ClientGroups.SingleOrDefault(cgroup => cgroup.ResourceId.Equals(groupId)); 134 if(cg == null) 135 return; 136 137 //Get all the affected clients 138 List<Client> clients = Context.Clients.Where(c => c.UseCalendarFromResourceId.Equals(cg.ResourceId)).ToList(); 139 140 //Set new state 141 foreach (Client client in clients) { 142 client.CalendarSyncStatus = (forcePush ? Enum.GetName(typeof(CalendarState), CalendarState.ForceFetch) : Enum.GetName(typeof(CalendarState), CalendarState.Fetch)); 143 } 144 145 Context.SubmitChanges(); 146 147 //Get all Subgroups 148 List<ClientGroup> groups = (from cg1 in Context.ClientGroups 149 where cg1.Resource.ClientGroup_Resources.Any( 150 cgr => cgr.ClientGroupId.Equals(groupId)) 151 select cg1).ToList(); 152 153 //If they have their own calendar - stop propagation 154 //otherweise - propagate 155 foreach (ClientGroup cgroup in groups) { 156 if(cgroup.Resource.UptimeCalendars.Count == 0) 157 NotifyClientsOfNewCalendar(groupId, forcePush); 158 } 98 159 } 99 160
Note: See TracChangeset
for help on using the changeset viewer.