Esempio n. 1
0
        public bool Connect()
        {
            var bizService = new UserManagerClient();

            try
            {
                if (bizService.ClientCredentials != null)
                {
                    bizService.ClientCredentials.UserName.UserName = UserName;
                    bizService.ClientCredentials.UserName.Password = Password;
                }
                bizService.Open();

                Connected = bizService.TryConnect();

                if (Connected)
                {
                    Info   = bizService.GetUserInfo();
                    UserId = Info.Id;
                }
                return(Connected);
            }
            catch (Exception e)
            {
                try
                {
                    using (var writer = new StreamWriter("c:\\distr\\cissa\\ConnectionErrors.log", true))
                    {
                        writer.WriteLine("{0}: \"{1}\"; message: \"{2}\"", DateTime.Now, UserName, e.Message);
                        if (e.InnerException != null)
                        {
                            writer.WriteLine("  - inner exception: \"{0}\"", e.InnerException.Message);
                        }
                        writer.WriteLine("  -- Stack: {0}", e.StackTrace);
                    }
                }
                catch (Exception)
                {
                }
            }
            finally
            {
                try
                {
                    bizService.Close();
                }
                catch
                {
                    bizService.Abort();
                    throw;
                }
            }
            return(false);
        }
Esempio n. 2
0
        protected UserManagerClient GetUserManager()
        {
            var um = new UserManagerClient();

            if (um.ClientCredentials != null)
            {
                um.ClientCredentials.UserName.UserName = Connection.UserName;
                um.ClientCredentials.UserName.Password = Connection.Password;
            }
            um.Open();

            return(um);
        }