Search in sources :

Example 1 with Service

use of ca.etsmtl.applets.etsmobile.model.Service in project ETSMobile-Android2 by ApplETS.

the class DataManager method getDataFromSignet.

/**
	 * Robospice request manager for everything not related to Signet-Mobile the
	 * class (result) must be mapped with Gson
	 * 
	 * @param request
	 * @param listener
	 * @return true if request is sent
	 */
// public boolean sendRequest(TypedRequest request, RequestListener<Object>
// listener) {
//
// final Object key = request.createCacheKey();
// spiceManager.execute(request, key, DurationInMillis.ONE_SECOND,
// listener);
// return true;
// }
/**
	 * Send a request to Signet-Mobile Web Service
	 * 
	 * @param method
	 *            Int, methods are stored in SignetMethod
	 * @param creds
	 *            User Credentials
	 * @param listener
	 *            The callback
	 * @param params
	 *            Some methods require more than the credentials pass them here
	 */
public void getDataFromSignet(int method, final UserCredentials creds, final RequestListener<Object> listener, String... params) {
    // inline asynctask
    new AsyncTask<Object, Void, Object>() {

        private Exception exception = null;

        private Object result;

        @Override
        protected Object doInBackground(Object... params) {
            try {
                final int methodID = (Integer) params[0];
                String[] reqParams = (String[]) params[1];
                final SignetsMobileSoap signetsMobileSoap = new SignetsMobileSoap();
                String username = "";
                String password = "";
                if (methodID < SignetMethods.BOTTIN_LIST_DEPT || methodID > SignetMethods.BOTTIN_GET_LIST_SERVICE_AND_EMP) {
                    username = creds.getUsername();
                    password = creds.getPassword();
                }
                switch(methodID) {
                    case SignetMethods.INFO_ETUDIANT:
                        result = signetsMobileSoap.infoEtudiant(username, password);
                        dbHelper.getDao(Etudiant.class).createOrUpdate((Etudiant) result);
                        break;
                    case SignetMethods.LIST_COURS:
                        result = signetsMobileSoap.listeCours(username, password);
                        break;
                    case SignetMethods.LIST_INT_SESSION:
                        String SesFin = reqParams[0];
                        String SesDebut = reqParams[1];
                        result = signetsMobileSoap.listeCoursIntervalleSessions(username, password, SesDebut, SesFin);
                        break;
                    case SignetMethods.LIST_SESSION:
                        result = signetsMobileSoap.listeSessions(username, password);
                        break;
                    case SignetMethods.LIST_PROGRAM:
                        result = signetsMobileSoap.listeProgrammes(username, password);
                        break;
                    case SignetMethods.LIST_COEQ:
                        String pNomElementEval = reqParams[0];
                        String pSession = reqParams[1];
                        String pGroupe = reqParams[2];
                        String pSigle = reqParams[3];
                        result = signetsMobileSoap.listeCoequipiers(username, password, pSigle, pGroupe, pSession, pNomElementEval);
                        break;
                    case SignetMethods.LIST_EVAL:
                        String pSession1 = reqParams[0];
                        String pGroupe1 = reqParams[1];
                        String pSigle1 = reqParams[2];
                        result = signetsMobileSoap.listeElementsEvaluation(username, password, pSigle1, pGroupe1, pSession1);
                        break;
                    case SignetMethods.LIST_HORAIRE_PROF:
                        String pSession2 = reqParams[0];
                        result = signetsMobileSoap.listeHoraireEtProf(username, password, pSession2);
                        break;
                    case SignetMethods.LIRE_HORAIRE:
                        String pSession3 = reqParams[0];
                        String prefixeSigleCours = reqParams[1];
                        result = signetsMobileSoap.lireHoraire(pSession3, prefixeSigleCours);
                        break;
                    case SignetMethods.LIRE_JOURS_REMPLACES:
                        String pSession4 = reqParams[0];
                        result = signetsMobileSoap.lireJoursRemplaces(pSession4);
                        break;
                    case SignetMethods.BOTTIN_LIST_DEPT:
                        result = new WebServiceSoap().GetListeDepartement();
                        break;
                    case SignetMethods.BOTTIN_GET_FICHE:
                        String numero = reqParams[0];
                        String PathFiche = reqParams[1];
                        result = new WebServiceSoap().GetFiche(numero, PathFiche);
                        break;
                    case SignetMethods.BOTTIN_GET_FICHE_DATA:
                        String Id = reqParams[0];
                        result = new WebServiceSoap().GetFicheData(Id);
                        break;
                    case SignetMethods.BOTTIN_GET_ALL:
                        result = new WebServiceSoap().Recherche(null, null, null);
                        break;
                    case SignetMethods.BOTTIN_GET_FICHE_BY_SERVICE:
                        String filtreServiceCode = reqParams[0];
                        result = new WebServiceSoap().Recherche(null, null, filtreServiceCode);
                        break;
                    case SignetMethods.BOTTIN_GET_LIST_SERVICE_AND_EMP:
                        ArrayOfService arrayOfService = new WebServiceSoap().GetListeDepartement();
                        HashMap<String, List<FicheEmploye>> listeEmployeByService = new HashMap<String, List<FicheEmploye>>();
                        ArrayOfFicheEmploye arrayOfFicheEmploye;
                        for (int i = 0; i < arrayOfService.size(); i++) {
                            Service service = arrayOfService.get(i);
                            arrayOfFicheEmploye = new WebServiceSoap().Recherche(null, null, "" + service.ServiceCode);
                            listeEmployeByService.put(service.Nom, arrayOfFicheEmploye);
                        }
                        result = listeEmployeByService;
                        break;
                    case SignetMethods.LIST_EXAMENS_FINAUX:
                        String pSession5 = reqParams[0];
                        result = signetsMobileSoap.listeHoraireExamensFin(username, password, pSession5);
                        break;
                    case SignetMethods.LIST_SEANCES:
                        String pCoursGroupe = reqParams[0];
                        String pSession6 = reqParams[1];
                        String pDateDebut = reqParams[2];
                        String pDateFin = reqParams[3];
                        result = signetsMobileSoap.lireHoraireDesSeances(username, password, pCoursGroupe, pSession6, pDateDebut, pDateFin);
                        break;
                    case SignetMethods.LIST_SEANCES_CURRENT_AND_NEXT_SESSION:
                        ListeDeSessions listeDeSessions = signetsMobileSoap.listeSessions(username, password);
                        listeSeances listeSeances = new listeSeances();
                        DateTime dt = new DateTime();
                        DateTime dtEnd = new DateTime();
                        for (Trimestre trimestre : listeDeSessions.liste) {
                            dtEnd = new DateTime(trimestre.dateFin);
                            if (dt.isBefore(dtEnd.plusDays(1))) {
                                listeSeances.ListeDesSeances.addAll(signetsMobileSoap.lireHoraireDesSeances(username, password, "", trimestre.abrege, "", "").ListeDesSeances);
                            }
                        }
                        result = listeSeances;
                        break;
                    case SignetMethods.LIST_EXAM_CURRENT_AND_NEXT_SESSION:
                        ListeDeSessions listeDeSessions2 = signetsMobileSoap.listeSessions(username, password);
                        listeHoraireExamensFinaux listeHoraireExamensFinaux = new listeHoraireExamensFinaux();
                        DateTime dt2 = new DateTime();
                        DateTime dtEnd2 = new DateTime();
                        for (Trimestre trimestre : listeDeSessions2.liste) {
                            dtEnd2 = new DateTime(trimestre.dateFin);
                            if (dt2.isBefore(dtEnd2.plusDays(1))) {
                                listeHoraireExamensFinaux.listeHoraire.addAll(signetsMobileSoap.listeHoraireExamensFin(username, password, trimestre.abrege).listeHoraire);
                            }
                        }
                        result = listeHoraireExamensFinaux;
                        break;
                    case SignetMethods.LIST_JOURSREMPLACES_CURRENT_AND_NEXT_SESSION:
                        ListeDeSessions listeDeSessions3 = signetsMobileSoap.listeSessions(username, password);
                        listeJoursRemplaces listeJoursRemplaces = new listeJoursRemplaces();
                        DateTime dt3 = new DateTime();
                        DateTime dtEnd3 = new DateTime();
                        for (Trimestre trimestre : listeDeSessions3.liste) {
                            dtEnd3 = new DateTime(trimestre.dateFin);
                            if (dt3.isBefore(dtEnd3.plusDays(1))) {
                                listeJoursRemplaces.listeJours.addAll(signetsMobileSoap.lireJoursRemplaces(trimestre.abrege).listeJours);
                            }
                        }
                        result = listeJoursRemplaces;
                        break;
                    default:
                        break;
                }
            } catch (Exception e) {
                e.printStackTrace();
                exception = e;
            }
            return null;
        }

        protected void onPostExecute(Object result2) {
            if (exception != null) {
                listener.onRequestFailure(new SpiceException("Couldn't get datas"));
            } else {
                listener.onRequestSuccess(result);
            }
        }
    }.execute(method, params);
}
Also used : Etudiant(ca.etsmtl.applets.etsmobile.model.Etudiant) HashMap(java.util.HashMap) SpiceException(com.octo.android.robospice.persistence.exception.SpiceException) WebServiceSoap(ca.etsmtl.applets.etsmobile.http.soap.WebServiceSoap) ArrayOfService(ca.etsmtl.applets.etsmobile.model.ArrayOfService) Service(ca.etsmtl.applets.etsmobile.model.Service) ListeDeSessions(ca.etsmtl.applets.etsmobile.model.ListeDeSessions) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye) ArrayOfFicheEmploye(ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye) SQLException(java.sql.SQLException) SpiceException(com.octo.android.robospice.persistence.exception.SpiceException) DateTime(org.joda.time.DateTime) ArrayOfService(ca.etsmtl.applets.etsmobile.model.ArrayOfService) ca.etsmtl.applets.etsmobile.model.listeSeances(ca.etsmtl.applets.etsmobile.model.listeSeances) ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces(ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces) Trimestre(ca.etsmtl.applets.etsmobile.model.Trimestre) SignetsMobileSoap(ca.etsmtl.applets.etsmobile.http.soap.SignetsMobileSoap) List(java.util.List) ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux(ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux) ArrayOfFicheEmploye(ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye)

Example 2 with Service

use of ca.etsmtl.applets.etsmobile.model.Service in project ETSMobile-Android2 by ApplETS.

the class SignetsRequestTask method doInBackground.

@Override
protected Object doInBackground(Object... params) {
    try {
        final int methodID = (Integer) params[0];
        String[] reqParams = (String[]) params[1];
        Context c = taskContext.get();
        final SignetsMobileSoap signetsMobileSoap = new SignetsMobileSoap(TLSUtilities.createETSOkHttpClient(c));
        String username = "";
        String password = "";
        if (methodID < SignetsMethods.BOTTIN_LIST_DEPT || methodID > SignetsMethods.BOTTIN_GET_LIST_SERVICE_AND_EMP) {
            username = credentials.getUsername();
            password = credentials.getPassword();
        }
        switch(methodID) {
            case SignetsMethods.INFO_ETUDIANT:
                result = signetsMobileSoap.infoEtudiant(username, password);
                dbHelper.getDao(Etudiant.class).createOrUpdate((Etudiant) result);
                break;
            case SignetsMethods.LIST_COURS:
                result = signetsMobileSoap.listeCours(username, password);
                break;
            case SignetsMethods.LIST_INT_SESSION:
                String SesFin = reqParams[0];
                String SesDebut = reqParams[1];
                result = signetsMobileSoap.listeCoursIntervalleSessions(username, password, SesDebut, SesFin);
                break;
            case SignetsMethods.LIST_SESSION:
                result = signetsMobileSoap.listeSessions(username, password);
                break;
            case SignetsMethods.LIST_PROGRAM:
                result = signetsMobileSoap.listeProgrammes(username, password);
                break;
            case SignetsMethods.LIST_COEQ:
                String pNomElementEval = reqParams[0];
                String pSession = reqParams[1];
                String pGroupe = reqParams[2];
                String pSigle = reqParams[3];
                result = signetsMobileSoap.listeCoequipiers(username, password, pSigle, pGroupe, pSession, pNomElementEval);
                break;
            case SignetsMethods.LIST_EVAL:
                String pSession1 = reqParams[0];
                String pGroupe1 = reqParams[1];
                String pSigle1 = reqParams[2];
                result = signetsMobileSoap.listeElementsEvaluation(username, password, pSigle1, pGroupe1, pSession1);
                break;
            case SignetsMethods.LIST_HORAIRE_PROF:
                String pSession2 = reqParams[0];
                result = signetsMobileSoap.listeHoraireEtProf(username, password, pSession2);
                break;
            case SignetsMethods.LIRE_HORAIRE:
                String pSession3 = reqParams[0];
                String prefixeSigleCours = reqParams[1];
                result = signetsMobileSoap.lireHoraire(pSession3, prefixeSigleCours);
                break;
            case SignetsMethods.LIRE_JOURS_REMPLACES:
                String pSession4 = reqParams[0];
                result = signetsMobileSoap.lireJoursRemplaces(pSession4);
                break;
            case SignetsMethods.BOTTIN_LIST_DEPT:
                result = new WebServiceSoap().GetListeDepartement();
                break;
            case SignetsMethods.BOTTIN_GET_FICHE:
                String numero = reqParams[0];
                String PathFiche = reqParams[1];
                result = new WebServiceSoap().GetFiche(numero, PathFiche);
                break;
            case SignetsMethods.BOTTIN_GET_FICHE_DATA:
                String Id = reqParams[0];
                result = new WebServiceSoap().GetFicheData(Id);
                break;
            case SignetsMethods.BOTTIN_GET_ALL:
                result = new WebServiceSoap().Recherche(null, null, null);
                break;
            case SignetsMethods.BOTTIN_GET_FICHE_BY_SERVICE:
                String filtreServiceCode = reqParams[0];
                result = new WebServiceSoap().Recherche(null, null, filtreServiceCode);
                break;
            case SignetsMethods.BOTTIN_GET_LIST_SERVICE_AND_EMP:
                ArrayOfService arrayOfService = new WebServiceSoap().GetListeDepartement();
                HashMap<String, List<FicheEmploye>> listeEmployeByService = new HashMap<String, List<FicheEmploye>>();
                ArrayOfFicheEmploye arrayOfFicheEmploye;
                for (int i = 0; i < arrayOfService.size(); i++) {
                    Service service = arrayOfService.get(i);
                    arrayOfFicheEmploye = new WebServiceSoap().Recherche(null, null, "" + service.ServiceCode);
                    listeEmployeByService.put(service.Nom, arrayOfFicheEmploye);
                }
                result = listeEmployeByService;
                break;
            case SignetsMethods.LIST_EXAMENS_FINAUX:
                String pSession5 = reqParams[0];
                result = signetsMobileSoap.listeHoraireExamensFin(username, password, pSession5);
                break;
            case SignetsMethods.LIST_SEANCES:
                String pCoursGroupe = reqParams[0];
                String pSession6 = reqParams[1];
                String pDateDebut = reqParams[2];
                String pDateFin = reqParams[3];
                result = signetsMobileSoap.lireHoraireDesSeances(username, password, pCoursGroupe, pSession6, pDateDebut, pDateFin);
                break;
            case SignetsMethods.LIST_SEANCES_CURRENT_AND_NEXT_SESSION:
                ListeDeSessions listeDeSessions = signetsMobileSoap.listeSessions(username, password);
                listeSeances listeSeances = new listeSeances();
                DateTime dt = new DateTime();
                for (Trimestre trimestre : listeDeSessions.liste) {
                    DateTime dtEnd = new DateTime(trimestre.dateFin);
                    if (dt.isBefore(dtEnd.plusDays(1))) {
                        listeSeances.ListeDesSeances.addAll(signetsMobileSoap.lireHoraireDesSeances(username, password, "", trimestre.abrege, "", "").ListeDesSeances);
                    }
                }
                result = listeSeances;
                break;
            case SignetsMethods.LIST_EXAM_CURRENT_AND_NEXT_SESSION:
                ListeDeSessions listeDeSessions2 = signetsMobileSoap.listeSessions(username, password);
                listeHoraireExamensFinaux listeHoraireExamensFinaux = new listeHoraireExamensFinaux();
                DateTime dt2 = new DateTime();
                for (Trimestre trimestre : listeDeSessions2.liste) {
                    DateTime dtEnd2 = new DateTime(trimestre.dateFin);
                    if (dt2.isBefore(dtEnd2.plusDays(1))) {
                        listeHoraireExamensFinaux.listeHoraire.addAll(signetsMobileSoap.listeHoraireExamensFin(username, password, trimestre.abrege).listeHoraire);
                    }
                }
                result = listeHoraireExamensFinaux;
                break;
            case SignetsMethods.LIST_JOURSREMPLACES_CURRENT_AND_NEXT_SESSION:
                ListeDeSessions listeDeSessions3 = signetsMobileSoap.listeSessions(username, password);
                listeJoursRemplaces listeJoursRemplaces = new listeJoursRemplaces();
                DateTime dt3 = new DateTime();
                for (Trimestre trimestre : listeDeSessions3.liste) {
                    DateTime dtEnd3 = new DateTime(trimestre.dateFin);
                    if (dt3.isBefore(dtEnd3.plusDays(1))) {
                        listeJoursRemplaces.listeJours.addAll(signetsMobileSoap.lireJoursRemplaces(trimestre.abrege).listeJours);
                    }
                }
                result = listeJoursRemplaces;
                break;
            default:
                break;
        }
    } catch (Exception e) {
        e.printStackTrace();
        exception = e;
    }
    return null;
}
Also used : Context(android.content.Context) Etudiant(ca.etsmtl.applets.etsmobile.model.Etudiant) HashMap(java.util.HashMap) WebServiceSoap(ca.etsmtl.applets.etsmobile.http.soap.WebServiceSoap) ArrayOfService(ca.etsmtl.applets.etsmobile.model.ArrayOfService) Service(ca.etsmtl.applets.etsmobile.model.Service) ListeDeSessions(ca.etsmtl.applets.etsmobile.model.ListeDeSessions) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye) ArrayOfFicheEmploye(ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye) DateTime(org.joda.time.DateTime) SpiceException(com.octo.android.robospice.persistence.exception.SpiceException) ArrayOfService(ca.etsmtl.applets.etsmobile.model.ArrayOfService) ca.etsmtl.applets.etsmobile.model.listeSeances(ca.etsmtl.applets.etsmobile.model.listeSeances) ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces(ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces) Trimestre(ca.etsmtl.applets.etsmobile.model.Trimestre) SignetsMobileSoap(ca.etsmtl.applets.etsmobile.http.soap.SignetsMobileSoap) List(java.util.List) ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux(ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux) ArrayOfFicheEmploye(ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye)

Example 3 with Service

use of ca.etsmtl.applets.etsmobile.model.Service in project ETSMobile-Android2 by ApplETS.

the class BottinSyncJob method getListeEmployeByService.

private HashMap<String, List<FicheEmploye>> getListeEmployeByService() throws Exception {
    ArrayOfService arrayOfService = new WebServiceSoap().GetListeDepartement();
    HashMap<String, List<FicheEmploye>> listeEmployeByService = new HashMap<String, List<FicheEmploye>>();
    ArrayOfFicheEmploye arrayOfFicheEmploye;
    for (int i = 0; i < arrayOfService.size(); i++) {
        Service service = arrayOfService.get(i);
        arrayOfFicheEmploye = new WebServiceSoap().Recherche(null, null, "" + service.ServiceCode);
        listeEmployeByService.put(service.Nom, arrayOfFicheEmploye);
    }
    return listeEmployeByService;
}
Also used : ArrayOfService(ca.etsmtl.applets.etsmobile.model.ArrayOfService) HashMap(java.util.HashMap) WebServiceSoap(ca.etsmtl.applets.etsmobile.http.soap.WebServiceSoap) ArrayOfService(ca.etsmtl.applets.etsmobile.model.ArrayOfService) Service(ca.etsmtl.applets.etsmobile.model.Service) List(java.util.List) FicheEmploye(ca.etsmtl.applets.etsmobile.model.FicheEmploye) ArrayOfFicheEmploye(ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye) ArrayOfFicheEmploye(ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye)

Aggregations

WebServiceSoap (ca.etsmtl.applets.etsmobile.http.soap.WebServiceSoap)3 ArrayOfFicheEmploye (ca.etsmtl.applets.etsmobile.model.ArrayOfFicheEmploye)3 ArrayOfService (ca.etsmtl.applets.etsmobile.model.ArrayOfService)3 FicheEmploye (ca.etsmtl.applets.etsmobile.model.FicheEmploye)3 Service (ca.etsmtl.applets.etsmobile.model.Service)3 HashMap (java.util.HashMap)3 List (java.util.List)3 SignetsMobileSoap (ca.etsmtl.applets.etsmobile.http.soap.SignetsMobileSoap)2 Etudiant (ca.etsmtl.applets.etsmobile.model.Etudiant)2 ListeDeSessions (ca.etsmtl.applets.etsmobile.model.ListeDeSessions)2 Trimestre (ca.etsmtl.applets.etsmobile.model.Trimestre)2 ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux (ca.etsmtl.applets.etsmobile.model.listeHoraireExamensFinaux)2 ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces (ca.etsmtl.applets.etsmobile.model.listeJoursRemplaces)2 ca.etsmtl.applets.etsmobile.model.listeSeances (ca.etsmtl.applets.etsmobile.model.listeSeances)2 SpiceException (com.octo.android.robospice.persistence.exception.SpiceException)2 DateTime (org.joda.time.DateTime)2 Context (android.content.Context)1 SQLException (java.sql.SQLException)1