private int MakeUser(string sfirst, string slast, string semail, bool badmin) { ArrayList alGroups = new ArrayList(); alGroups.Add((int)InternalSecureGroups.ProjectManager); using (IDataReader reader = SecureGroup.GetListGroups()) { while (reader.Read()) { int iGroupId = (int)reader["GroupId"]; if (iGroupId > 8) { alGroups.Add(iGroupId); break; } } } int iIMGroup = 0; using (DataTable table = IMGroup.GetListIMGroup()) { foreach (DataRow row in table.Rows) { if (!(bool)row["is_partner"]) { iIMGroup = (int)row["IMGroupId"]; break; } } } int userId = -1; #region makeuser if (semail != "") { int id = User.GetUserByEmail(semail); if (id <= 0) { string strLogin = semail.Substring(0, semail.IndexOf("@")); int i = 0; bool fl = false; do { string tmpLogin = strLogin; if (i > 0) { tmpLogin = tmpLogin + i.ToString(); } using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin)) { if (reader.Read()) { fl = true; } else { fl = false; } } i++; }while (fl); string sFirst = (sfirst == "") ? strLogin : sfirst; string sLast = (slast == "") ? strLogin : slast; if (i > 1) { strLogin = strLogin + (i - 1).ToString(); } ArrayList newList = new ArrayList(alGroups); if (badmin) { newList.Add((int)InternalSecureGroups.Administrator); } userId = User.Create(strLogin, "ibn", sFirst, sLast, semail, true, newList, iIMGroup, "", "", "", "", "", "", "", Security.CurrentUser.TimeZoneId, Security.CurrentUser.LanguageId, null, null, -1); } } #endregion return(userId); }
private void ShowStep(int step) { for (int i = 0; i <= _stepCount; i++) { ((Panel)steps[i]).Visible = false; } ((Panel)steps[step - 1]).Visible = true; if (step == _stepCount + 1) { ArrayList alGroups = new ArrayList(); using (IDataReader reader = SecureGroup.GetListGroups()) { while (reader.Read()) { int iGroupId = (int)reader["GroupId"]; if (iGroupId > 8) { alGroups.Add(iGroupId); break; } } } int iIMGroup = 0; using (DataTable table = IMGroup.GetListIMGroup()) { if (table.Rows.Count > 0) { iIMGroup = (int)table.Rows[0]["IMGroupId"]; } } #region txtEMail1 if (txtEMail1.Text != "") { int id = User.GetUserByEmail(txtEMail1.Text); if (id <= 0) { string strLogin = txtEMail1.Text.Substring(0, txtEMail1.Text.IndexOf("@")); int i = 0; bool fl = false; do { string tmpLogin = strLogin; if (i > 0) { tmpLogin = tmpLogin + i.ToString(); } using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin)) { if (reader.Read()) { fl = true; } else { fl = false; } } i++; }while (fl); string sFirst = (txtFirstName1.Text == "") ? strLogin : txtFirstName1.Text; string sLast = (txtLastName1.Text == "") ? strLogin : txtLastName1.Text; if (i > 1) { strLogin = strLogin + (i - 1).ToString(); } User.Create(strLogin, "ibn", sFirst, sLast, txtEMail1.Text, alGroups, iIMGroup, "", "", "", "", "", "", Security.CurrentUser.LanguageId, ""); } } #endregion #region txtEMail2 if (txtEMail2.Text != "") { int id = User.GetUserByEmail(txtEMail2.Text); if (id <= 0) { string strLogin = txtEMail2.Text.Substring(0, txtEMail2.Text.IndexOf("@")); int i = 0; bool fl = false; do { string tmpLogin = strLogin; if (i > 0) { tmpLogin = tmpLogin + i.ToString(); } using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin)) { if (reader.Read()) { fl = true; } else { fl = false; } } i++; }while (fl); string sFirst = (txtFirstName2.Text == "") ? strLogin : txtFirstName2.Text; string sLast = (txtLastName2.Text == "") ? strLogin : txtLastName2.Text; if (i > 1) { strLogin = strLogin + (i - 1).ToString(); } User.Create(strLogin, "ibn", sFirst, sLast, txtEMail2.Text, alGroups, iIMGroup, "", "", "", "", "", "", Security.CurrentUser.LanguageId, ""); } } #endregion #region txtEMail3 if (txtEMail3.Text != "") { int id = User.GetUserByEmail(txtEMail3.Text); if (id <= 0) { string strLogin = txtEMail3.Text.Substring(0, txtEMail3.Text.IndexOf("@")); int i = 0; bool fl = false; do { string tmpLogin = strLogin; if (i > 0) { tmpLogin = tmpLogin + i.ToString(); } using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin)) { if (reader.Read()) { fl = true; } else { fl = false; } } i++; }while (fl); string sFirst = (txtFirstName3.Text == "") ? strLogin : txtFirstName3.Text; string sLast = (txtLastName3.Text == "") ? strLogin : txtLastName3.Text; if (i > 1) { strLogin = strLogin + (i - 1).ToString(); } User.Create(strLogin, "ibn", sFirst, sLast, txtEMail3.Text, alGroups, iIMGroup, "", "", "", "", "", "", Security.CurrentUser.LanguageId, ""); } } #endregion #region txtEMail4 if (txtEMail4.Text != "") { int id = User.GetUserByEmail(txtEMail4.Text); if (id <= 0) { string strLogin = txtEMail4.Text.Substring(0, txtEMail4.Text.IndexOf("@")); int i = 0; bool fl = false; do { string tmpLogin = strLogin; if (i > 0) { tmpLogin = tmpLogin + i.ToString(); } using (IDataReader reader = User.GetUserInfoByLogin(tmpLogin)) { if (reader.Read()) { fl = true; } else { fl = false; } } i++; }while (fl); string sFirst = (txtFirstName4.Text == "") ? strLogin : txtFirstName4.Text; string sLast = (txtLastName4.Text == "") ? strLogin : txtLastName4.Text; if (i > 1) { strLogin = strLogin + (i - 1).ToString(); } User.Create(strLogin, "ibn", sFirst, sLast, txtEMail4.Text, alGroups, iIMGroup, "", "", "", "", "", "", Security.CurrentUser.LanguageId, ""); } } #endregion UserLightPropertyCollection pc = Security.CurrentUser.Properties; PortalConfig.PortalShowAdminWizard = cbShowNextTime.Checked; if (pc["USetup_ShowStartupWizard"] == null || pc["USetup_ShowStartupWizard"] == "True") { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "try{window.opener.top.right.location.href='" + ResolveClientUrl("~/Workspace/default.aspx") + "?BTab=Workspace&wizard=1';} catch (e) {} window.close();", true); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), Guid.NewGuid().ToString(), "try{window.opener.top.location.href='" + ResolveClientUrl("~/Apps/Shell/Pages/default.aspx") + "';} catch (e) {} window.close();", true); } } }