示例#1
0
        public ActionResult SetUserStatus(UserStatusUpdate model)
        {
            UserInfo userForUpd;

            var userId = model.UserId;
            var status = model.Status;

            using (UserStore store = new UserStore(this.dbContext))
            {
                userForUpd = store.FindByIdAsync(userId).Result;

                if (userForUpd == null)
                {
                    return(BadRequest("There is no user with id " + userId));
                }

                if (userForUpd.status == status)
                {
                    return(BadRequest($"The user already has '{status.ToString()}' status"));
                }

                userForUpd.status = status;
                store.Update(userForUpd);
            }

            new MailHelper(_config).SendUpdateStatusNotification(
                GetRefererUri(), userForUpd,
                $"your status has been changed to \"{Enum.GetName(typeof(Model.UserStatus), status)}\"");

            return(Ok());
        }
 private void SetStatus(string statusId)
 {
     var statusDetails = _statusMessageList.GetList().FirstOrDefault(s => s.Id.ToLower() == statusId);
     if (statusDetails != null)
     {
         UserStatusUpdate statusUpdate = new UserStatusUpdate(_peopleManager);
         statusUpdate.UserId = _userId;
         statusUpdate.StatusMessageDetails = statusDetails;
         statusUpdate.UpdateRequest();
     }
 }
        public HttpResponseMessage EditUserInfo(UserStatusUpdate model, int id)
        {
            if (!ModelState.IsValid)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState));
            }

            SucessResponse response = new SucessResponse();

            _userDataService.UpdateUserStatus(model);

            return(Request.CreateResponse(response));
        }
示例#4
0
        protected void SetUserStatus(string statusId)
        {
            var peopleManager = PeopleManager.GetInstance(_session);
            var statusList    = new StatusMessageList(peopleManager);

            statusList.StartWatching();
            var userStatusUpdate = new UserStatusUpdate(peopleManager, _session.UserId)
            {
                StatusMessageDetails = statusList[statusId]
            };

            userStatusUpdate.UpdateRequest();
            statusList.StopWatching();
        }
示例#5
0
        public void UpdateUserStatus(UserStatusUpdate model)
        {
            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Users_UpdateV2",
                                         inputParamMapper : delegate(SqlParameterCollection u)
            {
                u.AddWithValue("@Id", model.Id);
                u.AddWithValue("@UserId", model.UserId);
                u.AddWithValue("@EnrollmentStatusId", model.EnrollmentStatusId);
            });

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.UserSections_Insert",
                                         inputParamMapper : delegate(SqlParameterCollection param)
            {
                param.AddWithValue("@UserId", model.UserId);
                param.AddWithValue("@SectionId", model.SectionId);
                param.AddWithValue("@EnrollmentStatusId", model.EnrollmentStatusId);
            });
        }
示例#6
0
        public void ChangeUserStatus(string NewStatus)
        {
            UserStatusUpdate  statusUpdate = new UserStatusUpdate(PeopleManager);
            StatusMessageList msgList      = new StatusMessageList(PeopleManager);

            msgList.StartWatching();
            foreach (StatusMessageDetails d in msgList.GetList())
            {
                if (NewStatus == d.MessageText)
                {
                    statusUpdate.StatusMessageDetails = d;
                }
            }
            if (statusUpdate.StatusMessageDetails != null)
            {
                //statusUpdate.UpdateRequest();
                statusUpdate.UpdateRequestAsync(ConnectCompleted, null);
            }
            else
            {
                return;
            }
            UpdateCurrentUserStatus();
        }
        private void DataFromServer(object?sender, MessageEventArgs e)
        {
            if (e.IsPing)
            {
                return;
            }
            IncomingWSS?data = JsonSerializer.Deserialize(e.Data, IncomingWSSContext.Default.IncomingWSS);

            switch (data?.type)
            {
            case DataType.Login:
                Token = data.token;
                break;

            case DataType.Error:
                if (Token is null)
                {
                    Error = data.error;
                }
                else
                {
                    if (OnError is not null)
                    {
                        _ = OnError.Invoke(new Exception(data.error));
                    }
                }
                break;

            case DataType.Message_Create:
                if (MessageReceived is not null)
                {
                    string?obj = data?.data.ToString();
                    if (obj is not null)
                    {
                        SocketMessage?m = JsonSerializer.Deserialize <SocketMessage>(obj);
                        if (m is not null)
                        {
                            m.decrypt(Encryption.File.Channels.GetKey(m.channel_id));
                            _ = MessageReceived.Invoke(m);
                        }
                    }
                }
                break;

            case DataType.Status_Update:
                if (UserStatusUpdate is not null)
                {
                    string?obj = data?.data.ToString();
                    if (obj is not null)
                    {
                        StatusUpdate?SU = JsonSerializer.Deserialize <StatusUpdate>(obj);
                        if (SU is not null)
                        {
                            SocketRemoteUser after = SocketRemoteUser.GetUser(SU.id);
                            after.status = SU.after;
                            SocketRemoteUser before = (SocketRemoteUser)after.Clone();
                            before.status = SU.before;
                            _             = UserStatusUpdate.Invoke(before, after);
                        }
                    }
                }
                break;

            case DataType.Friend_Request:
                if (ReceivedFriendRequest is not null)
                {
                    string?obj = data?.data.ToString();
                    if (obj is not null)
                    {
                        FriendRequest?request = JsonSerializer.Deserialize <FriendRequest>(obj);
                        if (request is not null)
                        {
                            _ = ReceivedFriendRequest.Invoke(SocketRemoteUser.GetUser(request.id));
                        }
                    }
                }
                break;

            case DataType.Friend_Request_Result:
                if (FriendRequestResult is not null)
                {
                    string?obj = data?.data.ToString();
                    if (obj is not null)
                    {
                        FriendRequestResult?FRR = JsonSerializer.Deserialize <FriendRequestResult>(obj);
                        if (FRR is not null && FRR.channel is not null && FRR.id is not null && FRR.result is not null)
                        {
                            SocketChannel chan = SocketChannel.GetChannel((long)FRR.channel);
                            chans.Add(chan);
                            SocketRemoteUser from1 = SocketRemoteUser.GetUser((long)FRR.id);
                            from1.Channel = chan;
                            _             = FriendRequestResult.Invoke(from1, (bool)FRR.result);
                        }
                    }
                }
                break;

            case DataType.Call_Info:
                if (IncommingCall is not null)
                {
                    string?obj = data?.data.ToString();
                    if (obj is not null)
                    {
                        callinfoinc?ci = JsonSerializer.Deserialize <callinfoinc>(obj);
                        if (ci is not null)
                        {
                            _ = IncommingCall.Invoke(SocketChannel.GetChannel(ci.channel), SocketRemoteUser.GetUser(ci.from));
                        }
                    }
                }
                break;

            case DataType.Call_Data:
                if (AudioClient is not null)
                {
                    AudioClient.Givedata(data.data);
                }
                break;

            case DataType.Key_Exchange:
                try
                {
                    string?obj = data?.data.ToString();
                    if (obj is not null)
                    {
                        KeyExchange?KE = JsonSerializer.Deserialize <KeyExchange>(obj);
                        if (KE is not null)
                        {
                            Encryption.File.Channels.AddKey(KE.channel, Encryption.Encoder.GetString(Encryption.Decrypt(Convert.FromBase64String(KE.key))));
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (OnError is not null)
                    {
                        OnError.Invoke(ex);
                    }
                }
                break;

            default:
                break;
            }
        }
        public void UpdateUserStatus(UserStatusUpdate model)
        {
            DataProvider.ExecuteNonQuery(GetConnection, "dbo.Users_UpdateV2",
               inputParamMapper: delegate(SqlParameterCollection u)
               {
               u.AddWithValue("@Id", model.Id);
               u.AddWithValue("@UserId", model.UserId);
               u.AddWithValue("@EnrollmentStatusId", model.EnrollmentStatusId);
               });

            DataProvider.ExecuteNonQuery(GetConnection, "dbo.UserSections_Insert",
               inputParamMapper: delegate(SqlParameterCollection param)
               {
                   param.AddWithValue("@UserId", model.UserId);
                   param.AddWithValue("@SectionId", model.SectionId);
                   param.AddWithValue("@EnrollmentStatusId", model.EnrollmentStatusId);

               });
        }
示例#9
0
 public void SetStatus(string statusId)
 {
     try
     {
         _traceContext.Status("Setting status to " + statusId);
         var statusDetails = _statusMessageList.GetList().FirstOrDefault(s => s.Id.ToLower() == statusId.ToLower());
         if (statusDetails != null)
         {
             UserStatusUpdate statusUpdate = new UserStatusUpdate(_peopleManager);
             statusUpdate.UserId = _userId;
             statusUpdate.StatusMessageDetails = statusDetails;
             _traceContext.Status("Sending status update request");
             statusUpdate.UpdateRequest();
         }
         else
         {
             _traceContext.Warning("status message not found");
             _statusMessageList.GetList().ToList().ForEach(s => _traceContext.Status("Status: " + s.Id));
         }
     }
     catch (Exception ex)
     {
         _traceContext.Exception(ex, "Unable to set status");
     }
 }