private void Login() { LoginServiceClient client = null; try { client = new LoginServiceClient(); client.ClientCredentials.UserName.UserName = Username; client.ClientCredentials.UserName.Password = CreateHash(Username, Password); LoginData = client.GetLoginData(); DialogResult = true; } catch (Exception ex) { } finally { if (client != null) { client.Close(); } } }
static void Main(string[] args) { string factoryID; string [] factories; loginService = ConnectionUtils.getLoginService(); sessionID = testLogin(); factories = getFactories(loginService, sessionID); factoryID = factories[0]; bool connected = connectToFactory(factoryID); registerMQListener(factoryID); Console.WriteLine("Connected to factory: " + connected); loginService.Close(); factoryService = ConnectionUtils.getFactoryService(); factory connectedFactory = factoryService.getFactory(sessionID); printFactory(connectedFactory); string itemId1 = createItem(1, 17, 42, FactoryServiceReference.direction.SOUTH); string itemId2 = createItem(89, 0, 0, FactoryServiceReference.direction.NORTH); connectedFactory = factoryService.getFactory(sessionID); printFactory(connectedFactory); int x = 20; int y = 20; direction dir = direction.WEST; position pos = getPosition(20, 20, direction.WEST); Console.WriteLine("Moving item " + itemId1 + " to " + x + "," + y + ", direction:" + dir); factoryService.moveItem(sessionID, itemId1, pos); connectedFactory = factoryService.getFactory(sessionID); printFactory(connectedFactory); Console.WriteLine("deleting item " + itemId1); factoryService.deleteItem(sessionID, itemId1); connectedFactory = factoryService.getFactory(sessionID); printFactory(connectedFactory); Console.WriteLine("Warte auf input"); Console.ReadKey(); }
private string GetDataProxyClient() { LoginServiceClient client = new LoginServiceClient(); string content = client.GetData(); client.Close(); return content; }
private void WizardPageUnloaded(object sender, System.Windows.RoutedEventArgs e) { try { if (_client != null) { _client.Close(); } } catch (Exception exception) { Console.WriteLine(exception); } }
private void closeServices() { if (loginService != null) { loginService.Close(); } if (factoryService != null) { factoryService.Close(); } if (simulationService != null) { simulationService.Close(); } }
private bool IsLoggedIn() { LoginServiceClient client = new LoginServiceClient(new InstanceContext(new NoOpCallbacks())); try { bool result = client.IsLoggedIn(); client.Close(); return(result); } catch { client.Abort(); return(false); } }
public void Save() { try { if (_loginServiceClient != null) { _loginServiceClient.Close(); } } catch (Exception e) { if (_loginServiceClient != null) { _loginServiceClient.Abort(); } } }
public void open() { using (var client = new LoginServiceClient("WSHttpBinding_ILoginService")) { try { AuthenticationStatus request = client.Authenticate(customerApiKey, serviceUserPassword, userApiKey, serviceUser, out message, out token); if (request == AuthenticationStatus.Ok) { client.Close(); } else { client.Abort(); // Authentication failed, see message property for details. } } catch (Exception ex) { message = "Unexpected error occured while establishing the UltiPro authentication session. " + ex.ToString(); } } }
static void Main(string[] args) { string factoryID; string [] factories; loginService = ConnectionUtils.getLoginService(); sessionID = testLogin(); factories = getFactories(loginService, sessionID); factoryID = factories[0]; bool connected = connectToFactory(factoryID); registerMQListener(factoryID); Console.WriteLine("Connected to factory: "+connected); loginService.Close(); factoryService = ConnectionUtils.getFactoryService(); factory connectedFactory = factoryService.getFactory(sessionID); printFactory(connectedFactory); string itemId1 = createItem(1, 17, 42, FactoryServiceReference.direction.SOUTH); string itemId2 = createItem(89, 0, 0, FactoryServiceReference.direction.NORTH); connectedFactory = factoryService.getFactory(sessionID); printFactory(connectedFactory); int x = 20; int y = 20; direction dir = direction.WEST; position pos = getPosition(20, 20, direction.WEST); Console.WriteLine("Moving item " + itemId1 + " to " + x + "," + y + ", direction:" + dir); factoryService.moveItem(sessionID, itemId1, pos); connectedFactory = factoryService.getFactory(sessionID); printFactory(connectedFactory); Console.WriteLine("deleting item " + itemId1); factoryService.deleteItem(sessionID, itemId1); connectedFactory = factoryService.getFactory(sessionID); printFactory(connectedFactory); Console.WriteLine("Warte auf input"); Console.ReadKey(); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { /* Inicializar Variables */ int idAplicacion = 126; string direccionBase = "http://uaslp.mx"; if (Request.QueryString["Ticket"] == null) { XDocument ticketXml; LoginServiceClient proxy = new LoginServiceClient("WSHttpBinding_ILoginService"); if (Request.QueryString["ReturnUrl"] == null) { ticketXml = XDocument.Parse(proxy.NuevaSesion(idAplicacion)); } else { ticketXml = XDocument.Parse(proxy.NuevaSesionConUrlRetorno(idAplicacion, direccionBase + Request.QueryString["ReturnUrl"])); } proxy.Close(); HttpCookie aCookie = new HttpCookie("SC"); aCookie.Value = ticketXml.Root.LastAttribute.Value; aCookie.Expires = DateTime.Now.AddMinutes(10.0); Response.Cookies.Add(aCookie); Response.Redirect("https://serviciosenlinea.uaslp.mx/LoginGateway/Default.aspx?Ticket=" + ticketXml.Root.FirstAttribute.Value); } else { if (Request.Cookies["SC"] == null) { Response.Redirect("Default.aspx"); } else { int ticket; int valido = 0; string claveSesion = Server.HtmlEncode(Request.Cookies["SC"].Value); Response.Cookies["SC"].Expires = DateTime.Now.AddDays(-1); //Validar cookie if (int.TryParse(Request.QueryString["Ticket"], out ticket)) { LoginServiceClient proxy = new LoginServiceClient("WSHttpBinding_ILoginService"); valido = proxy.ValidaCliente(ticket, claveSesion); proxy.Close(); } switch (valido) { case 0: // Cookie no es valida o expiro Ticket. FailureDiv.Visible = true; FailureText.Text = "Inicio de Sesión no valido."; break; case 1: // Ok Cookie Valida! //Obtener Resultado LoginServiceClient proxy = new LoginServiceClient("WSHttpBinding_ILoginService"); XDocument estadoXml = XDocument.Parse(proxy.EstadoUsuario(ticket, claveSesion)); proxy.Close(); if (estadoXml.Root.HasAttributes) { //Verificar que no exista error XAttribute errorAttribute = estadoXml.Root.Attribute("TextoError"); if (errorAttribute == null) { //Si esta autentificado Autentificar por programacion la sesion local. try { if (bool.Parse(estadoXml.Root.Attribute("Autenticado").Value)) { /*Aqui se redirecciona a otra pagina*/ FormsAuthentication.RedirectFromLoginPage(estadoXml.Root.Attribute("Usuario").Value, false); return; } else { FailureText.Text = "El Usuario no esta autentificado"; } } catch { FailureText.Text = "Error: No fue posible autentificar al usuario."; } } else { FailureText.Text = "Se agoto el tiempo."; } } else { FailureText.Text = "El Ticket Expiro."; } FailureDiv.Visible = true; break; case -1: // Error al conectar, no se pudo validar cookie! FailureDiv.Visible = true; FailureText.Text = "No se pudo validar, Intentelo de nuevo."; break; } } } } }
private bool IsLoggedIn() { LoginServiceClient client = new LoginServiceClient(new InstanceContext(new NoOpCallbacks())); try { bool result = client.IsLoggedIn(); client.Close(); return result; } catch { client.Abort(); return false; } }