Пример #1
0
 internal Boolean InsertLivre(LivreBO pObjLivre)
 {
     LivreBO Livre;
     try {
         using (var livreProxy = new LivreIFACClient()) {
             Livre = livreProxy.InsertLivre(CGlobalCache.SessionManager.Token, pObjLivre, CGlobalCache.SessionManager.Personne.Administrateur.AdministrateurId);
         }
     } catch (Exception ex) {
         throw;
     }
     if (Livre == null) {
         return false;
     }
     // Ajout du livre au cache
     CGlobalCache.LstLivreSelectAll.Add(Livre);
     if (CGlobalCache.SessionManager.Personne.Client != null && Livre.BibliothequeId == CGlobalCache.SessionManager.Personne.Client.BibliothequeId) {
         CGlobalCache.LstLivreByBibliotheque.Add(Livre);
     }
     return true;
 }
        private void LoadFicheLivre(LivreBO pLivreBo)
        {
            CreateFicheLivre();
            var livreIFac = new LivreIFACClient();

            AsyncGuiFicheDeLivreSelectForClientById asyncExecute = livreIFac.SelectFicheLivreForClientByLivreId;
            try {
                asyncExecute.BeginInvoke(CGlobalCache.SessionManager.Token, CGlobalCache.SessionManager.Personne.Client.ClientId, pLivreBo.LivreId, xx => {
                    var samplePersDelegate = (AsyncGuiFicheDeLivreSelectForClientById)((AsyncResult)xx).AsyncDelegate;
                    _actualFicheLivre = samplePersDelegate.EndInvoke(xx);
                    if (_ficheDeLivre == null || _actualFicheLivre == null) {
                        livreIFac.Close();
                        return;
                    }
                    _ficheDeLivre.SetFicheDeLivre(pLivreBo, _actualFicheLivre);
                    livreIFac.Close();
                }, null);
            } catch(Exception) {
                livreIFac.Close();
                MessageBox.Show(Resources.DashboardManager_loadFicheLivre_Erreur_lors_de_la_recuperation_des_informations_sur_le_livre_demande_);
            }
        }
        public static void ReloadLivreCache()
        {
            Lock = 1;
            LivreIFACClient livreIFacSelectAll = null;

            try {
                livreIFacSelectAll = new LivreIFACClient();
                var selectGuiSampleRefLivreDelegate = new AsyncGuiLivreSelectAll(livreIFacSelectAll.SelectAll);
                selectGuiSampleRefLivreDelegate.BeginInvoke(SessionManager.Token, result =>{
                    LivreSelectAllResult(result);
                    livreIFacSelectAll.Close();
                }, null);
            } catch (Exception){
                if (livreIFacSelectAll != null){
                    livreIFacSelectAll.Close();
                }
            }
        }
        public static Boolean LoadCache(FrmMdi pFrmMdi)
        {
            var bReturn = true;
            PersonneIFACClient personneIFac = null;
            EmpruntIFACClient empruntIFac = null;
            ClientIFACClient clientIFac = null;
            PersonneIFACClient personneIFacById = null;
            RefLivreIFACClient refLivreIFacSelectAll = null;
            LivreIFACClient livreIFacSelectAll = null;
            LivreIFACClient livreIFacSelectByBliotheque = null;
            LivreStatusIFACClient livreStatusIFacSelectAll = null;
            BibliothequeIFACClient bibliothequeIFacSelectAll = null;
            DemandeReservationIFACClient demandeReservationIFacByClient = null;
            ReservationIFACClient reservationIfacClient = null;
            ItemIFACClient itemIfacClient = null;

            try {
                _ofrmMdi = pFrmMdi;
                personneIFac = new PersonneIFACClient();
                //AsyncGuiPersonne selectGuiSamplePersonneDelegate = personneIFac.SelectAll;
                var selectGuiSamplePersonneDelegate = new AsyncGuiPersonne(personneIFac.SelectAll);
                selectGuiSamplePersonneDelegate.BeginInvoke(SessionManager.Token, PersonneResults, null);

                empruntIFac = new EmpruntIFACClient();
                AsyncGuiEmpruntSelectAll selectGuiSampleEmpruntSelectAll = empruntIFac.SelectAll;
                selectGuiSampleEmpruntSelectAll.BeginInvoke(SessionManager.Token, EmpruntSelectAllResult, null);
                //personneIFacById = new PersonneIFACClient();
                //var selectGuiSamplePersonneByIdDelegate = new AsyncGuiPersonneById(personneIFacById.SelectById);
                //selectGuiSamplePersonneByIdDelegate.BeginInvoke(SessionManager.Token, 1, PersonneByIdResult, null);

                //var selectGuiSamplePersonneByNameDelegate = new AsyncGuiPersonneByName(personneIFac.SelectByName);
                //selectGuiSamplePersonneByNameDelegate.BeginInvoke("toto", PersonneByNameResult, null);

                clientIFac = new ClientIFACClient();
                var selectGuiSampleClientDelegate = new AsyncGuiClient(clientIFac.SelectAll);
                selectGuiSampleClientDelegate.BeginInvoke(SessionManager.Token, ClientResults, null);

                refLivreIFacSelectAll = new RefLivreIFACClient();
                var selectGuiSampleRefLivreDelegate = new AsyncGuiRefLivreSelectAll(refLivreIFacSelectAll.SelectAll);
                selectGuiSampleRefLivreDelegate.BeginInvoke(SessionManager.Token, RefLivreSelectAllResult, null);

                livreIFacSelectAll = new LivreIFACClient();
                var selectGuiSampleLivreDelegate = new AsyncGuiLivreSelectAll(livreIFacSelectAll.SelectAll);
                selectGuiSampleLivreDelegate.BeginInvoke(SessionManager.Token, LivreSelectAllResult, null);

                livreIFacSelectByBliotheque = new LivreIFACClient();
                AsyncGuiLivreSelectByBibliotheque selectGuiSampleLivreByBibliothequeDelegate = livreIFacSelectByBliotheque.SelectByBibliotheque;
                selectGuiSampleLivreByBibliothequeDelegate.BeginInvoke(SessionManager.Token, SessionManager.Personne.Client.Bibliotheque, LivreSelectByBibliothequeResult, null);

                demandeReservationIFacByClient = new DemandeReservationIFACClient();
                ASyncGuiDemandeReservationSelectByClient selectGuiSampleNewDemandeReservationByClientDelegate = demandeReservationIFacByClient.SelectNewByClient;
                selectGuiSampleNewDemandeReservationByClientDelegate.BeginInvoke(SessionManager.Token, SessionManager.Personne.Client, NewDemandeReservationResults, null);

                ASyncGuiDemandeReservationSelectByClient selectGuiSampleOldDemandeReservationByClientDelegate = demandeReservationIFacByClient.SelectOldByClient;
                selectGuiSampleOldDemandeReservationByClientDelegate.BeginInvoke(SessionManager.Token, SessionManager.Personne.Client, OldDemandeReservationResults, null);

                AyncGuiEmpruntSelectAllByClientId selectGuiSampleEmpruntDelegate = empruntIFac.SelectEmpruntByClientId;
                selectGuiSampleEmpruntDelegate.BeginInvoke(SessionManager.Token, SessionManager.PersonneId ,EmpruntResults, null);

                reservationIfacClient = new ReservationIFACClient();
                AsyncGuiReservationSelectEnCoursValidByClientId selectGuiSampleReservationEnCoursValidByClientIdDelegate = reservationIfacClient.SelectEnCoursValidByClientId;
                selectGuiSampleReservationEnCoursValidByClientIdDelegate.BeginInvoke(SessionManager.Token, SessionManager.PersonneId, ReservationSelectValidByClientIdResult, null);

                AsyncGuiReservationSelectAll selectGuiSampleReservationDelegate = reservationIfacClient.SelectAll;
                selectGuiSampleReservationDelegate.BeginInvoke(SessionManager.Token, ReservationResults, null);

                ASyncGuiDemandeReservationSelectAll selectGuiSampleDemandeReservationByClientDelegate = demandeReservationIFacByClient.SelectAll;
                selectGuiSampleDemandeReservationByClientDelegate.BeginInvoke(SessionManager.Token, DemandeReservationResults, null);

                if (SessionManager.IsAdministrateur){
                    itemIfacClient = new ItemIFACClient();
                    AsyncGuiItemSelectByAdministrateurId selectGuiSampleItemByAdministrateurId = itemIfacClient.SelectByAdministrateurId;
                    selectGuiSampleItemByAdministrateurId.BeginInvoke(SessionManager.Token, SessionManager.Personne.Administrateur.AdministrateurId, ItemSelectByAdministrateurIdResult, null);
                } else {
                    _ofrmMdi.SetLoadingText(@"Item");
                    DecrementILock();
                }

                livreStatusIFacSelectAll = new LivreStatusIFACClient();
                var selectGuiSampleLivreStatusDelegate = new ASyncGuiLivreStatusSelectAll(livreStatusIFacSelectAll.SelectAll);
                selectGuiSampleLivreStatusDelegate.BeginInvoke(SessionManager.Token, LivreStatusSelecAllResult, null);

                bibliothequeIFacSelectAll = new BibliothequeIFACClient();
                var selectGuiSampleBibliothequeDelegate = new ASyncGuiBibliothequeSelectAll(bibliothequeIFacSelectAll.SelectAll);
                selectGuiSampleBibliothequeDelegate.BeginInvoke(SessionManager.Token, BibliothequeSelectAllResult, null);

                while (!AutoEvent.WaitOne(50, true)) {
                    Application.DoEvents();
                }

            } catch (Exception) {
                bReturn = false;
            } finally {
                if (personneIFac != null) {
                    personneIFac.Close();
                }
                if (empruntIFac != null) {
                    empruntIFac.Close();
                }
                if (clientIFac != null) {
                    clientIFac.Close();
                }
                if (personneIFacById != null) {
                    personneIFacById.Close();
                }
                if (refLivreIFacSelectAll != null) {
                    refLivreIFacSelectAll.Close();
                }
                if (livreIFacSelectAll != null) {
                    livreIFacSelectAll.Close();
                }
                if (livreIFacSelectByBliotheque != null) {
                    livreIFacSelectByBliotheque.Close();
                }
                if (livreStatusIFacSelectAll != null) {
                    livreStatusIFacSelectAll.Close();
                }
                if (bibliothequeIFacSelectAll != null) {
                    bibliothequeIFacSelectAll.Close();
                }
                if (demandeReservationIFacByClient != null) {
                    demandeReservationIFacByClient.Close();
                }
                if (reservationIfacClient != null){
                    reservationIfacClient.Close();
                }
                _ofrmMdi.DecrementILockMdi();
            }
            return bReturn;
        }
        private void SearchLivreField()
        {
            var livreIFac = new LivreIFACClient();

            AsyncGuiSelectListLivre asyncExecute = livreIFac.SelectByInfo;
            try {
                asyncExecute.BeginInvoke(CGlobalCache.SessionManager.Token, txtLivreField.Text, CGlobalCache.ActualBibliotheque.BibliothequeId, result => {
                    var samplePersDelegate = (AsyncGuiSelectListLivre)((AsyncResult)result).AsyncDelegate;
                    _lstLivreField = samplePersDelegate.EndInvoke(result);
                    if (_lstLivreField.Count > 0) {
                        _bCmbClientFieldToogle = false;
                        var tmpLivreDatas = _lstLivreField.Select(yy => new { Key = yy.InternalReference + ": " + yy.ToString(), Value = yy }).ToList();
                        tmpLivreDatas.Insert(0, new { Key = "", Value = null as LivreBO });
                        cmbLivreField.DataSource = null;
                        cmbLivreField.DataSource = tmpLivreDatas;
                        cmbLivreField.ValueMember = "Value";
                        cmbLivreField.DisplayMember = "Key";
                        cmbLivreField.Enabled = true;
                        _bCmbClientFieldToogle = true;
                    } else {
                        cmbLivreField.DataSource = null;
                        cmbLivreField.Enabled = false;
                    }
                    livreIFac.Close();
                }, null);
            } catch(Exception) {
                livreIFac.Close();
                MessageBox.Show(Resources.EmpruntManagement_SearchLivreField_Erreur_lors_de_la_recuperation_des_informations_sur_le_livre_demande_);
            }
        }