/// <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); }
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(); }
/// <summary> /// If SavedListUo is defined just return otherwise check in default folder for ListName /// </summary> string ResolveSavedListUo() { if (SavedListUo != null) { return("CNLIST_" + SavedListUo.Id); } if (ListName.Text == "") { return(""); } UserObject uo = new UserObject(UserObjectType.CnList, SS.I.UserName, ListName.Text); UserObjectTree.AssignDefaultObjectFolder(uo, UserObjectType.CnList); SavedListUo = UserObjectDao.ReadHeader(uo); if (SavedListUo != null) { return("CNLIST_" + SavedListUo.Id); } string errMsg = "List " + ListName.Text + " does not exist"; MessageBoxMx.Show(errMsg, UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); // return null if nonexistant list }
/// <summary> /// See if valid advanced calculated field /// </summary> /// <returns></returns> private bool IsValidAdvancedCalcField() { List <MetaColumn> mcList; string advExpr; if (Lex.IsNullOrEmpty(AdvancedExpr.Text)) { MessageBoxMx.Show( "The calculated field expression is blank", UmlautMobius.String); return(false); } try { advExpr = ParseAdvancedExpr(AdvancedExpr.Text, out mcList); } catch (Exception ex) { MessageBoxMx.Show(ex.Message, UmlautMobius.String); return(false); } string errmsg = QueryEngine.ValidateCalculatedFieldExpression(advExpr); if (!Lex.IsNullOrEmpty(errmsg)) { MessageBoxMx.Show( "Invalid calculated field expression:\r\n\r\n" + errmsg, UmlautMobius.String); return(false); } return(true); }
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(); }
/// <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(""); } }
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); }
/// <summary> /// See if saving this query would have an acceptable effect /// on any persisted alert results. /// </summary> /// <param name="q"></param> /// <returns>True if ok to save</returns> public static bool QuerySaveOkForAlertResults( Query q) { Alert alert = GetAlertByQueryId(q.UserObject.Id); if (alert == null) { return(true); // no alert so ok } if (alert.LastCheck != DateTime.MinValue && // has alert been checked? q.AlertQueryState != GetAlertQueryCriteria(q)) // have criteria changed? { DialogResult dr = MessageBoxMx.Show( "Since the search criteria for this new-data alerting query have changed the \n" + "alert state will be \"reset\" which means that the next time the alert runs it will\n" + "not mail out any detected data changes but will simply record the current state of\n" + "the data with respect to the new search criteria. Subsequent alert runs will then\n" + "check for new data changes.\n\n" + "Do you still want to continue to save the query?", UmlautMobius.String, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr != DialogResult.Yes) { return(false); } alert.LastCheck = DateTime.MinValue; // reset the alert alert.LastResults = null; // (should already be null) alert.Write(); } return(true); }
public bool ValidateData() { bool dayChecked = checkBoxSunday.Checked || checkBoxMonday.Checked || checkBoxTuesday.Checked || checkBoxWednesday.Checked || checkBoxThursday.Checked || checkBoxFriday.Checked || checkBoxSaturday.Checked; if (!dayChecked) { MessageBoxMx.Show("You must select a day of the week."); return(false); } if (textEditNumWeeks.EditValue == null || int.Parse(textEditNumWeeks.EditValue.ToString()) < 1) { MessageBoxMx.Show("You must enter the weekly interval."); return(false); } return(true); }
private void DeleteFavoriteMenuItem_Click(object sender, EventArgs e) { SessionManager.LogCommandUsage("ContentsFavoritesDelete"); MetaTreeNode node = QbContentsTree.CurrentContentsMetaTreeNode; if (node == null) { return; } if (String.IsNullOrEmpty(node.Target)) { return; } DialogResult dr = MessageBoxMx.Show( "Are you sure you want to delete: '" + node.Label + "' ?", "Confirm Delete", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); if (dr != DialogResult.Yes) { return; } SessionManager.Instance.MainMenuControl.DeleteFavorite(node); }
/// <summary> /// Return true if query is ok for alert or there is no alert associated with query /// </summary> /// <param name="q"></param> /// <returns></returns> public static bool QueryValidForAlert(Query q) { int criteriaCount = q.GetCriteriaCount(true, false); // count simple criteria if (q.LogicType == QueryLogicType.Complex && !String.IsNullOrEmpty(q.ComplexCriteria)) { criteriaCount = 1; } if (criteriaCount == 0) { MessageBoxMx.Show( "An alert cannot be defined on this query because it does not contain any search criteria.\n" + "You may want to use the \"Where data exists\" criteria on one of the fields in the query.", UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } if (q.KeyCriteria.ToLower().IndexOf("in list current") >= 0 || Lex.Contains(q.KeyCriteria, "in list " + UserObject.TempFolderNameQualified)) { MessageBoxMx.Show( "An alert cannot be defined on this query because it uses a volatile temporary list criteria.\n" + "If you save the temporary list and then use this saved list as the criteria then you can define an alert on the query.", UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.Information); return(false); } return(true); }
/// <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; }
private void MoveColumnDown_Click(object sender, EventArgs e) { if (!AllowColumnModifications()) { return; } int r = View.FocusedRowHandle; if (r < 0) { return; } if ((AnnotationTable && r <= 0) || (UserDatabase && r <= 1) || // keep initial col position(s) as is r >= View.RowCount - 1) { MessageBoxMx.Show("This column can't be moved down."); return; } DataRow dr = ColGridDataTable.NewRow(); dr.ItemArray = ColGridDataTable.Rows[r].ItemArray; ColGridDataTable.Rows.RemoveAt(r); ColGridDataTable.Rows.InsertAt(dr, r + 1); View.FocusedRowHandle = r + 1; return; }
internal void ZoomMenuItem_Click(object sender, EventArgs e) { ActivateZooming(); string msg = @"To zoom in: - Hold down the Shift key and then click on the point to zoom in to or - Hold down the Shift key and then draw a rectangle around the area to zoom in to or - Hold down the Ctrl key and click the plus (+) key or - Use the mouse wheel To zoom out: - Hold down the Alt key and then click in the region to be zoomed out or - Hold down the Ctrl key and click the minus (-) key or - Use the mouse wheel To scroll: - Use the scroll bars or - Hold down the Space key and then press and drag with the mouse or - Hold down the Ctrl key and then use the cursor (arrow) keys"; MessageBoxMx.Show(msg); return; }
/// <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; }
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 } }
/// <summary> /// Run alert in background /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void RunAlert_Click(object sender, EventArgs e) { int row, alertId; string msg = ""; row = V.GetFocusedDataSourceRowIndex(); if (row < 0) { return; } alertId = (int)DataTable.Rows[row]["AlertId"]; string command = "Check Alert " + alertId + " forceEmail"; try { CommandLine.StartBackgroundSession(command); msg = "The Alert has been started in the background.\n" + "You will receive an email when it completes."; } catch (Exception ex) { msg = "Failed to start background alert: " + ex.Message; } MessageBoxMx.Show(msg); return; }
/// <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; } }
/// <summary> /// Run Query & return any error message /// </summary> /// <param name="query"></param> /// <param name="queryDest"></param> /// <param name="outputFormContext"></param> /// <param name="browseExistingResults">If true browse existing results</param> /// <param name="suppressNoDataMessage"></param> /// <returns>Command command or an error message</command></returns> public static string RunQuery( Query query, OutputDest outputDest, OutputFormContext outputFormContext, ExitingQueryResultsDelegate exitingQueryResultsCallBack = null, bool browseExistingResults = false, bool suppressNoDataMessage = false ) { ResultsFormat rf = new ResultsFormat(); rf.OutputDestination = outputDest; rf.OutputFormContext = outputFormContext; rf.CustomExitingQueryResultsCallback = exitingQueryResultsCallBack; rf.SuppressNoDataMessage = suppressNoDataMessage; string response = RunQuery2(query, rf, browseExistingResults); query.UseResultKeys = false; // turn off use of keys if (response != "" && !response.ToLower().StartsWith("command") && !suppressNoDataMessage) { MessageBoxMx.Show( response, UmlautMobius.String, MessageBoxButtons.OK, MessageBoxIcon.Information); response = "Command EditQuery"; } return(response); }
/// <summary> /// Show with up to 4 custom buttons /// </summary> /// <param name="message"></param> /// <param name="caption"></param> /// <param name="button1"></param> /// <param name="button2"></param> /// <param name="button3"></param> /// <param name="button4"></param> /// <param name="icon"></param> /// <returns>Value of 1 - 4 corresponding to button pressed </returns> public static int ShowWithCustomButtons( string message, string caption, string button1, string button2, string button3, string button4, MessageBoxIcon icon, int width = -1, int height = -1) { if (!SS.I.Attended) { ClientLog.Message("Show: " + message); return((int)DialogResult.OK); } Progress.Hide(); // hide any progress message MessageBoxMx mb = new MessageBoxMx(); if (JupyterGuiConverter.ConversionsEnabled) { MessageBoxMx2 mb2 = new MessageBoxMx2(); new JupyterGuiConverter().ConvertFormOrUserControl(mb2); } int rc = mb.ShowInstance(message, caption, button1, button2, button3, button4, icon, width, height); return(rc); }
/// <summary> /// See if valid basic calculated field /// </summary> /// <returns></returns> private bool IsValidBasicCalcField() { for (int cfcci = 0; cfcci < CfColCtls.Count; cfcci++) { CalcFieldColumnControl cfcc = CfColCtls[cfcci]; bool validate = false; // decide if we should validate this field if (cfcci == 0) { validate = true; // always validate 1st field } else if (cfcci == 1 && !Lex.StartsWith(Operation.Text, "none")) { validate = true; // validate 2nd field if operator is not "none" } else if (cfcc.FieldSelectorControl.MetaColumn != null) { validate = true; } if (validate && !ValidateField(cfcc)) { return(false); } } if (!CondFormatRulesCtl.AreValid()) // are any rules valid { Tabs.SelectedTabPageIndex = 1; return(false); } CondFormatRules rules = CondFormatRulesCtl.GetRules(); if (CalcField.SourceColumnType == MetaColumnType.Structure && rules.Count == 0) { Tabs.SelectedTabPageIndex = 1; MessageBoxMx.Show( "Calculated fields on chemical structures must use classification\r\n" + "for the calculated field value", UmlautMobius.String); return(false); } if (rules.Count > 0) // must have at least one rule { foreach (CondFormatRule rule in rules) // must have name for each rule { if (String.IsNullOrEmpty(rule.Name)) { Tabs.SelectedTabPageIndex = 1; MessageBoxMx.Show("A name must be defined for each rule if using rule names the as calculated value", UmlautMobius.String); return(false); } } } return(true); }
private void BrowseQueries_Click(object sender, EventArgs e) { string prompt = "Select Query"; UserObject uo = UserObjectOpenDialog.ShowDialog(UserObjectType.Query, prompt, QueryUo); if (uo == null) { return; } Alert existingAlert = Alert.GetAlertByQueryId(uo.Id); if (existingAlert != null) // only 1 alert per query per user is allowed { if (Alert.Id <= 0 || // if this is a new alert or (Alert.Id > 0 && Alert.Id != existingAlert.Id)) // another alert exists for the query { MessageBoxMx.Show("You already an existing alert for query " + Lex.Dq(uo.Name), "Mobius", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } Query q = QbUtil.ReadQuery(uo.Id); if (!Alert.QueryValidForAlert(q)) { return; } QueryUo = uo; QueryName.Text = QueryUo.Name; }
/// <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(); } }
/// <summary> /// If the file is a UNC name check to see if the services can write to it /// </summary> /// <param name="fileName"></param> public static DialogResult CanWriteFileFromServiceAccount( string fileName) { //if (DisplayedUncWarningMessage) return DialogResult.OK; if (!fileName.StartsWith(@"\\")) { return(DialogResult.OK); } ; Progress.Show("Checking Mobius background write privileges...", UmlautMobius.String, false); bool canWrite = ServerFile.CanWriteFileFromServiceAccount(fileName); Progress.Hide(); //canWrite = false; // debug if (canWrite) { return(DialogResult.OK); } DialogResult dr = MessageBoxMx.Show( "The specified file is in a shared Windows network folder.\n" + "Mobius can't currently perform a background export directly to this file.\n" + "However, if write access to this shared folder is granted to the <mobiusAccount>\n" + "account then Mobius will be able to export directly to the specified file.", "Mobius", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); DisplayedUncWarningMessage = true; return(dr); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
/// <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; } }
/// <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); }