Exemplo n.º 1
0
        private void Login_To_System()
        {
            // Set cursor as hourglass
            Cursor.Current = Cursors.WaitCursor;
            this.SaveInfo();
            UserInfoMessage userInfo = Request.RequestLogin(this.Login_TB_UserName.Text, this.Login_TB_Password.Text);

            if (userInfo == null)
            {
                ///Return False here
                Debug.WriteLine("Cannot login to system");
                this.LoginForm_LB_Info.Text = "Không thể đăng nhập vào hệ thống.\nKiểm tra lại Tên đăng nhập/Mật khẩu";
            }
            else if (userInfo.roleType == "2")
            {
                Debug.WriteLine("Cannot login to system with this role");
                this.LoginForm_LB_Info.Text = "Không thể đăng nhập vào hệ thống \nbằng quyền người duyệt";
            }
            else
            {
                Debug.WriteLine("Login done");
                this.LoginForm_LB_Info.Text = "";
                AppsSettings.GetInstance().UserInfo = userInfo;
                DialogResult = DialogResult.OK;
            }
            // Set cursor as default arrow
            Cursor.Current = Cursors.Default;
        }
Exemplo n.º 2
0
 /// <summary>
 /// سازنده کلاس
 /// </summary>
 public BUserInfo()
 {
     infoProviders += new UserInfoMessage(this.GetRemainLeaveTransferFromYearAgoToCurrentYear);
     infoProviders += new UserInfoMessage(this.GetRemainMonthLeave);
     infoProviders += new UserInfoMessage(this.GetRemainYearLeave);
     infoProviders += new UserInfoMessage(this.GetUsedYearLeave);
     infoProviders += new UserInfoMessage(this.GetRemainLeaveLoss);
 }
Exemplo n.º 3
0
        void OnUserInfoMessage(UserInfoMessage message)
        {
            var state = (UserInfoState)message.State;

            if (state == UserInfoState.Update)
            {
                OnUserUpdated(message.GetUser());
            }
            else if (state == UserInfoState.PresenceDiscovered)
            {
                OnPresenceMessage(message.GetUser(), discovered: true);
            }
        }
Exemplo n.º 4
0
        internal void SendCurrentUserInfoMessage(IPAddress remoteIP, bool IsReply)
        {
            if (remoteIP == null || remoteIP == IPAddress.None)
            {
                return;
            }
            IPEndPoint receiverEndPoint = new IPEndPoint(remoteIP, MulticastGroupIpEndPoint.Port);

            UserInfo currentUserInfo = UserInfo.GetCurrentUserInfo();

            Message message = new UserInfoMessage(currentUserInfo);

            message.HeaderData.IsReply = IsReply;

            Socket udpSocket = SocketHelper.GetUdpSocketForSender();

            SendMessage(udpSocket, receiverEndPoint, message);
        }
Exemplo n.º 5
0
        public void OnClientConnected(NetConnection client)
        {
            Log.Information("Client has conected {connection}", client);

            var user = new User(_nameGenerator.GenerateRandomFirstName());

            Log.Information("Random name assigned to user {name}", user.Nickname);

            Users.Add(user, client);

            _globalChannel.Participants.Add(user);

            var userInfo = new UserInfoMessage
            {
                UserData     = user,
                ChatChannels = new List <ChatChannel> {
                    _globalChannel
                }
            };

            // send the client a message with their user data
            _server.NetworkPipe.SendClient(client, "UserInfo", userInfo);
            _server.NetworkPipe.SendReliable("ChannelUpdate", _globalChannel);
        }
Exemplo n.º 6
0
 /// <inheritdoc />
 public void UpdateProfile(UserInfoMessage profile)
 {
     ValidateError(Invoke(f => f.UpdateProfile2(SessionId, profile)));
 }
Exemplo n.º 7
0
 /// <inheritdoc />
 public void CreateProfile(UserInfoMessage profile)
 {
     ValidateError(Invoke(f => f.CreateProfile2(profile)));
 }
Exemplo n.º 8
0
        private void ProcessMessage(Message message, IPAddress remoteIP)
        {
            if (message == null || message.HeaderData == null)
            {
                return;
            }
            switch (message.HeaderData.MsgDataType)
            {
            case EMsgDataType.Signon:
            {
                SignonManager.SignonMgr.ProcessSignonMessage(remoteIP, message.HeaderData.IsReply);
            }
            break;

            case EMsgDataType.ReceiveConfirmation:
            {
                if ((message is ReceiveConfirmationMessage) == false)
                {
                    break;
                }
                ReceiveConfirmationMessage receiveConfirmationMessage = message as ReceiveConfirmationMessage;
                if (receiveConfirmationMessage == null)
                {
                    break;
                }
                if (ReceivedConfirmationList == null)
                {
                    ReceivedConfirmationList = new List <int>();
                }
                lock (ReceivedConfirmationList)
                {
                    ReceivedConfirmationList.Add(receiveConfirmationMessage.ReceiveConfirmRefNo);
                }
            }
            break;

            case EMsgDataType.UserInfo:
            {
                if ((message is UserInfoMessage) == false || remoteIP == IPAddress.None)
                {
                    break;
                }
                UserInfoMessage userInfoMessage = message as UserInfoMessage;
                if (userInfoMessage == null || userInfoMessage.UserInfo == null)
                {
                    break;
                }
                userInfoMessage.UserInfo._IPAddress = remoteIP.ToString();
                SignonManager.SignonMgr.ProcessUserInfoMessage(userInfoMessage.UserInfo, remoteIP, message.HeaderData.IsReply);
            }
            break;

            case EMsgDataType.Text:
            {
                if ((message is TextMessage) == false || remoteIP == IPAddress.None)
                {
                    break;
                }
                TextMessage textMessage = message as TextMessage;
                if (textMessage == null)
                {
                    break;
                }
                textMessage.TextMessageData._IPAddress   = remoteIP.ToString();
                textMessage.TextMessageData._ReceiptTime = DateTime.Now;
                ProcessTextMessage(textMessage.TextMessageData);
            }
            break;
            }
        }
Exemplo n.º 9
0
 public BUserInfo()
 {
     infoProviders += new UserInfoMessage(this.GetRemainMonthLeave);
     infoProviders += new UserInfoMessage(this.GetRemainYearLeave);
 }
Exemplo n.º 10
0
        public static UserInfoMessage RequestLogin(string username, string password)
        {
            try
            {
                // Create a request using a URL that can receive a post.
                string     uri     = string.Format("{0}/login", AppsSettings.GetInstance().ApiUrl);
                WebRequest request = GetWebRequester(uri, "");
                // Set the Method property of the request to POST.
                string boundary = CreateFormDataBoundary();
                request.Method      = "POST";
                request.ContentType = "multipart/form-data; boundary=" + boundary;

                // Get the request stream.
                Stream dataStream = request.GetRequestStream();
                // Write the data to the request stream.
                string FormDataTemplate = "--{0}\r\nContent-Disposition: form-data; name=\"{1}\"\r\n\r\n{2}\r\n";

                string item      = String.Format(FormDataTemplate, boundary, "username", username);
                byte[] itemBytes = Encoding.UTF8.GetBytes(item);
                dataStream.Write(itemBytes, 0, itemBytes.Length);

                item      = String.Format(FormDataTemplate, boundary, "password", password);
                itemBytes = Encoding.UTF8.GetBytes(item);
                dataStream.Write(itemBytes, 0, itemBytes.Length);

                byte[] endBytes = Encoding.UTF8.GetBytes("--" + boundary + "--");
                dataStream.Write(endBytes, 0, endBytes.Length);
                // Close the Stream object.
                dataStream.Close();

                // Get the response.
                WebResponse response = request.GetResponse();
                // Display the status.
                Debug.WriteLine(((HttpWebResponse)response).StatusDescription);

                // Get the stream containing content returned by the server.
                // The using block ensures the stream is automatically closed.
                using (dataStream = response.GetResponseStream())
                {
                    // Open the stream using a StreamReader for easy access.
                    StreamReader reader = new StreamReader(dataStream);
                    // Read the content.
                    string responseFromServer = reader.ReadToEnd();
                    // Display the content.
                    Debug.WriteLine(responseFromServer);
                    try
                    {
                        UserInfoMessage RspMsg = JsonConvert.DeserializeObject <UserInfoMessage>(responseFromServer);
                        return(RspMsg);
                    }
                    catch (Exception e)
                    {
                        Debug.WriteLine(e);
                    }
                }

                // Close the response.
                response.Close();

                return(null);
            }
            catch (Exception e)
            {
                Debug.WriteLine(String.Format("{0}", e));
                return(null);
            }
        }