示例#1
0
        public IList <ApplicationData> GetAppsWithGroupId(int groupId)
        {
            List <ApplicationData> appsList = new List <ApplicationData>();

            // get all applications
            IList <ApplicationData> allAppsList = GetAllApplications();

            // get the group-application list
            GroupApplications groupApp = new GroupApplications()
            {
                group_id = groupId
            };
            DataTable groupAppDataTable = DbHelper.GetInstance().ReadData(groupApp);

            foreach (DataRow groupAppRow in groupAppDataTable.Rows)
            {
                int appId = int.Parse(groupAppRow[GroupApplications.GROUP_ID].ToString());
                foreach (ApplicationData data in allAppsList)
                {
                    if (data.id == appId)
                    {
                        appsList.Add(data);
                        break;
                    }
                }
            }

            return(appsList.AsReadOnly());
        }
示例#2
0
        public int AddGroup(string groupName, bool shareDesktop, bool allowMaintenace, int left, int top, int right, int bottom, List <int> allowApps)
        {
            int groupId = -1;

            Group dbGroup = new Group {
                label = groupName, share_full_desktop = shareDesktop, allow_maintenance = allowMaintenace, monitor_left = left, monitor_top = top, monitor_right = right, monitor_bottom = bottom
            };

            if (DbHelper.GetInstance().AddData(dbGroup))
            {
                // get the added index number
                foreach (GroupData data in GetAllGroups())
                {
                    if (data.name.CompareTo(groupName) == 0)
                    {
                        groupId = data.id;
                        break;
                    }
                }

                // add the application list to this group
                foreach (int appId in allowApps)
                {
                    GroupApplications groupApp = new GroupApplications()
                    {
                        application_id = appId,
                        group_id       = groupId,
                    };

                    DbHelper.GetInstance().AddData(groupApp);
                }
            }

            return(groupId);
        }