2019-05-15 14:56:09 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) Copyright Ascensio System Limited 2010-2018
|
|
|
|
*
|
|
|
|
* This program is freeware. You can redistribute it and/or modify it under the terms of the GNU
|
|
|
|
* General Public License (GPL) version 3 as published by the Free Software Foundation (https://www.gnu.org/copyleft/gpl.html).
|
|
|
|
* In accordance with Section 7(a) of the GNU GPL its Section 15 shall be amended to the effect that
|
|
|
|
* Ascensio System SIA expressly excludes the warranty of non-infringement of any third-party rights.
|
|
|
|
*
|
|
|
|
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. For more details, see GNU GPL at https://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* You can contact Ascensio System SIA by email at sales@onlyoffice.com
|
|
|
|
*
|
|
|
|
* The interactive user interfaces in modified source and object code versions of ONLYOFFICE must display
|
|
|
|
* Appropriate Legal Notices, as required under Section 5 of the GNU GPL version 3.
|
|
|
|
*
|
|
|
|
* Pursuant to Section 7 § 3(b) of the GNU GPL you must retain the original ONLYOFFICE logo which contains
|
|
|
|
* relevant author attributions when distributing the software. If the display of the logo in its graphic
|
|
|
|
* form is not reasonably feasible for technical reasons, you must include the words "Powered by ONLYOFFICE"
|
|
|
|
* in every copy of the program you distribute.
|
|
|
|
* Pursuant to Section 7 § 3(e) we decline to grant you any rights under trademark law for use of our trademarks.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
2019-08-15 12:04:42 +00:00
|
|
|
using System.Text;
|
2020-08-27 14:01:37 +00:00
|
|
|
|
2019-08-15 12:04:42 +00:00
|
|
|
using ASC.Notify.Recipients;
|
2019-08-08 09:26:58 +00:00
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
namespace ASC.Core.Users
|
2019-11-25 09:49:12 +00:00
|
|
|
{
|
2019-05-15 14:56:09 +00:00
|
|
|
[Serializable]
|
|
|
|
public sealed class UserInfo : IDirectRecipient, ICloneable
|
|
|
|
{
|
|
|
|
public UserInfo()
|
|
|
|
{
|
|
|
|
Status = EmployeeStatus.Active;
|
2019-09-02 15:09:45 +00:00
|
|
|
ActivationStatus = EmployeeActivationStatus.NotActivated;
|
2019-05-15 14:56:09 +00:00
|
|
|
LastModified = DateTime.UtcNow;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public Guid ID { get; set; }
|
|
|
|
|
|
|
|
public string FirstName { get; set; }
|
|
|
|
|
|
|
|
public string LastName { get; set; }
|
|
|
|
|
|
|
|
public string UserName { get; set; }
|
|
|
|
|
|
|
|
public DateTime? BirthDate { get; set; }
|
|
|
|
|
|
|
|
public bool? Sex { get; set; }
|
|
|
|
|
2019-11-15 15:04:05 +00:00
|
|
|
public EmployeeStatus Status { get; set; }
|
2019-11-25 09:49:12 +00:00
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
public EmployeeActivationStatus ActivationStatus { get; set; }
|
|
|
|
|
|
|
|
public DateTime? TerminatedDate { get; set; }
|
|
|
|
|
|
|
|
public string Title { get; set; }
|
|
|
|
|
|
|
|
public DateTime? WorkFromDate { get; set; }
|
|
|
|
|
2019-08-30 12:40:57 +00:00
|
|
|
public string Email { get; set; }
|
|
|
|
|
2019-11-25 09:49:12 +00:00
|
|
|
private string contacts;
|
|
|
|
public string Contacts
|
|
|
|
{
|
|
|
|
get => contacts;
|
|
|
|
set
|
|
|
|
{
|
|
|
|
contacts = value;
|
2020-10-12 19:39:23 +00:00
|
|
|
ContactsFromString(contacts);
|
2019-11-25 09:49:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<string> ContactsList { get; set; }
|
2019-05-15 14:56:09 +00:00
|
|
|
|
|
|
|
public string Location { get; set; }
|
|
|
|
|
|
|
|
public string Notes { get; set; }
|
|
|
|
|
|
|
|
public bool Removed { get; set; }
|
|
|
|
|
|
|
|
public DateTime LastModified { get; set; }
|
|
|
|
|
|
|
|
public int Tenant { get; set; }
|
|
|
|
|
|
|
|
public bool IsActive
|
|
|
|
{
|
|
|
|
get { return ActivationStatus.HasFlag(EmployeeActivationStatus.Activated); }
|
|
|
|
}
|
2019-11-25 09:49:12 +00:00
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
public string CultureName { get; set; }
|
2019-11-25 09:49:12 +00:00
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
public string MobilePhone { get; set; }
|
2019-11-25 09:49:12 +00:00
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
public MobilePhoneActivationStatus MobilePhoneActivationStatus { get; set; }
|
|
|
|
|
|
|
|
public string Sid { get; set; } // LDAP user identificator
|
2019-11-25 09:49:12 +00:00
|
|
|
|
2019-11-15 15:04:05 +00:00
|
|
|
public string SsoNameId { get; set; } // SSO SAML user identificator
|
2019-11-25 09:49:12 +00:00
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
public string SsoSessionId { get; set; } // SSO SAML user session identificator
|
2019-11-25 09:49:12 +00:00
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
public DateTime CreateDate { get; set; }
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
{
|
2022-01-14 13:12:37 +00:00
|
|
|
return $"{FirstName} {LastName}".Trim();
|
2019-05-15 14:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
|
|
|
return ID.GetHashCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
{
|
2019-08-15 13:41:38 +00:00
|
|
|
return obj is UserInfo ui && ID.Equals(ui.ID);
|
2019-05-15 14:56:09 +00:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:49:12 +00:00
|
|
|
public bool Equals(UserInfo obj)
|
|
|
|
{
|
|
|
|
return obj != null && ID.Equals(obj.ID);
|
|
|
|
}
|
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
public CultureInfo GetCulture()
|
|
|
|
{
|
|
|
|
return string.IsNullOrEmpty(CultureName) ? CultureInfo.CurrentCulture : CultureInfo.GetCultureInfo(CultureName);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string[] IDirectRecipient.Addresses
|
|
|
|
{
|
2022-01-19 10:24:11 +00:00
|
|
|
get { return !string.IsNullOrEmpty(Email) ? new[] { Email } : Array.Empty<string>(); }
|
2019-05-15 14:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool CheckActivation
|
|
|
|
{
|
|
|
|
get { return !IsActive; /*if user already active we don't need activation*/ }
|
|
|
|
}
|
|
|
|
|
|
|
|
string IRecipient.ID
|
|
|
|
{
|
|
|
|
get { return ID.ToString(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
string IRecipient.Name
|
|
|
|
{
|
|
|
|
get { return ToString(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
public object Clone()
|
|
|
|
{
|
|
|
|
return MemberwiseClone();
|
|
|
|
}
|
|
|
|
|
2019-08-30 12:40:57 +00:00
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
internal string ContactsToString()
|
|
|
|
{
|
2019-11-25 09:49:12 +00:00
|
|
|
if (ContactsList == null || ContactsList.Count == 0) return null;
|
2019-05-15 14:56:09 +00:00
|
|
|
var sBuilder = new StringBuilder();
|
2019-11-25 09:49:12 +00:00
|
|
|
foreach (var contact in ContactsList)
|
2019-05-15 14:56:09 +00:00
|
|
|
{
|
2022-01-14 13:12:37 +00:00
|
|
|
sBuilder.Append($"{contact}|");
|
2019-05-15 14:56:09 +00:00
|
|
|
}
|
|
|
|
return sBuilder.ToString();
|
|
|
|
}
|
|
|
|
|
|
|
|
internal UserInfo ContactsFromString(string contacts)
|
|
|
|
{
|
2019-09-02 15:09:45 +00:00
|
|
|
if (string.IsNullOrEmpty(contacts)) return this;
|
|
|
|
|
2019-11-25 09:49:12 +00:00
|
|
|
if (ContactsList == null)
|
2019-09-02 15:09:45 +00:00
|
|
|
{
|
2019-11-25 09:49:12 +00:00
|
|
|
ContactsList = new List<string>();
|
2019-09-02 15:09:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-11-25 09:49:12 +00:00
|
|
|
ContactsList.Clear();
|
2019-09-02 15:09:45 +00:00
|
|
|
}
|
|
|
|
|
2019-11-25 09:49:12 +00:00
|
|
|
ContactsList.AddRange(contacts.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries));
|
2019-09-02 15:09:45 +00:00
|
|
|
|
2019-05-15 14:56:09 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|