Пример #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();
     }
 }
Пример #2
0
        private void InitListeSites()
        {
            DateTime?dt = CTimosInventoryRegistre.DateDonneesTimos;

            if (dt != null)
            {
                m_lblDateData.Text = I.T("Last data sync : @1|20048", dt.Value.ToShortDateString() + " " +
                                         dt.Value.ToString("HH:mm"));
            }
            else
            {
                m_lblDateData.Text = "";
            }
            CMemoryDb db = CTimosInventoryDb.GetTimosDatas();
            CListeEntitesDeMemoryDb <CSite> lst = new CListeEntitesDeMemoryDb <CSite>(db);

            m_wndListeSites.BeginUpdate();
            m_wndListeSites.Items.Clear();
            lst.Filtre = new CFiltreMemoryDb(CSite.c_champIdSiteParent + " is null");
            lst.Sort   = CSite.c_champLibelle;
            foreach (CSite site in lst)
            {
                ListViewItem item = new ListViewItem(site.Libelle);
                item.Tag = site;
                m_wndListeSites.Items.Add(item);
            }
            m_wndListeSites.EndUpdate();
        }
Пример #3
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();
        }
Пример #4
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);
                }
            }
        }
Пример #5
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();
        }
Пример #6
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();
            }
        }
Пример #7
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();
        }
Пример #8
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();
        }
Пример #9
0
 private void m_btnDebugData_Click(object sender, EventArgs e)
 {
     CFormViewData.ViewData(CTimosInventoryDb.GetTimosDatas());
 }
Пример #10
0
 //--------------------------------------------------------------
 private void SaveDatas()
 {
     m_panelEquipements.MajChamps();
     CTimosInventoryDb.SetDbInventaire(CTimosInventoryDb.GetInventaireDatas());
 }
Пример #11
0
        //-------------------------------------------------------------------
        private void m_btnCreerBase_Click(object sender, EventArgs e)
        {
            bool bMajOk = false;

            CFormWaiting.DoWork((DoWorkDelegate) delegate(CFormWaiting waiter)
            {
                List <int> lstIds = new List <int>();
                foreach (TreeNode node in CheckedNodes())
                {
                    CSite site = node.Tag as CSite;
                    if (site != null && site.IdTimos != null)
                    {
                        lstIds.Add(site.IdTimos.Value);
                    }
                }
                if (lstIds.Count == 0)
                {
                    waiter.ShowError(I.T("You should select sites you want to import|20004"));
                    return;
                }
                try
                {
                    waiter.ReportProgress(I.T("Connecting to Timos|20009"));
                    InventoryService.InventoryService service = new TimosInventory.InventoryService.InventoryService();
                    service.Url    = CTimosInventoryRegistre.TimosServiceURL;
                    int nIdSession = service.OpenSession();
                    if (nIdSession < 0)
                    {
                        waiter.ShowError(I.T("Can not open distant session|20001"));
                        return;
                    }

                    DateTime dt = DateTime.Now;
                    waiter.ReportProgress(I.T("Updating configuration data|20015"));
                    DataSet ds = service.GetBaseConfig(nIdSession);

                    CMemoryDb db = CMemoryDb.FromDataSet(ds);

                    waiter.ReportProgress(I.T("Importing @1 site(s)|20011", lstIds.Count.ToString()));
                    ds = service.GetSites(nIdSession, lstIds.ToArray());

                    db.EnforceConstraints = false;
                    ds.EnforceConstraints = false;

                    CImporteurDataTimos.IntegreTableDepuisTimos(ds.Tables[CSite.c_nomTable],
                                                                db);
                    CImporteurDataTimos.IntegreTableDepuisTimos(ds.Tables[CParametrageSystemeCoordonnees.c_nomTable],
                                                                db);
                    CImporteurDataTimos.IntegreTableDepuisTimos(ds.Tables[CParametrageNiveau.c_nomTable], db);

                    CListeEntitesDeMemoryDb <CSite> lstSites = new CListeEntitesDeMemoryDb <CSite>(db);
                    foreach (CSite site in lstSites)
                    {
                        if (site.IdTimos != null)
                        {
                            waiter.ReportProgress(I.T("Import site @1 details|20016", site.Libelle));
                            ds = service.GetEquipments(nIdSession, site.IdTimos.Value);
                            CImporteurDataTimos.IntegreTableDepuisTimos(ds.Tables[CEquipement.c_nomTable],
                                                                        db);
                            CImporteurDataTimos.IntegreTableDepuisTimos(ds.Tables[CParametrageSystemeCoordonnees.c_nomTable],
                                                                        db);
                            CImporteurDataTimos.IntegreTableDepuisTimos(ds.Tables[CParametrageNiveau.c_nomTable], db);
                            CImporteurDataTimos.IntegreTableDepuisTimos(ds.Tables[CRelationEquipementChampCustom.c_nomTable],
                                                                        db);
                        }
                    }

                    db.EnforceConstraints = true;

                    service.CloseSession(nIdSession);
                    TimeSpan sp = DateTime.Now - dt;
                    Console.WriteLine("Récupère sites : " + sp.TotalMilliseconds);

                    CTimosInventoryDb.SetDbTimos(db);
                    CTimosInventoryRegistre.DateDonneesTimos = DateTime.Now;
                    bMajOk = true;
                }
                catch (Exception ex)
                {
                    waiter.ShowError(ex.ToString());
                    return;
                }
                finally
                {
                }
            });
            if (bMajOk)
            {
                Close();
            }
        }