private void InsertDemandeReservation(Action<DemandeReservationBO> callbackAction = null) { var objDemandeReservation = new DemandeReservationBO {Client = CGlobalCache.SessionManager.Personne.Client, RefLivre = _livreSelected.RefLivre}; var demandeReservationIFacClient = new DemandeReservationIFACClient(); AsyncGuiDemandeReservationInsert insertGuiSampleDemandeReservationDelegate = demandeReservationIFacClient.InsertDemandeReservation; insertGuiSampleDemandeReservationDelegate.BeginInvoke(CGlobalCache.SessionManager.Token, objDemandeReservation, result =>{ var sampleInsertDemandeReservationDelegate = (AsyncGuiDemandeReservationInsert)((AsyncResult)result).AsyncDelegate; var objDemandeReservationResult = sampleInsertDemandeReservationDelegate.EndInvoke(result); demandeReservationIFacClient.Close(); if (objDemandeReservationResult == null){ MessageBox.Show(Resources.DashboardManager_totoToolStripMenuItem_Click_Le_livre_n_a_pas_pu_etre_ajoute_dans_votre_liste_de_demande); return; } //CGlobalCache.AddNewDemandeReservationByClient(objDemandeReservationResult); CGlobalCache.LstNewDemandeReservationByClient.Add(objDemandeReservationResult); if (CGlobalCache.SessionManager.Personne.Administrateur != null){ CGlobalCache.LstDemandeReservationSelectAll.Add(objDemandeReservationResult); } LoadDemandeReservation(); if (callbackAction == null){ return; } callbackAction(objDemandeReservationResult); }, null); }
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; }
public static void ReloadSelectAllDemandeReservationCache() { var demandeReservationIFacSelectNew = new DemandeReservationIFACClient(); ASyncGuiDemandeReservationSelectByClient selectGuiSampleDemandeReservationNewDelegate = demandeReservationIFacSelectNew.SelectNewByClient; selectGuiSampleDemandeReservationNewDelegate.BeginInvoke(SessionManager.Token, SessionManager.Personne.Client, result => { var sampleEmpDelegate = (ASyncGuiDemandeReservationSelectByClient)((AsyncResult)result).AsyncDelegate; LstNewDemandeReservationByClient = new ObservableCollection<DemandeReservationBO>(sampleEmpDelegate.EndInvoke(result)); demandeReservationIFacSelectNew.Close(); }, null); var demandeReservationIFacSelectOld = new DemandeReservationIFACClient(); ASyncGuiDemandeReservationSelectByClient selectGuiSampleDemandeReservationOldDelegate = demandeReservationIFacSelectNew.SelectNewByClient; selectGuiSampleDemandeReservationOldDelegate.BeginInvoke(SessionManager.Token, SessionManager.Personne.Client, result => { var sampleEmpDelegate = (ASyncGuiDemandeReservationSelectByClient)((AsyncResult)result).AsyncDelegate; LstNewDemandeReservationByClient = new ObservableCollection<DemandeReservationBO>(sampleEmpDelegate.EndInvoke(result)); demandeReservationIFacSelectOld.Close(); }, null); }
private Boolean InsertDemandeReservation() { Boolean bResult = false; DemandeReservationBO objDemandeReservation = new DemandeReservationBO(), demandeReservationResult; objDemandeReservation.Client = CGlobalCache.SessionManager.Personne.Client; objDemandeReservation.RefLivre = _livreSelected.RefLivre; DemandeReservationIFACClient demandeReservationIFacClient = null; try { demandeReservationIFacClient = new DemandeReservationIFACClient(); demandeReservationResult = demandeReservationIFacClient.InsertDemandeReservation(CGlobalCache.SessionManager.Token, objDemandeReservation); } catch (Exception ex) { throw; } finally { if (demandeReservationIFacClient != null) { demandeReservationIFacClient.Close(); } } if (demandeReservationResult != null) { CGlobalCache.AddNewDemandeReservationByClient(demandeReservationResult); bResult = true; } return bResult; }