private void PopulatePermissions() { // Clear the file info tree PriviledgesTreeView.Nodes.Clear(); PriviledgesTreeView.Sorted = true; string groupSection = MOG_Priviledges.MainSections.Group.ToString(); SortedList groupNodeList = new SortedList(); if (mPriviledgesIni.SectionExist(groupSection)) { int groupsCount = mPriviledgesIni.CountKeys(groupSection); for (int i = 0; i < groupsCount; ++i) { string groupName = mPriviledgesIni.GetKeyNameByIndex(groupSection, i); TreeNode groupNode = new TreeNode(groupName); groupNodeList.Add(groupName, groupNode); PriviledgesTreeView.Nodes.Add(groupNode); } } string userSection = MOG_Priviledges.MainSections.Users.ToString(); // If [Users] exists... if (mPriviledgesIni.SectionExist(userSection)) { int usersCount = mPriviledgesIni.CountKeys(userSection); string[] users = new string[usersCount]; string[] groups = new string[usersCount]; // Foreach user... for (int i = 0; i < usersCount; ++i) { // Get user's name and group string userName = mPriviledgesIni.GetKeyNameByIndex(userSection, i); string userGroup = mPriviledgesIni.GetKeyByIndex(userSection, i); // Create our use's node TreeNode userNode = new TreeNode(userName); SortedList availablePermissions = new SortedList(); // If the userGroup exists... if (mPriviledgesIni.SectionExist(userGroup)) { int permissionsCount = mPriviledgesIni.CountKeys(userGroup); string key, value; // Foreach permission in userGroup... for (int j = 0; j < permissionsCount; ++j) { key = mPriviledgesIni.GetKeyNameByIndex(userGroup, j); value = mPriviledgesIni.GetKeyByIndex(userGroup, j); // Populate the permissions sorted list availablePermissions.Add(key, value); } // end for on permissions if (mPriviledgesIni.SectionExist(userName)) { int userPermissionsCount = mPriviledgesIni.CountKeys(userName); // Foreach userPermission... for (int k = 0; k < userPermissionsCount; ++k) { key = mPriviledgesIni.GetKeyNameByIndex(userName, k); value = mPriviledgesIni.GetKeyByIndex(userName, k); string currentValue = (string)availablePermissions.GetByIndex(availablePermissions.IndexOfKey(key)); if (availablePermissions.ContainsKey(key) && currentValue != value) { string newPermissionEntry = key + "=" + value; TreeNode overrideNode = new TreeNode(newPermissionEntry); overrideNode.ForeColor = Color.Red; userNode.Nodes.Add(overrideNode); availablePermissions.Remove(key); } } } } // Foreach permission for this user... foreach (DictionaryEntry userPermission in availablePermissions) { string permissionEntry = userPermission.Key.ToString() + "=" + userPermission.Value.ToString(); TreeNode permissionNode = new TreeNode(permissionEntry); if (userPermission.Value.ToString().ToLower() == "true") { permissionNode.Checked = true; } else { permissionNode.Checked = false; } userNode.Nodes.Add(permissionNode); } TreeNode groupNode = (TreeNode)groupNodeList.GetByIndex(groupNodeList.IndexOfKey(userGroup)); groupNode.Nodes.Add(userNode); } // end for on users } // end if on [Users] }
public void TargetConsoleRemoveSync() { // Build a list of exactly what should be on the xbox mGetFileCount = true; mTotalFilesToCopy = 0; bool success = true; string CopyFileMap = mSourcePath + "\\MOG\\platformSincMap." + mMog.GetActivePlatform().mPlatformName + ".info"; if (DosUtils.FileExist(CopyFileMap)) { if (!DosUtils.FileDelete(CopyFileMap)) { return; } } // Create the new map mPendingCopy = new MOG_Ini(CopyFileMap); InitializeFileMap(); mFileMapCreate = true; // Initialize our progress dialog mProgress = new CallbackDialogForm(); string message = "Preforming platform remove data Sync: \n" + " Project Sync file map:" + mProjectSyncFile + "\n" + " User Sync file map:" + mUserSyncFile + "\n"; mProgress.DialogInitialize("(" + mTargetConsole + ")Platform Remove Data Sync", message, ""); Application.DoEvents(); for (int i = 0; i < mPlatformSync.CountKeys("FileMap"); i++) { string sourcePath = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", i).ToLower()); string targetPath = sourcePath.Replace(mSourcePath, mSyncRoot); string filePattern = mPlatformSync.GetKeyByIndex("FileMap", i).ToLower(); success = SyncDirectories(sourcePath, filePattern, mSyncRoot); mProgress.DialogUpdate((i * 100) / mPlatformSync.CountKeys("FileMap"), sourcePath + "\n" + targetPath); Application.DoEvents(); // Create the needed directory on the xbox string newDirName = RemapDirectoryString(targetPath); if (mConsoleCopy) { if (!XboxUtils.FileExist(newDirName)) { mPendingCopy.PutSectionString("CREATE_DIR", newDirName); mPendingCopy.Save(); } } else { if (!DosUtils.FileExist(newDirName)) { mPendingCopy.PutSectionString("CREATE_DIR", newDirName); mPendingCopy.Save(); } } } if (mConsoleCopy) { // Logon to correct xbox XboxUtils.SetXboxName(mTargetConsole, false); } mProgress.DialogInitialize("Sync Remove", "Scanning console for non-needed assets", ""); ArrayList deletableAssets = new ArrayList(); // Verify the xbox for each of these files for (int j = 0; j < mPlatformSync.CountKeys("FileMap"); j++) { string sourcePath = FormatString(mPlatformSync.GetKeyNameByIndex("FileMap", j).ToLower()); string targetPath = sourcePath.Replace(mSourcePath, mSyncRoot); string walkFiles = XboxUtils.GetFiles(targetPath + "\\"); mProgress.DialogUpdate((j * 100) / mPlatformSync.CountKeys("FileMap"), sourcePath + "\n" + targetPath); Application.DoEvents(); if (walkFiles.Length != 0 && walkFiles.IndexOf(",") != -1) { string [] files = walkFiles.Split(",".ToCharArray()); for (int k = 0; k < files.Length; k++) { string targetFile = files[k]; if (Path.GetExtension(targetFile) != "") { // Check to see if this file exists in the map if (!mPendingCopy.KeyExist("MAP", targetFile)) { // Get the list of deletable assets deletableAssets.Add(targetFile); } } } } } mProgress.DialogKill(); mProgress = null; if (deletableAssets.Count != 0) { if (guiConfirmDialog.MessageBoxDialog("Console Remove Sync", "Is is OK to Delete the Following Assets?", deletableAssets, MessageBoxButtons.OKCancel) == DialogResult.OK) { // Delete the assets in the list from off the xbox foreach (string str in guiConfirmDialog.SelectedItems) { string [] parts = str.Split(",;".ToCharArray()); if (parts != null && parts.Length >= 2) { string assetDeleteName = parts[0]; XboxUtils.FileDelete(assetDeleteName); } } } } else { MOG_REPORT.ShowMessageBox("Sync Remove", "This target does not have any files that need to be deleted", MessageBoxButtons.OK); } }