Ejemplo n.º 1
0
        private void LoginThread(object state)
        {
            IChannelFactoryService channelFactoryService = null;
            string    error     = null;
            Exception exception = null;

            try
            {
                channelFactoryService             = ServiceActivator.CreateInstance <IChannelFactoryService>(UserSessionService, TokenCache);
                UserSessionService.ConfigFilename = ConfigHelper.LoadClientConfig(channelFactoryService);
            }
            catch (SecurityNegotiationException ex)
            {
                exception = ex;
                error     = StringResources.Login_InvalidCredentials;
                TokenCache.Flush();
            }
            catch (MessageSecurityException ex)
            {
                exception = ex;
                error     = StringResources.Login_InvalidCredentials;
                TokenCache.Flush();
            }
            catch (Exception ex)
            {
                exception = ex;
                error     = ex.ToString();
                TokenCache.Flush();
            }
            finally
            {
                channelFactoryService.Dispose();
            }

            if (exception != null)
            {
                try
                {
                    EventLog.WriteEntry(StringResources.Title, string.Format("{0} - {1}", StringResources.Login_Login, exception.ToString()), EventLogEntryType.Warning);
                }
                catch
                {
                }
            }

            System.Windows.Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action <string>(LoginCompleted), error);
        }