コード例 #1
0
    static void Main(string[] args)
    {
        Dictionary <Type, MessageProcessor> messageProcessors = new Dictionary <Type, MessageProcessor>();

        messageProcessors.Add(typeof(string), new MessageProcessor <LoginMessage>());
        LoginMessage     message   = new LoginMessage();
        Type             key       = message.GetType();
        MessageProcessor processor = messageProcessors[key];
        object           source    = null;

        processor.ProcessMessage(source, message);
    }
コード例 #2
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            //Set the UI to read only
            Messagelabel.Content     = "";
            OKButton.IsEnabled       = false;
            CancelButton.IsEnabled   = true;
            SettingsButton.IsEnabled = false;

            //send message
            LoginMessage LoginMsg = new LoginMessage();

            LoginMsg.UserName = this.UserNameTextBox.Text;
            LoginMsg.Password = PasswordTextBox.Password;

            i9Message responseMsg = i9MessageManager.SendMessage(MobileMessageType.Admin, AdminType.Login, "LoginPage", LoginMsg.GetType(), LoginMsg);

            if (responseMsg.ErrorStatus.IsError)
            {
                Messagelabel.Content = responseMsg.ErrorStatus.ErrorMsg +
                                       Environment.NewLine + responseMsg.ErrorStatus.ErrorException +
                                       Environment.NewLine + DateTime.Now.ToString();

                OKButton.IsEnabled       = true;
                CancelButton.IsEnabled   = true;
                SettingsButton.IsEnabled = true;

                return;
            }

            if (responseMsg.MsgBodyDataSet == null || responseMsg.MsgBodyDataSet.Tables[0].Rows.Count <= 0)
            {
                Messagelabel.Content = "Wrong user name or password, please try again.";

                OKButton.IsEnabled       = true;
                CancelButton.IsEnabled   = true;
                SettingsButton.IsEnabled = true;

                return;
            }

            //Save Login Information
            SettingManager.Instance.LoginDataSet = responseMsg.MsgBodyDataSet;

            MainWindow.mMainWindow.StatusBarItemUserName = "******" + UserNameTextBox.Text;
            MainWindow.mMainWindow.StatusBarItemMessage  = "";

            if (LaunchMobileTerminalCheckBox.IsChecked == false || LaunchMobileTerminalCheckBox.IsChecked == null)
            {
                ModuleManager.Instance.NavigateTo(this, "SplashPage");
                //ModuleManager.Instance.NavigateTo(this, "MainMenuPage");
            }
            else
            {
                ModuleManager.Instance.NavigateTo(this, "MobileTerminalPage");
            }
        }
コード例 #3
0
        protected void LoginButton_Click(Object sender, EventArgs e)
        {
            LoginMessage LoginMsg = new LoginMessage();

            LoginMsg.UserName = this.UserName.Text;
            LoginMsg.Password = Password.Text;

            //i9MessageManager.mIi9MessageManager = new InvertService.BusinessLib.i9MessageManagerBLL();
            i9Message responseMsg = i9MessageManagerBLL.SendMessage(MobileMessageType.Admin, AdminType.Login, "LoginPage", LoginMsg.GetType(), LoginMsg);

            if (responseMsg.ErrorStatus.IsError)
            {
                FailureText.Text = responseMsg.ErrorStatus.ErrorMsg;
                return;
            }

            if (responseMsg.MsgBodyDataSet.Tables[0].Rows.Count <= 0)
            {
                FailureText.Text = "Wrong user name or password, please try again.";

                return;
            }

            //Go To Main Window
            Session.Add("Login", "true");
            Session.Add("Badge", responseMsg.MsgBodyDataSet.Tables["i9SysPersonnel"].Rows[0]["BadgeNumber"].ToString());
            Session.Add("LoginDataSet", responseMsg.MsgBodyDataSet);

            Response.Redirect("~/");
        }
コード例 #4
0
 public ResultMessage Registration([FromBody] LoginMessage message)
 {
     try
     {
         if (message.GetType().GetProperties().Where(pi => pi.GetValue(message) is string)
             .Select(pi => (string)pi.GetValue(message))
             .Any(string.IsNullOrEmpty))
         {
             return(new ResultMessage()
             {
                 Type = ResultType.Decline,
                 Message = "Some fields are empty"
             });
         }
         if (MainContext.Instance.User.GetBy(x => x.DeviceId == message.DeviceId) != null)
         {
             return(new ResultMessage()
             {
                 Type = ResultType.Decline,
                 Message = "There's an user in db with this deviceId"
             });
         }
         try
         {
             if (MainContext.Instance.User.Insert(new Models.Models.User()
             {
                 DeviceId = message.DeviceId,
                 IsAdmin = false,
                 Login = message.Login,
                 Password = message.Password
             }))
             {
                 var users = MainContext.Instance.User.GetAll().LastOrDefault();
                 var index = 1;
                 if (users != null)
                 {
                     index = users.UserId;
                 }
                 if (MainContext.Instance.Person.Insert(new Models.Models.Person()
                 {
                     UserId = index
                 }))
                 {
                     return(new ResultMessage()
                     {
                         Type = ResultType.Success,
                         Message = "User successfully added to db"
                     });
                 }
                 return(new ResultMessage()
                 {
                     Type = ResultType.Decline,
                     Message = "User been created, but can't create personal info entity." +
                               "Create it through website(http://notbadtracker.azurewebsites.net/)"
                 });
             }
             else
             {
                 return(new ResultMessage()
                 {
                     Type = ResultType.Decline,
                     Message = "Can't add new user with this data"
                 });
             }
         }
         catch (Exception)
         {
             return(new ResultMessage()
             {
                 Type = ResultType.Decline,
                 Message = "Input user information does not meet the requirements"
             });;
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine($"Internal server exception: {ex.Message}");
         return(new ResultMessage()
         {
             Type = ResultType.UnknownError,
             Message = "Internal server error " +
                       $"{ex.Message}"
         });
     }
 }