Esempio n. 1
0
        private void Login_Click(object sender, EventArgs e)
        {
            var serverClient = new ServerServiceClient();

            String user = userTextBox.Text;
            String pass = passTextBox.Text;

            serverClient.ClientCredentials.UserName.UserName = user;
            serverClient.ClientCredentials.UserName.Password = pass;

            loginButton.Enabled = false;
            passTextBox.Text = "";

            serverClient.Open();
            launchMainForm(serverClient);
            try
            {

            }
            catch ( Exception exception )
            {
                serverClient.Abort();
                var info = new InfoForm();
                info.Add(exception.Message);
                info.ShowDialog(this);

            }
        }
Esempio n. 2
0
        private void launchMainForm(ServerServiceClient serverClient)
        {
            if (serverClient.State == CommunicationState.Opened)
            {
                // Handling user interfaces
                RegistView mf = new RegistView(serverClient);
                this.Visible = false;

                // Running Main form
                mf.ShowDialog(this);

                // Restoring Login interface
                this.Visible = true;
                loginButton.Enabled = true;

                // Close connection
                serverClient.Close();
                return;
            }
            serverClient.Abort();
            var info = new InfoForm();
            info.Add("Erro a conectar ao servidor");
            info.ShowDialog(this);
            loginButton.Enabled = true;
        }
Esempio n. 3
0
        private void Login_Click(object sender, EventArgs e)
        {
            var serverClient = new ServerServiceClient();

            String user = userTextBox.Text;
            String pass = passTextBox.Text;

            serverClient.ClientCredentials.UserName.UserName = user;
            serverClient.ClientCredentials.UserName.Password = pass;

            loginButton.Enabled = false;
            passTextBox.Text    = "";


            serverClient.Open();
            launchMainForm(serverClient);
            try
            {
            }
            catch (Exception exception)
            {
                serverClient.Abort();
                var info = new InfoForm();
                info.Add(exception.Message);
                info.ShowDialog(this);
            }
        }
Esempio n. 4
0
        private void launchMainForm(ServerServiceClient serverClient)
        {
            if (serverClient.State == CommunicationState.Opened)
            {
                // Handling user interfaces
                RegistView mf = new RegistView(serverClient);
                this.Visible = false;

                // Running Main form
                mf.ShowDialog(this);

                // Restoring Login interface
                this.Visible        = true;
                loginButton.Enabled = true;

                // Close connection
                serverClient.Close();
                return;
            }
            serverClient.Abort();
            var info = new InfoForm();

            info.Add("Erro a conectar ao servidor");
            info.ShowDialog(this);
            loginButton.Enabled = true;
        }
 public static void CloseAfariaServiceServer(ServerServiceClient svcServer)
 {
     try
     {
         if (svcServer != null)
         {
             // Get the state of the service
             System.ServiceModel.CommunicationState commState = svcServer.State;
             // If the service is faulted, we still need to abort
             if (commState == System.ServiceModel.CommunicationState.Faulted)
             {
                 svcServer.Abort();
             }
             // If the state is not already closed or in the process of closing, we should close the context
             else if (commState != System.ServiceModel.CommunicationState.Closing ||
                 commState != System.ServiceModel.CommunicationState.Closed)
             {
                 // Get the context info to get the context ID, although we saved this in the context string variable
                 Server.ContextInfo contextInfo = svcServer.GetContextInfo();
                 // Assure that there is a valid context ID
                 if (!string.IsNullOrWhiteSpace(contextInfo.ContextId))
                 {
                     // Close the context
                     svcServer.CloseContext();
                 }
                 // Now close the service
                 svcServer.Close();
             }
             // If the channel is closing/closed, attempt to close out the context, but don't need to close state
             else
             {
                 // We will likely throw an exception here.
                 svcServer.CloseContext();
             }
             svcServer = null;
         }
     }
     catch (Exception ex)
     {
         // Just ouput the exception, proper handling should initiate a new service, initiate the context to the previous,
         // and then close out the context and service
         Console.WriteLine(ex.Message.ToString());
         logger.Error("Error while closing Server service", ex);
     }
 }