Пример #1
0
        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;
                }
            }
        }
Пример #2
0
        /// //////////////////////////////////////////
        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);
        }
Пример #3
0
        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
                    {
                    }
                }
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
        //-------------------------------------------------------------------------------------------------------------------------------
        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[] { });
        }
Пример #6
0
        //-------------------------------------------------------------------------------------------------------------------------------
        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);
            }
        }
Пример #7
0
        //-------------------------------------------------------------------------------------------------------------------------------
        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);
        }
Пример #8
0
        //-------------------------------------------------------------------------------------------------------------------------------
        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);
        }
Пример #9
0
        //-------------------------------------------------------------------------------------------------------------------------------
        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);
        }
Пример #10
0
        //-------------------------------------------------------------------------------------------------------------------------
        // 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
        }
Пример #11
0
        //-------------------------------------------------------------------------------------------------------------------------
        public void LogoutUser()
        {
            AspectizeUser             aspectizeUser          = ExecutingContext.CurrentUser;
            int                       nIdsession             = (int)aspectizeUser[CUserTimosWebApp.c_champSessionId];
            ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize));

            serviceClientAspectize.CloseSession(nIdsession);
        }
Пример #12
0
        //-------------------------------------------------------------------------------------------------------------------------
        // Get Profile (ie initial DataSet) of user, authenticated or not
        DataSet IUserProfile.GetUserProfile()
        {
            // Get current user
            AspectizeUser aspectizeUser = ExecutingContext.CurrentUser;

            if (aspectizeUser.IsAuthenticated)
            {
                IEntityManager em = EntityManager.FromDataSet(DataSetHelper.Create());

                // Initialise l'utilisateur connecté
                var user = em.CreateInstance <User>();
                user.IsAuthentificated = true;
                user.Name            = (string)aspectizeUser[CUserTimosWebApp.c_champUserName];
                user.Login           = (string)aspectizeUser[CUserTimosWebApp.c_champUserLogin];
                user.TimosKey        = (string)aspectizeUser[CUserTimosWebApp.c_champUserKey];
                user.TimosSessionId  = (int)aspectizeUser[CUserTimosWebApp.c_champSessionId];
                user.IsAdministrator = (bool)aspectizeUser[CUserTimosWebApp.c_champIsAdministrator];

                // Instancie les To do de l'utilisateur en cours
                ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize));
                CResultAErreur            result = serviceClientAspectize.GetTodosForUser(user.TimosSessionId, user.TimosKey);

                if (result && result.Data != null)
                {
                    DataSet ds = result.Data as DataSet;
                    if (ds != null && ds.Tables.Contains(CTodoTimosWebApp.c_nomTable))
                    {
                        DataTable dt = ds.Tables[CTodoTimosWebApp.c_nomTable];

                        foreach (DataRow row in dt.Rows)
                        {
                            var todo = em.CreateInstance <Todos>();
                            todo.TimosId            = (int)row[CTodoTimosWebApp.c_champId];
                            todo.Label              = (string)row[CTodoTimosWebApp.c_champLibelle];
                            todo.StartDate          = (DateTime)row[CTodoTimosWebApp.c_champDateDebut];
                            todo.Instructions       = (string)row[CTodoTimosWebApp.c_champInstructions];
                            todo.ElementType        = (string)row[CTodoTimosWebApp.c_champTypeElementEdite];
                            todo.ElementId          = (int)row[CTodoTimosWebApp.c_champIdElementEdite];
                            todo.ElementDescription = (string)row[CTodoTimosWebApp.c_champElementDescription];
                            todo.DureeStandard      = (int)row[CTodoTimosWebApp.c_champDureeStandard];
                            int nEtat = (int)row[CTodoTimosWebApp.c_champEtatTodo];
                            todo.EtatTodo = (EtatTodo)nEtat;
                            if (row[CTodoTimosWebApp.c_champDateFin] == DBNull.Value)
                            {
                                todo.EndDate = null;
                            }
                            else
                            {
                                todo.EndDate = (DateTime)row[CTodoTimosWebApp.c_champDateFin];
                            }
                        }
                    }
                }

                // Récupère la liste des Actions globales disponibles pour cet utilisateur
                try
                {
                    result = serviceClientAspectize.GetActionsForUser(user.TimosSessionId, user.TimosKey);
                    if (!result)
                    {
                        throw new SmartException(1010, "Erreur GetExportsForUser(nTimosSessionId = " + user.TimosSessionId + ", keyUser = "******")" +
                                                 Environment.NewLine +
                                                 result.MessageErreur);
                    }

                    if (result && result.Data != null)
                    {
                        DataSet ds = result.Data as DataSet;

                        if (ds != null && ds.Tables.Contains(CActionWeb.c_nomTable))
                        {
                            DataTable dt = ds.Tables[CActionWeb.c_nomTable];

                            foreach (DataRow row in dt.Rows)
                            {
                                var action = em.CreateInstance <Action>();
                                action.Id           = (int)row[CActionWeb.c_champId];
                                action.Libelle      = (string)row[CActionWeb.c_champLibelle];
                                action.Instructions = (string)row[CActionWeb.c_champInstructions];
                                action.IsGlobale    = (bool)row[CActionWeb.c_champIsGlobale];
                                action.HasForm      = (bool)row[CActionWeb.c_champHasForm];

                                // Variables Texte
                                action.IDT1 = (string)row[CActionWeb.c_champIdVarText1];
                                action.IDT2 = (string)row[CActionWeb.c_champIdVarText2];
                                action.IDT3 = (string)row[CActionWeb.c_champIdVarText3];
                                action.IDT4 = (string)row[CActionWeb.c_champIdVarText4];
                                action.IDT5 = (string)row[CActionWeb.c_champIdVarText5];
                                action.IDT6 = (string)row[CActionWeb.c_champIdVarText6];
                                action.IDT7 = (string)row[CActionWeb.c_champIdVarText7];
                                action.IDT8 = (string)row[CActionWeb.c_champIdVarText8];
                                action.IDT9 = (string)row[CActionWeb.c_champIdVarText9];

                                action.LBLT1 = (string)row[CActionWeb.c_champLabelVarText1];
                                action.LBLT2 = (string)row[CActionWeb.c_champLabelVarText2];
                                action.LBLT3 = (string)row[CActionWeb.c_champLabelVarText3];
                                action.LBLT4 = (string)row[CActionWeb.c_champLabelVarText4];
                                action.LBLT5 = (string)row[CActionWeb.c_champLabelVarText5];
                                action.LBLT6 = (string)row[CActionWeb.c_champLabelVarText6];
                                action.LBLT7 = (string)row[CActionWeb.c_champLabelVarText7];
                                action.LBLT8 = (string)row[CActionWeb.c_champLabelVarText8];
                                action.LBLT9 = (string)row[CActionWeb.c_champLabelVarText9];

                                string strValeursVarText1 = (string)row[CActionWeb.c_champValeursVarText1];
                                string strValeursVarText2 = (string)row[CActionWeb.c_champValeursVarText2];
                                string strValeursVarText3 = (string)row[CActionWeb.c_champValeursVarText3];
                                string strValeursVarText4 = (string)row[CActionWeb.c_champValeursVarText4];
                                string strValeursVarText5 = (string)row[CActionWeb.c_champValeursVarText5];
                                string strValeursVarText6 = (string)row[CActionWeb.c_champValeursVarText6];
                                string strValeursVarText7 = (string)row[CActionWeb.c_champValeursVarText7];
                                string strValeursVarText8 = (string)row[CActionWeb.c_champValeursVarText8];
                                string strValeursVarText9 = (string)row[CActionWeb.c_champValeursVarText9];

                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText1, "T1");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText2, "T2");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText3, "T3");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText4, "T4");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText5, "T5");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText6, "T6");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText7, "T7");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText8, "T8");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarText9, "T9");

                                // Variables Int
                                action.IDN1  = (string)row[CActionWeb.c_champIdVarInt1];
                                action.IDN2  = (string)row[CActionWeb.c_champIdVarInt2];
                                action.IDN3  = (string)row[CActionWeb.c_champIdVarInt3];
                                action.LBLN1 = (string)row[CActionWeb.c_champLabelVarInt1];
                                action.LBLN2 = (string)row[CActionWeb.c_champLabelVarInt2];
                                action.LBLN3 = (string)row[CActionWeb.c_champLabelVarInt3];

                                string strValeursVarInt1 = (string)row[CActionWeb.c_champValeursVarInt1];
                                string strValeursVarInt2 = (string)row[CActionWeb.c_champValeursVarInt2];
                                string strValeursVarInt3 = (string)row[CActionWeb.c_champValeursVarInt3];
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarInt1, "N1");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarInt2, "N2");
                                TodosService.FillValeursVariableForAction(em, action, strValeursVarInt3, "N3");

                                // Variables Date
                                action.IDD1  = (string)row[CActionWeb.c_champIdVarDate1];
                                action.IDD2  = (string)row[CActionWeb.c_champIdVarDate2];
                                action.IDD3  = (string)row[CActionWeb.c_champIdVarDate3];
                                action.LBLD1 = (string)row[CActionWeb.c_champLabelVarDate1];
                                action.LBLD2 = (string)row[CActionWeb.c_champLabelVarDate2];
                                action.LBLD3 = (string)row[CActionWeb.c_champLabelVarDate3];
                                // Variables Bool
                                action.IDB1  = (string)row[CActionWeb.c_champIdVarBool1];
                                action.IDB2  = (string)row[CActionWeb.c_champIdVarBool2];
                                action.IDB3  = (string)row[CActionWeb.c_champIdVarBool3];
                                action.LBLB1 = (string)row[CActionWeb.c_champLabelVarBool1];
                                action.LBLB2 = (string)row[CActionWeb.c_champLabelVarBool2];
                                action.LBLB3 = (string)row[CActionWeb.c_champLabelVarBool3];
                            }
                        }

                        em.Data.AcceptChanges();
                        return(em.Data);
                    }
                }
                catch (Exception ex)
                {
                    throw new SmartException(1010, "Erreur GetExportsForUser(nTimosSessionId = " + user.TimosSessionId + ", keyUser = "******")" +
                                             Environment.NewLine +
                                             result.MessageErreur);
                }

                em.Data.AcceptChanges();
                return(em.Data);
            }
            // No profile for unanthenticated user
            return(null);
        }
Пример #13
0
        //-------------------------------------------------------------------------------------------------------------------------
        // This Command is called when user is remembered, instead of Authenticate
        bool IPersistentAuthentication.ValidateUser(AspectizeUser user)
        {
            int nIdsession = (int)user[CUserTimosWebApp.c_champSessionId];

            ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize));

            if (serviceClientAspectize.GetSession(nIdsession))
            {
                return(true);
            }

            return(false);
        }
Пример #14
0
        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;
            }
        }
Пример #15
0
        static void Main(string[] args)
        {
            CResultAErreur result        = CResultAErreur.True;
            string         strServeurUrl = "tcp://127.0.0.1:8160";
            int            nTcpChannel   = 0;
            string         strBindTo     = "";

            try
            {
                AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);

                //SUPPRIMé journal d'évenements: sur les postes clients qui ne sont pas autorisés
                //à créer un journal d'évenements, ça bloque, et comme ce n'est pas
                //très important sur un poste client, il n'y a plus
                //de journal d'évenements TIMOS sur les postes clients.
                //C2iEventLog.Init("", "Client Timos", NiveauBavardage.VraiPiplette);

                result = CSC2iMultitiersClient.Init(nTcpChannel, strServeurUrl, strBindTo);

                LifetimeServices.LeaseTime            = new TimeSpan(0, 5, 0);
                LifetimeServices.LeaseManagerPollTime = new TimeSpan(0, 5, 0);
                LifetimeServices.SponsorshipTimeout   = new TimeSpan(0, 3, 0);
                LifetimeServices.RenewOnCallTime      = new TimeSpan(0, 8, 0);

                C2iSponsor.EnableSecurite();

                if (result)
                {
                    /*CSessionClient session = CSessionClient.CreateInstance();
                     *
                     * CAuthentificationSessionTimosLoginPwd authParams = new CAuthentificationSessionTimosLoginPwd(
                     *  "youcef",
                     *  "minutes",
                     *  new CParametresLicence(new List<string>(), new List<string>()));
                     *
                     * //result = session.OpenSession(authParams, "Console de test", ETypeApplicationCliente.Windows);/
                     * result = session.OpenSession(new CAuthentificationSessionProcess(), "Console de test", ETypeApplicationCliente.Process);
                     *
                     * if (!result)
                     * {
                     *  result.EmpileErreur("Erreur lors de l'authentification");
                     *  Console.WriteLine("Erreur lors de l'authentification");
                     *  Console.ReadKey();
                     *  return;
                     * }
                     *
                     * /*
                     * string strLogin = "******";
                     * string strPassCrypte = C2iCrypto.Crypte("minutes");
                     *
                     * CContexteDonnee contexte = new CContexteDonnee(session.IdSession, true, false);
                     * CDonneesActeurUtilisateur utilisateurTimos = new CDonneesActeurUtilisateur(contexte);
                     * if (utilisateurTimos.ReadIfExists(new CFiltreData(CDonneesActeurUtilisateur.c_champLogin + "=@1 and " +
                     *      CDonneesActeurUtilisateur.c_champPassword + "=@2",
                     *      strLogin, strPassCrypte)))
                     * {
                     *  result.Data = utilisateurTimos;
                     *  Console.WriteLine("Utilisateur " + strLogin + " connecté");
                     *  Console.ReadKey();
                     *  return;
                     * }*/

                    ITimosServiceForAspectize serviceClientAspectize = (ITimosServiceForAspectize)C2iFactory.GetNewObject(typeof(ITimosServiceForAspectize));
                    string strNomGestionnaire = serviceClientAspectize.GetType().ToString();
                    result = serviceClientAspectize.OpenSession("youcef", "minutes");
                    if (result)
                    {
                        Console.WriteLine("Key utilisateur connecté = " + (string)result.Data);
                        Console.ReadKey();
                    }

                    Console.WriteLine("Nom du gestionnaire : " + strNomGestionnaire);
                    Console.ReadKey();
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(e.Message);
                Console.WriteLine(e.Message);
                Console.WriteLine("Erreur. Pressez n'importe quelle touche pour quitter");
                Console.ReadKey();
            }
        }