//---------------------------------------------------------------- public void RefreshNombreUtilises() { lock (typeof(CLockerNbUsed)) { m_listRecords = new List <CNombreUtilisePourTypeLicence>(); Dictionary <string, int?> dicUsed = new Dictionary <string, int?>(); foreach (Type tp in CContexteDonnee.GetAllTypes()) { if (m_LicenceLogiciel is CLicenceDemo) { if (!typeof(CRelationElementAChamp_ChampCustom).IsAssignableFrom(tp)) { string strNomType = DynamicClassAttribute.GetNomConvivial(tp); dicUsed[strNomType] = GetNbUsedInDbForType(tp); Attribute attr = tp.GetCustomAttribute(typeof(TableAttribute), true); if (attr != null) { string strNomTable = ((TableAttribute)attr).NomTable; m_dicNomTableToIdTypeLimite[strNomTable] = strNomType; m_dicTablesLimitees[strNomTable] = true; } } } else { object[] attribs = tp.GetCustomAttributes(typeof(LicenceCountAttribute), true); if (attribs != null && attribs.Length > 0) { LicenceCountAttribute counter = attribs[0] as LicenceCountAttribute; int?nNb = null; if (!dicUsed.TryGetValue(counter.CountTypeName, out nNb)) { nNb = 0; } nNb += GetNbUsedInDbForType(tp); dicUsed[counter.CountTypeName] = nNb; } } } foreach (KeyValuePair <string, int?> kv in dicUsed) { CNombreUtilisePourTypeLicence nb = new CNombreUtilisePourTypeLicence(kv.Key, kv.Value.Value); m_listRecords.Add(nb); } } }
//----------------------------------------------------------------------------------------- //write m_listRecords into the file m_stSaveFileFullName public CResultAErreur Save(Dictionary <string, int> dictionary) { CResultAErreur result = CResultAErreur.True; if (!m_bHasTypesLimites) { return(result); } DateTime dateNow = DateTime.Now; foreach (KeyValuePair <string, int> kvp in dictionary) { CLicenceTypePrtct type = m_LicenceLogiciel.GetTypeProtege(kvp.Key); if (type != null)//on sauvegarde que des types limités par la licence { CNombreUtilisePourTypeLicence record = FindExistingRecord(type.Nom); if (record == null) { CNombreUtilisePourTypeLicence addRecord = new CNombreUtilisePourTypeLicence(kvp.Key, kvp.Value); m_listRecords.Add(addRecord); } else { int indx = m_listRecords.IndexOf(record); m_listRecords.RemoveAt(indx); record.NombreUtilise += kvp.Value; m_listRecords.Add(record); } FreeElements(kvp.Key, kvp.Value);//les modif. sont commitées, on les efface de m_CreationsEnCours } } return(result); }
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; } }