/// <summary> /// Setup the form with existing criteria /// </summary> /// <param name="qc"></param> void Setup( QueryColumn qc) { MetaTable mt = null; string listName, mcName, tok, tok1, tok2, tok3, txt; int i1; if (qc != null && qc.QueryTable != null) { mt = qc.QueryTable.MetaTable; } Text = qc.ActiveLabel + " Criteria"; Prompt.Text = "Choose one of the following " + qc.ActiveLabel + " criteria options."; Cid.Text = ""; CidListDisplay.Text = ""; ListName.Text = ""; SavedListUo = null; CidLo.Text = ""; CidHi.Text = ""; TempListName.Properties.Items.Clear(); // build dropdown of available temp list names foreach (TempCidList tl0 in SS.I.TempCidLists) { TempListName.Properties.Items.Add(tl0.Name); } TempListName.Text = "Current"; Lex lex = new Lex(); lex.OpenString(qc.Criteria); mcName = lex.GetUpper(); // metacolumn name if (Lex.Ne(mcName, qc.MetaColumnName)) // check if col name is first token { // if not assume it's simply missing and that the operator is the first token lex.Backup(); mcName = qc.MetaColumnName; } tok = lex.GetUpper(); // operator tok1 = lex.GetUpper(); // following tokens */ tok2 = lex.GetUpper(); tok3 = lex.GetUpper(); if (tok == "=" || tok == "") { tok1 = CompoundId.Format(tok1, mt); Cid.Text = tok1; EQ.Checked = true; } else if (tok == "IN" && tok1.StartsWith("(")) // list saved with query only { InList.Checked = true; CidListString = qc.Criteria; i1 = CidListString.IndexOf("("); // just get the list itself if parenthesized if (i1 >= 0) { CidListString = CidListString.Substring(i1 + 1); } if (CidListString.EndsWith(")")) { CidListString = CidListString.Substring(0, CidListString.Length - 1); } SetCidListDisplay(); } else if (tok == "IN" && (Lex.Eq(Lex.RemoveAllQuotes(tok2), "CURRENT") || Lex.StartsWith(tok2, UserObject.TempFolderNameQualified))) { // temp list if (Lex.StartsWith(tok2, UserObject.TempFolderNameQualified)) { tok2 = tok2.Substring(UserObject.TempFolderNameQualified.Length); } TempListName.Text = tok2; TempList.Checked = true; } else if (tok == "IN") // saved list { SavedListUo = QueryEngine.ResolveCnListReference(tok2); if (SavedListUo != null) { listName = SavedListUo.Name; } else { listName = "Nonexistant list"; // list deleted } ListName.Text = listName; SavedList.Checked = true; } else if (tok == "BETWEEN") { tok1 = CompoundId.Format(tok1); CidLo.Text = tok1; tok3 = CompoundId.Format(tok3); CidHi.Text = tok3; Between.Checked = true; } }
/// <summary> /// Process command line to create a user /// </summary> /// <param name="commandLine"></param> /// <returns></returns> public static string CreateUser( string commandLine) { string tok, msg; Lex lex = new Lex(); lex.OpenString(commandLine); if (!Security.IsAdministrator(SS.I.UserName)) { return("You must be a Mobius administrator to create users"); } string userName = lex.GetUpper(); // get user name bool interactive = Lex.IsNullOrEmpty(userName); while (true) { UserInfo ui = new UserInfo(); int i1 = userName.IndexOf(@"\"); if (i1 < 0) { i1 = userName.IndexOf(@"/"); // try forward slash } if (i1 < 0) // domain not specified, default is AM { ui.UserName = userName; } else if (i1 > 0) { ui.UserDomainName = userName.Substring(0, i1); ui.UserName = userName.Substring(i1 + 1); } if (interactive) // prompt { DialogResult dr = CreateUserDialog.ShowDialog(ui, "Create User"); if (dr == DialogResult.Cancel) { return(""); } } else { // Syntax: CREATE USER [domain\]userid firstname [mi] lastname [emailAddress] [company] [site] [department] ui.FirstName = Lex.CapitalizeFirstLetters(Lex.RemoveAllQuotes(lex.Get())); tok = Lex.CapitalizeFirstLetters(Lex.RemoveAllQuotes(lex.Get())); if (tok.Length == 1) { ui.MiddleInitial = tok; } else { lex.Backup(); } ui.LastName = Lex.CapitalizeFirstLetters(Lex.RemoveAllQuotes(lex.Get())); ui.EmailAddress = Lex.CapitalizeFirstLetters(Lex.RemoveAllQuotes(lex.Get())); ui.Company = Lex.CapitalizeFirstLetters(Lex.RemoveAllQuotes(lex.Get())); ui.Site = Lex.CapitalizeFirstLetters(Lex.RemoveAllQuotes(lex.Get())); ui.Department = Lex.CapitalizeFirstLetters(Lex.RemoveAllQuotes(lex.Get())); } UserInfo existingUi = Security.ReadUserInfo(ui.UserName); try { Security.CreateUser(ui); if (existingUi == null) { msg = "User successfully created"; } else { msg = "User information updated"; } msg += "\n\n" + "User: "******"\n" + "Domain: " + ui.UserDomainName + "\n" + "First Name: " + ui.FirstName + "\n" + "Middle Initial: " + ui.MiddleInitial + "\n" + "Last Name: " + ui.LastName; } catch (Exception ex) { msg = "User creation failed: " + ex.Message; } if (!interactive) { return(msg); } MessageBoxMx.Show(msg); userName = ""; } }