Exemplo n.º 1
0
        private void SaveTempListMenuItem_Click(object sender, EventArgs e)
        {
            string listName = ((ToolStripMenuItem)sender).Text;

            CommandExec.ExecuteCommandAsynch("List SaveCurrentToTemp " + Lex.AddDoubleQuotes(listName));
            UpdateNode(listName);
        }
Exemplo n.º 2
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;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Change the owner of a UserObject
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>

        public static string ChangeOwner(
            int objId,
            string newOwner)
        {
            newOwner = newOwner.ToUpper();

            UserObject uo = UserObjectDao.ReadHeader(objId);

            if (uo == null)
            {
                return("User object not found: " + objId);
            }
            if (uo.Owner == newOwner)
            {
                return("This user object is already owned by " + newOwner);
            }
            if (!Security.IsAdministrator(SS.I.UserName) && Lex.Ne(uo.Owner, SS.I.UserName))
            {
                return("You're not authorized to change the owner of this user object");
            }

            if (!Security.CanLogon(newOwner))
            {
                return("Not a valid userId: " + newOwner);
            }

            UserInfo ui  = Security.GetUserInfo(newOwner);
            string   msg = "Are you sure you want to transfer ownership of " + Lex.AddDoubleQuotes(uo.Name) + "\n" +
                           "to " + ui.FullName + "?";
            DialogResult dr = MessageBoxMx.Show(msg, "Change Owner", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

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

            UserObject uo2 = uo.Clone();

            uo2.Owner = newOwner;
            UserObjectTree.GetValidUserObjectTypeFolder(uo2);          // set valid parent folder
            Permissions.UpdateAclForNewOwner(uo2, uo.Owner, newOwner); // Set the ACL to give us r/w access
            uo2.Content = "ChangeOwner";                               // indicate changing owner
            if (UserObjectDao.ReadHeader(uo2) != null)
            {
                return("A user object with that name already exists for the specified new user");
            }
            UserObjectDao.UpdateHeader(uo2, false, false);

            if (Data.InterfaceRefs.IUserObjectIUD != null)
            {
                Data.InterfaceRefs.IUserObjectIUD.UserObjectDeleted(uo);                                                        // remove from view
            }
            string newOwnerName = SecurityUtil.GetPersonNameReversed(newOwner);

            return("Ownership of \"" + uo2.Name + "\" has been changed to " + newOwnerName);
        }
Exemplo n.º 4
0
        public void Execute(string command)
        {
            try
            {
                command = command.Replace("%20", " ");                 // convert any special URL characters (todo: more complete translation)
                DebugLog.Message("MobiusClientIntegrationPoint Command: " + Lex.AddDoubleQuotes(command));
                CommandExec.PostCommand(command);
            }

            catch (Exception ex)
            {
                string msg =
                    "Error executing external command: " + command + "\n\n" +
                    DebugLog.FormatExceptionMessage(ex);

                ServicesLog.Message(msg);
                MessageBoxMx.ShowError(msg);
            }
        }
Exemplo n.º 5
0
/// <summary>
/// Copy assay data to clipboard
/// </summary>
/// <param name="includeLabels"></param>
/// <param name="includeInternalNames"></param>

        private void CopyAssayData(
            bool includeLabels,
            bool includeInternalNames)
        {
            string            s    = "";
            DataRowCollection rows = ItemGridDataTable.Rows;

            for (int ri = 0; ri < rows.Count; ri++)
            {
                DataRow dr    = rows[ri];
                string  label = dr["LabelColumn"] as string;
                string  name  = dr["InternalNameColumn"] as string;

                string txt = "";

                if (includeLabels && includeInternalNames)
                {
                    if (label.Contains(","))
                    {
                        label = Lex.AddDoubleQuotes(label);
                    }
                    txt = label + "," + name;
                }

                else if (includeLabels)
                {
                    txt = label;
                }

                else if (includeInternalNames)
                {
                    txt = name;
                }

                s += txt + "\r\n";
            }

            Clipboard.SetText(s);
            return;
        }
Exemplo n.º 6
0
        /// <summary>
        /// ExportToMOE
        /// </summary>
        /// <param name="mtName"></param>
        /// <param name="mcName"></param>
        /// <param name="url"></param>

        void ExportToMOEMethod(
            string url,
            QueryManager qm,
            ResultsFormatter fmtr,
            ResultsField rfld)
        {
            List <string> fileList = ExportToFilesMethod(url, qm, fmtr, rfld);            // download the files first

            string moeExecutable, moeArgs = "";

            if (!GetMoeExecutable(out moeExecutable, out moeArgs))
            {
                return;                         // failed
            }
            if (UseExistingMoeInstance.Checked) // -openfiles uses any existing instance, if not included then starts new instance
            {
                moeArgs += " -openfiles ";
            }

            for (int fi = 0; fi < fileList.Count; fi++)
            {
                moeArgs += Lex.AddDoubleQuotes(fileList[fi]) + " ";
            }

            try
            {
                Progress.Show("Passing data to MOE...");
                Process p = Process.Start(moeExecutable, moeArgs);
                Progress.Hide();
                return;
            }

            catch (Exception ex)
            {
                try { Progress.Hide(); } catch { }
                throw new Exception(ex.Message, ex);
            }
        }
Exemplo n.º 7
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
        }
Exemplo n.º 8
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;
            }
        }
Exemplo n.º 9
0
 private void SaveNewTempListMenuItem_Click(object sender, EventArgs e)
 {
     CommandExec.ExecuteCommandAsynch("List SaveCurrentToNewTemp " + Lex.AddDoubleQuotes(((ToolStripMenuItem)sender).Text));
     RemoveAddedNodes();             // rebuild the full trees
     Setup();
 }