private static DataTable GetAllGroups() { var groupUMP = new GroupManagement(); var UserGroup = groupUMP.GroupTable(); return(UserGroup.DefaultView.ToTable(false, new string[] { "GroupId", "GroupName", "GroupDescription", "GroupNameLower", "GroupDescriptionLower", "GroupColor" })); }
protected override void OnInit(EventArgs e) { base.OnInit(e); groupManagement = new GroupManagement(GetDirectory(), username); }
public List <SearchObject> GetAllActiveGroups() { GroupManagement groupManagement = new GroupManagement(); var groupList = groupManagement.GetAllActiveGroups().OrderBy(x => x.GroupName) .Select( row => new SearchObject { Key = row.GroupId.ToString(), Value = row.GroupName, Attribute = row.GroupColor }).Distinct().ToList(); return(groupList); }
/// <summary> /// tao model gom danh sach group va cac resources cua no /// </summary> /// <returns></returns> List <GroupManagement> InitModel() { List <GroupManagement> result = new List <GroupManagement>(); //load toan bo group tu database List <PerGroup> groups = PerGroupDAO.getAll(); foreach (PerGroup group in groups) { //gan tung group cho thuoc tinh group cua model GroupManagement groupManagement = new GroupManagement(); groupManagement.PerGroup = group; groupManagement.GetListResourcesByGroupID(group.GroupID); result.Add(groupManagement); } return(result); }
/// <summary> /// Add System Admin /// </summary> /// <param name="userName">User name</param> /// <param name="firstName">Full name of user</param> /// <param name="lastName">Last name of user</param> /// <param name="emailId">Email Id</param> /// <param name="password">Password</param> public static void AddSystemAdmin(string userName, string firstName, string lastName, string emailId, string password) { LogExtension.LogInfo("Creating system admin", MethodBase.GetCurrentMethod()); var encrypt = new Cryptography(); var umpUser = new User(); var userManagement = new UserManagement(GlobalAppSettings.QueryBuilder, GlobalAppSettings.DataProvider); var groupManagement = new GroupManagement(GlobalAppSettings.QueryBuilder, GlobalAppSettings.DataProvider); umpUser.Password = Convert.ToBase64String(encrypt.Encryption(password)); umpUser.CreatedDate = DateTime.UtcNow; umpUser.ModifiedDate = DateTime.UtcNow; umpUser.IsActive = true; umpUser.IsDeleted = false; umpUser.ResetPasswordCode = "default"; umpUser.ActivationCode = "default"; umpUser.UserName = userName; umpUser.FirstName = firstName.Trim(); umpUser.LastName = lastName.Trim(); umpUser.DisplayName = (umpUser.FirstName.Trim() + " " + umpUser.LastName.Trim()).Trim(); umpUser.Email = emailId; umpUser.IsActivated = true; var activationCode = String.Empty; var activationExpirationDate = new DateTime(); LogExtension.LogInfo("Adding user in user table", MethodBase.GetCurrentMethod()); var result = userManagement.AddUser(umpUser, out activationExpirationDate, out activationCode); if (result.Status) { LogExtension.LogInfo("Adding user in user table succesful", MethodBase.GetCurrentMethod()); LogExtension.LogInfo("Adding user in super admin group table", MethodBase.GetCurrentMethod()); var userGroup = groupManagement.AddUserInGroup(Convert.ToInt32(result.ReturnValue), 1); LogExtension.LogInfo("Is user added in super admin?" + userGroup, MethodBase.GetCurrentMethod()); //var permissionSet = new PermissionSet(); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllCategories, // TargetId = 1 //}); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllReports, // TargetId = 1 //}); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllSchedules, // TargetId = 1 //}); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllDataSources, // TargetId = 1 //}); //permissionSet.AddPermissionToGroup(new Permission //{ // PermissionAccess = PermissionAccess.Create, // PermissionEntity = PermissionEntity.AllFiles, // TargetId = 1 //}); } else { LogExtension.LogInfo("Error in adding user in user table", MethodBase.GetCurrentMethod()); } }
static void ThreadFunc() { string masterBedroom = "uuid:RINCON_000E5810848C01400"; ZonePlayer zonePlayer = new ZonePlayer(masterBedroom); Console.WriteLine(zonePlayer.DeviceProperties.Icon); //UPnPDevice mediaServer = zonePlayer.MediaServer; //UPnPDevice mediaRenderer = zonePlayer.MediaRenderer; //AudioIn audioIn = zonePlayer.AudioIn; DeviceProperties deviceProperties = zonePlayer.DeviceProperties; RenderingControl renderingControl = zonePlayer.RenderingControl; AVTransport avTransport = zonePlayer.AVTransport; ContentDirectory contentDirectory = zonePlayer.ContentDirectory; GroupManagement groupManagement = zonePlayer.GroupManagement; //ZoneGroupTopology zoneGroupTopology = zonePlayer.ZoneGroupTopology; //ConnectionManager connectionManager = zonePlayer.ConnectionManager; foreach (XPathNavigator node in contentDirectory.Browse("0", BrowseFlags.BrowseDirectChildren, "*", "")) { Console.WriteLine(node.OuterXml); #if FOO string path = HttpUtility.UrlDecode(node.SelectSingleNode("@id", Sonority.XPath.Globals.Manager).Value); path = path.Replace(@"S://", @"\\"); path = path.Replace('/', '\\'); string destination = Path.Combine(@"c:\temp\nuevo", Path.GetFileName(path)); Console.WriteLine("{0}", path); File.Copy(path, destination); #endif } foreach (QueueItem node in zonePlayer.Queue) { Console.WriteLine(node); } zonePlayer.Queue.ToString(); avTransport.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); contentDirectory.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); renderingControl.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged); #if FOO using (foo bar = new foo()) { // check updateIDs first Queue <string> queue = new Queue <string>(); queue.Enqueue("S:"); queue.Enqueue("0"); while (queue.Count > 0) { string currentObject = queue.Dequeue(); // box is down, ignore for now. if (currentObject.StartsWith("S://13CFB6DD7F03432", StringComparison.OrdinalIgnoreCase)) { continue; } foreach (XPathNavigator node in contentDirectory.Browse(currentObject, BrowseFlags.BrowseDirectChildren, "*", "")) { if (node.LocalName == "container") { // recurse into container queue.Enqueue(node.SelectSingleNode("@id").Value); } bar.AddRecord( node.SelectSingleNode("@id", XPath.Globals.Manager).Value, node.SelectSingleNode("@parentID", XPath.Globals.Manager).Value, 0, node); } } } Thread.Sleep(Timeout.Infinite); Console.WriteLine(contentDirectory.ToString()); Console.WriteLine(avTransport.ToString()); // avTransport.Play("1"); #endif while (true) { Thread.Sleep(30000); foreach (ZoneGroup zp in disc.Topology) { Console.WriteLine("{0} -> {1}", zp.Coordinator.UniqueDeviceName, zp.Coordinator.DeviceProperties.ZoneName); } } }
/// <summary> /// Invoked when a message stanza has been received. /// </summary> /// <param name="stanza">The stanza which has been received.</param> /// <returns>true to intercept the stanza or false to pass the stanza /// on to the next handler.</returns> public bool Input(Message message) { if (message.Type == MessageType.Management) { // Do we receive an user invitation ? if (message.Data["userinvite"] != null) { XmlElement e = message.Data["userinvite"]; try { string invitationId = e.GetAttribute("id"); string action = e.GetAttribute("action"); // 'create', 'update', 'delete' string type = e.GetAttribute("type"); // 'received', 'sent' string status = e.GetAttribute("status"); // 'canceled', 'accepted' , 'pending' UserInvitation.Raise(this, new UserInvitationEventArgs(invitationId, action, type, status)); } catch (Exception) { } } // Do we receive message about conversation management else if (message.Data["conversation"] != null) { XmlElement e = message.Data["conversation"]; string conversationID = e.GetAttribute("id"); string action = e.GetAttribute("action"); // 'create', 'update', 'delete' Dictionary <string, string> data = new Dictionary <string, string>(); if (e["type"] != null) { data.Add("type", e["type"].InnerText); } if (e["peerId"] != null) { data.Add("peerId", e["peerId"].InnerText); } if (e["peer"] != null) { data.Add("jid_im", e["peer"].InnerText); } if (e["mute"] != null) { data.Add("mute", e["mute"].InnerText); } if (e["lastMessageText"] != null) { data.Add("lastMessageText", e["lastMessageText"].InnerText); } if (e["lastMessageSender"] != null) { data.Add("lastMessageSender", e["lastMessageSender"].InnerText); } if (e["lastMessageDate"] != null) { data.Add("lastMessageDate", e["lastMessageDate"].InnerText); } if (e["unreceivedMessageNumber"] != null) { data.Add("unreceivedMessageNumber", e["unreceivedMessageNumber"].InnerText); } if (e["unreadMessageNumber"] != null) { data.Add("unreadMessageNumber", e["unreadMessageNumber"].InnerText); } ConversationManagement.Raise(this, new ConversationManagementEventArgs(conversationID, action, data)); } // Do we receive message about favorite management else if (message.Data["favorite"] != null) { XmlElement e = message.Data["favorite"]; string id = e.GetAttribute("id"); string action = e.GetAttribute("action"); // 'create', 'update', 'delete' string type = e.GetAttribute("type"); // 'user', 'room', 'bot' string position = e.GetAttribute("position"); string peerId = e.GetAttribute("peer_id"); FavoriteManagement.Raise(this, new FavoriteManagementEventArgs(id, action, type, position, peerId)); } // Do we receive message about userpassword management else if (message.Data["userpassword"] != null) { XmlElement e = message.Data["userpassword"]; string action = e.GetAttribute("action"); // 'update' only ? if (action == "update") { PasswordUpdated.Raise(this, new EventArgs()); } } // Do we receive message about room/bubble management else if (message.Data["room"] != null) { XmlElement e = message.Data["room"]; string roomId = e.GetAttribute("roomid"); string roomJid = e.GetAttribute("roomjid"); string userJid = e.GetAttribute("userjid"); // Not empty if user has been accepted / invited / unsubscribed / deleted string status = e.GetAttribute("status"); // Not empty if user has been accepted / invited / unsubscribed / deleted string privilege = e.GetAttribute("privilege"); // Not empty if user has changed it's role: user / moderator / guest string topic = e.GetAttribute("topic"); // Not empty if room updated string name = e.GetAttribute("name"); // Not empty if room updated string lastAvatarUpdateDate = e.GetAttribute("lastAvatarUpdateDate"); // Not empty if avatar has been updated. if deleted "null" string string avatarAction = ""; if (e["avatar"] != null) { avatarAction = e["avatar"].GetAttribute("action"); } RoomManagement.Raise(this, new RoomManagementEventArgs(roomId, roomJid, userJid, status, privilege, name, topic, lastAvatarUpdateDate, avatarAction)); } // Do we receive message about visualvoicemail else if (message.Data["visualvoicemail"] != null) { // WE DO NOTHING HERE // WE USE "file" message and file descrptior to manage voice message //XmlElement e = message.Data["visualvoicemail"]; //string msgId = e.GetAttribute("msgid"); //string action = e.GetAttribute("action"); //string fileId = e["fileid"]?.InnerText; //string url = e["url"]?.InnerText; //string mimeType = e["mime"]?.InnerText; //string fileName = e["filename"]?.InnerText; //string size = e["size"]?.InnerText; //string md5 = e["md5sum"]?.InnerText; //string duration = e["duration"]?.InnerText; ////log.LogDebug("duration:[{0}]", duration); //VoiceMailManagement.Raise(this, new VoiceMailManagementEventArgs(msgId, fileId, action, url, mimeType, fileName, size, md5, duration)); } // Do we receive message about file else if (message.Data["file"] != null) { XmlElement e = message.Data["file"]; string action = e.GetAttribute("action"); string fileId = e["fileid"]?.InnerText; FileManagement.Raise(this, new FileManagementEventArgs(fileId, action)); } // Do we receive message about thumbnail else if (message.Data["thumbnail"] != null) { XmlElement e = message.Data["thumbnail"]; string fileId = e["fileid"]?.InnerText; string widthStr = e["originalwidth"]?.InnerText; string heightStr = e["originalheight"]?.InnerText; int width = 0; int height = 0; try { int.TryParse(widthStr, out width); int.TryParse(heightStr, out height); } catch (Exception exc) { log.LogWarning("[Input] Exception occurred for thumbnail: [{0}]", Util.SerializeException(exc)); } ThumbnailManagement.Raise(this, new ThumbnailEventArgs(fileId, width, height)); } else if (message.Data["channel"] != null) { XmlElement e = message.Data["channel"]; string jid = message.To.GetBareJid().ToString(); string channelId = e.GetAttribute("channelid"); string action = ""; string type = ""; // Check avatar node if (e["avatar"] != null) { type = "avatar"; action = e["avatar"].GetAttribute("action"); } else { action = e.GetAttribute("action"); if (e["type"] != null) { type = e["type"].InnerText; } } ChannelManagement.Raise(this, new ChannelManagementEventArgs(jid, channelId, action, type)); } else if (message.Data["channel-subscription"] != null) { XmlElement e = message.Data["channel-subscription"]; string jid = e.GetAttribute("jid"); string channelId = e.GetAttribute("channelid"); string action = e.GetAttribute("action"); string type = ""; // Never Type info receive in this case ChannelManagement.Raise(this, new ChannelManagementEventArgs(jid, channelId, action, type)); } else if (message.Data["group"] != null) { XmlElement e = message.Data["group"]; GroupManagement.Raise(this, new MessageEventArgs(e.ToXmlString())); } else if (message.Data["recordingfile"] != null) { XmlElement e = message.Data["recordingfile"]; RecordingFile.Raise(this, new MessageEventArgs(e.ToXmlString())); } else { log.LogInformation("[Input] Message not managed"); } // Since it's a Management message, we prevent next handler to parse it return(true); } else if (message.Type == MessageType.Chat) { if (message.Data["x", "jabber:x:conference"] != null) { XmlElement e; String roomId, roomJid, roomName; String userid, userjid, userdisplayname; String subject; userid = userjid = userdisplayname = ""; subject = ""; e = message.Data["x", "jabber:x:conference"]; roomId = e.GetAttribute("roomid"); if (String.IsNullOrEmpty(roomId)) { roomId = e.GetAttribute("thread"); } roomJid = e.GetAttribute("jid"); roomName = e.GetAttribute("name"); e = message.Data["x", "jabber:x:bubble:conference:owner"]; if (e != null) { userid = e.GetAttribute("userid"); userjid = e.GetAttribute("jid"); userdisplayname = e.GetAttribute("displayname"); } e = message.Data["subject"]; if (e != null) { subject = e.InnerText; } // Since it's a room invitation, we prevent next handler to parse it RoomInvitation.Raise(this, new RoomInvitationEventArgs(roomId, roomJid, roomName, userid, userjid, userdisplayname, subject)); return(true); } } else if (message.Type == MessageType.Headline) { // Do we receive an event of pubsub type ? if (message.Data["event", "http://jabber.org/protocol/pubsub#event"] != null) { XmlElement e = message.Data["event", "http://jabber.org/protocol/pubsub#event"]; if (e["items"] != null) { ChanneItemManagement.Raise(this, new MessageEventArgs(e["items"].ToXmlString())); return(true); } else if (e["update"] != null) { ChanneItemManagement.Raise(this, new MessageEventArgs(e["update"].ToXmlString())); return(true); } } } // Pass the message on to the next handler. return(false); }