/// <summary> /// Gets the users information from the WCF service if authentication passes. /// </summary> /// <param name="username">Username to try to authenticate.</param> /// <param name="password">Password to try to authenticate.</param> /// <returns>User demographical information</returns> public void GetUserInfo(string username, string password) { using (GlucaTrack.Services.GTServiceClient service = new GlucaTrack.Services.GTServiceClient()) { service.Open(); try { if (service.State == CommunicationState.Opened) { //validate the users login and get the users information back GlucaTrack.Services.DSUser userinfo = service.ValidateLogin(username, password); //populate the login model with the info from the web service GlucaTrack.Services.DSUser.sp_GetLoginRow loginrow = userinfo.sp_GetLogin.First(); this.FirstName = loginrow.firstname; this.MiddleName = loginrow.middlename; this.LastName = loginrow.lastname; this.Address1 = loginrow.address1; this.Address2 = loginrow.Isaddress2Null() ? string.Empty : loginrow.address2; this.City = loginrow.city; this.State = loginrow.state; this.Zipcode = loginrow.zipcode; this.LastSync = loginrow.Islast_syncNull() ? DateTime.MinValue : loginrow.last_sync; this.LastWebLogin = loginrow.Islast_webloginNull() ? DateTime.MinValue : loginrow.last_weblogin; this.UserType = loginrow.usertype; this.SessionId = loginrow.sessionid; } else { throw new ApplicationException("Service is closed."); } } catch (System.ServiceModel.FaultException fex) { throw new ApplicationException(fex.Message); } } }
/// <summary> /// Gets the users information from the WCF service if authentication passes. /// </summary> /// <param name="username">Username to try to authenticate.</param> /// <param name="password">Password to try to authenticate.</param> /// <returns>User demographical information</returns> public void GetUserInfo(string username, string password) { using (GlucaTrack.Services.GTServiceClient service = new GlucaTrack.Services.GTServiceClient()) { service.Open(); try { if (service.State == CommunicationState.Opened) { //validate the users login and get the users information back GlucaTrack.Services.DSUser userinfo = service.ValidateLogin(username, password); //populate the login model with the info from the web service GlucaTrack.Services.DSUser.sp_GetLoginRow loginrow = userinfo.sp_GetLogin.First(); this.FirstName = loginrow.firstname; this.MiddleName = loginrow.middlename; this.LastName = loginrow.lastname; this.Address1 = loginrow.address1; this.Address2 = loginrow.Isaddress2Null() ? string.Empty : loginrow.address2; this.City = loginrow.city; this.State = loginrow.state; this.Zipcode = loginrow.zipcode; this.LastSync = loginrow.Islast_syncNull() ? DateTime.MinValue : loginrow.last_sync; this.LastWebLogin = loginrow.Islast_webloginNull() ? DateTime.MinValue : loginrow.last_weblogin; this.UserType = loginrow.usertype; this.SessionId = loginrow.sessionid; } else throw new ApplicationException("Service is closed."); } catch(System.ServiceModel.FaultException fex) { throw new ApplicationException(fex.Message); } } }