Exemple #1
0
        /// <summary>
        /// Gets the user info by UserID and ClientID
        /// </summary>
        /// <param name="clientLogin">The user object</param>
        /// <returns></returns>
        public Response GetUserStatusByUserIDAndClientID(UserDto clientLogin)
        {
            var response     = new Response();
            var userBL       = new UserBL();
            var appVersionBL = new AppVersionBL();

            // Get the user data
            UserDto user = userBL.GetUserByUserIDAndClientID(clientLogin);

            if (user != null)
            {
                response.Results.Add("Success");
                // For security only past the data required
                UserDto userToSend = new UserDto
                {
                    DeleteInd  = user.DeleteInd,
                    ClientId   = user.ClientId,
                    SDAOppMgmt = user.SDAOppMgmt,
                    UserId     = user.UserId
                };
                // Serialize the object
                string userSerialize = JsonConvert.SerializeObject(userToSend);
                response.Results.Add(userSerialize);

                var version = appVersionBL.GetLatestSWVersion("SMDESKTOP");
                response.Results.Add(version);
            }
            else
            {
                response.Results.Add("Error");
                response.Errors.Add("Invalid user data.");
            }
            return(response);
        }
Exemple #2
0
        /// <summary>
        /// possible results
        /// Invalid – if no record was selected
        /// ValidNoOppy – record was selected, (user.sdaoppmgmt is N or (user.sdaoppmgmt is null and (client.sdaoppmgmt is N or null))
        /// ValidOppy - record was selected, (user.sdaoppmgmt is Y or (user.sdaoppmgmt is null and client.sdaoppmgmt is Y))
        /// </summary>
        /// <param name="clientId"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public UserCloudStatusDto GetUserAppStatus(int clientId, int userId)
        {
            UserCloudStatusDto userCloudStatusDto = new UserCloudStatusDto();

            try
            {
                var userBL          = new UserBL();
                var appVersionBL    = new AppVersionBL();
                var configurationBL = new ConfigurationBL();

                UserDto userDto = new UserDto()
                {
                    ClientId = clientId,
                    UserId   = userId
                };
                var user   = userBL.GetUserByUserIDAndClientID(userDto);
                var client = GetClientById(clientId);

                if (user != null && client != null)
                {
                    userCloudStatusDto.ClientId = client.ClientId;
                    userCloudStatusDto.UserId   = user.UserId;
                    if (!user.DeleteInd.Equals("Y"))
                    {
                        if ((Utilitary.SafeToUpper(user.SDAOppMgmt).Equals("N")) || (string.IsNullOrEmpty(Utilitary.SafeToUpper(user.SDAOppMgmt)) && (String.IsNullOrEmpty(client.SDAOppMgmt) || Utilitary.SafeToUpper(client.SDAOppMgmt).Equals("N"))))
                        {
                            userCloudStatusDto.UserStatus = "ValidNoOppy";
                        }
                        else if (Utilitary.SafeToUpper(user.SDAOppMgmt).Equals("Y") || (string.IsNullOrEmpty(user.SDAOppMgmt) && Utilitary.SafeToUpper(client.SDAOppMgmt).Equals("Y")))
                        {
                            userCloudStatusDto.UserStatus = "ValidOppy";
                        }

                        //getting application information
                        string appVersion = appVersionBL.GetLatestSWVersion("SMDESKTOP");
                        if (!string.IsNullOrEmpty(appVersion))
                        {
                            userCloudStatusDto.AppVersion = appVersion;
                        }

                        //getting configuration dates
                        var ValidUserNextCheckHours    = configurationBL.GetConfigurationListByName("ValidUserNextCheckHours").FirstOrDefault();
                        var ValidUserNextCheckReqdDays = configurationBL.GetConfigurationListByName("ValidUserNextCheckReqDays").FirstOrDefault();
                        if (ValidUserNextCheckHours != null)
                        {
                            userCloudStatusDto.ValidUserNextCheckHours = ValidUserNextCheckHours.Value.ToString();
                        }
                        if (ValidUserNextCheckReqdDays != null)
                        {
                            userCloudStatusDto.ValidUserNextCheckReqDays = ValidUserNextCheckReqdDays.Value.ToString();
                        }
                        //updating user last check datetime
                        userBL.UpdateUserLastCheckDT(user);
                    }
                }

                if (string.IsNullOrEmpty(userCloudStatusDto.UserStatus))
                {
                    userCloudStatusDto.UserStatus = "Invalid";
                }
            }
            catch (Exception e)
            {
                userCloudStatusDto.UserStatus = userCloudStatusDto.UserStatus + "Error: " + e.Message;
            }
            return(userCloudStatusDto);
        }