protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { var users = CoreContext.UserManager.GetUsers(EmployeeStatus.Active).Select(r => new { id = r.ID, displayName = DisplayUserSettings.GetFullUserName(r), avatarSmall = UserPhotoManager.GetSmallPhotoURL(r.ID), groups = CoreContext.UserManager.GetUserGroups(r.ID).Select(x => new { id = x.ID, name = x.Name, manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID)).UserName }) .ToList(), isVisitor = r.IsVisitor(), isAdmin = r.IsAdmin(), isOwner = r.IsOwner() }).ToList(); var groups = CoreContext.UserManager.GetDepartments().Select(x => new { id = x.ID, name = x.Name }).ToList(); yield return(RegisterObject("ApiResponsesMyProfile", new { response = users.FirstOrDefault(r => r.id.Equals(SecurityContext.CurrentAccount.ID)) })); yield return(RegisterObject("ApiResponses_Profiles", new { response = users })); yield return(RegisterObject("ApiResponses_Groups", new { response = groups })); }
private static object PrepareUserInfo(UserInfo userInfo) { return(new { id = userInfo.ID, displayName = DisplayUserSettings.GetFullUserName(userInfo), title = userInfo.Title, avatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID), avatarBig = UserPhotoManager.GetBigPhotoURL(userInfo.ID), profileUrl = CommonLinkUtility.ToAbsolute(CommonLinkUtility.GetUserProfile(userInfo.ID.ToString(), false)), groups = CoreContext.UserManager.GetUserGroups(userInfo.ID).Select(x => new { id = x.ID, name = x.Name, manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID)).UserName }).ToList(), isPending = userInfo.ActivationStatus == EmployeeActivationStatus.Pending, isActivated = userInfo.ActivationStatus == EmployeeActivationStatus.Activated, isVisitor = userInfo.IsVisitor(), isOutsider = userInfo.IsOutsider(), isAdmin = userInfo.IsAdmin(), isOwner = userInfo.IsOwner(), contacts = GetContacts(userInfo), created = userInfo.CreateDate, email = userInfo.Email, isLDAP = userInfo.Sid != null }); }
private static object PrepareUserInfo(UserInfo userInfo) { return(new { id = userInfo.ID, displayName = DisplayUserSettings.GetFullUserName(userInfo), title = userInfo.Title, avatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID), avatarBig = UserPhotoManager.GetBigPhotoURL(userInfo.ID), profileUrl = CommonLinkUtility.ToAbsolute(CommonLinkUtility.GetUserProfile(userInfo.ID.ToString(), false)), groups = CoreContext.UserManager.GetUserGroupsId(userInfo.ID), isPending = userInfo.ActivationStatus == EmployeeActivationStatus.Pending, isActivated = userInfo.ActivationStatus.HasFlag(EmployeeActivationStatus.Activated), isVisitor = userInfo.IsVisitor(), isOutsider = userInfo.IsOutsider(), isAdmin = userInfo.IsAdmin(), isOwner = userInfo.IsOwner(), contacts = GetContacts(userInfo), created = userInfo.CreateDate, email = userInfo.Email, isLDAP = userInfo.IsLDAP(), isSSO = userInfo.IsSSO(), isTerminated = userInfo.Status == EmployeeStatus.Terminated }); }
public override List <UsageSpaceStatItem> GetStatData() { using (var mail_db = DbManager.FromHttpContext(MailDatabaseId)) { var query = new SqlQuery("mail_attachment a") .InnerJoin("mail_mail m", Exp.EqColumns("a.id_mail", "m.id")) .Select("m.id_user") .Select("sum(a.size) as size") .Where("a.tenant", TenantProvider.CurrentTenantID) .Where("a.need_remove", 0) .GroupBy(1) .OrderBy(2, false); return(mail_db.ExecuteList(query) .Select(r => { var user_id = new Guid(Convert.ToString(r[0])); var user = CoreContext.UserManager.GetUsers(user_id); var item = new UsageSpaceStatItem { Name = DisplayUserSettings.GetFullUserName(user, false), ImgUrl = UserPhotoManager.GetSmallPhotoURL(user.ID), Url = CommonLinkUtility.GetUserProfile(user.ID), SpaceUsage = Convert.ToInt64(r[1]), Disabled = user.Status == EmployeeStatus.Terminated }; return item; }) .ToList()); } }
public override List <UsageSpaceStatItem> GetStatData() { if (!DbRegistry.IsDatabaseRegistered(MailDatabaseId)) { DbRegistry.RegisterDatabase(MailDatabaseId, ConfigurationManager.ConnectionStrings[MailDatabaseId]); } using (var mail_db = new DbManager(MailDatabaseId)) { var query = new SqlQuery("mail_attachment a") .InnerJoin("mail_mail m", Exp.EqColumns("a.id_mail", "m.id")) .Select("m.id_user") .Select("sum(a.size) as size") .Where("m.tenant", TenantProvider.CurrentTenantID) .Where("a.need_remove", 0) .GroupBy(1) .OrderBy(2, false); return(mail_db.ExecuteList(query) .Select(r => { var user_id = new Guid(Convert.ToString(r[0])); var user = CoreContext.UserManager.GetUsers(user_id); var item = new UsageSpaceStatItem { Name = DisplayUserSettings.GetFullUserName(user, false), ImgUrl = UserPhotoManager.GetSmallPhotoURL(user.ID), Url = CommonLinkUtility.GetUserProfile(user.ID), SpaceUsage = Convert.ToInt64(r[1]) }; return item; }) .ToList()); } }
protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { var currentProject = "0"; if (context.Request.GetUrlRewriter() != null) { currentProject = HttpUtility.ParseQueryString(context.Request.GetUrlRewriter().Query)["prjID"]; if (string.IsNullOrEmpty(currentProject) && context.Request.UrlReferrer != null) { currentProject = HttpUtility.ParseQueryString(context.Request.UrlReferrer.Query)["prjID"]; } } using (var scope = DIHelper.Resolve()) { var engineFactory = scope.Resolve <EngineFactory>(); var team = engineFactory.ProjectEngine.GetTeam(Convert.ToInt32(currentProject)) .Select(r => new { id = r.UserInfo.ID, displayName = DisplayUserSettings.GetFullUserName(r.UserInfo.ID), email = r.UserInfo.Email, userName = r.UserInfo.UserName, avatarSmall = UserPhotoManager.GetSmallPhotoURL(r.UserInfo.ID), avatar = UserPhotoManager.GetBigPhotoURL(r.UserInfo.ID), status = r.UserInfo.Status, groups = CoreContext.UserManager.GetUserGroups(r.UserInfo.ID).Select(x => new { id = x.ID, name = x.Name, manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID)) .UserName }).ToList(), isVisitor = r.UserInfo.IsVisitor(), isAdmin = r.UserInfo.IsAdmin(), isOwner = r.UserInfo.IsOwner(), isManager = r.IsManager, canReadFiles = r.CanReadFiles, canReadMilestones = r.CanReadMilestones, canReadMessages = r.CanReadMessages, canReadTasks = r.CanReadTasks, canReadContacts = r.CanReadContacts, title = r.UserInfo.Title, profileUrl = r.UserInfo.GetUserProfilePageURL() }).OrderBy(r => r.displayName).ToList(); return(new List <KeyValuePair <string, object> >(1) { RegisterObject( new { Team = new { response = team }, projectFolder = engineFactory.FileEngine.GetRoot(Convert.ToInt32(currentProject)) }) }); } }
public ThumbnailsDataWrapper(Guid userId, UserPhotoManager userPhotoManager) { Original = userPhotoManager.GetPhotoAbsoluteWebPath(userId); Retina = userPhotoManager.GetRetinaPhotoURL(userId); Max = userPhotoManager.GetMaxPhotoURL(userId); Big = userPhotoManager.GetBigPhotoURL(userId); Medium = userPhotoManager.GetMediumPhotoURL(userId); Small = userPhotoManager.GetSmallPhotoURL(userId); }
public ThumbnailsDataWrapper(Tenant tenant, Guid userId) { Original = UserPhotoManager.GetPhotoAbsoluteWebPath(tenant, userId); Retina = UserPhotoManager.GetRetinaPhotoURL(tenant.TenantId, userId); Max = UserPhotoManager.GetMaxPhotoURL(tenant.TenantId, userId); Big = UserPhotoManager.GetBigPhotoURL(tenant.TenantId, userId); Medium = UserPhotoManager.GetMediumPhotoURL(tenant.TenantId, userId); Small = UserPhotoManager.GetSmallPhotoURL(tenant.TenantId, userId); }
public static string GetHtmlImgUserAvatar(Guid userId) { var imgPath = UserPhotoManager.GetSmallPhotoURL(userId); if (imgPath != null) { return("<img class=\"userMiniPhoto\" src=\"" + imgPath + "\"/>"); } return(string.Empty); }
protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { var userInfoList = new List <UserInfo> { CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID) }; var groupInfoList = new List <GroupInfo>(); if (SecurityContext.IsAuthenticated && !CoreContext.Configuration.Personal) { userInfoList = CoreContext.UserManager.GetUsers(EmployeeStatus.Active).ToList(); groupInfoList = CoreContext.UserManager.GetDepartments().ToList(); } var users = userInfoList.Select(r => new { id = r.ID, displayName = DisplayUserSettings.GetFullUserName(r), avatarSmall = UserPhotoManager.GetSmallPhotoURL(r.ID), groups = CoreContext.UserManager.GetUserGroups(r.ID).Select(x => new { id = x.ID, name = x.Name, manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID)).UserName }) .ToList(), isPending = r.ActivationStatus == EmployeeActivationStatus.Pending, isVisitor = r.IsVisitor(), isAdmin = r.IsAdmin(), isOwner = r.IsOwner() }).ToList(); var groups = groupInfoList.Select(x => new { id = x.ID, name = x.Name }).ToList(); var currentTenant = CoreContext.TenantManager.GetCurrentTenant(); var hubToken = Common.Utils.Signature.Create(string.Join(",", currentTenant.TenantId, SecurityContext.CurrentAccount.ID, currentTenant.TenantAlias)); var hubUrl = ConfigurationManager.AppSettings["web.hub"] ?? "https://signalr.teamlab.info"; if (!hubUrl.EndsWith("/")) { hubUrl += "/"; } yield return(RegisterObject("Hub", new { Token = hubToken, Url = hubUrl + "signalr" })); yield return(RegisterObject("ApiResponsesMyProfile", new { response = users.FirstOrDefault(r => r.id.Equals(SecurityContext.CurrentAccount.ID)) })); yield return(RegisterObject("ApiResponses_Profiles", new { response = users })); yield return(RegisterObject("ApiResponses_Groups", new { response = groups })); }
public static string GetHTMLSmallUserAvatar(Guid userID) { string imgPath = UserPhotoManager.GetSmallPhotoURL(userID); if (imgPath != null) { return("<img class=\"userMiniPhoto\" alt='' src=\"" + imgPath + "\"/>"); } return(string.Empty); }
public EmployeeWraper(UserInfo userInfo, ApiContext context) { Id = userInfo.ID; DisplayName = DisplayUserSettings.GetFullUserName(userInfo); if (!string.IsNullOrEmpty(userInfo.Title)) { Title = userInfo.Title; } if (EmployeeWraperFull.CheckContext(context, "avatarSmall")) { AvatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID) + "?_=" + userInfo.LastModified.GetHashCode(); } }
public EmployeeWraper(UserInfo userInfo, ApiContext httpContext) { Id = userInfo.ID; DisplayName = DisplayUserSettings.GetFullUserName(userInfo); if (!string.IsNullOrEmpty(userInfo.Title)) { Title = userInfo.Title; } var userInfoLM = userInfo.LastModified.GetHashCode(); if (httpContext.Check("avatarSmall")) { AvatarSmall = UserPhotoManager.GetSmallPhotoURL(httpContext.Tenant.TenantId, userInfo.ID, out var isdef) + (isdef ? "" : $"?_={userInfoLM}"); } if (Id != Guid.Empty) { var profileUrl = CommonLinkUtility.GetUserProfile(userInfo, false); ProfileUrl = CommonLinkUtility.GetFullAbsolutePath(httpContext.HttpContext, profileUrl); } }
private ActionResult LoginView(UserInfo user, bool byThirdParty, string email, string password) { var tenant = CoreContext.TenantManager.GetCurrentTenant(false); if (tenant == null) { return(Redirect(ConfigurationManager.AppSettings["web.notenant-url"])); } var logopath = SettingsManager.Instance.LoadSettings <TenantInfoSettings>(tenant.TenantId).GetAbsoluteCompanyLogoPath(); var mobiledir = ConfigurationManager.AppSettings["mobile.redirect-url"]; if (!string.IsNullOrEmpty(logopath) && !string.IsNullOrEmpty(mobiledir)) { mobiledir = "/" + mobiledir.Trim('~', '/') + "/"; if (logopath.Contains(mobiledir)) { logopath = logopath.Replace(mobiledir, "/"); } } if (SecurityContext.IsAuthenticated) { //If already authorized redir to home return(RedirectAuthorized()); } return(View("SignIn", new LoginModel { Email = email, Password = password, CompanyInfo = CoreContext.TenantManager.GetCurrentTenant().Name, CompanyLogo = logopath, TenantAddress = CoreContext.TenantManager.GetCurrentTenant().TenantDomain, IsAuthentificated = SecurityContext.IsAuthenticated, UserInfo = CoreContext.UserManager.GetUsers(SecurityContext.CurrentAccount.ID), UserPhoto = UserPhotoManager.GetSmallPhotoURL(SecurityContext.CurrentAccount.ID), RequestCode = user != null, ByThirdParty = byThirdParty })); }
protected EmployeeWraper Init(EmployeeWraper result, UserInfo userInfo) { result.Id = userInfo.ID; result.DisplayName = DisplayUserSettingsHelper.GetFullUserName(userInfo); if (!string.IsNullOrEmpty(userInfo.Title)) { result.Title = userInfo.Title; } var userInfoLM = userInfo.LastModified.GetHashCode(); if (HttpContext.Check("avatarSmall")) { result.AvatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID, out var isdef) + (isdef ? "" : $"?_={userInfoLM}"); } if (result.Id != Guid.Empty) { var profileUrl = CommonLinkUtility.GetUserProfile(userInfo, false); result.ProfileUrl = CommonLinkUtility.GetFullAbsolutePath(profileUrl); } return(result); }
///<summary> ///</summary> ///<param name="userInfo"></param> ///<exception cref="ArgumentException"></exception> public EmployeeWraperFull(UserInfo userInfo) : base(userInfo) { if (userInfo == Core.Users.Constants.LostUser) { throw new ArgumentException("user not found"); } Id = userInfo.ID; UserName = userInfo.UserName; FirstName = userInfo.FirstName; LastName = userInfo.LastName; Birthday = (ApiDateTime)userInfo.BirthDate; Sex = userInfo.Sex.HasValue ? userInfo.Sex.Value ? "male" : "female" : ""; Status = userInfo.Status; Terminated = (ApiDateTime)userInfo.TerminatedDate; Title = userInfo.Title; Department = userInfo.Department; WorkFrom = (ApiDateTime)userInfo.WorkFromDate; Email = userInfo.Email; Location = userInfo.Location; Notes = userInfo.Notes; Email = userInfo.Email; FillConacts(userInfo); Groups = Core.CoreContext.UserManager.GetUserGroups(userInfo.ID).Select(x => new GroupWrapperSummary(x)).ToList(); try { AvatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID); AvatarMedium = UserPhotoManager.GetMediumPhotoURL(userInfo.ID); Avatar = UserPhotoManager.GetBigPhotoURL(userInfo.ID); } catch (Exception) { } }
public static string GetSmallPhotoURL(this UserInfo userInfo, int tenantId) { return(UserPhotoManager.GetSmallPhotoURL(tenantId, userInfo.ID)); }
public static string GetSmallPhotoURL(this UserInfo userInfo) { return(UserPhotoManager.GetSmallPhotoURL(userInfo.ID)); }
public EmployeeWraperFull(UserInfo userInfo, ApiContext context) : base(userInfo) { UserName = userInfo.UserName; IsVisitor = userInfo.IsVisitor(); FirstName = userInfo.FirstName; LastName = userInfo.LastName; Birthday = (ApiDateTime)userInfo.BirthDate; if (userInfo.Sex.HasValue) { Sex = userInfo.Sex.Value ? "male" : "female"; } Status = userInfo.Status; ActivationStatus = userInfo.ActivationStatus; Terminated = (ApiDateTime)userInfo.TerminatedDate; if (!string.IsNullOrEmpty(userInfo.Department)) { Department = userInfo.Department; } WorkFrom = (ApiDateTime)userInfo.WorkFromDate; Email = userInfo.Email; if (!string.IsNullOrEmpty(userInfo.Location)) { Location = userInfo.Location; } if (!string.IsNullOrEmpty(userInfo.Notes)) { Notes = userInfo.Notes; } if (!string.IsNullOrEmpty(userInfo.MobilePhone)) { MobilePhone = userInfo.MobilePhone; } MobilePhoneActivationStatus = userInfo.MobilePhoneActivationStatus; if (!string.IsNullOrEmpty(userInfo.CultureName)) { CultureName = userInfo.CultureName; } FillConacts(userInfo); var groups = Core.CoreContext.UserManager.GetUserGroups(userInfo.ID).Select(x => new GroupWrapperSummary(x)).ToList(); if (groups.Any()) { Groups = groups; } try { if (CheckContext(context, "avatarSmall")) { AvatarSmall = UserPhotoManager.GetSmallPhotoURL(userInfo.ID); } if (CheckContext(context, "avatarMedium")) { AvatarMedium = UserPhotoManager.GetMediumPhotoURL(userInfo.ID); } if (CheckContext(context, "avatar")) { Avatar = UserPhotoManager.GetBigPhotoURL(userInfo.ID); } } catch (Exception) { } try { IsOnline = false; IsAdmin = userInfo.IsAdmin(); if (CheckContext(context, "listAdminModules")) { var listAdminModules = userInfo.GetListAdminModules(); if (listAdminModules.Any()) { ListAdminModules = listAdminModules; } } IsOwner = userInfo.IsOwner(); } catch (Exception) { } }
public FileUploadResult ProcessUpload(HttpContext context) { var result = new FileUploadResult(); try { if (context.Request.Files.Count != 0) { Guid userId; try { userId = new Guid(context.Request["userId"]); } catch { userId = SecurityContext.CurrentAccount.ID; } SecurityContext.DemandPermissions(new UserSecurityProvider(userId), Constants.Action_EditUser); var userPhoto = context.Request.Files[0]; if (userPhoto.InputStream.Length > SetupInfo.MaxImageUploadSize) { result.Success = false; result.Message = FileSizeComment.FileImageSizeExceptionString; return(result); } var data = new byte[userPhoto.InputStream.Length]; var br = new BinaryReader(userPhoto.InputStream); br.Read(data, 0, (int)userPhoto.InputStream.Length); br.Close(); CheckImgFormat(data); if (context.Request["autosave"] == "true") { if (data.Length > SetupInfo.MaxImageUploadSize) { throw new ImageSizeLimitException(); } var mainPhoto = UserPhotoManager.SaveOrUpdatePhoto(userId, data); result.Data = new { main = mainPhoto, retina = UserPhotoManager.GetRetinaPhotoURL(userId), max = UserPhotoManager.GetMaxPhotoURL(userId), big = UserPhotoManager.GetBigPhotoURL(userId), medium = UserPhotoManager.GetMediumPhotoURL(userId), small = UserPhotoManager.GetSmallPhotoURL(userId), }; } else { result.Data = UserPhotoManager.SaveTempPhoto(data, SetupInfo.MaxImageUploadSize, UserPhotoManager.OriginalFotoSize.Width, UserPhotoManager.OriginalFotoSize.Height); } result.Success = true; } else { result.Success = false; result.Message = PeopleResource.ErrorEmptyUploadFileSelected; } } catch (UnknownImageFormatException) { result.Success = false; result.Message = PeopleResource.ErrorUnknownFileImageType; } catch (ImageWeightLimitException) { result.Success = false; result.Message = PeopleResource.ErrorImageWeightLimit; } catch (ImageSizeLimitException) { result.Success = false; result.Message = PeopleResource.ErrorImageSizetLimit; } catch (Exception ex) { result.Success = false; result.Message = ex.Message.HtmlEncode(); } return(result); }
protected override IEnumerable <KeyValuePair <string, object> > GetClientVariables(HttpContext context) { var currentProject = "0"; if (context.Request.GetUrlRewriter() != null) { currentProject = HttpUtility.ParseQueryString(context.Request.GetUrlRewriter().Query)["prjID"]; if (string.IsNullOrEmpty(currentProject) && context.Request.UrlReferrer != null) { currentProject = HttpUtility.ParseQueryString(context.Request.UrlReferrer.Query)["prjID"]; } } var filter = new TaskFilter { SortBy = "deadline", SortOrder = false, MilestoneStatuses = new List <MilestoneStatus> { MilestoneStatus.Open }, ProjectIds = new List <int> { Convert.ToInt32(currentProject) } }; var milestones = Global.EngineFactory.MilestoneEngine.GetByFilter(filter) .Select(m => new { id = m.ID, title = m.Title, deadline = ClientUserResources.SetDate(m.DeadLine, TimeZoneInfo.Local), projectOwner = new { id = m.Project.ID } }); var team = Global.EngineFactory.ProjectEngine.GetTeam(Convert.ToInt32(currentProject)) .Select(r => new { id = r.UserInfo.ID, displayName = DisplayUserSettings.GetFullUserName(r.UserInfo.ID), userName = r.UserInfo.UserName, avatarSmall = UserPhotoManager.GetSmallPhotoURL(r.UserInfo.ID), status = r.UserInfo.Status, groups = CoreContext.UserManager.GetUserGroups(r.UserInfo.ID).Select(x => new { id = x.ID, name = x.Name, manager = CoreContext.UserManager.GetUsers(CoreContext.UserManager.GetDepartmentManager(x.ID)).UserName }).ToList(), isVisitor = r.UserInfo.IsVisitor(), isAdmin = r.UserInfo.IsAdmin(), isOwner = r.UserInfo.IsOwner(), isManager = r.IsManager, canReadFiles = r.CanReadFiles, canReadMilestones = r.CanReadMilestones, canReadMessages = r.CanReadMessages, canReadTasks = r.CanReadTasks, canReadContacts = r.CanReadContacts, isAdministrator = r.UserInfo.IsAdmin(), title = r.UserInfo.Title, profileUrl = r.UserInfo.GetUserProfilePageURL() }).OrderBy(r => r.displayName).ToList(); return(new List <KeyValuePair <string, object> >(2) { RegisterObject("Milestones", new { response = milestones }), RegisterObject("Team", new { response = team }) }); }