/// <summary> /// Create channel object from Ice channel object /// </summary> /// <param name="u"></param> /// <returns></returns> internal static VirtualServerEntity.Channel getChannel(Channel c) { var channel = new VirtualServerEntity.Channel() { Id = c.id, Name = c.name, Description = c.description, ParentId = c.parent, Links = c.links, Position = c.position, Temporary = c.temporary, }; return(channel); }
/// <summary> /// Update exist channel /// </summary> /// <param name="channel"></param> /// <param name="setAcl">add acls and groups?</param> public void UpdateChannel(VirtualServerEntity.Channel channel, bool setAcl = false) { // set channel info var state = new Channel(channel.Id, channel.Name, channel.ParentId, channel.Links, channel.Description, false, channel.Position); // WARNING! LINKS MUST BE VALID OR InvalidChannelException will be thrown _server.setChannelState(state); if (setAcl) { // set groups Group[] groups = new Group[channel.Groups.Count]; for (int i = 0; i < channel.Groups.Count; i++) { var g = channel.Groups[i]; groups[i] = new Group(g.Name, g.Inherited, g.Inherit, g.Inheritable, g.Add, g.Remove, g.Members); } // set acls ACL[] acls = new ACL[channel.Acls.Count]; for (int i = 0; i < channel.Acls.Count; i++) { var a = channel.Acls[i]; acls[i] = new ACL(a.ApplyHere, a.ApplySubs, a.Inherited, a.UserId, a.Group, a.Allow, a.Deny); } _server.setACL(channel.Id, acls, groups, channel.InheritAcl); } // update in cache if (_entity.Channels.ContainsKey(channel.Id)) { _entity.Channels[channel.Id] = channel; } else { _entity.Channels.Add(channel.Id, channel); } }