void Start () { if(StaticData.IsRelog) { if(ServerHandler.server != null) server = ServerHandler.server ; else { ServerHandler.server = new ServerService (); server = ServerHandler.server ; } Relog(); } else { ShowLoginScreen (); isConnected = ConnectionManager.IsConnected (false); if (isConnected && !offlineMode) { if(ServerHandler.server == null) ServerHandler.server = new ServerService (); server = ServerHandler.server ; Invoke("DownloadVistoriadores" , 0.4f); } else { List<Vistoriador> list = ServerHandler.vistoriadorDAO.LoadAllIncludingDeleted(); if(list.Count == 0) { Vistoriador vistoriadorPadrao = new Vistoriador(); vistoriadorPadrao.nome = "Master"; vistoriadorPadrao.usuario = "admin"; vistoriadorPadrao.senha = "1234"; ServerHandler.vistoriadorDAO.SaveOrUpdate(vistoriadorPadrao); } } } }
public void OnRegisterClick () { string user = lblregisterUser.text; string pass = lblregisterPass.text; string person = lblregisterName.text; string json = null; string id = null; //Cadastrar Vistoriador Vistoriador novoVistoriador = new Vistoriador (); novoVistoriador.id = 0; novoVistoriador.nome = person; novoVistoriador.usuario = user; novoVistoriador.senha = pass; json = novoVistoriador.GetJson (); if (isConnected) { id = server.saveOrUpdateVistoriador (json); novoVistoriador.id = int.Parse (id); } ServerHandler.vistoriadorDAO.SaveOrUpdate (novoVistoriador); print (novoVistoriador); ShowLoginScreen (); }
public void OnLoginClick () { username = lblUser.text; senha = lblSenha.text; string json = ""; isConnected = ConnectionManager.IsConnected (false) && !offlineMode; if (isConnected) { json = server.login (username + "_" + senha); if (json != null && json.StartsWith ("Exception")) { carregando.SetActive(false); PopupsManager.Instance.ShowPopupMessage ("Erro do Servidor", "Não foi possível fazer login. Tente novamente mais tarde."); return; } if (!string.IsNullOrEmpty (json)) { vistoriador = new Vistoriador (json); json = server.findVistoriaByVistoriador (vistoriador.id); vistorias = JsonBehaviour.GetList<Vistoria> (json); vistoriador = ServerHandler.vistoriadorDAO.LoadById(vistoriador.id); carregando.SetActive(true); } else { carregando.SetActive(false); PopupsManager.Instance.ShowPopupMessage ("Erro no Login", "Usuário ou senha incorretos."); return; } } else { vistoriador = ServerHandler.vistoriadorDAO.login (username, senha); } if (vistoriador != null) { carregando.SetActive(true); ServerHandler.user = username; ServerHandler.pass = senha; StaticData.vistoriadorAtual = vistoriador; List<Vistoria> ultimaVistoria = new VistoriaDAO ().LoadByVistoriador (vistoriador); for(int i = 0; i < vistoriasTable.transform.childCount; i++) { Destroy (vistoriasTable.transform.GetChild(i).gameObject); } if (ultimaVistoria != null && ultimaVistoria.Count > 0) { GameObject row = NGUITools.AddChild (vistoriasTable.gameObject, vistoriasPrefab); row.GetComponent <VistoriaRow> ().vistoria = ultimaVistoria[0]; row.GetComponent <VistoriaRow> ().online = false; newButton.enabled = false; deleteButton.enabled = true; // sendButton.enabled = true; } else { newButton.enabled = true; deleteButton.enabled = false; //sendButton.enabled = false; } if (vistorias != null && vistorias.Count > 0) { foreach (var item in vistorias) { GameObject row = NGUITools.AddChild (vistoriasTable.gameObject, vistoriasPrefab); row.GetComponent <VistoriaRow> ().vistoria = item; row.GetComponent <VistoriaRow> ().online = true; } } ShowVistoriasScreen (); carregando.SetActive(false); } else { PopupsManager.Instance.ShowPopupMessage ("Erro no Login", "Usuário ou senha incorretos."); } }