public CDefinitionProprieteDynamique[] GetDefinitionsChamps(CObjetPourSousProprietes objet, CDefinitionProprieteDynamique defParente) { List <CDefinitionProprieteDynamique> lstProps = new List <CDefinitionProprieteDynamique>(); if (objet == null) { return(lstProps.ToArray()); } Type tp = objet.TypeAnalyse; if (tp == null) { return(lstProps.ToArray()); } if (!C2iFactory.IsInit()) { return(lstProps.ToArray()); } CContexteDonnee contexte = CContexteDonneeSysteme.GetInstance(); CListeObjetsDonnees liste = new CListeObjetsDonnees(contexte, typeof(CSmartField)); liste.Filtre = new CFiltreData(CSmartField.c_champTypeCible + "=@1", tp.ToString()); foreach (CSmartField champ in liste) { CDefinitionProprieteDynamiqueSmartField def = new CDefinitionProprieteDynamiqueSmartField(champ); def.HasSubProperties = CFournisseurGeneriqueProprietesDynamiques.HasSubProperties(def.TypeDonnee.TypeDotNetNatif); def.Rubrique = champ.Categorie; lstProps.Add(def); } return(lstProps.ToArray()); }
private void FillListeConnectes() { IGestionnaireSessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions)); CInfoSessionAsDynamicClass[] sessions = gestionnaire.GetInfosSessionsActives(); m_listeSessions = new List <CInfoSessionAsDynamicClass>(); foreach (CInfoSessionAsDynamicClass session in sessions) { if (!session.IsSystem || !m_chkHideSystem.Checked) { m_listeSessions.Add(session); } } m_wndListeSession.Remplir(m_listeSessions, false); foreach (ListViewItem item in m_wndListeSession.Items) { CInfoSessionAsDynamicClass info = item.Tag as CInfoSessionAsDynamicClass; if (info != null && info.Invalide) { item.BackColor = m_pictInvalide.BackColor; } if (info != null && info.IdSession == CTimosApp.SessionClient.IdSession) { item.BackColor = m_pictCurrent.BackColor; } if (info != null && info.DureeInactivité.Duree.Hours >= 4) { item.BackColor = m_pictInactif.BackColor; } } }
public CDefinitionProprieteDynamique[] GetDefinitionsChamps(CObjetPourSousProprietes objet, CDefinitionProprieteDynamique defParente) { List <CDefinitionProprieteDynamique> lstProps = new List <CDefinitionProprieteDynamique>(); if (objet == null) { return(lstProps.ToArray()); } Type tp = objet.TypeAnalyse; if (tp == null) { return(lstProps.ToArray()); } if (!C2iFactory.IsInit()) { return(lstProps.ToArray()); } CContexteDonnee contexte = CContexteDonneeSysteme.GetInstance(); CListeObjetsDonnees listeEntites = new CListeObjetsDonnees(contexte, typeof(CListeEntites)); listeEntites.Filtre = new CFiltreData( CListeEntites.c_champTypeElementSourceDeRecherche + "=@1", tp.ToString()); foreach (CListeEntites liste in listeEntites) { CDefinitionProprieteDynamiqueListeEntites def = new CDefinitionProprieteDynamiqueListeEntites(liste); def.Rubrique = I.T("Lists|60"); lstProps.Add(def); } return(lstProps.ToArray()); }
/// ////////////////////////////////////////////////////////////// protected override sc2i.common.CResultAErreur MyExecute(CContexteExecutionAction contexte) { CResultAErreur result = CResultAErreur.True; IDeclencheurActionSurServeur declencheur = (IDeclencheurActionSurServeur)C2iFactory.GetNewObjetForSession("CDeclencheurActionSurServeur", typeof(IDeclencheurActionSurServeur), contexte.IdSession); if (declencheur == null) { result.EmpileErreur(I.T("Release action allocation server fail|187")); return(result); } CContexteEvaluationExpression contexteEval = new CContexteEvaluationExpression(Process); contexteEval.AttacheObjet(typeof(CContexteDonnee), contexte.ContexteDonnee); Hashtable valeursParametres = new Hashtable(); foreach (DictionaryEntry entry in m_tableValeursParametres) { string strProp = (string)entry.Key; C2iExpression expression = (C2iExpression)entry.Value; //Cherche la propriété result = expression.Eval(contexteEval); if (!result) { result.EmpileErreur(I.T("Error during @1 value evaluation|188", entry.Key.ToString())); return(result); } valeursParametres[entry.Key] = result.Data; } return(declencheur.ExecuteAction(m_strCodeActionServeur, valeursParametres)); }
//------------------------------------------------------------------------------------------- public CResultAErreurType <CSessionImport> DoImportSurServeur( int nIdSession, DataTable tableSource, COptionExecutionSmartImport options, IIndicateurProgression indicateur) { ISmartImporterAgent st = C2iFactory.GetNewObjetForSession("CSmartImporterAgent", typeof(ISmartImporterAgent), nIdSession) as ISmartImporterAgent; CResultAErreurType <CSessionImport> result = st.DoSmartImport(tableSource, this, options, indicateur); return(result); }
/// <summary> /// Le data du result contient un datatable avec la structure du résultat /// </summary> /// <param name="nIdSession"></param> /// <returns></returns> public CResultAErreur GetStructureResultat(int nIdSession) { I2iRequeteServeur objetServeur = (I2iRequeteServeur)C2iFactory.GetNewObjetForSession("C2iRequeteServeur", typeof(I2iRequeteServeur), nIdSession); IElementAVariablesDynamiquesAvecContexteDonnee elementAVariable = this; if (m_elementAVariablesExterne != null) { elementAVariable = m_elementAVariablesExterne; } return(objetServeur.ExecuteRequete(this, elementAVariable, true)); }
/// <summary> /// Le data du result contient un datatable avec le résulat de la requête /// </summary> /// <param name="nIdSession"></param> /// <returns></returns> public CResultAErreur ExecuteRequete(int nIdSession) { I2iRequeteAvanceeServeur objetServeur = (I2iRequeteAvanceeServeur)C2iFactory.GetNewObjetForSession("C2iRequeteAvanceeServeur", typeof(I2iRequeteAvanceeServeur), nIdSession); CResultAErreur result = objetServeur.ExecuteRequete(this); if (!result) { return(result); } result.Data = ((CDataTableFastSerialize)result.Data).DataTableObject; return(result); }
public static bool RefreshFromSNMP(object obj) { CEquipementLogique eqpt = obj as CEquipementLogique; if (eqpt == null) { return(false); } CSpvEquip eqptSpv = CSpvEquip.GetObjetSpvFromObjetTimos(eqpt); if (eqptSpv == null) { return(false); } string strIP = eqptSpv.AdresseIP; string strCommunaute = eqptSpv.CommunauteSnmp; CChampCustom[] lstChamps = eqpt.TousLesChamps; string strOldContexteModif = eqpt.ContexteDonnee.IdModificationContextuelle;; eqpt.ContexteDonnee.IdModificationContextuelle = CSpvChampCustomSNMP.c_contexteModificationRefreshFromSNMP; IRequeteSNMPServeur requeteurServeur = C2iFactory.GetNewObjetForSession("CRequeteSNMPServeur", typeof(IRequeteSNMPServeur), eqpt.ContexteDonnee.IdSession) as IRequeteSNMPServeur; foreach (CChampCustom champ in lstChamps) { CSpvChampCustomSNMP champSNMP = CSpvChampCustomSNMP.GetObjetSpvFromObjetTimos(champ); if (champSNMP != null && champSNMP.OID != null && champSNMP.OID.Length > 0 && champSNMP.FormuleIndex != null) { CContexteEvaluationExpression ctxFormule = new CContexteEvaluationExpression(eqpt); CResultAErreur result = champSNMP.FormuleIndex.Eval(ctxFormule); if (result) { try { int nIndex = Convert.ToInt32(result.Data); string strOid = champSNMP.OID + "." + nIndex.ToString(); CRequeteSnmpOID requete = new CRequeteSnmpOID(strIP, strCommunaute, strOid); result = requeteurServeur.GetValue(requete); if (result) { eqpt.SetValeurChamp(champ, result.Data); } } catch {} } } } eqpt.ContexteDonnee.IdModificationContextuelle = strOldContexteModif; return(true); }
/// ////////////////////////////////////////// public override CResultAErreur MyEval(CContexteEvaluationExpression ctx, object[] listeParametres) { CResultAErreur result = CResultAErreur.True; try { IDatabaseRegistre registre = (IDatabaseRegistre)C2iFactory.GetNew2iObjetServeur(typeof(IDatabaseRegistre), CSessionClient.GetSessionUnique().IdSession); result.Data = registre.GetValeurString(listeParametres[0].ToString(), listeParametres[1].ToString()); return(result); } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); return(result); } }
/// ////////////////////////////////////////// public override CResultAErreur MyEval(CContexteEvaluationExpression ctx, object[] valeursParametres) { CResultAErreur result = CResultAErreur.True; try { IGestionnaireSessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions)); CInfoSessionAsDynamicClass[] infos = gestionnaire.GetInfosSessionsActives(); result.Data = infos; return(result); } catch { result.EmpileErreur(I.T("Error while retrieving active sessions|20056")); } return(result); }
//----------------------------------------------------------------------------------------------- public IEnumerable <CDefinitionProprieteDynamique> GetDefinitionsFonctionsSupplementaires(CObjetPourSousProprietes objet) { List <CDefinitionProprieteDynamique> lstProps = new List <CDefinitionProprieteDynamique>(); if (objet == null) { return(lstProps.ToArray()); } Type tp = objet.TypeAnalyse; if (tp == null) { return(lstProps.ToArray()); } if (!C2iFactory.IsInit()) { return(lstProps.ToArray()); } CContexteDonnee contexte = CContexteDonneeSysteme.GetInstance(); CListeObjetsDonnees liste = new CListeObjetsDonnees(contexte, typeof(CFonctionDynamiqueInDb)); liste.Filtre = new CFiltreData(CFonctionDynamiqueInDb.c_champTypeObjets + "=@1", tp.ToString()); foreach (CFonctionDynamiqueInDb fonctionInDb in liste) { CFonctionDynamique fonction = fonctionInDb.Fonction; if (fonction != null) { CDefinitionFonctionDynamique def = new CDefinitionFonctionDynamique(fonction); if (fonctionInDb.Categorie.Length == 0) { def.Rubrique = I.T("Methods|58"); } else { def.Rubrique = fonctionInDb.Categorie; } lstProps.Add(def); } } return(lstProps.ToArray()); }
//---------------------------------------------------------------------------------- public CResultAErreur Export(int nIdSession, IEnumerable list, ref DataSet ds, IElementAVariablesDynamiquesAvecContexteDonnee elementAVariablesPourFiltre, IIndicateurProgression indicateur) { if (list is CListeObjetsDonnees && m_bTraitementSurServeur) { CResultAErreur result = CResultAErreur.True; CStringSerializer serializer = new CStringSerializer(ModeSerialisation.Ecriture); I2iSerializable listeToSerialize = (I2iSerializable)list; result = serializer.TraiteObject(ref listeToSerialize); if (!result) { return(result); } I2iExporteurSurServeur exporteur = ( I2iExporteurSurServeur )C2iFactory.GetNewObjetForSession("C2iExporteurSurServeur", typeof(I2iExporteurSurServeur), nIdSession); try { result = exporteur.ExportData(serializer.String, this, elementAVariablesPourFiltre, indicateur); if (result) { ds = (DataSet)result.Data; } } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); result.EmpileErreur(I.T("Error during the export on the server|101")); } return(result); } if (IsStructureComplexe) { return(ExportComplexe(nIdSession, list, ref ds, elementAVariablesPourFiltre, indicateur)); } else { return(ExportSimple(nIdSession, list, ref ds, indicateur)); } }
/// //////////////////////////////////////////////////////// protected override CResultAErreur MyExecute(CContexteExecutionAction contexte) { CResultAErreur result = CResultAErreur.True; //Calcule la nouvelle valeur CContexteEvaluationExpression contexteEval = new CContexteEvaluationExpression(Process); contexteEval.AttacheObjet(typeof(CContexteDonnee), contexte.ContexteDonnee); result = ExpressionValeur.Eval(contexteEval); if (!result) { result.EmpileErreur(I.T("Error during @1 formula evaluation|216", ExpressionValeur.ToString())); return(result); } object nouvelleValeur = result.Data; IDatabaseRegistre registre = (IDatabaseRegistre)C2iFactory.GetNew2iObjetServeur(typeof(IDatabaseRegistre), contexte.IdSession); registre.SetValeur(m_strCleRegistre, nouvelleValeur == null?"":nouvelleValeur.ToString()); return(result); }
private void AssureMenu( ) { if (DesignMode) { return; } if (m_menuCustom == null && !DesignMode) { IDatabaseRegistre registre = (IDatabaseRegistre)C2iFactory.GetNew2iObjetServeur(typeof(IDatabaseRegistre), CTimosApp.SessionClient.IdSession); int nId = (int)registre.GetValeurLong(c_cleRegistre, -1); m_menuCustom = new CMenuCustom(CSc2iWin32DataClient.ContexteCourant); if (!m_menuCustom.ReadIfExists(nId)) { // Si l'ID n'éxiste pas alors on cherche par une requette pour être sûr CListeObjetsDonnees listeMenus = new CListeObjetsDonnees( CSc2iWin32DataClient.ContexteCourant, typeof(CMenuCustom), new CFiltreData(CMenuCustom.c_champIdMenuParent + " IS NULL")); if (listeMenus.Count >= 1) { // On a trouvé le premier menu sans parent m_menuCustom = (CMenuCustom)listeMenus[0]; } else { //Construction du menu par défaut m_menuCustom.CreateNew(); m_menuCustom.Libelle = I.T("Home|714"); m_menuCustom.Action = null; AddMenuStandard(m_menuCustom, I.T("Assets management|1"), typeof(CFormMenuPatrimoine)); AddMenuStandard(m_menuCustom, I.T("Organisation|4"), typeof(CFormMenuOrganisation)); AddMenuStandard(m_menuCustom, I.T("Maintenance|8"), typeof(CFormMenuMaintenance)); AddMenuStandard(m_menuCustom, I.T("Engineering|6"), typeof(CFormMenuIngenierie)); AddMenuStandard(m_menuCustom, I.T("Configuration|7"), typeof(CFormMenuConfiguration)); m_menuCustom.CommitEdit(); registre.SetValeur(c_cleRegistre, m_menuCustom.Id.ToString()); } } } }
/// ////////////////////////////////////////// public override CResultAErreur MyEval(CContexteEvaluationExpression ctx, object[] valeursParametres) { CResultAErreur result = CResultAErreur.True; try { ISynchroMediation synchro = C2iFactory.GetNewObjetForSession("CSynchroMediation", typeof(ISynchroMediation), 0) as ISynchroMediation; result = synchro.DoSynchro(); if (result) { result.Data = true; } else { result.Data = false; } } catch (Exception e) { result.EmpileErreur(new CErreurException(e)); } return(result); }
public CResultAErreur SetValueSNMP(CContexteDonnee contexte, object valeur) { CResultAErreur result = CResultAErreur.True; IRequeteSNMPServeur requeteurServeur = C2iFactory.GetNewObjetForSession("CRequeteSNMPServeur", typeof(IRequeteSNMPServeur), contexte.IdSession) as IRequeteSNMPServeur; if (requeteurServeur == null) { result.EmpileErreur(I.T("Can not instanciate SNMP Query server|20001")); return(result); } result = GetRequeteSNMPOID(contexte); if (!result) { return(result); } CRequeteSnmpOID requeteOID = result.Data as CRequeteSnmpOID; if (requeteOID == null) { result.EmpileErreur(I.T("Error while creating OID SNMP QUERY|20005")); return(result); } return(requeteurServeur.SetValue(requeteOID, valeur)); }
public CDefinitionProprieteDynamique[] GetDefinitionsChamps(CObjetPourSousProprietes objet, CDefinitionProprieteDynamique defParente) { List <CDefinitionProprieteDynamique> lstProps = new List <CDefinitionProprieteDynamique>(); if (objet == null) { return(lstProps.ToArray()); } Type tp = objet.TypeAnalyse; if (tp == null) { return(lstProps.ToArray()); } if (!C2iFactory.IsInit()) { return(lstProps.ToArray()); } CContexteDonnee contexte = CContexteDonneeSysteme.GetInstance(); CListeObjetsDonnees liste = new CListeObjetsDonnees(contexte, typeof(CChampCalcule)); liste.Filtre = new CFiltreData(CChampCalcule.c_champTypeObjets + "=@1", tp.ToString()); foreach (CChampCalcule champ in liste) { CDefinitionProprieteDynamiqueChampCalcule def = new CDefinitionProprieteDynamiqueChampCalcule(champ); def.HasSubProperties = CFournisseurGeneriqueProprietesDynamiques.HasSubProperties(def.TypeDonnee.TypeDotNetNatif); if (def.Rubrique.Length == 0) { def.Rubrique = I.T("Complementary informations|59"); } lstProps.Add(def); } return(lstProps.ToArray()); }
//------------------------------------------------------------------------------------------------------------------------------- public DataSet GetListeExportsForCurrentUser() { AspectizeUser aspectizeUser = ExecutingContext.CurrentUser; IEntityManager em = EntityManager.FromDataSet(DataSetHelper.Create()); if (aspectizeUser.IsAuthenticated) { int nTimosSessionId = (int)aspectizeUser[CUserTimosWebApp.c_champSessionId]; string keyUser = (string)aspectizeUser[CUserTimosWebApp.c_champUserKey]; ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize)); CResultAErreur result = serviceClientAspectize.GetSession(nTimosSessionId); if (!result) { throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter"); } try { result = serviceClientAspectize.GetExportsForUser(nTimosSessionId, keyUser); if (!result) { throw new SmartException(1010, "Erreur GetExportsForUser(nTimosSessionId = " + nTimosSessionId + ", keyUser = "******")" + Environment.NewLine + result.MessageErreur); } if (result && result.Data != null) { DataSet ds = result.Data as DataSet; if (ds != null && ds.Tables.Contains(CExportWeb.c_nomTable)) { DataTable dt = ds.Tables[CExportWeb.c_nomTable]; foreach (DataRow row in dt.Rows) { var export = em.CreateInstance <Export>(); export.Id = (string)row[CExportWeb.c_champId]; export.Libelle = (string)row[CExportWeb.c_champLibelle]; export.Description = (string)row[CExportWeb.c_champDescription]; export.UpdatePeriod = (int)row[CExportWeb.c_champPeriode]; var fs = ExecutingContext.GetService <IFileService>("TimosFileService"); string relativePath = export.Id + ".json"; string fullPath = fs.GetFileUrl(relativePath); fullPath = fullPath.Substring(16); if (File.Exists(fullPath)) { export.DataDate = File.GetLastWriteTime(fullPath); } else { export.DataDate = null; } } } em.Data.AcceptChanges(); return(em.Data); } } catch (Exception ex) { throw new SmartException(1010, "Erreur GetExportsForUser(nTimosSessionId = " + nTimosSessionId + ", keyUser = "******")" + Environment.NewLine + ex.Message); } } else { throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter"); } return(null); }
/// ///////////////////////////////////////////////// public static CResultAErreur PurgeEntites(int nIdSession, Type typeObjets, int[] nIds) { IActionSupprimerEntiteServeur objetServeur = (IActionSupprimerEntiteServeur)C2iFactory.GetNewObjetForSession("CActionSupprimerEntiteServeur", typeof(IActionSupprimerEntiteServeur), nIdSession); CResultAErreur result = objetServeur.PurgeEntites(typeObjets, nIds); return(result); }
public CCasteurValeurString ReadRegistre(string strCle, string strValeurParDefaut) { IDatabaseRegistre registre = (IDatabaseRegistre)C2iFactory.GetNew2iObjetServeur(typeof(IDatabaseRegistre), IdSession); return(new CCasteurValeurString(strCle, registre.GetValeurString(strCle, strValeurParDefaut))); }
private void m_lnkFermer_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { if (m_wndListeSession.CheckedItems.Count == 0) { MessageBox.Show(I.T("Check sessions to close first !|20519")); return; } if (MessageBox.Show( I.T("You will send a stop message to @1 sessions. Please confirm this action|20515", m_wndListeSession.CheckedItems.Count.ToString()), I.T("Confirmation|20516"), MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } ArrayList lstThreads = new ArrayList(); m_listeServicesToLaunch.Clear(); m_listeThreadsEnAttente.Clear(); ThreadStart funcStart = new ThreadStart(AskForClose); StringBuilder bl = new StringBuilder(); int nNbSessionsSysteme = 0; foreach (ListViewItem item in m_wndListeSession.CheckedItems) { CInfoSessionAsDynamicClass info = item.Tag as CInfoSessionAsDynamicClass; if (info != null && info.IsSystem) { nNbSessionsSysteme++; bl.Append(info.IdSession); bl.Append(','); } } string strMessage = ""; if (nNbSessionsSysteme > 0) { bl.Remove(bl.Length - 1, 1); if (nNbSessionsSysteme > 1) { strMessage = I.T("Sessions @1 are system sessions and will not be close|20517", bl.ToString()); } else { strMessage = I.T("@1 session is a system session and will not be closed|20518", bl.ToString()); } MessageBox.Show(strMessage); } IGestionnaireSessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions)); foreach (ListViewItem item in m_wndListeSession.CheckedItems) { CInfoSessionAsDynamicClass info = item.Tag as CInfoSessionAsDynamicClass; if (info != null && !info.IsSystem) { int nIdSession = info.IdSession; CSessionClient session = CSessionClient.GetSessionForIdSession(nIdSession); try { if (!info.Invalide) { CServiceSurClientFermerApplication service = (CServiceSurClientFermerApplication)session.GetServiceSurClient(CServiceSurClientFermerApplication.c_idService); if (service != null) { lock (m_listeServicesToLaunch) { m_listeServicesToLaunch.Add(service); } Thread th = new Thread(funcStart); th.Start(); } } else { ISessionClientSurServeur sessionSurServeur = gestionnaire.GetSessionClientSurServeur(info.IdSession); sessionSurServeur.CloseSession(); } } catch { } } } }
//------------------------------------------------------------------------------------------------------------------------- // Authenticate user, using Security Service Configuration AspectizeUser IAuthentication.Authenticate(string userName, string secret, AuthenticationProtocol protocol, HashHelper.Algorithm algorithm, string challenge) { var parts = secret.Split('#'); string otp = parts[0]; //string password = string.Join("#", parts, 1, parts.Length - 1); string password = parts[1]; string state = parts[2]; string messageLog = "== Authenticate Radius Step 2 ==============" + Environment.NewLine + "Timos user name : " + userName + Environment.NewLine + "Radius Host : " + m_strRadiusHost + Environment.NewLine + "Radius Port : " + m_nRadiusPort + Environment.NewLine + "Shared Key : " + m_strRadiusSharedKey + Environment.NewLine + "OTP : " + otp + Environment.NewLine + "STATE : " + state + Environment.NewLine; string reponseRadius = "Request not sent"; if (userName != "youcef") { try { reponseRadius = AdministrationService.AuthenticateRadius(m_strRadiusHost, m_nRadiusPort, m_strRadiusSharedKey, userName, otp, state); messageLog += "Radius response : " + reponseRadius + Environment.NewLine; } catch (Exception ex) { messageLog += "Radius response : " + ex.Message + Environment.NewLine; } Context.Log(InfoType.Information, messageLog); var parts2 = reponseRadius.Split('#'); if (parts2[0] != "2") { return(AspectizeUser.GetUnAuthenticatedUser()); // L'authentification OTP a échoué } } else { messageLog += "Radius response : " + reponseRadius + Environment.NewLine; Context.Log(InfoType.Information, messageLog); } // Authentification TIMOS ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize)); CResultAErreur result = serviceClientAspectize.OpenSession(userName, password); if (result && result.Data is Dictionary <string, object> ) { string strUserKey = ""; // Build Key-Value attached to User Dictionary <string, object> dicoProperties = (Dictionary <string, object>)result.Data; strUserKey = (string)dicoProperties[CUserTimosWebApp.c_champUserKey]; // Build Role List List <string> roles = new List <string>(); roles.Add("Registered"); // Build and return authenticated user with Properties and Roles return(AspectizeUser.GetAuthenticatedUser(strUserKey, roles.ToArray(), dicoProperties)); } return(AspectizeUser.GetUnAuthenticatedUser()); // Fin authentification TIMOS }
private void FillPageNotifications() { IGestionnaireNotification gestionnaire = (IGestionnaireNotification)C2iFactory.GetNewObjetForSession("CGestionnaireNotification", typeof(IGestionnaireNotification), CSessionClient.GetSessionUnique().IdSession); //m_labelNbRecepteursNotification.Text = gestionnaire.GetNbRecepteurs().ToString(); }
private void FillListeConnectes() { IGestionnaireSessions gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions)); int[] listeIdSessions = gestionnaire.GetListeIdSessionsConnectees(); string strNomGestionnaire = gestionnaire.GetType().ToString(); m_listView.Items.Clear(); foreach (int nId in listeIdSessions) { ListViewItem item = new ListViewItem(); item.Tag = nId; while (item.SubItems.Count < m_listView.Columns.Count) { item.SubItems.Add(""); } item.SubItems[colIdSession.Index].Text = nId.ToString(); IInfoSession session = gestionnaire.GetSessionClient(nId); try { session.GetInfoUtilisateur(); } catch { session = gestionnaire.GetSessionClientSurServeur(nId); item.BackColor = Color.Red; session = gestionnaire.GetSessionClientSurServeur(nId); } if (session == null) { item.BackColor = Color.Red; session = gestionnaire.GetSessionClientSurServeur(nId); item.SubItems[colNom.Index].Text = "#ERREUR ACCES"; } try { item.SubItems[colNom.Index].Text = session.GetInfoUtilisateur().NomUtilisateur; item.SubItems[colAppli.Index].Text = session.DescriptionApplicationCliente; item.SubItems[colType.Index].Text = session.TypeApplicationCliente.ToString(); DateTime dt = session.DateHeureConnexion; TimeSpan span = DateTime.Now - dt; string strChaine = ""; if (span.TotalDays > 1) { strChaine = ((int)span.TotalDays).ToString() + "j"; } if (span.TotalHours > 0) { strChaine += ((int)(span.TotalHours % 24)).ToString() + "h"; } strChaine += ((int)(span.TotalMinutes % 60)).ToString() + "m"; item.SubItems[colHeure.Index].Text = strChaine; string strKeyUtilisateur = ""; if (session.GetInfoUtilisateur().KeyUtilisateur != null) { strKeyUtilisateur = session.GetInfoUtilisateur().KeyUtilisateur.StringValue; item.SubItems[colIdUser.Index].Text = strKeyUtilisateur; CContexteDonnee ctx = new CContexteDonnee(session.IdSession, true, false); CDonneesActeurUtilisateur user = CUtilSession.GetUserForSession(ctx); if (user != null) { CListeObjetsDonnees lstEtapesPourActeur = user.Acteur.GetEtapeWorkflowsEnCours(); int nbTodo = lstEtapesPourActeur.Count; item.SubItems[colNbToDo.Index].Text = nbTodo.ToString(); } } } catch { if (nId == 0) { item.SubItems[colNom.Index].Text = "SERVEUR"; } else { item.BackColor = Color.Red; item.SubItems[colNom.Index].Text = "#ERREUR ACCES#"; } } if (nId == CSessionClient.GetSessionUnique().IdSession) { item.BackColor = Color.LightGreen; } m_listView.Items.Add(item); } }
public static List <CInfoLicenceUserProfil> GetProfilsPossibles(int nIdSession) { if (m_profils == null) { IGestionnaireProfilLicence gestionnaire = (IGestionnaireProfilLicence)C2iFactory.GetNewObjetForSession("CGestionnaireProfilLicence", typeof(IGestionnaireProfilLicence), nIdSession); m_profils = gestionnaire.GetProfilsPossibles(); } return(new List <CInfoLicenceUserProfil>(m_profils)); }
public CDefinitionProprieteDynamique[] GetDefinitionsChamps(CObjetPourSousProprietes objet, CDefinitionProprieteDynamique defParente) { List <CDefinitionProprieteDynamique> lstProps = new List <CDefinitionProprieteDynamique>(); if (objet == null) { return(lstProps.ToArray()); } Type tp = objet.TypeAnalyse; if (tp == null) { return(lstProps.ToArray()); } if (!C2iFactory.IsInit()) { return(lstProps.ToArray()); } //Champs custom CRoleChampCustom role = CRoleChampCustom.GetRoleForType(tp); CRestrictionUtilisateurSurType rest = null; CSessionClient session = CSessionClient.GetSessionUnique(); if (session != null) { IInfoUtilisateur info = session.GetInfoUtilisateur(); if (info != null) { rest = info.GetRestrictionsSur(tp, null); } } if (role != null) { CContexteDonnee contexte = CContexteDonneeSysteme.GetInstance(); CListeObjetsDonnees listeChamps = CChampCustom.GetListeChampsForRole(contexte, role.CodeRole); foreach (CChampCustom champ in listeChamps) { if (rest != null) { ERestriction restChamp = rest.GetRestriction(champ.CleRestriction); if ((restChamp & ERestriction.Hide) == ERestriction.Hide) { continue; } } if (champ.ListeValeurs.Count > 0) { CDefinitionProprieteDynamiqueChampCustomDisplayValue def = new CDefinitionProprieteDynamiqueChampCustomDisplayValue(champ); if (champ.Categorie.Trim() != "") { def.Rubrique = champ.Categorie; } else { def.Rubrique = I.T("Complementary informations|59"); } lstProps.Add(def); } } } return(lstProps.ToArray()); }
//------------------------------------------------------------------------------------------------------------------------------- public byte[] GetExportForExcel(string keyExport, string strLibelle) { AspectizeUser aspectizeUser = ExecutingContext.CurrentUser; IEntityManager em = EntityManager.FromDataSet(DataSetHelper.Create()); if (aspectizeUser.IsAuthenticated) { int nTimosSessionId = (int)aspectizeUser[CUserTimosWebApp.c_champSessionId]; ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize)); CResultAErreur result = serviceClientAspectize.GetSession(nTimosSessionId); if (!result) { throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter"); } try { IFileService fs = ExecutingContext.GetService <IFileService>("TimosFileService"); string relativePath = keyExport + ".json"; string fullPath = fs.GetFileUrl(relativePath); fullPath = fullPath.Substring(16); if (File.Exists(fullPath)) { byte[] buffer = fs.ReadBytes(relativePath); string jsonLecture = Encoding.ASCII.GetString(buffer); DataSet dsExport = JsonConvert.DeserializeObject <DataSet>(jsonLecture); if (dsExport != null) { IAspectizeExcel aspectizeExcel = ExecutingContext.GetService <IAspectizeExcel>("AspectizeExcel"); var bytes = aspectizeExcel.ToExcel(dsExport, null); ExecutingContext.SetHttpDownloadFileName(string.Format(strLibelle + " {0:yyyyMMddHHmm}.xlsx", File.GetLastWriteTime(fullPath))); return(bytes); } } } catch (Exception ex) { throw new SmartException(1010, "Erreur GetExportForExcel(nTimosSessionId = " + nTimosSessionId + ", keyExport = " + keyExport + ")" + Environment.NewLine + ex.Message); } } else { throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter"); } return(new byte[] { }); }
//------------------------------------------------------------------------------------------------------------------------------- public void UpdateAllExports() { try { ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize)); CResultAErreur result = serviceClientAspectize.GetExportsForUser(0, ""); if (result && result.Data != null) { DataSet ds = result.Data as DataSet; if (ds != null && ds.Tables.Contains(CExportWeb.c_nomTable)) { DataTable dt = ds.Tables[CExportWeb.c_nomTable]; foreach (DataRow row in dt.Rows) { string keyExport = (string)row[CExportWeb.c_champId]; string strLibelleExport = (string)row[CExportWeb.c_champLibelle]; int nUpdatePeriod = (int)row[CExportWeb.c_champPeriode]; try { // On vérifie la période de rafraichissement (en heures) var fs = ExecutingContext.GetService <IFileService>("TimosFileService"); string relativePath = keyExport + ".json"; string fullPath = fs.GetFileUrl(relativePath); fullPath = fullPath.Substring(16); if (File.Exists(fullPath)) { DateTime lastDataDate = File.GetLastWriteTime(fullPath); TimeSpan span = DateTime.Now - lastDataDate; if (span.TotalHours < nUpdatePeriod) { continue; } } result = serviceClientAspectize.GetDataSetExport(0, keyExport); if (!result) { Context.Log(InfoType.Warning, "Erreur GetDataSetExport(" + keyExport + ")" + Environment.NewLine + "Export label : " + strLibelleExport + Environment.NewLine + result.MessageErreur); } if (result && result.Data != null) { DataSet dsExport = result.Data as DataSet; if (dsExport != null && dsExport.Tables.Count > 0) { DataTable dtExport = dsExport.Tables[0]; string json = JsonConvert.SerializeObject(dsExport, Formatting.None); MemoryStream stream = new MemoryStream(Encoding.ASCII.GetBytes(json)); fs.Write(relativePath, stream); } } } catch (Exception ex) { Context.Log(InfoType.Warning, "Erreur GetDataSetExport(" + keyExport + ")" + Environment.NewLine + "Export label : " + strLibelleExport + Environment.NewLine + ex.Message); } } } } } catch (Exception ex) { Context.Log(InfoType.Warning, ex.Message); } }
//------------------------------------------------------------------------------------------------------------------------------- public DataSet GetExportForDisplay(string keyExport, string strLibelle, string strDescription) { AspectizeUser aspectizeUser = ExecutingContext.CurrentUser; IEntityManager em = EntityManager.FromDataSet(DataSetHelper.Create()); if (aspectizeUser.IsAuthenticated) { int nTimosSessionId = (int)aspectizeUser[CUserTimosWebApp.c_champSessionId]; ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize)); CResultAErreur result = serviceClientAspectize.GetSession(nTimosSessionId); if (!result) { throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter"); } try { IFileService fs = ExecutingContext.GetService <IFileService>("TimosFileService"); string relativePath = keyExport + ".json"; string fullPath = fs.GetFileUrl(relativePath); fullPath = fullPath.Substring(16); if (File.Exists(fullPath)) { byte[] buffer = fs.ReadBytes(relativePath); string jsonLecture = Encoding.ASCII.GetString(buffer); DataSet dsExport = JsonConvert.DeserializeObject <DataSet>(jsonLecture); if (dsExport != null && dsExport.Tables.Count > 0) { Export export = em.CreateInstance <Export>(); export.Id = keyExport; export.Libelle = strLibelle; export.Description = strDescription; export.DataDate = File.GetLastWriteTime(fullPath); // Extraction des données du DataSet DataTable tableExport = dsExport.Tables[0]; // On traite uniquement la première table int nIndexCol = 1; // Les 10 premières colonnes uniquement foreach (DataColumn col in tableExport.Columns) { export.data["COL" + nIndexCol] = col.ColumnName; nIndexCol++; if (nIndexCol > 10) { break; } } // Traitement des données (lignes) int nIndexRow = 0; foreach (DataRow row in tableExport.Rows) { string strIdCompose = keyExport + "#" + nIndexRow++; ExportDatas expData = em.GetInstance <ExportDatas>(strIdCompose); if (expData == null) { expData = em.CreateInstance <ExportDatas>(); expData.Id = strIdCompose; em.AssociateInstance <RelationExportDatas>(export, expData); } for (int i = 0; i < tableExport.Columns.Count && i < 10; i++) { if (row[i] == DBNull.Value) { expData.data[i + 1] = ""; } else { expData.data[i + 1] = row[i]; } } } } } } catch (Exception ex) { throw new SmartException(1010, "Erreur GetExportForDisplay(nTimosSessionId = " + nTimosSessionId + ", keyExport = " + keyExport + ")" + Environment.NewLine + ex.Message); } } else { throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter"); } em.Data.AcceptChanges(); return(em.Data); }
//------------------------------------------------------------------------------------------------------------------------------- public bool GetDataSetExport(string keyExport) { AspectizeUser aspectizeUser = ExecutingContext.CurrentUser; IEntityManager em = EntityManager.FromDataSet(DataSetHelper.Create()); if (aspectizeUser.IsAuthenticated) { int nTimosSessionId = (int)aspectizeUser[CUserTimosWebApp.c_champSessionId]; ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize)); CResultAErreur result = serviceClientAspectize.GetSession(nTimosSessionId); if (!result) { throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter"); } try { result = serviceClientAspectize.GetDataSetExport(nTimosSessionId, keyExport); if (!result) { throw new SmartException(1010, "Erreur GetDataSetExport(nTimosSessionId = " + nTimosSessionId + ", keyExport = " + keyExport + ")" + Environment.NewLine + result.MessageErreur); } if (result && result.Data != null) { DataSet ds = result.Data as DataSet; if (ds != null && ds.Tables.Count > 0) { var fs = ExecutingContext.GetService <IFileService>("TimosFileService"); string relativePath = keyExport + ".json"; string json = JsonConvert.SerializeObject(ds, Formatting.None); MemoryStream stream = new MemoryStream(Encoding.ASCII.GetBytes(json)); fs.Write(relativePath, stream); } } } catch (Exception ex) { throw new SmartException(1010, "Erreur GetExportsForUser(nTimosSessionId = " + nTimosSessionId + ", keyExport = " + keyExport + ")" + Environment.NewLine + ex.Message); } } else { throw new SmartException(1100, "Votre session a expiré, veuillez vous reconnecter"); } return(true); }