Exemplo n.º 1
0
 private void m_lnkSupprimerReleves_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     if (MessageBox.Show(I.T("Delete @1 survey(s)|20039", m_wndListeReleves.CheckedItems.Count.ToString() + " ?"),
                         "",
                         MessageBoxButtons.YesNo,
                         MessageBoxIcon.Question) == DialogResult.Yes)
     {
         foreach (ListViewItem item in m_wndListeReleves.CheckedItems)
         {
             CReleveSite rel = item.Tag as CReleveSite;
             if (rel != null)
             {
                 rel.ClearRelevesEquipements();
                 CResultAErreur result = rel.Delete();
                 if (!result)
                 {
                     CFormAlerte.Afficher(result.Erreur);
                     break;
                 }
             }
         }
         CTimosInventoryDb.GetInventaireDatas().AcceptChanges();
         CTimosInventoryDb.SetDbInventaire(CTimosInventoryDb.GetInventaireDatas());
         InitListeReleves();
     }
 }
Exemplo n.º 2
0
        public static void StartReleve(CSite site)
        {
            if (site == null)
            {
                return;
            }

            CReleveDb releveDb = CTimosInventoryDb.GetInventaireDatas();

            releveDb.AcceptChanges();
            //Cherche le relevé dans la base
            CReleveSite releve = new CReleveSite(releveDb);

            if (!releve.ReadIfExist(new CFiltreMemoryDb(
                                        CSite.c_champId + "=@1",
                                        site.Id)))
            {
                releve = CReleveSite.GetNewReleve(releveDb, site);
            }
            CFormReleveSite form = new CFormReleveSite();

            form.m_releve = releve;
            form.ShowDialog();
            form.Dispose();
        }
Exemplo n.º 3
0
        //------------------------------------------------------------------------
        public static void EditeReleve(CReleveSite releve)
        {
            CFormSelectActionsReleve frm = new CFormSelectActionsReleve();

            frm.m_releve = releve;
            frm.Show();
        }
Exemplo n.º 4
0
        private void m_wndListeReleves_ItemClick(ListViewItem item)
        {
            CReleveSite rel = item.Tag as CReleveSite;

            if (rel != null && rel.Site != null)
            {
                CFormReleveSite.StartReleve(rel.Site);
            }
        }
Exemplo n.º 5
0
        //-------------------------------------------------------------------
        public override CResultAErreur VerifieDonnees(CObjetDonnee objet)
        {
            CResultAErreur result = CResultAErreur.True;

            try
            {
                CReleveSite releve = objet as CReleveSite;
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
            }
            return(result);
        }
        //----------------------------------------------
        public void Init(CReleveSite releve)
        {
            CListeEntitesDeMemoryDb <CReleveEquipement> lstEqpts = releve.RelevesEquipement;

            lstEqpts.Filtre = new CFiltreMemoryDb(CReleveEquipement.c_champIdContenant + " is null");
            lstEqpts.Sort   = CEquipement.c_champCoordonnee;
            List <CItemInventaire> lstItems = new List <CItemInventaire>();

            foreach (CReleveEquipement relEq in lstEqpts)
            {
                CItemInventaire item = new CItemInventaire(null, relEq);
                lstItems.Add(item);
            }
            Items = lstItems.ToArray();
        }
Exemplo n.º 7
0
        //--------------------------------------------------------------------------
        private void m_btnExecuter_Click(object sender, EventArgs e)
        {
            CResultAErreur result = SaveAll();

            if (!result)
            {
                CFormAlerte.Afficher(result.Erreur);
                return;
            }
            using (CContexteDonnee ctx = new CContexteDonnee(m_releve.ContexteDonnee.IdSession, true, false))
            {
                CReleveSite     releve  = m_releve;
                CVersionDonnees version = releve.VersionDonneesPourApplication;
                if (version == null)
                {
                    releve.BeginEdit();
                    version = new CVersionDonnees(releve.ContexteDonnee);
                    version.CreateNewInCurrentContexte();
                    version.CodeTypeVersion = (int)CTypeVersion.TypeVersion.Previsionnelle;
                    version.Libelle         = I.T("Site @1 survey (@2)|20796",
                                                  releve.Site.LibelleComplet, releve.DateReleve.ToShortDateString());
                    releve.VersionDonneesPourApplication = version;
                    releve.CommitEdit();
                }
                version = releve.VersionDonneesPourApplication;
                //ctx.SetVersionDeTravail(version.Id, false);
                foreach (CTraitementReleveEquipement traitement in m_listeTraitements)
                {
                    result = traitement.Execute(ctx, null);
                    if (!result)
                    {
                        break;
                    }
                }
                if (result)
                {
                    result = ctx.SaveAll(true);
                }
                if (result)
                {
                    MessageBox.Show(I.T("Modifications have been applied|20798"));
                }
                if (!result)
                {
                    CFormAlerte.Afficher(result.Erreur);
                }
            }
        }
Exemplo n.º 8
0
        //------------------------------------------------------------------------
        private CResultAErreur SaveAll()
        {
            CResultAErreur result       = CResultAErreur.True;
            CReleveSite    releveToSave = m_releve;

            releveToSave.BeginEdit();
            releveToSave.StatutEquipementParDefaut = m_cmbDefaultStatus.ElementSelectionne as CStatutEquipement;
            foreach (CTraitementReleveEquipement traitement in m_listeTraitements)
            {
                traitement.StoreInContexte(releveToSave.ContexteDonnee);
            }
            result = releveToSave.CommitEdit();
            if (!result)
            {
                releveToSave.CancelEdit();
            }
            return(result);
        }
Exemplo n.º 9
0
    //-------------------------------------------------------------
    private static CResultAErreur IntegreReleve(TID.releve.CReleveSite releve,
                                                CContexteDonnee ctx)
    {
        CResultAErreur result      = CResultAErreur.True;
        CReleveSite    releveTimos = new CReleveSite(ctx);

        releveTimos.CreateNewInCurrentContexte();
        CSite site = GetObjetTimos <CSite>(releve.Row[TID.CSite.c_champId], ctx);

        if (site == null)
        {
            result.EmpileErreur("Site doesn't exists");
            return(result);
        }
        try
        {
            //Précharge les données
            CListeObjetsDonnees lst = new CListeObjetsDonnees(ctx, typeof(CTypeEquipement));
            lst.AssureLectureFaite();
            lst = new CListeObjetsDonnees(ctx, typeof(CRelationTypeEquipement_Constructeurs));
            lst.AssureLectureFaite();
            lst = site.Equipements;
            releveTimos.Site       = site;
            releveTimos.DateReleve = releve.DateReleve;
            CListeEntitesDeMemoryDb <TID.releve.CReleveEquipement> lstEqpts = releve.RelevesEquipement;
            lstEqpts.Filtre = new CFiltreMemoryDb(TID.releve.CReleveEquipement.c_champIdContenant + " is null");
            foreach (TID.releve.CReleveEquipement relEq in lstEqpts)
            {
                result = IntegreReleveEquipement(relEq, null, releveTimos);
                if (!result)
                {
                    return(result);
                }
            }
        }
        catch (Exception e)
        {
            result.EmpileErreur(new CErreurException(e));
        }
        return(result);
    }
Exemplo n.º 10
0
        //--------------------------------------------------------------
        public static CReleveEquipement CreateEquipement(CReleveSite releveSite,
                                                         CReleveEquipement releveEquipementParent)
        {
            CReleveEquipement relEq = new CReleveEquipement((CReleveDb)releveSite.Database);

            relEq.CreateNew();
            relEq.ReleveSite             = releveSite;
            relEq.IsPresent              = true;
            relEq.ReleveEquipementParent = releveEquipementParent;

            if (!EditeEquipement(relEq))
            {
                if (relEq.Equipement != null)
                {
                    relEq.Equipement.Delete();
                }
                relEq.Delete();
                return(null);
            }
            return(relEq);
        }
Exemplo n.º 11
0
    //-------------------------------------------------------------
    private static CResultAErreur IntegreReleveEquipement(
        TID.releve.CReleveEquipement releveEq,
        CReleveEquipement relEqParentTimos,
        CReleveSite releveTimos)
    {
        CResultAErreur    result     = CResultAErreur.True;
        CReleveEquipement relEqTimos = new CReleveEquipement(releveTimos.ContexteDonnee);

        relEqTimos.CreateNewInCurrentContexte();
        relEqTimos.ReleveSite = releveTimos;
        //trouve l'équipement
        relEqTimos.Equipement            = GetObjetTimos <CEquipement>(releveEq.Row[TID.CEquipement.c_champId], releveTimos.ContexteDonnee);
        relEqTimos.TypeEquipement        = GetObjetTimos <CTypeEquipement>(releveEq.Row[TID.CTypeEquipement.c_champId], releveTimos.ContexteDonnee);
        relEqTimos.ReferenceConstructeur = GetObjetTimos <CRelationTypeEquipement_Constructeurs>(releveEq.Row[TID.CTypeEquipementConstructeur.c_champId], releveTimos.ContexteDonnee);
        relEqTimos.NumSerie               = releveEq.NumeroSerie;
        relEqTimos.Coordonnee             = releveEq.Coordonnee;
        relEqTimos.Presence               = releveEq.IsPresent;
        relEqTimos.Commentaire            = releveEq.Commentaire;
        relEqTimos.ReleveEquipementParent = relEqParentTimos;
        foreach (TID.releve.CRelationReleveEquipementChampCustom rel in releveEq.RelationsChampsCustom)
        {
            if (rel.ChampCustom != null && rel.ChampCustom.IdTimos != null)
            {
                relEqTimos.SetValeurChamp(rel.ChampCustom.IdTimos.Value, rel.Valeur);
            }
        }
        foreach (TID.releve.CReleveEquipement relContenu in releveEq.RelevesContenus)
        {
            result = IntegreReleveEquipement(relContenu, relEqTimos, releveTimos);
            if (!result)
            {
                return(result);
            }
        }
        return(result);
    }
Exemplo n.º 12
0
        private void m_lnkEnvoyerReleves_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            DateTime           dt         = DateTime.Now;
            List <CReleveSite> lstReleves = new List <CReleveSite>();

            foreach (ListViewItem item in m_wndListeReleves.CheckedItems)
            {
                CReleveSite rel = item.Tag as CReleveSite;
                if (rel != null)
                {
                    lstReleves.Add(rel);
                }
            }
            List <CReleveSite> lstTransmitted = new List <CReleveSite>();

            CFormWaiting.DoWork((DoWorkDelegate) delegate(CFormWaiting waiter)
            {
                waiter.ReportProgress(I.T("Connecting to Timos|20009"));
                InventoryService.InventoryService service = new TimosInventory.InventoryService.InventoryService();
                service.Url = CTimosInventoryRegistre.TimosServiceURL;

                int nIdSession;
                try
                {
                    nIdSession = service.OpenSession();

                    foreach (CReleveSite releve in lstReleves)
                    {
                        if (releve != null)
                        {
                            CMemoryDb db          = new CMemoryDb();
                            db.EnforceConstraints = false;
                            db.ImporteObjet(releve, true, false);
                            waiter.ReportProgress(I.T("Send survey @1|20038",
                                                      releve.Site.Libelle));
                            bool bResult = service.SendSurvey(nIdSession, db);
                            if (bResult)
                            {
                                lstTransmitted.Add(releve);
                            }
                        }
                    }
                    foreach (CReleveSite releve in lstTransmitted)
                    {
                        releve.ClearRelevesEquipements();
                        releve.Delete();
                    }
                    service.CloseSession(nIdSession);
                    TimeSpan sp = DateTime.Now - dt;
                    Console.WriteLine("Transmission relevé : " + sp.TotalMilliseconds);
                }
                catch
                {
                }
            });
            CTimosInventoryDb.SetDbInventaire(CTimosInventoryDb.GetInventaireDatas());
            if (lstTransmitted.Count != lstReleves.Count)
            {
                CFormAlerte.Afficher(I.T("Due to unknown error, Some surveys could not be send|20043"));
            }


            InitListeReleves();
        }
Exemplo n.º 13
0
 //-------------------------------------------------------------------------
 public CFormEditionReleveSite(CReleveSite ReleveSite, CListeObjetsDonnees liste)
     : base(ReleveSite, liste)
 {
     // Cet appel est requis par le Concepteur Windows Form.
     InitializeComponent();
 }