Exemple #1
0
        private void FillDialog()
        {
            IGestionnaireSessionsTimos gestionnaire = CSessionClient.GestionnaireSessions as IGestionnaireSessionsTimos;
            CLicenceLogicielPrtct      licence      = null;

            if (gestionnaire != null)
            {
                licence = gestionnaire.GetLicenceServeur();
            }
            if (licence == null)
            {
                MessageBox.Show(I.T("Global license error|20200"));
                Close();
                return;
            }
            m_lblNumeroLicence.Text = licence.Numero;
            m_lblNomClient.Text     = licence.Contrat.Client.Nom;
            if (licence.DateLimiteUtilisation != null)
            {
                m_panelDateExpiration.Visible = true;
                m_lblDateExpiration.Text      = licence.DateLimiteUtilisation.Value.ToShortDateString();
            }
            else
            {
                m_panelDateExpiration.Visible = false;
            }


            foreach (CLicenceModuleAppPrtct module in licence.ModulesApp)
            {
                int nIndex = m_lstModules.Items.Add(module.Nom);
            }

            IEnumerable <CNombreUtilisePourTypeLicence> lstRestant = gestionnaire.GetNombreRestantParType();

            if (lstRestant == null)
            {
                lstRestant = new List <CNombreUtilisePourTypeLicence>();
            }
            foreach (CLicenceTypePrtct type in licence.Types)
            {
                ListViewItem item       = new ListViewItem(type.Nom);
                string       strLicence = type.Nombre.ToString();

                item.SubItems.Add(strLicence);
                m_wndListeTypes.Items.Add(item);
                CNombreUtilisePourTypeLicence rest = lstRestant.FirstOrDefault(r => r.IdType.ToUpper() == type.Id.ToUpper());
                if (rest != null)
                {
                    item.SubItems.Add(rest.NombreUtilise.ToString());
                }
            }

            foreach (CUserLicencePrtct user in licence.UserLicences)
            {
                ListViewItem item = new ListViewItem(user.NbSimultane.ToString());
                item.SubItems.Add(user.GetNbUsed().ToString());
                if (user.DateValide != null)
                {
                    item.SubItems.Add(user.DateValide.DateTimeValue.ToShortDateString());
                }
                if (user.IsReadOnly)
                {
                    item.SubItems.Add(I.T("Read only|20215"));
                }
                else
                {
                    item.SubItems.Add(I.T("Full|20214"));
                }
                m_wndListeUsers.Items.Add(item);
            }

            m_listeAlertes = gestionnaire.GetAlertesLicences();
            if (m_listeAlertes.Count > 0)
            {
                m_pageLicence.ImageIndex = 0;
                m_panelAlertes.Visible   = true;
                foreach (CAlerteLicence alerte in m_listeAlertes)
                {
                    ListViewItem item = new ListViewItem(alerte.MessageAlerte);
                    switch (alerte.Gravite)
                    {
                    case EGraviteAlerte.Info:
                        item.ImageIndex = 1;
                        break;

                    case EGraviteAlerte.Critique:
                        item.ImageIndex = 0;
                        break;
                    }
                    m_wndListeAlertes.Items.Add(item);
                }
                m_tabControl.SelectedTab = m_pageLicence;
            }
            else
            {
                m_panelAlertes.Visible   = false;
                m_pageLicence.ImageIndex = -1;
            }
        }
        static void m_timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            if (m_bIsPolling)
            {
                return;
            }
            try
            {
                m_bIsPolling = true;

                IGestionnaireSessionsTimos gestionnaire   = (IGestionnaireSessionsTimos)C2iFactory.GetNewObject(typeof(IGestionnaireSessionsTimos));
                Dictionary <string, int?>  dicNbParProfil = new Dictionary <string, int?>();
                Dictionary <string, int?>  dicNbParUser   = new Dictionary <string, int?>();
                foreach (int nId in gestionnaire.GetListeIdSessionsConnectees())
                {
                    CSessionClientSurServeurTimos sessionSurServeur = gestionnaire.GetSessionClientSurServeur(nId) as CSessionClientSurServeurTimos;
                    if (sessionSurServeur != null && sessionSurServeur.UserLicence != null)
                    {
                        string strKeyUserLicence = sessionSurServeur.UserLicence.IdLys + " " + sessionSurServeur.UserLicence.ToString();
                        string strIdUtilisateur  = sessionSurServeur.KeyUtilisateur != null ? sessionSurServeur.KeyUtilisateur.StringValue : "";
                        int?   nVal = null;
                        try
                        {
                            if (sessionSurServeur.SessionClient.IsConnected)
                            {
                                if (!dicNbParProfil.TryGetValue(strKeyUserLicence, out nVal))
                                {
                                    nVal = 0;
                                }
                                nVal++;
                                dicNbParProfil[strKeyUserLicence] = nVal;
                                if (strIdUtilisateur.Length > 0)
                                {
                                    if (!dicNbParUser.TryGetValue(strIdUtilisateur, out nVal))
                                    {
                                        nVal = 0;
                                    }
                                    nVal++;
                                    dicNbParUser[strIdUtilisateur] = nVal;
                                }
                            }
                        }
                        catch { }
                    }
                }
                CDataHotelClient hotelClient = new CDataHotelClient();
                hotelClient.Init(m_strHotelURL);
                foreach (KeyValuePair <string, int?> kv in dicNbParProfil)
                {
                    string strIdEtt = kv.Key;
                    if (strIdEtt.Length == 0)
                    {
                        strIdEtt = "Empty";
                    }
                    hotelClient.StoreDataToSend(c_LicenceUsagePollingTableId, c_LicenceUsagePollingNbUsedFieldId,
                                                kv.Key, DateTime.Now, kv.Value.Value);
                }
                foreach (KeyValuePair <string, int?> kv in dicNbParUser)
                {
                    string strIdEtt = kv.Key;
                    if (strIdEtt.Length == 0)
                    {
                        strIdEtt = "Empty";
                    }
                    hotelClient.StoreDataToSend(c_LicenceUsagePollingTableId, c_LicenceUsagePollingNbUsedFieldId,
                                                kv.Key, DateTime.Now, kv.Value.Value);
                }
                hotelClient.FlushData();
            }
            catch { }
            finally{
                m_bIsPolling = false;
            }
        }