public static async Task<RolePriority> GetMaxPriority(User u)
 {
     UserServiceProxy usrv = new UserServiceProxy();
     var l = await usrv.MaterializeAllUsersInRole_UserIDsAsync(Cntx, u);
     if (l == null || l.Count() == 0)
         return new RolePriority { Major = -1, Minor = -1 };
     UsersInRoleServiceProxy uisvc = new UsersInRoleServiceProxy();
     foreach (var ir in l)
         ir.RoleRef = uisvc.MaterializeRoleRef(Cntx, ir);
     var uir = (from d in l orderby d.RoleRef.RolePriority descending, d.SubPriority descending select d).First();
     var roleids = (from d in l orderby d.RoleRef.RolePriority select d.RoleID).ToArray();
     return new RolePriority { Major = uir.RoleRef.RolePriority, Minor = uir.SubPriority, RoleIds = roleids, MaxRole = uir.RoleRef };
 }
 /// <summary>
 /// <see cref="UsersRoleHistory.User_OperatorID" /> is not initialized when the entity is created. Clients could call this method to load it provided a proper delegate <see cref="UsersRoleHistory.DelLoadUser_OperatorID" /> was setup
 /// before calling it.
 /// </summary>
 public void LoadUser_OperatorID()
 {
     if (_User_OperatorID != null)
         return;
     if (DelLoadUser_OperatorID != null)
         _User_OperatorID = DelLoadUser_OperatorID();
 }
 /// <summary>
 /// <see cref="EventCalendar.User_CreatedUserID" /> is not initialized when the entity is created. Clients could call this method to load it provided a proper delegate <see cref="EventCalendar.DelLoadUser_CreatedUserID" /> was setup
 /// before calling it.
 /// </summary>
 public void LoadUser_CreatedUserID()
 {
     if (CreatedUserID == null || _User_CreatedUserID != null)
         return;
     if (DelLoadUser_CreatedUserID != null)
         _User_CreatedUserID = DelLoadUser_CreatedUserID();
 }
 /// <summary>
 /// <see cref="ShortMessage.User_ToID" /> is not initialized when the entity is created. Clients could call this method to load it provided a proper delegate <see cref="ShortMessage.DelLoadUser_ToID" /> was setup
 /// before calling it.
 /// </summary>
 public void LoadUser_ToID()
 {
     if (ToID == null || _User_ToID != null)
         return;
     if (DelLoadUser_ToID != null)
         _User_ToID = DelLoadUser_ToID();
 }
Beispiel #5
0
 /// <summary>
 /// Internal use
 /// </summary>
 public User ShallowCopy(bool allData = false, bool preserveState = false)
 {
     User e = new User();
     e.StartAutoUpdating = false;
     e.ID = ID;
     e.Password = Password;
     if (preserveState)
         e.IsPasswordModified = IsPasswordModified;
     else
         e.IsPasswordModified = false;
     e.PasswordFormat = PasswordFormat;
     if (preserveState)
         e.IsPasswordFormatModified = IsPasswordFormatModified;
     else
         e.IsPasswordFormatModified = false;
     e.PasswordQuestion = PasswordQuestion;
     if (preserveState)
         e.IsPasswordQuestionModified = IsPasswordQuestionModified;
     else
         e.IsPasswordQuestionModified = false;
     e.PasswordAnswer = PasswordAnswer;
     if (preserveState)
         e.IsPasswordAnswerModified = IsPasswordAnswerModified;
     else
         e.IsPasswordAnswerModified = false;
     e.PasswordSalt = PasswordSalt;
     if (preserveState)
         e.IsPasswordSaltModified = IsPasswordSaltModified;
     else
         e.IsPasswordSaltModified = false;
     e.FirstName = FirstName;
     if (preserveState)
         e.IsFirstNameModified = IsFirstNameModified;
     else
         e.IsFirstNameModified = false;
     e.LastName = LastName;
     if (preserveState)
         e.IsLastNameModified = IsLastNameModified;
     else
         e.IsLastNameModified = false;
     e.CreateOn = CreateOn;
     e.Username = Username;
     e.IsAnonymous = IsAnonymous;
     if (preserveState)
         e.IsIsAnonymousModified = IsIsAnonymousModified;
     else
         e.IsIsAnonymousModified = false;
     e.IsApproved = IsApproved;
     if (preserveState)
         e.IsIsApprovedModified = IsIsApprovedModified;
     else
         e.IsIsApprovedModified = false;
     e.Status = Status;
     if (preserveState)
         e.IsStatusModified = IsStatusModified;
     else
         e.IsStatusModified = false;
     e.TimeZone = TimeZone;
     if (preserveState)
         e.IsTimeZoneModified = IsTimeZoneModified;
     else
         e.IsTimeZoneModified = false;
     e.FailedPasswordAnswerAttemptCount = FailedPasswordAnswerAttemptCount;
     if (preserveState)
         e.IsFailedPasswordAnswerAttemptCountModified = IsFailedPasswordAnswerAttemptCountModified;
     else
         e.IsFailedPasswordAnswerAttemptCountModified = false;
     e.FailedPasswordAnswerAttemptWindowStart = FailedPasswordAnswerAttemptWindowStart;
     if (preserveState)
         e.IsFailedPasswordAnswerAttemptWindowStartModified = IsFailedPasswordAnswerAttemptWindowStartModified;
     else
         e.IsFailedPasswordAnswerAttemptWindowStartModified = false;
     e.FailedPasswordAttemptCount = FailedPasswordAttemptCount;
     if (preserveState)
         e.IsFailedPasswordAttemptCountModified = IsFailedPasswordAttemptCountModified;
     else
         e.IsFailedPasswordAttemptCountModified = false;
     e.FailedPasswordAttemptWindowStart = FailedPasswordAttemptWindowStart;
     if (preserveState)
         e.IsFailedPasswordAttemptWindowStartModified = IsFailedPasswordAttemptWindowStartModified;
     else
         e.IsFailedPasswordAttemptWindowStartModified = false;
     e.LastLoginDate = LastLoginDate;
     if (preserveState)
         e.IsLastLoginDateModified = IsLastLoginDateModified;
     else
         e.IsLastLoginDateModified = false;
     e.LastPasswordChangedDate = LastPasswordChangedDate;
     if (preserveState)
         e.IsLastPasswordChangedDateModified = IsLastPasswordChangedDateModified;
     else
         e.IsLastPasswordChangedDateModified = false;
     e.DistinctString = GetDistinctString(true);
     e.IsPersisted = IsPersisted;
     if (preserveState)
         e.IsEntityChanged = IsEntityChanged;
     else
         e.IsEntityChanged = false;
     e.StartAutoUpdating = true;
     return e;
 }
Beispiel #6
0
 /// <summary>
 /// Update changes to the current entity compared to an input <paramref name="newdata" /> and set the entity to a proper state for updating.
 /// </summary>
 /// <param name="newdata">The "new" entity acting as the source of the changes, if any.</param>
 /// <returns>
 /// </returns>
 public void UpdateChanges(User newdata)
 {
     int cnt = 0;
     if (Password != newdata.Password)
     {
         Password = newdata.Password;
         IsPasswordModified = true;
         cnt++;
     }
     if (PasswordFormat != newdata.PasswordFormat)
     {
         PasswordFormat = newdata.PasswordFormat;
         IsPasswordFormatModified = true;
         cnt++;
     }
     if (PasswordQuestion != newdata.PasswordQuestion)
     {
         PasswordQuestion = newdata.PasswordQuestion;
         IsPasswordQuestionModified = true;
         cnt++;
     }
     if (PasswordAnswer != newdata.PasswordAnswer)
     {
         PasswordAnswer = newdata.PasswordAnswer;
         IsPasswordAnswerModified = true;
         cnt++;
     }
     if (PasswordSalt != newdata.PasswordSalt)
     {
         PasswordSalt = newdata.PasswordSalt;
         IsPasswordSaltModified = true;
         cnt++;
     }
     if (FirstName != newdata.FirstName)
     {
         FirstName = newdata.FirstName;
         IsFirstNameModified = true;
         cnt++;
     }
     if (LastName != newdata.LastName)
     {
         LastName = newdata.LastName;
         IsLastNameModified = true;
         cnt++;
     }
     if (IsAnonymous != newdata.IsAnonymous)
     {
         IsAnonymous = newdata.IsAnonymous;
         IsIsAnonymousModified = true;
         cnt++;
     }
     if (IsApproved != newdata.IsApproved)
     {
         IsApproved = newdata.IsApproved;
         IsIsApprovedModified = true;
         cnt++;
     }
     if (Status != newdata.Status)
     {
         Status = newdata.Status;
         IsStatusModified = true;
         cnt++;
     }
     if (TimeZone != newdata.TimeZone)
     {
         TimeZone = newdata.TimeZone;
         IsTimeZoneModified = true;
         cnt++;
     }
     if (FailedPasswordAnswerAttemptCount != newdata.FailedPasswordAnswerAttemptCount)
     {
         FailedPasswordAnswerAttemptCount = newdata.FailedPasswordAnswerAttemptCount;
         IsFailedPasswordAnswerAttemptCountModified = true;
         cnt++;
     }
     if (FailedPasswordAnswerAttemptWindowStart != newdata.FailedPasswordAnswerAttemptWindowStart)
     {
         FailedPasswordAnswerAttemptWindowStart = newdata.FailedPasswordAnswerAttemptWindowStart;
         IsFailedPasswordAnswerAttemptWindowStartModified = true;
         cnt++;
     }
     if (FailedPasswordAttemptCount != newdata.FailedPasswordAttemptCount)
     {
         FailedPasswordAttemptCount = newdata.FailedPasswordAttemptCount;
         IsFailedPasswordAttemptCountModified = true;
         cnt++;
     }
     if (FailedPasswordAttemptWindowStart != newdata.FailedPasswordAttemptWindowStart)
     {
         FailedPasswordAttemptWindowStart = newdata.FailedPasswordAttemptWindowStart;
         IsFailedPasswordAttemptWindowStartModified = true;
         cnt++;
     }
     if (LastLoginDate != newdata.LastLoginDate)
     {
         LastLoginDate = newdata.LastLoginDate;
         IsLastLoginDateModified = true;
         cnt++;
     }
     if (LastPasswordChangedDate != newdata.LastPasswordChangedDate)
     {
         LastPasswordChangedDate = newdata.LastPasswordChangedDate;
         IsLastPasswordChangedDateModified = true;
         cnt++;
     }
     IsEntityChanged = cnt > 0;
 }
 public static string GetJsonMessage(ShortMessage msg, string userId, User peer, bool dialog)
 {
     string json = "{ ";
     json += @"""id"": """ + msg.ID + @""", ";
     json += @"""from"": """ + msg.User_FromID.Username + @""", ";
     json += @"""fromId"": """ + msg.FromID + @""", ";
     json += @"""to"": """ + peer.Username + @""", ";
     json += @"""toId"": """ + peer.ID + @""", ";
     json += @"""replyToId"": """ + (msg.ReplyToID == null ? "" : msg.ReplyToID) + @""", ";
     json += @"""date"": " + GroupChatContext.getUnixJsonTime(msg.CreatedDate) + @", ";
     json += @"""self"": false, ";
     json += @"""text"": """ + msg.MsgText.Replace("\"", "\\\"") + @"""";
     if (dialog)
     {
         json += @", ""replies"": [";
         if (msg.ChangedShortMessages != null)
         {
             string subjson = "";
             foreach (var r in from d in msg.ChangedShortMessages orderby d.CreatedDate ascending select d)
                 subjson += GetJsonMessage(r, userId, peer, true) + ", ";
             json += subjson.TrimEnd(" ,".ToCharArray());
         }
         json += "]";
     }
     json += " }";
     return json;
 }
 /// <summary>
 /// <see cref="Announcement.UserRef" /> is not initialized when the entity is created. Clients could call this method to load it provided a proper delegate <see cref="Announcement.DelLoadUserRef" /> was setup
 /// before calling it.
 /// </summary>
 public void LoadUserRef()
 {
     if (CreatedUserID == null || _UserRef != null)
         return;
     if (DelLoadUserRef != null)
         _UserRef = DelLoadUserRef();
 }
Beispiel #9
0
 /// <summary>
 /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) primary key(s).
 /// </summary>
 /// <param name="other">The entity to be compared to.</param>
 /// <returns>
 ///   The result of comparison.
 /// </returns>
 public bool IsEntityIdentical(User other)
 {
     if (other == null)
         return false;
     if (ID != other.ID)
         return false;
     return true;
 }              
Beispiel #10
0
 /// <summary>
 /// <see cref="UsersInRole.User_AdminID" /> is not initialized when the entity is created. Clients could call this method to load it provided a proper delegate <see cref="UsersInRole.DelLoadUser_AdminID" /> was setup
 /// before calling it.
 /// </summary>
 public void LoadUser_AdminID()
 {
     if (AdminID == null || _User_AdminID != null)
         return;
     if (DelLoadUser_AdminID != null)
         _User_AdminID = DelLoadUser_AdminID();
 }
 public static string GetJsonUser(User user)
 {
     return GroupChatViewContext.GetJsonUser(user);
 }
 public static string GetJsonUser(User user)
 {
     var member = user.ChangedUserAppMembers[0];
     var cbk = (from d in member.ChangedMemberCallbacks select d).FirstOrDefault();
     bool hasIcon = !string.IsNullOrEmpty(member.IconMime);
     string json = "{ ";
     json += @"""id"": """ + user.ID + @""", ";
     json += @"""name"": """ + user.Username + @""", ";
     json += @"""email"": """ + member.Email + @""", ";
     json += @"""active"": " + (cbk == null || cbk.IsDisconnected || cbk.ConnectionID == null ? "false" : "true") + @", ";
     json += @"""icon"": " + (hasIcon ? "true" : "false") + @", ";
     json += @"""lastActive"": " + (cbk == null ? GroupChatContext.getUnixJsonTime(member.LastActivityDate) : GroupChatContext.getUnixJsonTime(cbk.LastActiveDate)) + @"";
     json += " }";
     return json;
 }
Beispiel #13
0
 /// <summary>
 /// Internal use
 /// </summary>
 public User ShallowCopy(bool allData = false)
 {
     User e = new User();
     e.IsInitializing = true;
     e.ID = ID;
     e.Password = Password;
     e.PasswordFormat = PasswordFormat;
     e.PasswordQuestion = PasswordQuestion;
     e.PasswordAnswer = PasswordAnswer;
     e.PasswordSalt = PasswordSalt;
     e.FirstName = FirstName;
     e.LastName = LastName;
     e.CreateOn = CreateOn;
     e.Username = Username;
     e.IsAnonymous = IsAnonymous;
     e.IsApproved = IsApproved;
     e.Status = Status;
     e.TimeZone = TimeZone;
     e.FailedPasswordAnswerAttemptCount = FailedPasswordAnswerAttemptCount;
     e.FailedPasswordAnswerAttemptWindowStart = FailedPasswordAnswerAttemptWindowStart;
     e.FailedPasswordAttemptCount = FailedPasswordAttemptCount;
     e.FailedPasswordAttemptWindowStart = FailedPasswordAttemptWindowStart;
     e.LastLoginDate = LastLoginDate;
     e.LastPasswordChangedDate = LastPasswordChangedDate;
     e.DistinctString = GetDistinctString(true);
     e.IsPersisted = true;
     e.IsEntityChanged = false;
     e.IsInitializing = false;
     return e;
 }
Beispiel #14
0
 public void UpdateInstance(User u)
 {
     IsPersisted = false;
     User.MergeChanges(u, this);
     IsPersisted = u.IsPersisted;
 }
Beispiel #15
0
 /// <summary>
 /// Whether or not the present entity is identitical to <paramref name="other" />, in the sense that they have the same (set of) intrinsic identifiers.
 /// </summary>
 /// <param name="other">The entity to be compared to.</param>
 /// <returns>
 ///   The result of comparison.
 /// </returns>
 public bool IsEntityTheSame(User other)
 {
     if (other == null)
         return false;
     else
         return Username == other.Username;
 }              
 /// <summary>
 /// <see cref="UserAssocInvitation.User_ToUserID" /> is not initialized when the entity is created. Clients could call this method to load it provided a proper delegate <see cref="UserAssocInvitation.DelLoadUser_ToUserID" /> was setup
 /// before calling it.
 /// </summary>
 public void LoadUser_ToUserID()
 {
     if (_User_ToUserID != null)
         return;
     if (DelLoadUser_ToUserID != null)
         _User_ToUserID = DelLoadUser_ToUserID();
 }
Beispiel #17
0
 /// <summary>
 /// Merge changes inside entity <paramref name="from" /> to the entity <paramref name="to" />. Any changes in <paramref name="from" /> that is not changed in <paramref name="to" /> is updated inside <paramref name="to" />.
 /// </summary>
 /// <param name="from">The "old" entity acting as merging source.</param>
 /// <param name="to">The "new" entity which inherits changes made in <paramref name="from" />.</param>
 /// <returns>
 /// </returns>
 public static void MergeChanges(User from, User to)
 {
     if (to.IsPersisted)
     {
         if (from.IsPasswordModified && !to.IsPasswordModified)
         {
             to.Password = from.Password;
             to.IsPasswordModified = true;
         }
         if (from.IsPasswordFormatModified && !to.IsPasswordFormatModified)
         {
             to.PasswordFormat = from.PasswordFormat;
             to.IsPasswordFormatModified = true;
         }
         if (from.IsPasswordQuestionModified && !to.IsPasswordQuestionModified)
         {
             to.PasswordQuestion = from.PasswordQuestion;
             to.IsPasswordQuestionModified = true;
         }
         if (from.IsPasswordAnswerModified && !to.IsPasswordAnswerModified)
         {
             to.PasswordAnswer = from.PasswordAnswer;
             to.IsPasswordAnswerModified = true;
         }
         if (from.IsPasswordSaltModified && !to.IsPasswordSaltModified)
         {
             to.PasswordSalt = from.PasswordSalt;
             to.IsPasswordSaltModified = true;
         }
         if (from.IsFirstNameModified && !to.IsFirstNameModified)
         {
             to.FirstName = from.FirstName;
             to.IsFirstNameModified = true;
         }
         if (from.IsLastNameModified && !to.IsLastNameModified)
         {
             to.LastName = from.LastName;
             to.IsLastNameModified = true;
         }
         if (from.IsIsAnonymousModified && !to.IsIsAnonymousModified)
         {
             to.IsAnonymous = from.IsAnonymous;
             to.IsIsAnonymousModified = true;
         }
         if (from.IsIsApprovedModified && !to.IsIsApprovedModified)
         {
             to.IsApproved = from.IsApproved;
             to.IsIsApprovedModified = true;
         }
         if (from.IsStatusModified && !to.IsStatusModified)
         {
             to.Status = from.Status;
             to.IsStatusModified = true;
         }
         if (from.IsTimeZoneModified && !to.IsTimeZoneModified)
         {
             to.TimeZone = from.TimeZone;
             to.IsTimeZoneModified = true;
         }
         if (from.IsFailedPasswordAnswerAttemptCountModified && !to.IsFailedPasswordAnswerAttemptCountModified)
         {
             to.FailedPasswordAnswerAttemptCount = from.FailedPasswordAnswerAttemptCount;
             to.IsFailedPasswordAnswerAttemptCountModified = true;
         }
         if (from.IsFailedPasswordAnswerAttemptWindowStartModified && !to.IsFailedPasswordAnswerAttemptWindowStartModified)
         {
             to.FailedPasswordAnswerAttemptWindowStart = from.FailedPasswordAnswerAttemptWindowStart;
             to.IsFailedPasswordAnswerAttemptWindowStartModified = true;
         }
         if (from.IsFailedPasswordAttemptCountModified && !to.IsFailedPasswordAttemptCountModified)
         {
             to.FailedPasswordAttemptCount = from.FailedPasswordAttemptCount;
             to.IsFailedPasswordAttemptCountModified = true;
         }
         if (from.IsFailedPasswordAttemptWindowStartModified && !to.IsFailedPasswordAttemptWindowStartModified)
         {
             to.FailedPasswordAttemptWindowStart = from.FailedPasswordAttemptWindowStart;
             to.IsFailedPasswordAttemptWindowStartModified = true;
         }
         if (from.IsLastLoginDateModified && !to.IsLastLoginDateModified)
         {
             to.LastLoginDate = from.LastLoginDate;
             to.IsLastLoginDateModified = true;
         }
         if (from.IsLastPasswordChangedDateModified && !to.IsLastPasswordChangedDateModified)
         {
             to.LastPasswordChangedDate = from.LastPasswordChangedDate;
             to.IsLastPasswordChangedDateModified = true;
         }
     }
     else
     {
         to.IsPersisted = from.IsPersisted;
         to.ID = from.ID;
         to.Password = from.Password;
         to.IsPasswordModified = from.IsPasswordModified;
         to.PasswordFormat = from.PasswordFormat;
         to.IsPasswordFormatModified = from.IsPasswordFormatModified;
         to.PasswordQuestion = from.PasswordQuestion;
         to.IsPasswordQuestionModified = from.IsPasswordQuestionModified;
         to.PasswordAnswer = from.PasswordAnswer;
         to.IsPasswordAnswerModified = from.IsPasswordAnswerModified;
         to.PasswordSalt = from.PasswordSalt;
         to.IsPasswordSaltModified = from.IsPasswordSaltModified;
         to.FirstName = from.FirstName;
         to.IsFirstNameModified = from.IsFirstNameModified;
         to.LastName = from.LastName;
         to.IsLastNameModified = from.IsLastNameModified;
         to.CreateOn = from.CreateOn;
         to.Username = from.Username;
         to.IsAnonymous = from.IsAnonymous;
         to.IsIsAnonymousModified = from.IsIsAnonymousModified;
         to.IsApproved = from.IsApproved;
         to.IsIsApprovedModified = from.IsIsApprovedModified;
         to.Status = from.Status;
         to.IsStatusModified = from.IsStatusModified;
         to.TimeZone = from.TimeZone;
         to.IsTimeZoneModified = from.IsTimeZoneModified;
         to.FailedPasswordAnswerAttemptCount = from.FailedPasswordAnswerAttemptCount;
         to.IsFailedPasswordAnswerAttemptCountModified = from.IsFailedPasswordAnswerAttemptCountModified;
         to.FailedPasswordAnswerAttemptWindowStart = from.FailedPasswordAnswerAttemptWindowStart;
         to.IsFailedPasswordAnswerAttemptWindowStartModified = from.IsFailedPasswordAnswerAttemptWindowStartModified;
         to.FailedPasswordAttemptCount = from.FailedPasswordAttemptCount;
         to.IsFailedPasswordAttemptCountModified = from.IsFailedPasswordAttemptCountModified;
         to.FailedPasswordAttemptWindowStart = from.FailedPasswordAttemptWindowStart;
         to.IsFailedPasswordAttemptWindowStartModified = from.IsFailedPasswordAttemptWindowStartModified;
         to.LastLoginDate = from.LastLoginDate;
         to.IsLastLoginDateModified = from.IsLastLoginDateModified;
         to.LastPasswordChangedDate = from.LastPasswordChangedDate;
         to.IsLastPasswordChangedDateModified = from.IsLastPasswordChangedDateModified;
     }
 }
 /// <summary>
 /// <see cref="UserGroupMember.UserRef" /> is not initialized when the entity is created. Clients could call this method to load it provided a proper delegate <see cref="UserGroupMember.DelLoadUserRef" /> was setup
 /// before calling it.
 /// </summary>
 public void LoadUserRef()
 {
     if (_UserRef != null)
         return;
     if (DelLoadUserRef != null)
         _UserRef = DelLoadUserRef();
 }
 /// <summary>
 /// <see cref="NotificationTaskSchedule.UserRef" /> is not initialized when the entity is created. Clients could call this method to load it provided a proper delegate <see cref="NotificationTaskSchedule.DelLoadUserRef" /> was setup
 /// before calling it.
 /// </summary>
 public void LoadUserRef()
 {
     if (AssignerID == null || _UserRef != null)
         return;
     if (DelLoadUserRef != null)
         _UserRef = DelLoadUserRef();
 }