Esempio n. 1
0
 //-------------------------------------------------------------------
 private void RecupereListeSites(CFormWaiting waiter)
 {
     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;
         }
         waiter.ReportProgress(I.T("Import site list...|20010"));
         DataSet ds = service.GetReferencesSites(nIdSession);
         service.CloseSession(nIdSession);
         CMemoryDb db = CMemoryDb.FromDataSet(ds);
         m_dbDeconnectee = db;
         UpdateArbre(waiter);
     }
     catch (Exception e)
     {
         waiter.ShowError(I.T("Error while transfering data|20008"));
         return;
     }
     finally
     {
     }
 }
Esempio n. 2
0
        //---------------------------------------------------------
        private void m_btnOk_Click(object sender, EventArgs e)
        {
            if (m_txtURL.Text != CTimosInventoryRegistre.TimosServiceURL)
            {
                InventoryService.InventoryService service = new TimosInventory.InventoryService.InventoryService();
                bool   bOk         = false;
                string strErrorMes = "";

                CFormWaiting.DoWork((DoWorkDelegate) delegate(CFormWaiting waiter)
                {
                    try
                    {
                        waiter.ReportProgress(I.T("Trying URL|20054"));
                        service.Url = m_txtURL.Text;
                        int nId     = service.OpenSession();
                        service.CloseSession(nId);
                        bOk = true;
                    }
                    catch (Exception ex)
                    {
                        strErrorMes = ex.ToString();
                    }
                });
                if (!bOk &&
                    MessageBox.Show(I.T("Can not connect to URL. Change settings anyway ?(@1)|20053", strErrorMes),
                                    "",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Warning) != DialogResult.Yes)
                {
                    return;
                }
                CTimosInventoryRegistre.TimosServiceURL = m_txtURL.Text;
            }

            /*List<string> lstIdsChamps = new List<string>();
             * foreach (ListViewItem item in m_wndListeChamps.CheckedItems)
             * {
             *  CChampCustom champ = item.Tag as CChampCustom;
             *  if (champ != null)
             *      lstIdsChamps.Add(champ.Id);
             * }
             * CTimosInventoryRegistre.IdChampsReleve = lstIdsChamps.ToArray();*/
            DialogResult = DialogResult.OK;
            Close();
        }
Esempio n. 3
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();
        }
Esempio n. 4
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();
            }
        }