Пример #1
0
		/// <summary>
		/// Rename a Spotfire Column
		/// </summary>
		/// <param name="ri"></param>

		void RenameColumn(int ri)
		{
			DataRow dRow = FieldDataTable.Rows[ri];
			string currentName = dRow["SpotfireColNameField"] as string;

			string newName = InputBoxMx.Show("Name:", "Rename Column", currentName);
			if (Lex.IsUndefined(newName) || newName == currentName) return;

			for (int ri2 = 0; ri2 < FieldDataTable.Rows.Count; ri2++)
			{
				if (ri2 == ri) continue;
				string name = FieldDataTable.Rows[ri2]["SpotfireColNameField"] as string;
				if (Lex.Eq(name, newName))
				{
					MessageBoxMx.ShowError("Name already in use: " + newName);
					return;
				}
			}

			dRow["SpotfireColNameField"] = newName;

			CurrentMap.ColumnMapCollection[ri].SpotfireColumnName = newName;

			Api.RenameColumn(CurrentMap.SpotfireDataTable?.Name, currentName, newName);

			return;
		}
Пример #2
0
/// <summary>
/// Change owner
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void ChangeOwnerMenuItem_Click(object sender, EventArgs e)
        {
            {
                List <string> users    = SecurityUtil.GetAllUsers();
                string        prompt   = "Enter the user name of the person to transfer ownership of " + Lex.AddDoubleQuotes(Uo.Name) + " to:";
                string        newOwner = InputBoxMx.Show(prompt, "Change Owner", "", users, -1, -1);
                if (Lex.IsNullOrEmpty(newOwner))
                {
                    return;
                }

                string newUserName = SecurityUtil.GetInternalUserName(newOwner);
                if (Lex.IsNullOrEmpty(newUserName))
                {
                    return;
                }

                string result = UserObjectUtil.ChangeOwner(Uo.Id, newUserName);
                if (!Lex.IsNullOrEmpty(result))
                {
                    MessageBoxMx.Show(result);
                    DialogResult = DialogResult.Cancel;                     // close the dialog
                }
                return;
            }
        }
Пример #3
0
        private void CreateUserGroupMenuItem_Click(object sender, EventArgs e)
        {
            if (!Security.IsAdministrator(SS.I.UserName) &&
                !Security.HasPrivilege(SS.I.UserName, "CreateUserGroup") &&
                !ServicesIniFile.ReadBool("CreateUserGroupByAnyUser", true))
            {
                MessageBoxMx.ShowError("Your account is not authorized to create and/or edit user groups");
                return;
            }

            string groupName = InputBoxMx.Show("Enter the name of the new user group to be created.", "Create User Group");

            if (Lex.IsNullOrEmpty(groupName))
            {
                return;
            }

            if (UserGroups.LookupExternalName(groupName) != null)
            {
                MessageBoxMx.ShowError("Group \"" + groupName + "\" already exists");
                return;
            }

            DialogResult dr = PermissionsGroupEditor.Show(groupName, true);

            if (dr == DialogResult.OK)
            {
                PermissionsList.ItemNameComboBox.Properties.Items.Clear();                 // rebuild for new group
            }
        }
Пример #4
0
        internal void ShowRunQueryUrl()
        {
            if (Query == null || Query.UserObject == null || Query.UserObject.Id <= 0)
            {
                MessageBoxMx.ShowError("The query must first be saved.");
                return;
            }

            string folder   = ServicesIniFile.Read("QueryLinksNetworkFolder"); // get unc form of folder
            string fileName = "Run_Query_" + Query.UserObject.Id + ".bat";     // file name
            string uncPath  = folder + '\\' + fileName;                        // unc file to write now and read later

            string       tempFile = TempFile.GetTempFileName();
            StreamWriter sw       = new StreamWriter(tempFile);
            string       cmd      =                                                            // batch command to start the Mobius client and run the specified query
                                    Lex.AddDoubleQuotes(ClientDirs.ExecutablePath) +           // path to executable in quotes
                                    " Mobius:Command='Run Query " + Query.UserObject.Id + "'"; // the mobius command to run

            sw.WriteLine(cmd);
            sw.Close();

            ServerFile.CopyToServer(tempFile, uncPath);
            FileUtil.DeleteFile(tempFile);

            string url = "file:///" + folder.Replace('\\', '/') + "/" + fileName;             // put in "file:" schema & switch slashes to get URL from UNC name

            InputBoxMx.Show(
                "The following URL can be used from a web page " +
                "to start Mobius and run the current query:",
                "Run Query URL",
                url);
            //"Mobius:Command='Run Query " + Query.UserObject.Id + "'"); // this is better but isn't accepted by SharePoint

            return;
        }
Пример #5
0
/// <summary>
/// Disable user
/// </summary>
/// <param name="commandLine"></param>
/// <returns></returns>

        public static string DisableUser(
            string commandLine)
        {
            string tok, msg;

            UserInfo ui  = new UserInfo();
            Lex      lex = new Lex();

            lex.OpenString(commandLine);
            string userName    = lex.Get();
            bool   interactive = Lex.IsNullOrEmpty(userName);

            while (true)
            {
                if (interactive)
                {
                    userName = InputBoxMx.Show("Enter the Username of the user to disable:", "Disable User", userName);
                    if (Lex.IsNullOrEmpty(userName))
                    {
                        return("");
                    }
                }

                userName = userName.ToUpper();
                if (Security.ReadUserInfo(userName) == null)
                {
                    msg = "User doesn't exist: " + userName;
                    if (!interactive)
                    {
                        return(msg);
                    }
                    MessageBoxMx.ShowError(msg);
                    continue;
                }

                try
                {
                    Security.RevokePrivilege(userName, "Logon");
                    msg = "User disabled: " + userName;
                }
                catch (Exception ex) { msg = "Disable user failed for: " + userName; }
                if (!interactive)
                {
                    return(msg);
                }

                MessageBoxMx.Show(msg);
                userName = "";
                continue;
            }
        }
Пример #6
0
        /// <summary>
        /// Save the specified list object
        /// </summary>
        /// <returns></returns>

        public static UserObject SaveList(
            CidList list,
            string caption,
            bool saveToTempList,
            string tempListName)
        {
            UserObject uo = null;
            String     name, txt;

            uo = new UserObject(UserObjectType.CnList);
            if (saveToTempList)
            {
                if (Lex.IsNullOrEmpty(tempListName))
                {
                    tempListName = InputBoxMx.Show("Enter the name of the temporary list to be saved to:", caption);
                }
                if (Lex.IsNullOrEmpty(tempListName))
                {
                    return(null);
                }

                uo.Owner        = SS.I.UserName;
                uo.ParentFolder = UserObject.TempFolderName;
                uo.Name         = tempListName;
            }

            else
            {
                uo = UserObjectSaveDialog.Show(caption, uo);              // save to permanent list
            }
            if (uo == null)
            {
                return(null);
            }
            if (!uo.IsTempObject)             // assign valid folder unless current list
            {
                UserObjectTree.GetValidUserObjectTypeFolder(uo);
            }

            SessionManager.DisplayStatusMessage("Saving List " + uo.Name + "...");

            list.UserObject = uo;
            int rc = Write(list);

            MainMenuControl.UpdateMruList(uo.InternalName);

            SessionManager.DisplayStatusMessage("");
            return(uo);
        }
Пример #7
0
        private bool GetPersonalMoeExecutableLocation(string mxp)
        {
            string moeArgs, newCl = "";

            while (true)             // loop til we get a valid executable name or cancelled
            {
                if (mxp != null)
                {
                    string msg =
                        "Unable to find MOE executable:\r\n\r\n" +
                        "  " + mxp + "\r\n\r\n" +
                        "Would you like to define a new location for the MOE executable?";
                    DialogResult dr = MessageBoxMx.Show(msg, "Can't Find MOE", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
                    if (dr != System.Windows.Forms.DialogResult.Yes)
                    {
                        return(false);
                    }
                }

                string cl = Preferences.Get("MoeCommandLine");                 // get any personal preference first

                string txt =
                    "Enter your preferred \"non-standard\" personal location for MOE executable file.\r\n" +
                    "For example, the Target field from the MOE Desktop shortcut.\r\n" +
                    "To use the system default executable set the value to blank.";

                newCl = InputBoxMx.Show(txt, "Set location of MOE executable file", cl);
                if (newCl == null)
                {
                    return(false);                               // cancelled
                }
                else if (newCl.Trim() == "")
                {
                    break;                                          // use system default
                }
                else
                {
                    ParseMoeCommandLine(newCl, out mxp, out moeArgs);
                    if (File.Exists(mxp))
                    {
                        break;
                    }
                }
            }

            Preferences.Set("MoeCommandLine", newCl);
            return(true);
        }
Пример #8
0
        private void ViewUserGroupMenuItem_Click(object sender, EventArgs e)
        {
            List <String> groups = UserGroups.GetAllGroups();

            string groupName = InputBoxMx.Show(
                "Select the User Group that you want to view", "View User Group", "", groups, -1, -1);

            if (Lex.IsNullOrEmpty(groupName))
            {
                return;
            }

            DialogResult dr = PermissionsGroupEditor.Show(groupName, false);

            return;
        }
Пример #9
0
        /// <summary>
        /// Build a Spotfire view for the QueryTable in the current query
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>

        public static string StoreSpotfireQueryTableSql()
        {
            string sqlStmtName = QbUtil.Query.UserObject.Name;

            if (Lex.StartsWith(sqlStmtName, "SF_"))             // trim the sf prefix
            {
                sqlStmtName = sqlStmtName.Substring(3);
            }

            while (true)
            {
                sqlStmtName = InputBoxMx.Show("Name to assign to stored SQL:", "Store Mobius QueryTable SQL for Use by Spotfire", sqlStmtName);
                if (Lex.IsUndefined(sqlStmtName))
                {
                    return("");
                }

                string existingSql = QueryEngine.ReadSpotfireSql(sqlStmtName, 0);
                if (Lex.IsDefined(existingSql))
                {
                    DialogResult dr = MessageBoxMx.Show(
                        "Sql statement " + sqlStmtName + " already exists.\r\n" +
                        "Do you want to overwrite it?",
                        "Confirm Overwrite", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

                    if (dr == DialogResult.No)
                    {
                        continue;                                            // allow name reentry
                    }
                    else if (dr == DialogResult.Cancel)
                    {
                        return("");
                    }
                }

                break;
            }

            Progress.Show("Saving SQL...");
            int id = QueryEngine.SaveSpotfireSql(sqlStmtName, QbUtil.Query);

            Progress.Hide();

            string msg = "Sql statement " + sqlStmtName + " has been stored.";

            return(msg);
        }
Пример #10
0
        /// <summary>
        /// AddToFavoritesList
        /// </summary>
        /// <param name="molEditorCtl"></param>
        /// <param name="searchType"></param>

        public static void AddToFavoritesList(
            MoleculeControl molEditorCtl,
            StructureSearchType searchType)
        {
            MoleculeListItem sli = null;
            DialogResult     dr;

            MoleculeMx mol = molEditorCtl.Molecule;

            if (MoleculeMx.IsUndefined(mol))
            {
                return;
            }

            mol = mol.Clone();             // make a copy for the list

            sli = FindStructure(mol, GetFavoriteStructuresList());
            if (sli != null)
            {
                dr = MessageBoxMx.Show("The current molecule already exists in Favorites list under the name: " + sli.Name + "\r\n" +
                                       "Do you still want the add the current query molecule to the Favorites list?", "Molecule already in Favorites", MessageBoxButtons.YesNoCancel);

                if (dr != DialogResult.Yes)
                {
                    return;
                }
            }

            string name = molEditorCtl.GetTemporaryStructureTag();

            name = InputBoxMx.Show("Enter the name that you want to assign to the molecule", "Enter Name", name);
            if (Lex.IsUndefined(name))
            {
                return;
            }

            sli              = new MoleculeListItem();
            sli.Name         = name;
            sli.Molecule     = mol;
            sli.UpdateDate   = DateTime.Now;
            sli.MoleculeType = StructureSearchTypeUtil.StructureSearchTypeToExternalName(searchType);
            FavoritesList.ItemList.Insert(0, sli);

            SaveStructureList(FavoritesList, FavoritesPreferencesParmName);
            return;
        }
Пример #11
0
        private void OpenDocumentButton_Click(object sender, EventArgs e)
        {
            string analysisPath = null;

            if (Api == null)
            {
                throw new Exception("Must start Analyst or WebPlayer first");
            }

            if (SVM == null)
            {
                SetupViewEnvironment();
            }

            if (SpotfireApiClient.UseWebPlayerClient)
            {
                string title       = "Select Spotfire Analysis";
                string prompt      = "Enter the name of the library analysis to open (e.g. /Mobius/Visualizations/MyAnalysisTemplate";
                string defaultText = SpotfireApiClient.DefaultAnalysisName;

                analysisPath = InputBoxMx.Show(prompt, title, defaultText);
                if (Lex.IsUndefined(analysisPath))
                {
                    return;
                }
            }

            else
            {
                if (String.IsNullOrWhiteSpace(OpenFileDialog.FileName))
                {
                    OpenFileDialog.FileName = DefaultAnalyisFilePath;
                }

                if (this.OpenFileDialog.ShowDialog() != DialogResult.OK)
                {
                    return;
                }

                analysisPath = this.OpenFileDialog.FileName;
            }

            OpenDocument(analysisPath);
            return;
        }
Пример #12
0
        /// <summary>
        /// Rename a tab page
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void RenameMenuItem_Click(object sender, EventArgs e)
        {
            ResultsPage page = GetCurrentResultsPage();

            List <string> imageNameList = new List <string>();           // put list of image names to use in dropdown
            var           l             = Bitmaps.I.ViewTypeImages.Images.Keys;

            foreach (string s in l)
            {
                imageNameList.Add(s);
            }

            string newName = InputBoxMx.Show("Enter the new name for " + page.ActiveTitle,
                                             "Rename", page.ActiveTitle, imageNameList, -1, -1);

            if (Lex.IsNullOrEmpty(newName))
            {
                return;
            }

            bool isImageName = imageNameList.Contains(newName);

            if (!isImageName)             // set title
            {
                page.Title = newName;
                if (page.Views.Count == 1)                 // if only one view rename it as well
                {
                    page.Views[0].Title = newName;
                }

                SetCurrentTabTitle(newName);
            }

            else             // set custom image name to use in tab
            {
                if (page.Views.Count == 1)
                {
                    page.Views[0].CustomViewTypeImageName = newName;
                }

                SetCurrentPageTabTitleAndImage();
            }

            return;
        }
Пример #13
0
        /// <summary>
        /// Build a Spotfire view for the QueryTable in the current query
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>

        public static string BuildSpotfireQueryTableView(string viewName)
        {
            string initialViewName = viewName;

            if (Lex.IsUndefined(initialViewName))
            {
                viewName = QbUtil.Query.UserObject.Name;
            }

            do
            {
                if (Lex.IsUndefined(initialViewName) || viewName.Length > 30)
                {
                    viewName = InputBoxMx.Show("Name to assign to stored SQL:", "Build QueryTable SQL for Use by Spotfire", viewName);
                    if (Lex.IsUndefined(viewName))
                    {
                        return("");
                    }
                }
            }while (viewName.Length > 30);

            string serializedQuery = QbUtil.Query.Serialize();

            string command = "BuildQueryTableOracleView " + viewName + " " + serializedQuery;

            Progress.Show("Executing Command...");
            string result = CommandLine.ExecuteServiceCommand(command);

            Progress.Hide();
            return(result);

            //QueryTable qt = QbUtil.Query.CurrentTable;
            //if (qt == null) return "No current QueryTable";

            //Query q = new Query();
            //qt = qt.Clone();
            //q.AddQueryTable(qt);

            //string initialViewName = viewName;
            //if (Lex.IsUndefined(initialViewName))
            //  viewName = "SF_" + qt.MetaTable.Name; // default view name has SF prefix
        }
Пример #14
0
        private void EditUserGroupMenuItem_Click(object sender, EventArgs e)
        {
            List <String> groups = UserGroups.GetEditableGroups(SS.I.UserName);

            if (groups.Count == 0)
            {
                MessageBoxMx.ShowError("There are no groups that you are currently authorized to edit");
                return;
            }

            string groupName = InputBoxMx.Show(
                "Select the User Group that you want to edit", "Edit User Group", "", groups, -1, -1);

            if (Lex.IsNullOrEmpty(groupName))
            {
                return;
            }

            DialogResult dr = PermissionsGroupEditor.Show(groupName, true);

            return;
        }
Пример #15
0
        /// <summary>
        /// Build Url for analysis including prompting for any parameters
        /// Example: https://[server></server>/SpotfireWeb/ViewAnalysis.aspx?file=/Mobius/Visualizations/MdbAssay_MOBIUS&configurationBlock=CorpId_LIST={1,3,5};
        /// </summary>
        /// <param name="sl"></param>
        /// <returns></returns>

        static string BuildUrl(SpotfireViewProps sl)
        {
            string url = sl.GetWebplayerUrlOfAnalysis();

            string parms = "";             // parm names & values for config block -

            //foreach (SpotfireParameter p0 in sl.Parameters.Values)
            //{

            SpotfireLinkParameter p0 = new SpotfireLinkParameter();

            p0.Name = "Compound Id";

            string vals = InputBoxMx.Show(
                "Enter desired values for " + p0.Name + ":\r\n" +
                "Example: 1, 2, 3",
                p0.Name + " Criteria");

            if (vals == null)
            {
                return(null);                                  // cancelled
            }
            if (parms != "")
            {
                parms += " ";
            }
            parms += "SQLPARMS=\"" + vals + "\"";

            //parms += p0.Name + "={" + vals + "}";
            //parms += p0.Name + "=\"" + vals + "\"";
            //}

            if (Lex.IsDefined(parms))
            {
                url += "&configurationBlock=" + parms + ";";                 // add the parms in the config block
            }
            return(url);
        }
Пример #16
0
        private void RenameMenuItem_Click(object sender, EventArgs e)
        {
            int ri = MoleculeGrid.LastMouseDownRowIdx;

            if (ri < 0)
            {
                return;
            }

            string newName = InputBoxMx.Show("Enter new name:", "Rename", StructureList.ItemList[ri].Name);

            if (Lex.IsUndefined(newName))
            {
                return;
            }

            StructureList.ItemList[ri].Name = newName;
            DataTable.Rows[ri]["NameCol"]   = newName;

            SaveStructureListToPreferences(StructureList, StructureList.Name);

            return;
        }
Пример #17
0
/// <summary>
/// Right-click commands on objects in a tree
/// </summary>
/// <param name="command">The command to process</param>
        /// <param name="mtn">MetaTreeNode</param>
        /// <param name="uo">Any associated user object</param>
        /// <param name="ctc">ContentsTreeControl</param>
/// <returns></returns>

        public static bool ProcessCommonRightClickObjectMenuCommands(
            string command,
            MetaTreeNode mtn,
            UserObject[] uoArray,
            ContentsTreeControl ctc)
        {
            UserObject uo2;
            string     txt;
            UserObject uo = null;

            if (uoArray != null && uoArray.Length == 1)
            {
                uo = uoArray[0];
            }

            //if (mtn == null)
            //{
            //	MessageBoxMx.ShowError("Operation is not allowed for this Database Contents node.");
            //	return true;
            //}

            if (Lex.Eq(command, "Cut"))
            {
                CopyCutDelete(command, uoArray, ctc, true, true);
            }

            else if (Lex.Eq(command, "Copy"))
            {
                CopyCutDelete(command, uoArray, ctc, true, false);
            }

            else if (Lex.Eq(command, "Paste"))
            {
                try
                {
                    txt = Clipboard.GetText();
                    //uo2 = UserObject.Deserialize(txt);
                    uoArray = Deserialize(txt);
                    if (uoArray == null)
                    {
                        throw new Exception("Not a UserObject");
                    }
                    //if (uo2 == null) throw new Exception("Not a UserObject");
                }
                catch (Exception ex)
                {
                    MessageBoxMx.ShowError("The clipboard does not contain a recognized user objects");
                    return(true);
                }

                foreach (var userObject in uoArray)
                {
                    Progress.Show("Pasting " + userObject.Name + "...", UmlautMobius.String, false);

                    Permissions.UpdateAclForNewOwner(userObject, userObject.Owner, SS.I.UserName); // fixup the ACL for the new owner
                    userObject.Owner        = SS.I.UserName;
                    userObject.ParentFolder = mtn.Name;
                    mtn = UserObjectTree.GetValidUserObjectTypeFolder(userObject);

                    for (int ci = 0; ; ci++) // find a name that's not used
                    {
                        UserObject uo3 = UserObjectDao.ReadHeader(userObject);
                        if (uo3 == null)
                        {
                            break;
                        }

                        if (ci == 0)
                        {
                            userObject.Name = "Copy of " + userObject.Name;
                        }
                        else if (ci == 1)
                        {
                            userObject.Name = Lex.Replace(userObject.Name, "Copy of ", "Copy (2) of ");
                        }
                        else
                        {
                            userObject.Name = Lex.Replace(userObject.Name, "Copy (" + ci + ") of ", "Copy (" + (ci + 1) + ") of ");
                        }
                    }

                    UserObject userObjectFinal = null;
                    if (UserObjectDao.ReadHeader(userObject.Id) != null) // create a deep clone if orignal object exists
                    {
                        userObjectFinal = DeepClone(userObject);
                    }

                    if (userObjectFinal == null)
                    {
                        userObjectFinal = userObject;
                    }

                    UserObjectDao.Write(userObjectFinal, userObjectFinal.Id); // write using the current id

                    Progress.Hide();
                }

                //if (ctc != null) // need to update form directly?
                //  UserObjectTree.RefreshSubtreeInTreeControl(uo2, ctc);
            }

            else if (Lex.Eq(command, "Delete"))
            {
                CopyCutDelete(command, uoArray, ctc, false, true);
            }

            else if (Lex.Eq(command, "Rename"))
            {
                if (!UserHasWriteAccess(uo))
                {
                    MessageBoxMx.ShowError("You are not authorized to rename " + uo.Name);
                    return(true);
                }

                string newName = InputBoxMx.Show("Enter the new name for " + uo.Name,
                                                 "Rename", uo.Name);

                if (newName == null || newName == "" || newName == uo.Name)
                {
                    return(true);
                }

                if (!IsValidUserObjectName(newName))
                {
                    MessageBoxMx.ShowError("The name " + newName + " is not valid.");
                    return(true);
                }

                uo2      = uo.Clone();
                uo2.Name = newName;
                uo2.Id   = 0;               // clear Id so not looked up by id

                if (!Lex.Eq(newName, uo.Name) && UserObjectDao.ReadHeader(uo2) != null)
                {
                    MessageBoxMx.ShowError(newName + " already exists.");
                    return(true);
                }

                uo2.Id = uo.Id;
                UserObjectDao.UpdateHeader(uo2);

                if (ctc != null)
                {
                    UserObjectTree.UpdateObjectInTreeControl(uo, uo2, ctc);
                }
            }

            else if (Lex.Eq(command, "MakePublic") ||
                     Lex.Eq(command, "MakePrivate"))
            {
                UserObjectAccess newAccess;
                MetaTreeNode     objFolder;

                if (!UserHasWriteAccess(uo))
                {
                    MessageBoxMx.ShowError("You are not authorized to make " + uo.Name +
                                           ((Lex.Eq(command, "MakePublic")) ? " public" : " private"));
                    return(true);
                }

                if (Lex.Eq(command, "MakePublic"))
                {
                    if (uo.ParentFolder == "DEFAULT_FOLDER")
                    {
                        MessageBoxMx.ShowError("Items in the Default Folder cannot be made public");
                        return(true);
                    }
                    else
                    {
                        //check the folder id parentage to ensure that the current folder isn't a subfolder of the default folder
                        if (UserObjectTree.FolderNodes.ContainsKey(uo.ParentFolder))
                        {
                            objFolder = UserObjectTree.FolderNodes[uo.ParentFolder];
                            while (objFolder != null)
                            {
                                if (objFolder.Target == "DEFAULT_FOLDER")
                                {
                                    MessageBoxMx.ShowError("Items in the Default Folder cannot be made public");
                                    return(true);
                                }
                                objFolder = objFolder.Parent;
                            }
                        }
                        else
                        {
                            throw new Exception("Failed to recognize the folder that this object is in!");
                        }
                    }

                    newAccess = UserObjectAccess.Public;
                }
                else
                {
                    //user folders cannot be made private if they contain public children
                    if (uo.Type == UserObjectType.Folder)
                    {
                        objFolder = UserObjectTree.BuildNode(uo);
                        if (UserObjectTree.FolderNodes.ContainsKey(objFolder.Target))
                        {
                            objFolder = UserObjectTree.FolderNodes[objFolder.Target];
                            for (int i = 0; i < objFolder.Nodes.Count; i++)
                            {
                                MetaTreeNode currentChild = (MetaTreeNode)objFolder.Nodes[i];
                            }
                        }
                    }

                    newAccess = UserObjectAccess.Private;
                }

                uo2 = UserObjectDao.Read(uo);
                if (uo2 == null)
                {
                    return(true);
                }
                if (uo2.AccessLevel == newAccess)
                {
                    return(true);                                              // no change
                }
                uo2.AccessLevel = newAccess;
                UserObjectDao.UpdateHeader(uo2);

                if (ctc != null)                 // need to update form directly?
                {
                    UserObjectTree.RefreshSubtreeInTreeControl(uo2, ctc);
                }

                return(true);
            }

            else if (Lex.Eq(command, "ChangeOwner"))
            {
                string newOwner = InputBoxMx.Show("Enter the user name of the person to transfer ownership of " + Lex.AddDoubleQuotes(uo.Name) + " to:",
                                                  "Change Owner", "");

                if (Lex.IsNullOrEmpty(newOwner))
                {
                    return(true);
                }

                string result = UserObjectUtil.ChangeOwner(uo.Id, newOwner);
                if (!Lex.IsNullOrEmpty(result))
                {
                    MessageBoxMx.Show(result);
                }
                return(true);
            }

            else if (Lex.Eq(command, "Permissions"))             // set object permissions
            {
                PermissionsDialog.Show(uo);
                return(true);
            }

            else if (Lex.Eq(command, "ViewSource"))
            {
                uo = UserObjectDao.Read(uo);
                if (uo == null)
                {
                    return(true);
                }

                string ext = ".txt";                 // default extension
                if (uo.Type == UserObjectType.Query ||
                    uo.Type == UserObjectType.Annotation)
                {
                    ext = ".xml";
                }
                string       cFile = ClientDirs.TempDir + @"\Source" + ext;
                StreamWriter sw    = new StreamWriter(cFile);
                sw.Write(uo.Content);
                sw.Close();

                SystemUtil.StartProcess(cFile);                 // show it
            }

            else
            {
                return(false);       // command not recognized
            }
            return(true);            // command recognized and processed
        }
Пример #18
0
/// <summary>
/// Delete all user account information and user objects
/// </summary>
/// <param name="commandLine"></param>
/// <returns></returns>

        public static string DeleteUser(
            string commandLine)
        {
            string tok, msg;

            Lex lex = new Lex();

            lex.OpenString(commandLine);
            string userName    = lex.Get();
            bool   interactive = Lex.IsNullOrEmpty(userName);

            while (true)
            {
                if (interactive)
                {
                    userName = InputBoxMx.Show("Enter the Username of the user to delete:", "Delete User", userName);
                    if (Lex.IsNullOrEmpty(userName))
                    {
                        return("");
                    }
                }

                userName = userName.ToUpper();
                UserInfo ui = Security.ReadUserInfo(userName);
                if (ui == null)
                {
                    msg = "User doesn't exist: " + userName;
                    if (!interactive)
                    {
                        return(msg);
                    }
                    MessageBoxMx.ShowError(msg);
                    continue;
                }

                msg = "Are you sure you want to delete user: "******" (" + ui.FullName + ")";
                DialogResult dr = MessageBoxMx.Show(msg, "Delete User", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);
                if (dr != DialogResult.Yes)
                {
                    if (!interactive)
                    {
                        return("");
                    }
                    else
                    {
                        continue;
                    }
                }

                bool result = Security.DeleteUser(userName);
                if (result == true)
                {
                    msg = "User deleted: " + userName;
                }
                else
                {
                    msg = "Delete user failed for: " + userName;
                }
                if (!interactive)
                {
                    return(msg);
                }

                MessageBoxMx.Show(msg);
                userName = "";
                continue;
            }
        }
Пример #19
0
/// <summary>
/// Update user
/// </summary>
/// <param name="commandLine"></param>
/// <returns></returns>

        public static string UpdateUser(
            string commandLine)
        {
            string msg;

            Lex lex = new Lex();

            lex.OpenString(commandLine);

            if (!Security.IsAdministrator(SS.I.UserName))
            {
                return("You must be a Mobius administrator to update users");
            }

            string userName    = lex.GetUpper();          // get user name
            bool   interactive = Lex.IsNullOrEmpty(userName);

            while (true)
            {
                if (interactive)
                {
                    userName = InputBoxMx.Show("Enter the Username of the user to update:", "Update User", userName);
                    if (Lex.IsNullOrEmpty(userName))
                    {
                        return("");
                    }
                }

                userName = userName.ToUpper();
                UserInfo ui = Security.ReadUserInfo(userName);

                if (ui == null)
                {
                    msg = "User doesn't exist: " + userName;
                    if (!interactive)
                    {
                        return(msg);
                    }
                    MessageBoxMx.ShowError(msg);
                    continue;
                }

                DialogResult dr = CreateUserDialog.ShowDialog(ui, "Update User");
                if (dr == DialogResult.Cancel)
                {
                    return("");
                }

                try
                {
                    Security.CreateUser(ui);
                    msg = "User information updated";
                }
                catch (Exception ex) { msg = "User update failed: " + ex.Message; }

                if (!interactive)
                {
                    return(msg);
                }

                MessageBoxMx.Show(msg);
                userName = "";
                continue;
            }
        }
Пример #20
0
        /// <summary>
        /// Selected a new target map
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void TargetMap_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (InSetup)
            {
                return;
            }
            string newTargetMap = TargetMap.Text;

            if (Lex.Eq(newTargetMap, "Retrieve KEGG Pathway...")) // lookup KEGG pathway
            {
                if (Math.Abs(1) == 1)                             // 2/1/2013, best available now e.g. http://www.kegg.jp/kegg-bin/show_pathway?hsa04010
                {
                    MessageBoxMx.ShowError(@"Automated access to pathway maps is now available through subsciption only.");
                    return;
                }

                SetTargetMapText(SelectedTargetMap);                 // keep current map for now

                string pathwayId = InputBoxMx.Show(
                    "Enter the KEGG pathway id (e.g. hsa00010) for the desired pathway. " +
                    "Pathway identifiers can be looked up at: " +
                    "<a href=\"http://www.genome.jp/kegg/pathway.html\" target=\"_blank\">http://www.genome.jp/kegg/pathway.html</a>",
                    "KEGG Pathway Identifier");

                if (String.IsNullOrEmpty(pathwayId))
                {
                    return;
                }

                try
                {
                    Progress.Show("Retrieving KEGG information for pathway: " + pathwayId, UmlautMobius.String, false);
                    TargetMap tm = TargetMapDao.GetKeggPathway(pathwayId);
                    Progress.Hide();
                    if (!MapLabelDict.ContainsKey(tm.Label.ToUpper()))
                    {
                        MapLabelDict[tm.Label.ToUpper()] = null;
                        MapLabelList.Add(tm.Label);
                        UserMapNames.Add(tm.Name);
                    }

                    TargetMap.Properties.Items.Clear();
                    TargetMap.Properties.Items.AddRange(MapLabelList);       // update list
                    SelectedTargetMap = tm.Label;
                    SetTargetMapText(SelectedTargetMap);                     // make current selection
                }

                catch (Exception ex)
                {
                    string msg = ex.Message;
                    Progress.Hide();
                    MessageBoxMx.ShowError("Pathway not found");
                    return;
                }

                return;
            }

            else if (newTargetMap.StartsWith("---"))             // divider selected, ignore
            {
                SetTargetMapText(SelectedTargetMap);
            }

            SetTargetMapText(newTargetMap);             // new map selected
        }
Пример #21
0
/// <summary>
/// PromptForNewTempListName()
/// </summary>
/// <returns></returns>

        public static string PromptForNewTempListName()
        {
            return(InputBoxMx.Show("Enter the name for the new temporary list", "New Temporary List"));
        }