Example #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();
     }
 }
Example #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();
        }
Example #3
0
        //--------------------------------------------------------------
        private void CFormCreerEquipement_Load(object sender, EventArgs e)
        {
            m_lblSite.Text = m_releveEqpt.ReleveSite.Site.Libelle;
            if (m_releveEqpt.ReleveEquipementParent != null)
            {
                m_panelEqptParent.Visible = true;
                m_lblEqptParent.Text      = m_releveEqpt.ReleveEquipementParent.NumeroSerie + " " +
                                            m_releveEqpt.ReleveEquipementParent.TypeEquipement.Libelle + " (" +
                                            m_releveEqpt.ReleveEquipementParent.CoordonneeComplete + ")";
            }
            else
            {
                m_panelEqptParent.Visible = false;
            }

            m_txtSerial.Text = m_releveEqpt.NumeroSerie;
            m_selectTypeEquipement.Init(m_releveEqpt, true);
            m_panelCoordonnee.Init(m_releveEqpt, true);

            CListeEntitesDeMemoryDb <CChampCustom> lstChamps = new CListeEntitesDeMemoryDb <CChampCustom>(CTimosInventoryDb.GetTimosDatas());

            lstChamps.Filtre = CChampCustom.GetFiltreChampsForRole(CReleveEquipement.c_roleChampCustom);
            if (lstChamps.Count() == 0)
            {
                m_panelChampsCustom.Visible = false;
            }
            else
            {
                m_panelChampsCustom.Visible = true;
                foreach (CChampCustom champOrg in lstChamps)
                {
                    CChampCustom champ = new CChampCustom(CTimosInventoryDb.GetInventaireDatas());
                    if (!champ.ReadIfExist(champOrg.Id))
                    {
                        champ = champOrg.GetChampInMemoryDb(CTimosInventoryDb.GetInventaireDatas());
                    }

                    if (champ != null)
                    {
                        CControleForCustomFieldReleve ctrl = new CControleForCustomFieldReleve();
                        m_panelChampsCustom.Controls.Add(ctrl);
                        ctrl.Dock = DockStyle.Left;
                        ctrl.Init(champ);
                    }
                }
            }

            foreach (Control ctrl in m_panelChampsCustom.Controls)
            {
                CControleForCustomFieldReleve c = ctrl as CControleForCustomFieldReleve;
                if (c != null)
                {
                    c.InitChamps(m_releveEqpt);
                }
            }
        }
Example #4
0
        private void InitListeReleves()
        {
            CMemoryDb db = CTimosInventoryDb.GetInventaireDatas();
            CListeEntitesDeMemoryDb <CReleveSite> lst = new CListeEntitesDeMemoryDb <CReleveSite>(db);

            m_wndListeReleves.BeginUpdate();
            m_wndListeReleves.Items.Clear();
            lst.Sort = CReleveSite.c_champDate;
            foreach (CReleveSite releve in lst)
            {
                CSite site = releve.Site;
                if (site != null)
                {
                    ListViewItem item = new ListViewItem(site.LibelleComplet);
                    item.Tag     = releve;
                    item.Checked = true;
                    m_wndListeReleves.Items.Add(item);
                }
            }
            m_wndListeReleves.EndUpdate();
        }
Example #5
0
        private void CFormReleveSite_FormClosing(object sender, FormClosingEventArgs e)
        {
            m_panelEquipements.MajChamps();
            CReleveDb releveDb = CTimosInventoryDb.GetInventaireDatas();

            if (releveDb.HasChanges())
            {
                DialogResult res = MessageBox.Show(I.T("Save changes ?|20036"), "",
                                                   MessageBoxButtons.YesNoCancel,
                                                   MessageBoxIcon.Question);
                if (res == DialogResult.Cancel)
                {
                    e.Cancel = true;
                    return;
                }
                if (res == DialogResult.No)
                {
                    CTimosInventoryDb.GetInventaireDatas().RejectChanges();
                    return;
                }
                SaveDatas();
            }
        }
Example #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            CListeEntitesDeMemoryDb <CReleveSite> lstReleves = new CListeEntitesDeMemoryDb <CReleveSite>(CTimosInventoryDb.GetInventaireDatas());

            if (lstReleves.Count() > 0)
            {
                if (MessageBox.Show(
                        I.T("You have unsent surveys on your computer. It is recommanded to send all surveys before obtain data from Timos. Continue anyway ?|20049"),
                        "",
                        MessageBoxButtons.YesNo,
                        MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
            }

            CFormPreparerBaseTravail form = new CFormPreparerBaseTravail();

            form.ShowDialog();
            form.Dispose();
            InitListeSites();
            InitListeReleves();
        }
Example #7
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();
        }
Example #8
0
 //--------------------------------------------------------------
 private void SaveDatas()
 {
     m_panelEquipements.MajChamps();
     CTimosInventoryDb.SetDbInventaire(CTimosInventoryDb.GetInventaireDatas());
 }