private void LoadUserData(string guid) { Durados.DataAccess.SqlAccess sqlAccess = new Durados.DataAccess.SqlAccess(); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@guid", guid); string sqlDuradosSys = string.Format("SELECT TOP 1 username FROM durados_user WITH(NOLOCK) WHERE guid=@guid"); object duradosSysUser = sqlAccess.ExecuteScalar(Durados.Web.Mvc.Maps.Instance.ConnectionString, sqlDuradosSys, parameters); if (duradosSysUser == null || duradosSysUser == DBNull.Value) { throw new Durados.DuradosException(Map.Database.Localizer.Translate("Username has no uniqe guid ,password canot be reset.")); } parameters.Clear(); parameters.Add("@username", duradosSysUser.ToString()); string sql = string.Format("SELECT TOP 1 {0} FROM {1} WITH(NOLOCK) WHERE {2}=@username", GetUserFieldsForSelect(), Map.Database.UserViewName, Map.Database.UsernameFieldName); object dataTable = sqlAccess.ExecuteTable(Map.Database.GetUserView().ConnectionString, sql, parameters, System.Data.CommandType.Text); if (dataTable == null || dataTable == DBNull.Value) { throw new Durados.DuradosException(Map.Database.Localizer.Translate("Username has no uniqe guid ,password canot be reset.")); } if (((System.Data.DataTable)dataTable).Rows.Count <= 0) { throw new Durados.DuradosException(UsernameNotExistsMessage); } userData = new Dictionary <string, string>(); System.Data.DataRow row = ((System.Data.DataTable)dataTable).Rows[0]; foreach (System.Data.DataColumn col in row.Table.Columns) { userData.Add(col.ColumnName, row[col.ColumnName].ToString()); } }
private void ApproveUser(string appName, string username) { Durados.Web.Mvc.Map map = Durados.Web.Mvc.Maps.Instance.GetMap(appName); string mapId = map.Id; if (string.IsNullOrEmpty(mapId)) { System.Data.DataRow appRow = Durados.Web.Mvc.Maps.Instance.GetAppRow(appName); mapId = appRow != null ? appRow["Id"].ToString() : string.Empty; } string userId = map.Database.GetUserID(username).ToString(); Dictionary <string, object> parameters2 = new Dictionary <string, object>(); parameters2.Add("@UserId", userId); parameters2.Add("@AppId", mapId); Durados.DataAccess.SqlAccess sql = new Durados.DataAccess.SqlAccess(); if (string.IsNullOrEmpty(sql.ExecuteScalar(Durados.Web.Mvc.Maps.Instance.DuradosMap.connectionString, "SELECT TOP 1 [ID] FROM [durados_UserApp] WHERE [UserId]=@UserId AND [AppId]=@AppId", parameters2))) { parameters2.Add("@newUser", username); parameters2.Add("@appName", appName); sql.ExecuteNonQuery(Durados.Web.Mvc.Maps.Instance.DuradosMap.Database.ConnectionString, "durados_AssignPendingApps @newUser,@appName", parameters2, AssignPendingAppsCallback); } }
private string GetUserGuid(string userName) { try { Durados.DataAccess.SqlAccess sql = new Durados.DataAccess.SqlAccess(); Dictionary <string, object> parameters = new Dictionary <string, object>(); parameters.Add("@username", userName); string userViewName = Map.Database.UserViewName; object guid = sql.ExecuteScalar(Durados.Web.Mvc.Maps.Instance.DuradosMap.connectionString, "SELECT TOP 1 [durados_user].[guid] FROM durados_user WITH(NOLOCK) WHERE [durados_user].[username]=@username", parameters); if (guid == null || guid == DBNull.Value) { throw new Durados.DuradosException(Map.Database.Localizer.Translate("Username has no uniqe guid ,password canot be reset.")); } return(guid.ToString()); } catch (Exception ex) { throw new Durados.DuradosException("User guid was not found.", ex); } }