/// <summary> /// Fixed: /// </summary> public PermissionModel( long referenceId, int deptId, int groupId, int userId, Permissions.Types permissionType) { ReferenceId = referenceId; if (deptId != 0) { DeptId = deptId; DeptName = SiteInfo.Dept(DeptId).Name; } if (groupId != 0) { GroupId = groupId; GroupName = new GroupModel( SiteSettingsUtilities.GroupsSiteSettings(), GroupId).GroupName; } if (userId != 0) { UserId = userId; var user = SiteInfo.User(UserId); Name = user.Name; } PermissionType = permissionType; }
private void Set(UserModel userModel, bool setData) { if (userModel.AccessStatus == Databases.AccessStatuses.Selected) { Authenticated = true; TenantId = userModel.TenantId; DeptId = userModel.DeptId; UserId = userModel.UserId; Dept = SiteInfo.Dept(tenantId: TenantId, deptId: DeptId); User = SiteInfo.User(context: this, userId: UserId); Language = userModel.Language; UserHostAddress = HttpContext.Current?.Request?.UserHostAddress; Developer = userModel.Developer; TimeZoneInfo = userModel.TimeZoneInfo; UserSettings = userModel.UserSettings; HasPrivilege = Permissions.PrivilegedUsers(loginId: userModel.LoginId); SetTenantCaches(); SetContractSettings(); SetPage(); if (setData) { SetData(); } } }
public void SetBySession(bool empty = false) { LoginId = HttpContext.Current?.User?.Identity.Name; if (HttpContext.Current?.Session != null && !empty) { TenantId = HttpContext.Current.Session["TenantId"].ToInt(); DeptId = HttpContext.Current.Session["DeptId"].ToInt(); UserId = HttpContext.Current.Session["UserId"].ToInt(); Dept = SiteInfo.Dept(tenantId: TenantId, deptId: DeptId); User = SiteInfo.User(context: this, userId: UserId); Language = HttpContext.Current.Session["Language"].ToStr(); Developer = HttpContext.Current.Session["Developer"].ToBool(); TimeZoneInfo = HttpContext.Current.Session["TimeZoneInfo"] as TimeZoneInfo; RdsUser = HttpContext.Current?.Session?["RdsUser"] as RdsUser; UserSettings = HttpContext.Current.Session["UserSettings"]? .ToString() .Deserialize <UserSettings>() ?? new UserSettings(); HasPrivilege = HttpContext.Current.Session["HasPrivilege"].ToBool(); Controller = GetController(); Action = GetAction(); Id = GetId(); SetTenantCaches(); } }
/// <summary> /// Fixed: /// </summary> public PermissionModel( Context context, long referenceId, int deptId, int groupId, int userId, Permissions.Types permissionType) { ReferenceId = referenceId; if (deptId != 0) { DeptId = deptId; DeptName = SiteInfo.Dept( tenantId: context.TenantId, deptId: DeptId).Name; } if (groupId != 0) { GroupId = groupId; GroupName = new GroupModel( context: context, ss: SiteSettingsUtilities.GroupsSiteSettings(context: context), groupId: GroupId) .GroupName; } if (userId != 0) { UserId = userId; var user = SiteInfo.User( context: context, userId: UserId); Name = user.Name; } PermissionType = permissionType; }
public bool Exists(Context context) { if (Id == 0) { return(false); } switch (Name) { case "Dept": return(SiteInfo.Dept( tenantId: context.TenantId, deptId: Id) != null); case "Group": return(new GroupModel( context: context, ss: SiteSettingsUtilities.GroupsSiteSettings(context: context), groupId: Id).AccessStatus == Databases.AccessStatuses.Selected); case "User": return(!SiteInfo.User( context: context, userId: Id).Anonymous()); default: return(false); } }
public ControlData ControlData(Context context, SiteSettings ss, bool withType = true) { switch (Name) { case "Dept": var dept = SiteInfo.Dept( tenantId: context.TenantId, deptId: Id); return(DisplayText( context: context, text: Displays.Depts(context: context), name: Id != 0 ? dept?.Name : null, title: dept?.Code, withType: withType)); case "Group": var groupModel = Id != 0 ? new GroupModel( context: context, ss: SiteSettingsUtilities.GroupsSiteSettings(context: context), groupId: Id) : null; return(DisplayText( context: context, text: Displays.Groups(context: context), name: groupModel?.AccessStatus == Databases.AccessStatuses.Selected ? groupModel.GroupName : null, title: null, withType: withType)); case "User": var user = SiteInfo.User( context: context, userId: Id); return(DisplayText( context: context, text: Displays.Users(context: context), name: Id != 0 ? user?.Name : null, title: Id != 0 ? user?.LoginId : null, withType: withType)); default: var column = ss?.GetColumn( context: context, columnName: Name); return(DisplayText( context: context, text: Displays.Column(context: context), name: column?.LabelText, title: column?.LabelTextDefault, withType: withType)); } }
public static HtmlBuilder HtmlDept( this HtmlBuilder hb, Context context, int id) { return(hb.P(css: "dept", action: () => hb .Icon(iconCss: "ui-icon-contact", text: SiteInfo.Dept( tenantId: context.TenantId, deptId: id).Name))); }
public bool ContainsDept(ServerScriptModelDeptModel dept) { return(GroupUtilities.Contains( context: Context, groupId: GroupId, dept: SiteInfo.Dept( tenantId: Context.TenantId, deptId: dept?.DeptId ?? 0))); }
public bool ContainsDept(int deptId) { return(GroupUtilities.Contains( context: Context, groupId: GroupId, dept: SiteInfo.Dept( tenantId: Context.TenantId, deptId: deptId))); }
public ControlData ControlData(Context context, SiteSettings ss, bool withType = true) { var typeName = withType ? DisplayTypeName(context: context) : null; switch (Name) { case "Dept": var dept = SiteInfo.Dept( tenantId: context.TenantId, deptId: Id); return(new ControlData( text: dept?.SelectableText( context: context, format: Parameters.Permissions.DeptFormat) + typeName, title: dept?.Tooltip())); case "Group": var group = SiteInfo.Group( tenantId: context.TenantId, groupId: Id); return(new ControlData( text: group?.SelectableText( context: context, format: Parameters.Permissions.GroupFormat) + typeName, title: group?.Tooltip())); case "User": var user = SiteInfo.User( context: context, userId: Id); return(new ControlData( text: user?.SelectableText( context: context, format: Parameters.Permissions.UserFormat) + typeName, title: user?.Tooltip(context: context))); default: var column = ss?.GetColumn( context: context, columnName: Name); return(new ControlData( id: Id, text: Displays.Column(context: context), name: column?.LabelText, title: column?.LabelTextDefault, typeName: typeName)); } }
public ServerScriptModelDeptModel Get(object id) { var dept = SiteInfo.Dept( tenantId: Context.TenantId, deptId: id.ToInt()); var deptModel = dept.Id > 0 ? new ServerScriptModelDeptModel( context: Context, tenantId: dept.TenantId, deptId: dept.Id, deptCode: dept.Code, deptName: dept.Name) : null; return(deptModel); }
private void Set(DataRow dataRow) { TenantId = dataRow.Int("TenantId"); Id = dataRow.Int("UserId"); DeptId = dataRow.Int("DeptId"); Dept = SiteInfo.Dept( tenantId: TenantId, deptId: DeptId); LoginId = dataRow.String("LoginId"); Name = dataRow.String("Name"); UserCode = dataRow.String("UserCode"); TenantManager = dataRow.Bool("TenantManager") || Permissions.PrivilegedUsers(loginId: dataRow.String("LoginId")); ServiceManager = dataRow.Bool("ServiceManager"); Disabled = dataRow.Bool("Disabled"); }
public ControlData ControlData(SiteSettings ss, bool withType = true) { switch (Name) { case "Dept": var dept = SiteInfo.Dept(Id); return(DisplayText( Displays.Depts(), Id != 0 ? dept?.Name : null, dept.Code, withType)); case "Group": var groupModel = Id != 0 ? new GroupModel(SiteSettingsUtilities.GroupsSiteSettings(), Id) : null; return(DisplayText( Displays.Groups(), groupModel?.AccessStatus == Databases.AccessStatuses.Selected ? groupModel.GroupName : null, null, withType)); case "User": var user = SiteInfo.User(Id); return(DisplayText( Displays.Users(), Id != 0 ? user?.Name : null, Id != 0 ? user?.LoginId : null, withType)); default: var column = ss?.GetColumn(Name); return(DisplayText( Displays.Column(), column?.LabelText, column?.LabelTextDefault, withType)); } }
private string Text(Context context, Column column, DataRow dataRow) { switch (column.ColumnName) { case "Dept": return(SiteInfo.Dept( tenantId: context.TenantId, deptId: dataRow.Int("DeptId")) ?.Name ?? "? " + dataRow.String(column.ColumnName)); case "Title": return(dataRow.String("ItemTitle")); default: return(dataRow.String(column.ColumnName)); } }
private void Set(DataRow dataRow) { TenantId = dataRow.Int("TenantId"); Id = dataRow.Int("UserId"); DeptId = dataRow.Int("DeptId"); Dept = SiteInfo.Dept( tenantId: TenantId, deptId: DeptId); LoginId = dataRow.String("LoginId"); Name = Strings.CoalesceEmpty(dataRow.String("Name"), LoginId); UserCode = dataRow.String("UserCode"); TenantManager = dataRow.Bool("TenantManager") || Permissions.PrivilegedUsers(loginId: dataRow.String("LoginId")); ServiceManager = dataRow.Bool("ServiceManager"); AllowCreationAtTopSite = dataRow.Bool("AllowCreationAtTopSite"); AllowGroupAdministration = dataRow.Bool("AllowGroupAdministration"); Disabled = dataRow.Bool("Disabled"); }
/// <summary> /// Fixed: /// </summary> private static void AddMember(this Dictionary <string, ControlData> data, DataRow dataRow) { var deptId = dataRow["DeptId"].ToInt(); var userId = dataRow["UserId"].ToInt(); var admin = dataRow.Table.Columns.Contains("Admin") ? dataRow["Admin"].ToBool() : false; var manager = admin ? "(" + Displays.Manager() + ")" : string.Empty; if (deptId > 0) { data.Add( "Dept," + deptId.ToString() + "," + admin, new ControlData(SiteInfo.Dept(deptId)?.Name + manager)); } else if (userId > 0) { data.Add( "User," + userId.ToString() + "," + admin, new ControlData(SiteInfo.UserName(userId) + manager)); } }
public static string ToNotice( this string self, Context context, string saved, Column column, NotificationColumnFormat notificationColumnFormat, bool updated, bool update) { if (column.HasChoices()) { switch (column.Type) { case Column.Types.Dept: return(notificationColumnFormat.DisplayText( self: SiteInfo.Dept( tenantId: context.TenantId, deptId: self.ToInt()).Name, saved: SiteInfo.Dept( tenantId: context.TenantId, deptId: saved.ToInt()).Name, column: column, updated: updated, update: update)); case Column.Types.Group: return(notificationColumnFormat.DisplayText( self: SiteInfo.Group( tenantId: context.TenantId, groupId: self.ToInt()).Name, saved: SiteInfo.Group( tenantId: context.TenantId, groupId: saved.ToInt()).Name, column: column, updated: updated, update: update)); case Column.Types.User: return(notificationColumnFormat.DisplayText( self: SiteInfo.UserName( context: context, userId: self.ToInt()), saved: SiteInfo.UserName( context: context, userId: saved.ToInt()), column: column, updated: updated, update: update)); default: return(notificationColumnFormat.DisplayText( self: column.Choice(self).Text, saved: column.Choice(saved).Text, column: column, updated: updated, update: update)); } } else { return(notificationColumnFormat.DisplayText( self: self, saved: saved, column: column, updated: updated, update: update)); } }
private void SetChoiceHash( int tenantId, long siteId, Dictionary <string, IEnumerable <string> > linkHash, IEnumerable <string> searchIndexes, int index, string line) { switch (line) { case "[[Depts]]": SiteInfo.TenantCaches[tenantId].DeptHash .Where(o => o.Value.TenantId == tenantId) .ForEach(o => AddToChoiceHash( o.Key.ToString(), SiteInfo.Dept(o.Key).Name)); break; case "[[Users]]": SiteInfo.SiteUsers(tenantId, siteId) .ToDictionary(o => o.ToString(), o => SiteInfo.UserName(o)) .Where(o => searchIndexes?.Any() != true || searchIndexes.All(p => o.Key.Contains(p) || o.Value.Contains(p))) .ForEach(o => AddToChoiceHash(o.Key, o.Value)); break; case "[[Users*]]": SiteInfo.TenantCaches[tenantId].UserHash .Where(o => o.Value.TenantId == tenantId) .ToDictionary(o => o.Key.ToString(), o => o.Value.Name) .Where(o => searchIndexes?.Any() != true || searchIndexes.All(p => o.Key.Contains(p) || o.Value.Contains(p))) .ForEach(o => AddToChoiceHash(o.Key, o.Value)); break; case "[[TimeZones]]": TimeZoneInfo.GetSystemTimeZones() .ForEach(o => AddToChoiceHash( o.Id, o.StandardName)); break; default: if (linkHash != null && linkHash.ContainsKey(line)) { linkHash[line].ForEach(value => AddToChoiceHash(value)); } else if (TypeName != "bit") { if (searchIndexes == null || searchIndexes.All(o => line.Contains(o))) { AddToChoiceHash(line); } } else { AddToChoiceHash((index == 0).ToOneOrZeroString(), line); } break; } }