/// <summary>
 /// Get details about User.
 /// </summary>
 /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
 /// <param name="UserIds">Array of user ids</param>
 /// <returns></returns>
 public UserReturnValue GetUser(HostSecurityToken oHostSecurityToken, Guid userMemberId)
 {
     UserReturnValue returnValue = null;
     if (Functions.ValidateIWSToken(oHostSecurityToken))
     {
         oUtilitiesService = new UtilitiesService();
         returnValue = oUtilitiesService.GetUser(Functions.GetLogonIdFromToken(oHostSecurityToken), userMemberId);
     }
     else
     {
         returnValue = new UserReturnValue();
         returnValue.Success = false;
         returnValue.Message = "Invalid Token";
     }
     return returnValue;
 }
        /// <summary>
        /// Get details about User.
        /// </summary>
        /// <param name="oHostSecurityToken">HostSecurityToken obtained when security provider of IWS is called</param>
        /// <param name="UserIds">Array of user ids</param>
        /// <returns></returns>
        public UserReturnValue GetUser(HostSecurityToken oHostSecurityToken, Guid userMemberId)
        {
            UserReturnValue returnValue = null;

            if (Functions.ValidateIWSToken(oHostSecurityToken))
            {
                oUtilitiesService = new UtilitiesService();
                returnValue       = oUtilitiesService.GetUser(Functions.GetLogonIdFromToken(oHostSecurityToken), userMemberId);
            }
            else
            {
                returnValue         = new UserReturnValue();
                returnValue.Success = false;
                returnValue.Message = "Invalid Token";
            }
            return(returnValue);
        }
        public UserReturnValue GetUserByUid(Guid logonId, int uid)
        {
            //UserReturnValue userReturnValue = new UserReturnValue();
            DsSystemUsers systemUserReturnValue = new DsSystemUsers();
            UserReturnValue userReturnValue = new UserReturnValue();
            userReturnValue.User = new User();
            //DsBranches branchReturnValue = new DsBranches();
            //OrganisationReturnValue organisationReturnValue = new OrganisationReturnValue();
            //dsDepartments departmentReturnValue = new dsDepartments();
            //DsWorkTypes workTypeReturnValue = new DsWorkTypes();
            //EarnerReturnValue earnerReturnValue = new EarnerReturnValue();
            //DsPersons personReturnValue = new DsPersons();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                        case DataConstants.UserType.Staff:
                            // Can do everything
                            break;
                        case DataConstants.UserType.Client:
                        case DataConstants.UserType.ThirdParty:
                            throw new Exception("Access denied");
                        default:
                            throw new Exception("Access denied");
                    }

                    systemUserReturnValue = SrvUserLookup.GetUser(uid);//SrvUserCommon.GetSystemUser();

                    userReturnValue.User.Forename = systemUserReturnValue.Tables[0].Rows[0]["PersonName"].ToString();
                    userReturnValue.User.Lastname = systemUserReturnValue.Tables[0].Rows[0]["PersonSurname"].ToString();
                    userReturnValue.User.MemOrOrgId = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["MemberID"].ToString());
                    userReturnValue.User.Name = systemUserReturnValue.Tables[0].Rows[0]["name"].ToString();
                    userReturnValue.User.Title = systemUserReturnValue.Tables[0].Rows[0]["PersonTitle"].ToString();
                    userReturnValue.User.Uid = int.Parse(systemUserReturnValue.Tables[0].Rows[0]["uid"].ToString());
                    userReturnValue.User.UserDefaBranch = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaBranch"].ToString());
                    userReturnValue.User.UserDefaDepartment = int.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaDepartment"].ToString());
                    userReturnValue.User.UserDefaEarner = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaEarner"].ToString());
                    userReturnValue.User.UserDefaPartner = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaPartner"].ToString());
                    userReturnValue.User.UserDefaWorkType = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaWorkType"].ToString());
                    userReturnValue.User.UserType = int.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserType"].ToString());

                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                userReturnValue.Success = false;
                userReturnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                userReturnValue.Success = false;
                userReturnValue.Message = ex.Message;
            }

            return userReturnValue;
        }
Exemple #4
0
        public UserReturnValue GetUserByUid(Guid logonId, int uid)
        {
            //UserReturnValue userReturnValue = new UserReturnValue();
            DsSystemUsers   systemUserReturnValue = new DsSystemUsers();
            UserReturnValue userReturnValue       = new UserReturnValue();

            userReturnValue.User = new User();
            //DsBranches branchReturnValue = new DsBranches();
            //OrganisationReturnValue organisationReturnValue = new OrganisationReturnValue();
            //dsDepartments departmentReturnValue = new dsDepartments();
            //DsWorkTypes workTypeReturnValue = new DsWorkTypes();
            //EarnerReturnValue earnerReturnValue = new EarnerReturnValue();
            //DsPersons personReturnValue = new DsPersons();

            try
            {
                // Get the logged on user from the current logons and add their
                // ApplicationSettings the list of concurrent sessions.
                Host.LoadLoggedOnUser(logonId);

                try
                {
                    Functions.RestrictRekoopIntegrationUser(UserInformation.Instance.DbUid);
                    switch (UserInformation.Instance.UserType)
                    {
                    case DataConstants.UserType.Staff:
                        // Can do everything
                        break;

                    case DataConstants.UserType.Client:
                    case DataConstants.UserType.ThirdParty:
                        throw new Exception("Access denied");

                    default:
                        throw new Exception("Access denied");
                    }

                    systemUserReturnValue = SrvUserLookup.GetUser(uid);//SrvUserCommon.GetSystemUser();

                    userReturnValue.User.Forename           = systemUserReturnValue.Tables[0].Rows[0]["PersonName"].ToString();
                    userReturnValue.User.Lastname           = systemUserReturnValue.Tables[0].Rows[0]["PersonSurname"].ToString();
                    userReturnValue.User.MemOrOrgId         = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["MemberID"].ToString());
                    userReturnValue.User.Name               = systemUserReturnValue.Tables[0].Rows[0]["name"].ToString();
                    userReturnValue.User.Title              = systemUserReturnValue.Tables[0].Rows[0]["PersonTitle"].ToString();
                    userReturnValue.User.Uid                = int.Parse(systemUserReturnValue.Tables[0].Rows[0]["uid"].ToString());
                    userReturnValue.User.UserDefaBranch     = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaBranch"].ToString());
                    userReturnValue.User.UserDefaDepartment = int.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaDepartment"].ToString());
                    userReturnValue.User.UserDefaEarner     = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaEarner"].ToString());
                    userReturnValue.User.UserDefaPartner    = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaPartner"].ToString());
                    userReturnValue.User.UserDefaWorkType   = Guid.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserDefaWorkType"].ToString());
                    userReturnValue.User.UserType           = int.Parse(systemUserReturnValue.Tables[0].Rows[0]["UserType"].ToString());
                }
                finally
                {
                    // Remove the logged on user's ApplicationSettings from the
                    // list of concurrent sessions
                    Host.UnloadLoggedOnUser();
                }
            }
            catch (System.Data.SqlClient.SqlException)
            {
                userReturnValue.Success = false;
                userReturnValue.Message = Functions.SQLErrorMessage;
            }
            catch (Exception ex)
            {
                userReturnValue.Success = false;
                userReturnValue.Message = ex.Message;
            }

            return(userReturnValue);
        }