示例#1
0
        public UserInfoModel GetUserInfo()
        {
            try
            {
                var accountName = @"" + (_user.Identity.Name != null ? _user.Identity.Name : WindowsIdentity.GetCurrent().Name);
                var employeeId  = GetEmployeeId();

                var binding = new BasicHttpBinding();
                binding.Name          = "UserInfoWebServiceSoap";
                binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                var addressUri = dbService.GetConfigurationProperties("UserInfoServiceUrl");

                if (addressUri.Contains("https"))
                {
                    binding.Security.Mode = BasicHttpSecurityMode.Transport;
                }

                var endpoint = new EndpointAddress(addressUri);
                var client   = new UserInfoServiceReference.UserInfoWebServiceSoapClient(binding, endpoint);
                Util.ApplyCredentials("", "", client.ClientCredentials);

                var element = client.getUserInfoByEmpIDAsync(employeeId).ConfigureAwait(true).GetAwaiter().GetResult();
                userInfoXml = element.ToString();
                var info     = Util.ConvertXElementToXmlDocument(element);
                var userInfo = Util.ConvertXmlNodeToObject <UserInfoModel>(info);

                employeeId = 0;
                var locationId     = 0;
                var jobCode        = 0;
                var departmentCode = 0;

                int.TryParse(userInfo.empID, out employeeId);
                int.TryParse(userInfo.locationID, out locationId);
                int.TryParse(userInfo.jobCode, out jobCode);
                int.TryParse(userInfo.dept, out departmentCode);

                if (employeeId < 0)
                {
                    employeeId = 0;
                }

                userInfo.empID      = employeeId.ToString();
                userInfo.locationID = locationId.ToString();
                userInfo.jobCode    = jobCode.ToString();
                userInfo.dept       = departmentCode.ToString();

                return(userInfo);
            }
            catch (Exception ex)
            {
                CustomLogging.ErrorLog(ex);
                return(new UserInfoModel());
            }
        }
示例#2
0
        public string[] GetWebClockMembership()
        {
            try
            {
                var userName = _user.Identity.Name != null
                            ? Util.GetUsernameWithoutDomain(_user.Identity.Name)
                            : Util.GetUsernameWithoutDomain(System.Security.Principal.WindowsIdentity.GetCurrent().Name);

                var userDomain = _user.Identity.Name != null
                        ? Util.GetDomainNameFromUsername(_user.Identity.Name)
                        : Util.GetDomainNameFromUsername(System.Security.Principal.WindowsIdentity.GetCurrent().Name);

                var accountName = @"" + (_user.Identity.Name != null ? _user.Identity.Name : WindowsIdentity.GetCurrent().Name);
                CustomLogging.InfoLog("Loggedin User = "******"UserInfoWebServiceSoap";
                binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                var addressUri = dbService.GetConfigurationProperties("UserInfoServiceUrl");

                if (addressUri.Contains("https"))
                {
                    binding.Security.Mode = BasicHttpSecurityMode.Transport;
                }

                var endpoint = new EndpointAddress(addressUri);
                var client   = new UserInfoServiceReference.UserInfoWebServiceSoapClient(binding, endpoint);

                Util.ApplyCredentials("", "", client.ClientCredentials);
                var webClockGroups = client.getMembershipBySAMAccountNameAsync(accountName).ConfigureAwait(true).GetAwaiter().GetResult();
                return(webClockGroups);
            }
            catch (Exception ex)
            {
                CustomLogging.ErrorLog(ex);
                return(null);
            }
        }
示例#3
0
        public int GetEmployeeId()
        {
            var employeeId = 0;

            try
            {
                var accountName = @"" + (_user.Identity.Name != null ? _user.Identity.Name : WindowsIdentity.GetCurrent().Name);

                var binding = new BasicHttpBinding();
                binding.Name          = "UserInfoWebServiceSoap";
                binding.Security.Mode = BasicHttpSecurityMode.TransportCredentialOnly;
                binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
                var addressUri = dbService.GetConfigurationProperties("UserInfoServiceUrl");

                if (addressUri.Contains("https"))
                {
                    binding.Security.Mode = BasicHttpSecurityMode.Transport;
                }

                var endpoint = new EndpointAddress(addressUri);
                var client   = new UserInfoServiceReference.UserInfoWebServiceSoapClient(binding, endpoint);
                Util.ApplyCredentials("", "", client.ClientCredentials);
                var empId = client.getMyEmpIDByAccountNameAsync(accountName).ConfigureAwait(true).GetAwaiter().GetResult();

                int.TryParse(empId, out employeeId);

                if (employeeId < 0)
                {
                    employeeId = 0;
                }
            }
            catch (Exception ex)
            {
                CustomLogging.ErrorLog(ex);
            }
            return(employeeId);
        }