Пример #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
     {
     }
 }
Пример #2
0
        //---------------------------------------------------
        public static void DoWork(DoWorkDelegate funcToCall)
        {
            CFormWaiting frm = new CFormWaiting();

            frm.m_funcToCall = funcToCall;
            frm.ShowDialog();
        }
Пример #3
0
        //-------------------------------------------------------------------
        public void UpdateArbre(CFormWaiting waiter)
        {
            if (m_dbDeconnectee == null)
            {
                RecupereListeSites(waiter);
            }
            if (m_dbDeconnectee == null)
            {
                return;
            }
            waiter.ReportProgress(I.T("Loading data...|20012"));
            CListeEntitesDeMemoryDb <CSite> lstSites = new CListeEntitesDeMemoryDb <CSite>(m_dbDeconnectee);

            lstSites.Filtre = new CFiltreMemoryDb(CSite.c_champIdSiteParent + " is null");
            lstSites.Sort   = CSite.c_champLibelle;
            Invoke((MethodInvoker) delegate
            {
                m_arbreSites.BeginUpdate();
                m_arbreSites.Nodes.Clear();
            });
            List <TreeNode> lstNodes = new List <TreeNode>();

            foreach (CSite site in lstSites)
            {
                TreeNode node = CreateNodeSite(site);
                lstNodes.Add(node);
            }
            Invoke((MethodInvoker) delegate
            {
                m_arbreSites.Nodes.AddRange(lstNodes.ToArray());
                m_arbreSites.EndUpdate();
            });
        }
Пример #4
0
 private void m_btnConnect_Click(object sender, EventArgs e)
 {
     using (CWaitCursor waiter = new CWaitCursor())
     {
         CFormWaiting.DoWork(new DoWorkDelegate(RecupereListeSites));
     }
 }
Пример #5
0
 private void AsyncUpdateArbre()
 {
     while (!IsHandleCreated)
     {
         System.Threading.Thread.Sleep(100);
     }
     this.Invoke((MethodInvoker) delegate
     {
         Refresh();
         CFormWaiting.DoWork(new DoWorkDelegate(UpdateArbre));
     });
 }
Пример #6
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();
        }
Пример #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();
        }
Пример #8
0
 private void m_btnConnect_Click_1(object sender, EventArgs e)
 {
     CFormWaiting.DoWork(new DoWorkDelegate(RecupereListeSites));
 }
Пример #9
0
 //------------------------------------------
 private void CFormPreparerBaseTravail_Load(object sender, EventArgs e)
 {
     Refresh();
     CFormWaiting.DoWork(new DoWorkDelegate(UpdateArbre));
 }
Пример #10
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();
            }
        }