예제 #1
0
        /////////////////////////////////////////////////////////////////////////////////
        public static CResultAErreur InitDefaultUrl(string strDefaultURL)
        {
            CResultAErreur result = CResultAErreur.True;

            m_instance = new C2iFactory();
            m_instance.m_strDefautUrl = strDefaultURL;
            return(result);
        }
예제 #2
0
 /////////////////////////////////////////////////////////////////////////////////
 public static CResultAErreur InitEnLocal(
     I2iObjetServeurFactory factory,
     Dictionary <string, MarshalByRefObject> dicLocalSingleton)
 {
     m_localFactory      = factory;
     m_localDicSingleton = dicLocalSingleton;
     m_instance          = new C2iFactory();
     return(CResultAErreur.True);
 }
예제 #3
0
        //////////////////////////////////////
        public static CAdUser GetUser(int nIdSession, string strId)
        {
            IAdUsersServer adUsers = (IAdUsersServer)C2iFactory.GetNewObjetForSession("CAdUsersServeur", typeof(IAdUsersServer), nIdSession);

            if (adUsers != null)
            {
                return(adUsers.GetUser(strId));
            }
            return(null);
        }
예제 #4
0
        //////////////////////////////////////
        public static CAdGroup GetGroup(int nIdSession, string strId)
        {
            IAdGroupsServeur adGroups = (IAdGroupsServeur)C2iFactory.GetNewObjetForSession("CAdGroupsServeur", typeof(IAdGroupsServeur), nIdSession);

            if (adGroups != null)
            {
                return(adGroups.GetGroup(strId));
            }
            return(null);
        }
예제 #5
0
        //////////////////////////////////////
        public static CAdComputer[] GetComputers(int nIdSession)
        {
            IAdComputersServer adComputers = (IAdComputersServer)C2iFactory.GetNewObjetForSession("CAdComputersServeur", typeof(IAdComputersServer), nIdSession);

            if (adComputers != null)
            {
                return(adComputers.GetComputers());
            }
            return(null);
        }
예제 #6
0
        /// ///////////////////////////////////////////////////////////////////
        public static void EnvoieNotifications(IDonneeNotification[] donnees)
        {
            if (donnees.Length == 0)
            {
                return;
            }
            IGestionnaireNotification gestionnaire = (IGestionnaireNotification)C2iFactory.GetNewObjetForSession("CGestionnaireNotification", typeof(IGestionnaireNotification), donnees[0].IdSessionEnvoyeur);

            if (gestionnaire != null)
            {
                gestionnaire.EnvoieNotifications(donnees);
            }
        }
예제 #7
0
        /////////////////////////////////////////////////////////////////////////////////
        private static C2iFactory GetInstance()
        {
#if PDA
            if (m_instance == null)
            {
                m_instance = new C2iFactory();
            }
#endif
            if (m_instance == null)
            {
                throw new Exception(I.T("C2iFactory wasn't initialized|101"));
            }
            return(m_instance);
        }
예제 #8
0
        ///////////////////////////////////////////////
        public CResultAErreur OpenSession(IAuthentificationSession authentification, string strDescriptionApplication, ETypeApplicationCliente typeApplication)
        {
            CResultAErreur        result       = CResultAErreur.True;
            IGestionnaireSessions gestionnaire = null;

            try
            {
                //Ne pas utiliser GestionnaireSessions car on a besoin du type de gestionnaire
                //Si l'appli utilise plusieurs gestionnaires de sessions
                gestionnaire = (IGestionnaireSessions)C2iFactory.GetNewObject(m_typeGestionnaireSessions);
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
                result.EmpileErreur(I.T("Error during the allowance of sessions manager|107"));
                return(result);
            }

            m_authentification = authentification;
            m_strDescription   = strDescriptionApplication;
            m_typeApplication  = typeApplication;
            try
            {
                result = gestionnaire.OpenSession(this);
                if (result)
                {
                    m_tableSessionParId[IdSession]    = this;
                    m_tableSessionsLocales[IdSession] = true;
                    if (AfterOpenSession != null)
                    {
                        AfterOpenSession(this);
                    }
                    if (m_nFirstSessionOuverte == -1)
                    {
                        m_nFirstSessionOuverte = IdSession;
                    }
                    GetDataThread(m_bUseSessionUtilisateurData).PushIdSession(IdSession);
                    m_bIsOpen = true;
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
                result.EmpileErreur(I.T("Error while opening session|108"));
                return(result);
            }
            return(result);
        }
예제 #9
0
        public static CResultAErreur Init(int nPort, string strFactoryURL, string strBindTo)
        {
            string         strNomChannel = c_nomChannel + "_" + nPort.ToString();
            CResultAErreur result        = CResultAErreur.True;

            try
            {
                if (ChannelServices.GetChannel(strNomChannel) == null)
                {
                    //SimmoTech.Utils.Remoting.CustomBinaryServerFormatterSinkProvider serverProv = new SimmoTech.Utils.Remoting.CustomBinaryServerFormatterSinkProvider();
                    BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
                    serverProv.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;


                    BinaryClientFormatterSinkProvider clientProv = new BinaryClientFormatterSinkProvider();
                    //SimmoTech.Utils.Remoting.CustomBinaryClientFormatterSinkProvider clientProv = new SimmoTech.Utils.Remoting.CustomBinaryClientFormatterSinkProvider();


                    Hashtable table = new Hashtable();
                    table["port"] = nPort;
                    table["name"] = strNomChannel;
                    if (strBindTo.Length > 0)
                    {
                        table["bindTo"] = strBindTo;
                    }
                    TcpChannel channel = new TcpChannel(table, clientProv, serverProv);

                    ChannelServices.RegisterChannel(channel);
                }
                C2iFactory.InitDefaultUrl(strFactoryURL);

                //teste que les paramètres sont Ok
                if (!C2iFactory.TestServeurParDefaut())
                {
                    result.EmpileErreur(I.T("The server @1 doesn't answer|105", strFactoryURL));
                }
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
                result.EmpileErreur(I.T("Error while SC2IClient initialization|106"));
            }
            return(result);
        }
        public static string[] GetNomsImprimantesServeur(int nIdSession)
        {
            IFournisseurNomImprimantesServeur fournisseur = (IFournisseurNomImprimantesServeur)C2iFactory.GetNewObjetForSession("CFournisseurNomImprimantesServeur", typeof(IFournisseurNomImprimantesServeur), nIdSession);

            return(fournisseur.GetNomsImprimantesSurServeur());
        }
예제 #11
0
        /////////////////////////////////////////////////////////////////////////////////
        public static CResultAErreur InitFromFile(string strFichierConfiguration)
        {
            /*
             * Schéma du fichier de configuration :
             *
             * <2ifactory>
             *      <default url="url"/>
             *      <namespace name="namespace" url="namespaceurl" />
             * </2ifactory>
             *
             * Toutes les classe du namespace "namespace" seront executées à partir de l'adresse "namespaceurl"
             * Les autres à partir de l'url default.
             *
             * Le format des url est du type "tcp://172.16.1.100:8085"
             *
             */
            CResultAErreur result = CResultAErreur.True;

            m_instance = new C2iFactory();
            try
            {
                bool          bZoneDetectee = false;
                XmlTextReader reader        = new XmlTextReader(strFichierConfiguration);
                while (reader.Read())
                {
                    if (reader.NodeType == XmlNodeType.Element && reader.Name.ToLower() == "sc2ifactory")
                    {
                        bZoneDetectee = true;
                    }
                    if (bZoneDetectee)
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name.ToLower())
                            {
                            case "default":
                                m_instance.m_strDefautUrl = reader.GetAttribute("url");
                                break;

                            case "namespace":
                                string strNameSpace = reader.GetAttribute("name");
                                string strUrl       = reader.GetAttribute("url");
                                m_instance.m_tableUrls[strNameSpace] = strUrl;
                                break;
                            }
                        }
                        if (reader.NodeType == XmlNodeType.EndElement &&
                            reader.Name.ToLower() == "sc2ifactory")
                        {
                            bZoneDetectee = false;
                        }
                    }
                }
                reader.Close();
            }
            catch (Exception e)
            {
                result.EmpileErreur(new CErreurException(e));
                return(result);
            }
            return(result);
        }
예제 #12
0
        public bool CloseSession()
        {
            CSessionClient session = CSessionClient.GetSessionForIdSession(IdSession);

            if (session != null)
            {
                try
                {
                    session.CloseSession();
                    return(true);
                }
                catch
                {
                    try
                    {
                        IGestionnaireSessions    gestionnaire      = (IGestionnaireSessions)C2iFactory.GetNewObject(typeof(IGestionnaireSessions));
                        ISessionClientSurServeur sessionSurServeur = gestionnaire.GetSessionClientSurServeur(IdSession);
                        sessionSurServeur.CloseSession();
                        return(true);
                    }
                    catch (Exception)
                    {
                        return(false);
                    }
                }
            }
            return(false);
        }