예제 #1
0
/// <summary>
/// Show import menu
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        private void ImportFileButton_Click(object sender, EventArgs e)
        {
            if (!AllowColumnModifications())
            {
                return;
            }

            if (Dtm.DataModified)
            {
                MessageBoxMx.ShowError("You must save the current changes to the data before you can import a new file.");
                return;
            }

            if (ImportFileContextMenu.Tag == null)
            {
                ImportFileContextMenu.Show(ImportFileButton,
                                           new System.Drawing.Point(0, ImportFileButton.Size.Height));
            }

            else
            {
                ImportUcdbContextMenu.Show(ImportFileButton,
                                           new System.Drawing.Point(0, ImportFileButton.Size.Height));
            }

            return;
        }
예제 #2
0
        /// <summary>
        /// Let the user select an existing annotation and edit it
        /// </summary>
        /// <returns></returns>

        public static MetaTable OpenExistingAnnotationTable(
            UserObject uo)
        {
            if (uo == null)             // prompt if not supplied
            {
                uo = UserObjectOpenDialog.ShowDialog(UserObjectType.Annotation, "Open Annotation");
            }
            if (uo == null)
            {
                return(null);
            }

            if (!Permissions.UserHasWriteAccess(SS.I.UserName, uo))
            {
                MessageBoxMx.ShowError("You are not authorized to edit this annotation table.");
                return(null);
            }

            UserDataEditor editor = new UserDataEditor();
            UserObject     uo2    = editor.Edit(uo);

            if (uo2 == null)
            {
                return(null);
            }

            string    tName = "ANNOTATION_" + uo.Id.ToString();
            MetaTable mt    = MetaTableCollection.Get(tName);          // return new version of metatable

            return(mt);
        }
예제 #3
0
        /// <summary>
        /// Build a basic database query for the user database
        /// </summary>
        /// <param name="uo"></param>
        /// <returns></returns>

        internal static bool BuildDatabaseQuery(
            UserObject uo)
        {
            List <UserObject> luo = UserDataEditor.GetUcdbUserObjects(uo.Id);

            if (luo == null || luo.Count == 0)
            {
                MessageBoxMx.ShowError("No tables found for database");
                return(false);
            }

            Query q = new Query();

            foreach (UserObject uo2 in luo)
            {
                if (!UserObject.IsMetaTableType(uo2.Type))
                {
                    continue;
                }

                string    mtName = uo2.Type.ToString() + "_" + uo2.Id;
                MetaTable mt     = MetaTableCollection.Get(mtName);
                if (mt == null)
                {
                    continue;
                }
                QueryTable qt = new QueryTable(mt);
                q.AddQueryTable(qt);
            }

            QbUtil.NewQuery(uo.Name);
            QbUtil.SetCurrentQueryInstance(q);
            return(true);
        }
예제 #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
        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
            }
        }
예제 #6
0
        /// <summary>
        /// Run query using supplied OutputDest displaying any error message
        /// </summary>
        /// <param name="query"></param>
        /// <param name="outputDest"></param>
        /// <returns></returns>

        public static string RunQuery(
            Query query,
            OutputDest outputDest)
        {
            try
            {
                bool browseExistingResults = QbUtil.BrowseExistingDataTable(query);
                return(RunQuery(query, outputDest, OutputFormContext.Session, null, browseExistingResults));
            }

            catch (UserQueryException ex)
            {             // just show message
                Progress.Hide();
                MessageBoxMx.ShowError(ex.Message);
                return("");
            }

            catch (Exception ex)
            {             // non-standard query exception, provide more detail
                Progress.Hide();
                string msg = DebugLog.FormatExceptionMessage(ex);

                if (!Lex.Contains(msg, "QueryLogged:"))                 // exception & query
                {
                    QueryEngine.LogExceptionAndSerializedQuery(msg, query);
                }
                else
                {
                    ServicesLog.Message(msg);                  // just log exception
                }
                MessageBoxMx.ShowError("Unexpected Exception\n\n" + msg);
                return("");
            }
        }
예제 #7
0
        /// <summary>
        /// Allow user to edit the form
        /// </summary>
        /// <returns></returns>

        public static bool Edit(
            QueryColumn qc)
        {
            if (InEdit)
            {
                return(false);                    // prevent reentry via multiple clicks on the edit button
            }
            InEdit = true;

            try
            {
                if (!SS.I.UserInfo.Privileges.CanRetrieveStructures)
                {
                    MessageBoxMx.ShowError("Structure Access Not Authorized");
                    return(false);
                }

                //if (Instance == null) // use single instance
                Instance = new CriteriaStructure();

                Instance.SetupForm(qc);

                DialogResult dr = Instance.ShowDialog(SessionManager.ActiveForm);
                if (dr == DialogResult.OK)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            finally { InEdit = false; }
        }
예제 #8
0
        /// <summary>
        /// See if client file can be opened for writing to default dir and optionally display error message if not
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>

        public static bool CanWriteFileToDefaultDir(
            string fileName)
        {
            if (!Directory.Exists(ClientDirs.DefaultMobiusUserDocumentsFolder))
            {
                MessageBoxMx.ShowError(
                    "Unable to write to your default import/export folder: \"" + ClientDirs.DefaultMobiusUserDocumentsFolder + "\"\n\n" +
                    "You can change your default folder if necessary with the Tools > Preferences command");

                return(false);
            }

            string msg = FileUtil.CanWriteFile(fileName);

            if (msg == "")
            {
                return(true);
            }
            MessageBoxMx.ShowError(
                "Unable to write file \"" + fileName + "\"to your Mobius default folder: \"" + ClientDirs.DefaultMobiusUserDocumentsFolder + "\"\n\n" +
                "Error message: " + msg + "\n\n" +
                "You can change your default folder if necessary with the Tools > Preferences command");

            return(false);
        }
예제 #9
0
        /// <summary>
        /// Create the view display controls and link them into the QueryResultsControl and the ResultsView object
        /// </summary>
        /// <returns></returns>

        public override Control AllocateRenderingControl()
        {
            if (RealizeSubQueryView() == null)             // be sure the subquery and view still exist
            {
                MessageBoxMx.ShowError("Failed to realize SubQueryId: " + SubQueryId + ", SubQuerySelectedViewId: " + SubQuerySelectedViewId);
                return(null);
            }

            Query            sq     = SubQuery;
            ResultsViewProps sqView = SubQuerySelectedView;

            if (Lex.IsUndefined(CustomViewTypeImageName))
            {
                CustomViewTypeImageName = sqView.CustomViewTypeImageName;
            }

            if (Lex.IsUndefined(Title))
            {
                Title = sqView.Title;
            }

            if (Sqm == null)
            {
                Sqm = SetupAndExecuteSecondaryQuery(sq, sqView);
            }

            RenderingControl = sqView.AllocateRenderingControl();             // allocate proper control for the subquery view we want to use

            return(RenderingControl);
        }
예제 #10
0
        private void NumericIntervalDialog_OK_Click(object sender, EventArgs e)
        {
            Decimal intervalSize;

            if (!Decimal.TryParse(IntervalSize.Text, out intervalSize) || intervalSize <= 0)
            {
                MessageBoxMx.ShowError("The interval size must be a positive number");
                IntervalSize.Focus();
                return;
            }

// Update the aggregation def

            AggregationDef ad = AggregationDef;

            if (!ad.IsGroupingType)
            {
                ad.Role = AggregationRole.RowGrouping;
            }

            ad.GroupingType = GroupingTypeEnum.NumericInterval;
            AggregationDef.NumericIntervalSize = intervalSize;
            DialogResult = DialogResult.OK;
            return;

            //UpdateGrid();
            //Hide();
        }
예제 #11
0
        bool Save(bool prompt)
        {
            UserObject uo2;

            if (!IsValidCalcField())
            {
                return(false);
            }
            if (!GetCalcFieldForm())
            {
                return(false);
            }
            if (prompt)
            {
                uo2 = UserObjectSaveDialog.Show("Save Calculated Field Definition", UoIn);
                if (uo2 == null)
                {
                    return(false);
                }
            }
            else
            {
                uo2 = UoIn.Clone();
            }

            if (!UserObjectUtil.UserHasWriteAccess(uo2))
            {             // is the user authorized to save this?
                MessageBoxMx.ShowError("You are not authorized to save this calculated field");
                return(false);
            }

            SessionManager.DisplayStatusMessage("Saving calculated field...");

            string content = CalcField.Serialize();

            uo2.Content = content;

            //need the name of the folder to which the object will be saved
            MetaTreeNode targetFolder = UserObjectTree.GetValidUserObjectTypeFolder(uo2);

            if (targetFolder == null)
            {
                MessageBoxMx.ShowError("Failed to save your calculated field.");
                return(false);
            }

            UserObjectDao.Write(uo2);

            string tName = "CALCFIELD_" + uo2.Id.ToString();

            QbUtil.UpdateMetaTableCollection(tName);
            MainMenuControl.UpdateMruList(tName);

            string title = "Edit Calculated Field - " + uo2.Name;

            Text = title;
            UoIn = uo2.Clone();             // now becomes input object
            SessionManager.DisplayStatusMessage("");
            return(true);
        }
예제 #12
0
        /// <summary>
        /// Edit alert properties
        /// </summary>

        void EditAlert()
        {
            int   alertId = 0;
            Alert alert;

            if (Query.UserObject.Id <= 0)             // query been saved?
            {
                MessageBoxMx.ShowError("This query must be saved before an alert can be defined on it.");
                return;
            }

            if (!Alert.QueryValidForAlert(Query))
            {
                return;                                               // be sure it is valid
            }
            if (!QbUtil.CanRunQueryInBackground(Query))
            {
                return;                                                     // further validity checks
            }
            int newAlertId = AlertProperties.Edit(Query.UserObject.Id, out alert);

            if (newAlertId == 0)
            {
                return;                              // no change
            }
            SetAlertText(alert);
            return;
        }
예제 #13
0
        private void DeleteDatabase_Click(object sender, EventArgs e)
        {
            DataRow      dr;
            UcdbDatabase ucdb;
            int          ri;

            ri = GridView.FocusedRowHandle;
            if (ri < 0)
            {
                MessageBoxMx.ShowError("You must select the user compound database first");
                return;
            }

            dr   = DataTable.Rows[ri];
            ucdb = (UcdbDatabase)dr["Ucdb"];

            DialogResult dR = MessageBoxMx.Show("Are you sure you want to delete user compound database: \"" +
                                                ucdb.Name + "\"?", UmlautMobius.String, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

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

            ucdb.RowState = UcdbRowState.Deleted;  // mark for deletion
            Udbs.UpdateDatabase(ucdb);             // mark data for deletion

            DataTable.Rows.RemoveAt(ri);
            RenumberRows();
        }
예제 #14
0
        /// <summary>
        /// Read in focused UserObject
        /// </summary>
        /// <param name="ri"></param>
        /// <param name="dr"></param>
        /// <param name="ucdb"></param>
        /// <param name="uo"></param>
        /// <returns></returns>

        bool GetFocusedUo(out int ri, out DataRow dr, out UcdbDatabase ucdb, out UserObject uo)
        {
            dr   = null;
            ucdb = null;
            uo   = null;

            ri = GridView.FocusedRowHandle;


            if (ri < 0)
            {
                MessageBoxMx.ShowError("You must select the user compound database first");
                return(false);
            }

            dr   = DataTable.Rows[ri];
            ucdb = (UcdbDatabase)dr["Ucdb"];

            uo = UserObjectDao.Read(UserObjectType.UserDatabase, ucdb.OwnerUserName, ucdb.NameSpace, ucdb.Name);
            if (uo == null)
            {
                MessageBoxMx.ShowError("Unable to find associated user database \"UserObject\" information");
                return(false);
            }

            return(true);
        }
예제 #15
0
        /// <summary>
        /// Click function to open an external web site when clicking on a CID in a SmallWorld database display
        /// </summary>
        /// <param name="args"></param>

        public static void OpenUrlFromSmallWorldCid(
            string cid)
        {
            string[] px = { "PBCHM", "PDB" };

            RootTable rt = CompoundId.GetRootTableFromCid(cid);

            if (rt == null || Lex.IsUndefined(rt.CidUrl))
            {
                if (rt != null && Lex.Contains(rt.MetaTableName, MetaTable.PrimaryRootTable))
                {
                    RelatedCompoundsDialog.Show(cid);
                    return;
                }

                MessageBoxMx.ShowError("Unable to determine url link for compound Id: " + cid);
                return;
            }

            string url = rt.CidUrl;

            foreach (string p in px)             // remove unwanted URLs
            {
                if (Lex.StartsWith(cid, p))
                {
                    cid = cid.Substring(p.Length);
                }
            }

            url = Lex.Replace(url, "[CID]", cid);
            SystemUtil.StartProcess(url);
            return;
        }
예제 #16
0
        /// <summary>
        /// See if client file can be opened for writing and optionally display error message if not
        /// </summary>
        /// <param name="fileName"></param>
        /// <returns></returns>

        public static bool CanWriteFile(
            string fileName,
            bool showErrorIfCantWrite)
        {
            string msg = "";

            if (!Lex.StartsWith(fileName, "http"))
            {
                msg = FileUtil.CanWriteFile(fileName);
                if (msg == "")
                {
                    return(true);
                }
            }

            else              // URL
            {
                return(true); // todo: really check
            }

            if (showErrorIfCantWrite)
            {
                MessageBoxMx.ShowError(
                    "Can't open file for writing: " + fileName + "\n" + msg);
            }
            return(false);
        }
예제 #17
0
        /// <summary>
        /// Load the root xml document and call the control's SetData method.  Register for the control's AfterTreeUpdate
        /// method so we can enable/disable various buttons.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ContentsTreeEditorDialog_Load(object sender, EventArgs e)
        {
            XmlDocument rootXml = new XmlDocument();
            string      msg     = "Begin \r\n\r\n";

            try
            {
                string treeXml = MetaTreeFactory.LockAndReadMetatreeXml();
                msg += string.IsNullOrEmpty(treeXml) ? "treeXml is null" : "treeXml is not null";
                msg += "\r\n\r\n";
                rootXml.LoadXml(treeXml);
                msg += "LoadXml success \r\n\r\n";
                contentsTreeEditorControl1.SetData(rootXml);
                msg += "SetData success \r\n\r\n";
                if (!string.IsNullOrEmpty(_fullNodePath))
                {
                    msg += "_fullNodePath is not null: " + _fullNodePath + " \r\n\r\n";
                    msg += (contentsTreeEditorControl1 == null) ? "contentsTreeEditorControl1 is null" : "contentsTreeEditorControl1 is not null";
                    msg += "SetData success \r\n\r\n";
                    contentsTreeEditorControl1.SetCurrentNode(_fullNodePath);
                }
                if (contentsTreeEditorControl1 == null)
                {
                    msg += "contentsTreeEditorControl1 is null \r\n\r\n";
                }
                contentsTreeEditorControl1.AfterTreeUpdate += AfterTreeUpdate;
            }
            catch (Exception ex)
            {
                msg += "Unable to open the database contents tree for editing.\r\n\r\n" + ex.Message;
                MessageBoxMx.ShowError(msg);
                Close();
            }
        }
예제 #18
0
/// <summary>
/// Save the SpotfireLink UserObject
/// </summary>
/// <param name="prompt"></param>
/// <returns></returns>

        bool Save(bool prompt)
        {
            UserObject uo2;

            if (!IsValidSpotfireLink())
            {
                return(false);
            }
            if (!GetSpotfireLinkForm())
            {
                return(false);
            }
            if (prompt)
            {
                uo2 = UserObjectSaveDialog.Show("Save Spotfire link Definition", UoIn);
                if (uo2 == null)
                {
                    return(false);
                }
            }

            else
            {
                uo2 = UoIn.Clone();
            }

            uo2.Content = SpotfireViewProps.Serialize();

            if (!UserObjectUtil.UserHasWriteAccess(uo2))
            {             // is the user authorized to save this?
                MessageBoxMx.ShowError("You are not authorized to save this Spotfire link");
                return(false);
            }

            SessionManager.DisplayStatusMessage("Saving Spotfire link...");

            //need the name of the folder to which the object will be saved
            MetaTreeNode targetFolder = UserObjectTree.GetValidUserObjectTypeFolder(uo2);

            if (targetFolder == null)
            {
                MessageBoxMx.ShowError("Failed to save your Spotfire link.");
                return(false);
            }

            UserObjectDao.Write(uo2);

            MainMenuControl.UpdateMruList(uo2.InternalName);

            string title = "Edit Spotfire Link - " + uo2.Name;

            Text = title;
            UoIn = uo2.Clone();             // now becomes input object
            SessionManager.DisplayStatusMessage("");
            return(true);
        }
예제 #19
0
        private void EditTempList_Click(object sender, EventArgs e)
        {
            if (Lex.IsNullOrEmpty(TempListName.Text))
            {
                MessageBoxMx.ShowError("A temporary list name must be selected first");
                return;
            }

            CidListCommand.EditTemp(TempListName.Text);
        }
예제 #20
0
        private void ShowMetaTableXmlMenuItem_Click(object sender, EventArgs e)
        {
            if (CurrentQt == null)
            {
                MessageBoxMx.ShowError("You must first select the desired table from the table list.");
                return;
            }

            CommandLine.ShowMetaTableXml(CurrentQt.MetaTable.Name);
        }
예제 #21
0
        bool IsBlank(TextEdit ctl)
        {
            if (!Lex.IsNullOrEmpty(ctl.Text))
            {
                return(false);
            }

            ctl.Focus();
            MessageBoxMx.ShowError("Missing value");
            return(true);
        }
예제 #22
0
        /// <summary>
        /// Recalculate model results
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

#if false
        private void RecalculateModelResultsMenuItem_Click(object sender, EventArgs e)
        {
            DataRow      dr;
            UcdbDatabase ucdb, ucdb2;
            UserObject   uo;
            int          ri;

            if (!GetFocusedUo(out ri, out dr, out ucdb, out uo))
            {
                return;
            }

            ucdb2 = Udbs.SelectDatabaseHeader(ucdb.DatabaseId);             // get new form of database
            if (ucdb2 == null)
            {
                return;                            // shouldn't happen
            }
            if (Udbs.UpdateIsRunning(ucdb2))
            {
                MessageBoxMx.ShowError("Update is currently running");
                return;
            }

            UcdbModel[] models = Udbs.SelectDatabaseModels(ucdb.DatabaseId);
            if (models.Length == 0)
            {
                MessageBoxMx.ShowError("No models for database");
                return;
            }

            ucdb2.PendingCompoundCount = ucdb2.CompoundCount;
            ucdb2.PendingCompoundId    = 0;
            ucdb2.PendingUpdateDate    = DateTime.MinValue;
            ucdb2.PendingStatus        = UcdbWaitState.ModelPredictions;
            ucdb2.RowState             = UcdbRowState.Modified;
            Udbs.UpdateDatabase(ucdb2);

            foreach (UcdbModel model in models)
            {
                model.PendingStatus = UcdbWaitState.ModelPredictions;
                model.RowState      = UcdbRowState.Modified;
            }
            Udbs.UpdateDatabaseModelAssoc(ucdb2, models);

            string command = "UpdateUcdbModelResults Pending " + ucdb2.DatabaseId;

            CommandLine.StartBackgroundSession(command);

            ucdb2.PendingUpdateDate = DateTime.Now;             // set value assuming background process started;
            dr["Ucdb"] = ucdb2;
            SetupDataRow(dr, ucdb2);
        }
예제 #23
0
        private void SummarizedViewMenuItem_Click(object sender, EventArgs e)
        {
            string    mtName = FocusedMetaTable.Name + MetaTable.SummarySuffix;          // indicate summary table
            MetaTable mt     = MetaTableCollection.Get(mtName);

            if (mt == null)
            {
                MessageBoxMx.ShowError("MetaTable not found: " + mtName);
                return;
            }

            RenderTable(mt, null);
        }
예제 #24
0
/// <summary>
/// Add a MetaTableItem to the DataTable
/// </summary>
/// <param name="mtName"></param>

        void AddMetaTableItemToDataTable(
            string mtName)
        {
            MetaTreeNode mtn = MetaTreeNodeCollection.GetNode(mtName);

            if (mtn != null && mtn.IsFolderType)
            {
                return;                                              // ignore folders
            }
            MetaTable mt = MetaTableCollection.Get(mtName);

            if (mt == null)
            {
                MessageBoxMx.ShowError("The selected item is not a recognized data table: " + mtName);
                return;
            }

            string allowedTypes = Qc.MetaColumn.TableMap;

            if (Lex.IsDefined(allowedTypes))             // see if supplied table is allowed
            {
                int      ai;
                string[] sa = allowedTypes.Split(',');
                for (ai = 0; ai < sa.Length; ai++)
                {
                    string allowedType = sa[ai];
                    if (Lex.IsUndefined(allowedType))
                    {
                        continue;
                    }
                    if (Lex.Contains(mt.Name, allowedType.Trim()))
                    {
                        break;
                    }
                }

                if (ai >= sa.Length)
                {
                    MessageBoxMx.ShowError("The selected data table is not is not of a type that can be added here (" + allowedTypes + ")");
                    return;
                }
            }

            MetaTableItem i = new MetaTableItem();

            i.ExternalName = mt.Label;
            i.InternalName = mt.Name;
            AddMetaTableItemToDataTable(i);

            return;
        }
예제 #25
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;
            }
        }
예제 #26
0
        /// <summary>
        /// Process aggregation item click
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void AggregationTypeMenuItem_Click(object sender, EventArgs e)
        {
            ToolStripItem mi = sender as ToolStripItem;

            if (mi.Tag == null)
            {
                return;                             // tag should contain internal AggregationType.Name
            }
            string aggTypeName        = mi.Tag.ToString();
            AggregationTypeDetail atd = AggregationTypeDetail.GetByTypeName(aggTypeName);

            if (atd == null)
            {
                throw new Exception("Unrecognized aggregation type: " + aggTypeName);
            }

            if (Qc.MetaColumn == null)
            {
                return;
            }

            if (Qc.MetaColumn.DataType == MetaColumnType.Structure ||
                Qc.MetaColumn.DataType == MetaColumnType.Image)
            {
                bool allowed = ((atd.Role == AggregationRole.DataSummary && atd.SummaryTypeId == SummaryTypeEnum.Count) ||
                                atd.Role == AggregationRole.Undefined);
                if (!allowed)
                {
                    MessageBoxMx.ShowError("Aggregation is not supported for this column");
                    return;
                }
            }

            if (atd.GroupingType == GroupingTypeEnum.NumericInterval)             // prompt for numeric interval
            {
                DialogResult dr = NumericIntervalDialog.ShowDialog(AggregationDef, UIMisc.MousePosition);
                if (dr != DialogResult.OK)
                {
                    return;
                }
            }

            AggregationDef.SetFromTypeName(aggTypeName);

            if (AggregationChangedDelegate != null)
            {
                AggregationChangedDelegate(this);
            }

            return;
        }
예제 #27
0
        private void SortButton_Click(object sender, EventArgs e)
        {
            GetColumns();

            if (Columns.Count == 0)
            {
                MessageBoxMx.ShowError("At least one sort column must be defined");
            }

            else
            {
                DialogResult = DialogResult.OK;
            }
        }
예제 #28
0
        bool TryParseMaxHits(out int maxHits)
        {
            if (Lex.IsUndefined(MaxHits.Text))
            {
                maxHits = -1;                                            // no limit
            }
            else if (!int.TryParse(MaxHits.Text, out maxHits) || maxHits == 0)
            {
                MessageBoxMx.ShowError("Invalid Maximum Hits value");
                return(false);
            }

            return(true);
        }
예제 #29
0
/// <summary>
/// Save current to specified destination
/// </summary>
/// <param name="saveToTempList"></param>
/// <param name="tempListName"></param>
/// <returns></returns>

        static UserObject SaveCurrentList(
            bool saveToTempList,
            string tempListName)
        {
            CidList curList = Read(CidList.CurrentListInternalName);

            if (curList == null || curList.Count == 0)
            {
                MessageBoxMx.ShowError("The current list is empty");
                return(null);
            }

            UserObject uo = SaveList(curList, "Save Current List", saveToTempList, tempListName);

            return(uo);
        }
예제 #30
0
        /// <summary>
        /// Remove table from query
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>

        private void Tabs_CloseButtonClick(object sender, EventArgs e)
        {
            if (Tabs.SelectedTabPageIndex == 0 && ShowCriteriaTab)
            {
                MessageBoxMx.ShowError("The Criteria Summary tab cannot be removed.");
                return;
            }

            int qti = Tabs.SelectedTabPageIndex;

            if (ShowCriteriaTab)
            {
                qti--;
            }
            QbUtil.RemoveQueryTable(qti);
        }