コード例 #1
0
ファイル: UserDefaults.cs プロジェクト: weblate/openpetra
        public static void UpdateUserDefaultsOnClient(String AUserName,
                                                      String AChangedUserDefaultCode,
                                                      String AChangedUserDefaultValue,
                                                      String AChangedUserDefaultModId,
                                                      Boolean ASingleCode = true)
        {
            String SingleOrMultipleIndicator;

            TLogging.LogAtLevel(7, "TMaintenanceUserDefaults.UpdateUserDefaultsOnClient: calling DomainManager.ClientTaskAdd...");

            if (AChangedUserDefaultCode == null)
            {
                if (AUserName == UserInfo.GetUserInfo().UserID)
                {
                    // Queue a ClientTask to the current User's PetraClient
                    DomainManager.CurrentClient.FTasksManager.ClientTaskAdd(
                        SharedConstants.CLIENTTASKGROUP_USERDEFAULTSREFRESH, "All",
                        null, null, null, null, 1);
                }
                else
                {
                    // Queue a ClientTask to any but the current User's PetraClient
                    TClientManager.QueueClientTask(AUserName,
                                                   SharedConstants.CLIENTTASKGROUP_USERDEFAULTSREFRESH,
                                                   "All",
                                                   null, null, null, null,
                                                   1, DomainManager.GClientID);
                }
            }
            else
            {
                if (ASingleCode)
                {
                    SingleOrMultipleIndicator = "Single";
                }
                else
                {
                    SingleOrMultipleIndicator = "Multiple";
                }

                if (AUserName == UserInfo.GetUserInfo().UserID)
                {
                    // Queue a ClientTask to the current User's PetraClient
                    if (DomainManager.CurrentClient != null)
                    {
                        DomainManager.CurrentClient.FTasksManager.ClientTaskAdd(SharedConstants.CLIENTTASKGROUP_USERDEFAULTSREFRESH,
                                                                                SingleOrMultipleIndicator,
                                                                                AChangedUserDefaultCode,
                                                                                AChangedUserDefaultValue,
                                                                                AChangedUserDefaultModId,
                                                                                UserInfo.GetUserInfo().ProcessID,
                                                                                1);
                    }
                }

                // Send the same ClientTask to all other running PetraClient instances where
                // the same user is logged in!
                TClientManager.QueueClientTask(AUserName,
                                               SharedConstants.CLIENTTASKGROUP_USERDEFAULTSREFRESH,
                                               SingleOrMultipleIndicator,
                                               AChangedUserDefaultCode,
                                               AChangedUserDefaultValue,
                                               AChangedUserDefaultModId,
                                               null,
                                               1,
                                               DomainManager.GClientID);
            }
        }
コード例 #2
0
        /// <summary>
        /// initialise the server for each Web Request
        /// </summary>
        private static bool Init()
        {
            string ConfigFileName = string.Empty;

            // make sure the correct config file is used
            string Instance = HttpContext.Current.Request.Url.ToString().Replace("http://", "").Replace("https://", "");

            Instance = Instance.Substring(0, Instance.IndexOf(".")).Replace("op_", "op").Replace("op", "op_");

            // for demo etc
            if (!Instance.StartsWith("op_"))
            {
                Instance = "op_" + Instance;
            }

            ConfigFileName = "/home/" + Instance + "/etc/PetraServerConsole.config";

            if (File.Exists(ConfigFileName))
            {
                // we are in a multi tenant hosting scenario
            }
            else if (Environment.CommandLine.Contains("/appconfigfile="))
            {
                // this happens when we use fastcgi-mono-server4
                ConfigFileName = Environment.CommandLine.Substring(
                    Environment.CommandLine.IndexOf("/appconfigfile=") + "/appconfigfile=".Length);

                if (ConfigFileName.IndexOf(" ") != -1)
                {
                    ConfigFileName = ConfigFileName.Substring(0, ConfigFileName.IndexOf(" "));
                }
            }
            else
            {
                // this is the normal behaviour when running with local http server
                ConfigFileName = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "web.config";
            }

            TTypedDataTable.ResetStaticVariables();
            TPdfPrinter.ResetStaticVariables();
            THTTPUtils.ResetStaticVariables();
            TSharedDataCache.TMPartner.ResetStaticVariables();
            TServerManagerBase.ResetStaticVariables();
            TClientManager.ResetStaticVariables();

            TSession.InitThread("TOpenPetraOrgSessionManager.Init", ConfigFileName);

            if (HttpContext.Current != null)
            {
                HttpContext.Current.Server.ScriptTimeout = Convert.ToInt32(
                    TimeSpan.FromMinutes(TAppSettingsManager.GetInt32("WebRequestTimeOutInMinutes", 15)).
                    TotalSeconds);
            }

            // if the Login Method is called: reset cookie, ignore any old session
            if ((HttpContext.Current != null) && (HttpContext.Current.Request.PathInfo == "/Login"))
            {
                TSession.CloseSession();
                TSession.InitThread("TOpenPetraOrgSessionManager.Init Reset", ConfigFileName);
            }

            Catalog.Init();

            ErrorCodeInventory.Init();
            ErrorCodeInventory.BuildErrorCodeInventory(typeof(Ict.Petra.Shared.PetraErrorCodes));
            ErrorCodeInventory.BuildErrorCodeInventory(typeof(Ict.Common.Verification.TStringChecks));

            TServerManager.TheServerManager = new TServerManager();

            // initialise the cached tables and the delegates
            TSetupDelegates.Init();

            TLogging.LogAtLevel(4, "Server has been initialised");

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Initialises Logging and parses Server settings from different sources.
        /// </summary>
        public TServerManager() : base()
        {
            // Create SystemDefaults Cache
            TSystemDefaultsCache.GSystemDefaultsCache = new TSystemDefaultsCache();
            DomainManager.GetSiteKeyFromSystemDefaultsCacheDelegate = @TSystemDefaultsCache.GSystemDefaultsCache.GetSiteKeyDefault;

            TCacheableTablesManager.InitializeUnit();
            TCacheableTablesManager.GCacheableTablesManager = new TCacheableTablesManager(new TDelegateSendClientTask(TClientManager.QueueClientTask));

            Assembly SysManAssembly   = Assembly.Load("Ict.Petra.Server.lib.MSysMan");
            Type     ImportExportType = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.ImportExport.TImportExportManager");

            FImportExportManager = (IImportExportManager)Activator.CreateInstance(ImportExportType,
                                                                                  (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                                  null,
                                                                                  null,
                                                                                  null);

            Assembly DBUpgradesAssembly  = Assembly.Load("Ict.Petra.Server.lib.MSysMan.DBUpgrades");
            Type     DatabaseUpgradeType = DBUpgradesAssembly.GetType("Ict.Petra.Server.MSysMan.DBUpgrades.TDBUpgrades");

            FDBUpgrades = (IDBUpgrades)Activator.CreateInstance(DatabaseUpgradeType,
                                                                (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                null,
                                                                null,
                                                                null);

            Type UserManagement = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.Maintenance.UserManagement.TUserManager");

            FUserManager = (IUserManager)Activator.CreateInstance(UserManagement,
                                                                  (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                  null,
                                                                  null,
                                                                  null);

            TClientManager.InitializeStaticVariables(TSystemDefaultsCache.GSystemDefaultsCache,
                                                     FUserManager,
                                                     new TErrorLog(),
                                                     new TLoginLog(),
                                                     new TMaintenanceLogonMessage(),
                                                     ExceptionHandling_DBConnectionBrokenCallback);

            //
            // Set up 'Timed Processing'
            //
            TTimedProcessing.DailyStartTime24Hrs = TAppSettingsManager.GetValue("Server.Processing.DailyStartTime24Hrs", "00:30");

            if (TAppSettingsManager.GetBoolean("Server.Processing.PartnerReminders.Enabled", true))
            {
                Assembly PartnerProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MPartner.processing");
                Type     PartnerReminderClass      = PartnerProcessingAssembly.GetType("Ict.Petra.Server.MPartner.Processing.TProcessPartnerReminders");
                TTimedProcessing.AddProcessingJob(
                    "TProcessPartnerReminders",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        PartnerReminderClass,
                        "Process"));
            }

            if (TAppSettingsManager.GetBoolean("Server.Processing.AutomatedIntranetExport.Enabled", false))
            {
                Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing");
                Type     IntranetExportClass      = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessAutomatedIntranetExport");
                TTimedProcessing.AddProcessingJob(
                    "TProcessAutomatedIntranetExport",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        IntranetExportClass,
                        "Process"));
            }

            if (TAppSettingsManager.GetBoolean("Server.Processing.DataChecks.Enabled", false))
            {
                Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing");
                Type     ProcessDataChecksClass   = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessDataChecks");
                TTimedProcessing.AddProcessingJob(
                    "TProcessDataChecks",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        ProcessDataChecksClass,
                        "Process"));
            }
        }
コード例 #4
0
ファイル: ServerManager.cs プロジェクト: weblate/openpetra
        /// <summary>
        /// Initialises Logging and parses Server settings from different sources.
        /// </summary>
        public TServerManager() : base()
        {
            Assembly SysManAssembly   = Assembly.Load("Ict.Petra.Server.lib.MSysMan");
            Type     ImportExportType = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.ImportExport.TImportExportManager");

            FImportExportManager = (IImportExportManager)Activator.CreateInstance(ImportExportType,
                                                                                  (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                                  null,
                                                                                  null,
                                                                                  null);

            Assembly DBUpgradesAssembly  = Assembly.Load("Ict.Petra.Server.lib.MSysMan.DBUpgrades");
            Type     DatabaseUpgradeType = DBUpgradesAssembly.GetType("Ict.Petra.Server.MSysMan.DBUpgrades.TDBUpgrades");

            FDBUpgrades = (IDBUpgrades)Activator.CreateInstance(DatabaseUpgradeType,
                                                                (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                null,
                                                                null,
                                                                null);

            Type UserManagement = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.Maintenance.UserManagement.TUserManager");

            FUserManager = (IUserManager)Activator.CreateInstance(UserManagement,
                                                                  (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                  null,
                                                                  null,
                                                                  null);

            TClientManager.InitializeStaticVariables(
                FUserManager,
                new TErrorLog(),
                new TLoginLog(),
                new TMaintenanceLogonMessage());

            //
            // Set up 'Timed Processing'
            //
            TTimedProcessing.DailyStartTime24Hrs = TAppSettingsManager.GetValue("Server.Processing.DailyStartTime24Hrs", "00:30");

            if (TAppSettingsManager.GetBoolean("Server.Processing.PartnerReminders.Enabled", true))
            {
                Assembly PartnerProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MPartner.processing");
                Type     PartnerReminderClass      = PartnerProcessingAssembly.GetType("Ict.Petra.Server.MPartner.Processing.TProcessPartnerReminders");
                TTimedProcessing.AddProcessingJob(
                    "TProcessPartnerReminders",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        PartnerReminderClass,
                        "Process"));
            }

            if (TAppSettingsManager.GetBoolean("Server.Processing.AutomatedIntranetExport.Enabled", false))
            {
                Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing");
                Type     IntranetExportClass      = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessAutomatedIntranetExport");
                TTimedProcessing.AddProcessingJob(
                    "TProcessAutomatedIntranetExport",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        IntranetExportClass,
                        "Process"));
            }

            if (TAppSettingsManager.GetBoolean("Server.Processing.DataChecks.Enabled", false))
            {
                Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing");
                Type     ProcessDataChecksClass   = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessDataChecks");
                TTimedProcessing.AddProcessingJob(
                    "TProcessDataChecks",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        ProcessDataChecksClass,
                        "Process"));
            }
        }
コード例 #5
0
ファイル: ServerManager.cs プロジェクト: merbst/openpetra
        /// <summary>
        /// Initialises Logging and parses Server settings from different sources.
        /// </summary>
        public TServerManager() : base()
        {
            // Create SystemDefaults Cache
            TSystemDefaultsCache.GSystemDefaultsCache = new TSystemDefaultsCache();
            DomainManager.GetSiteKeyFromSystemDefaultsCacheDelegate = @TSystemDefaultsCache.GSystemDefaultsCache.GetSiteKeyDefault;

            TCacheableTablesManager.InitializeUnit();
            TCacheableTablesManager.GCacheableTablesManager = new TCacheableTablesManager(new TDelegateSendClientTask(TClientManager.QueueClientTask));

            Assembly SysManAssembly   = Assembly.Load("Ict.Petra.Server.lib.MSysMan");
            Type     ImportExportType = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.ImportExport.TImportExportManager");

            FImportExportManager = (IImportExportManager)Activator.CreateInstance(ImportExportType,
                                                                                  (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                                  null,
                                                                                  null,
                                                                                  null);

            Assembly DBUpgradesAssembly  = Assembly.Load("Ict.Petra.Server.lib.MSysMan.DBUpgrades");
            Type     DatabaseUpgradeType = DBUpgradesAssembly.GetType("Ict.Petra.Server.MSysMan.DBUpgrades.TDBUpgrades");

            FDBUpgrades = (IDBUpgrades)Activator.CreateInstance(DatabaseUpgradeType,
                                                                (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                null,
                                                                null,
                                                                null);

            Type UserManagement = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.Maintenance.UserManagement.TUserManager");

            FUserManager = (IUserManager)Activator.CreateInstance(UserManagement,
                                                                  (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                  null,
                                                                  null,
                                                                  null);

            TClientManager.InitializeStaticVariables(TSystemDefaultsCache.GSystemDefaultsCache,
                                                     FUserManager,
                                                     new TErrorLog(),
                                                     new TLoginLog(),
                                                     new TMaintenanceLogonMessage(),
                                                     ExceptionHandling_DBConnectionBrokenCallback);

            // Set up the SYSADMIN user (#5650).
            // (This is required for all SubmitChanges method calls in the server's main AppDomain because
            // that Method references UserInfo.GUserInfo)
            // When using this with the Web Services, this does not apply to the threads for each session.
            TPetraIdentity PetraIdentity = new TPetraIdentity(
                "SYSADMIN", "", "", "", "",
                DateTime.MinValue, DateTime.MinValue, DateTime.MinValue,
                0, -1, -1, false, false, false);

            TPetraPrincipal Principal = new TPetraPrincipal(PetraIdentity, null);

            UserInfo.GUserInfo = Principal;

            //
            // Set up 'Timed Processing'
            //
            TTimedProcessing.DailyStartTime24Hrs = TAppSettingsManager.GetValue("Server.Processing.DailyStartTime24Hrs", "00:30");

            if (TAppSettingsManager.GetBoolean("Server.Processing.PartnerReminders.Enabled", true))
            {
                Assembly PartnerProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MPartner.processing");
                Type     PartnerReminderClass      = PartnerProcessingAssembly.GetType("Ict.Petra.Server.MPartner.Processing.TProcessPartnerReminders");
                TTimedProcessing.AddProcessingJob(
                    "TProcessPartnerReminders",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        PartnerReminderClass,
                        "Process"));
            }

            if (TAppSettingsManager.GetBoolean("Server.Processing.AutomatedIntranetExport.Enabled", false))
            {
                Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing");
                Type     IntranetExportClass      = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessAutomatedIntranetExport");
                TTimedProcessing.AddProcessingJob(
                    "TProcessAutomatedIntranetExport",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        IntranetExportClass,
                        "Process"));
            }

            if (TAppSettingsManager.GetBoolean("Server.Processing.DataChecks.Enabled", false))
            {
                Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing");
                Type     ProcessDataChecksClass   = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessDataChecks");
                TTimedProcessing.AddProcessingJob(
                    "TProcessDataChecks",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        ProcessDataChecksClass,
                        "Process"));
            }
        }
コード例 #6
0
ファイル: connectServer.cs プロジェクト: lxhelp/openpetra
        /// <summary>
        /// Initialize the Petra server and connect to the database
        /// </summary>
        /// <param name="AConfigName">just provide the server config file, plus AutoLogin and AutoLoginPasswd</param>
        public static TServerManager Connect(string AConfigName)
        {
            TDBTransaction LoginTransaction;
            bool           CommitLoginTransaction = false;
            bool           SystemEnabled;
            string         WelcomeMessage;
            IPrincipal     ThisUserInfo;
            Int32          ClientID;

            if (File.Exists(AConfigName))
            {
                new TAppSettingsManager(AConfigName);
            }
            else if (AConfigName.Length > 0)
            {
                TLogging.Log("cannot find config file " + Path.GetFullPath(AConfigName));
                Environment.Exit(-1);
            }
            else
            {
                new TAppSettingsManager();
            }

            new TLogging(TAppSettingsManager.GetValue("Server.LogFile"));

            CommonNUnitFunctions.InitRootPath();

            Catalog.Init();
            TServerManager.TheServerManager = new TServerManager();

            DBAccess.GDBAccessObj = new TDataBase();
            DBAccess.GDBAccessObj.EstablishDBConnection(TSrvSetting.RDMBSType,
                                                        TSrvSetting.PostgreSQLServer, TSrvSetting.PostgreSQLServerPort,
                                                        TSrvSetting.PostgreSQLDatabaseName,
                                                        TSrvSetting.DBUsername, TSrvSetting.DBPassword, "",
                                                        "Ict.Testing.NUnitPetraServer.TPetraServerConnector.Connect DB Connection");

            LoginTransaction = DBAccess.GDBAccessObj.BeginTransaction(IsolationLevel.RepeatableRead,
                                                                      ATransactionName: "Ict.Testing.NUnitPetraServer.TPetraServerConnector.Connect (Unit Test Login)");

            try
            {
                TClientManager.PerformLoginChecks(TAppSettingsManager.GetValue("AutoLogin").ToUpper(),
                                                  TAppSettingsManager.GetValue("AutoLoginPasswd"),
                                                  "NUNITTEST", "127.0.0.1", out SystemEnabled, LoginTransaction);

                CommitLoginTransaction = true;
            }
            catch (EPetraSecurityException)
            {
                // We need to set this flag to true here to get the failed login to be stored in the DB!!!
                CommitLoginTransaction = true;
            }
            finally
            {
                if (CommitLoginTransaction)
                {
                    DBAccess.GDBAccessObj.CommitTransaction();
                }
                else
                {
                    DBAccess.GDBAccessObj.RollbackTransaction();
                }
            }

            TConnectedClient CurrentClient = TClientManager.ConnectClient(
                TAppSettingsManager.GetValue("AutoLogin").ToUpper(),
                TAppSettingsManager.GetValue("AutoLoginPasswd"),
                "NUNITTEST", "127.0.0.1",
                TFileVersionInfo.GetApplicationVersion().ToVersion(),
                TClientServerConnectionType.csctLocal,
                out ClientID,
                out WelcomeMessage,
                out SystemEnabled,
                out ThisUserInfo);

            // the following values are stored in the session object
            DomainManager.GClientID     = ClientID;
            DomainManager.CurrentClient = CurrentClient;
            UserInfo.GUserInfo          = (TPetraPrincipal)ThisUserInfo;

            TSetupDelegates.Init();
            TSystemDefaultsCache.GSystemDefaultsCache = new TSystemDefaultsCache();
            DomainManager.GetSiteKeyFromSystemDefaultsCacheDelegate =
                @TSystemDefaultsCache.GSystemDefaultsCache.GetSiteKeyDefault;

            TUserDefaults.InitializeUnit();

            StringHelper.CurrencyFormatTable = DBAccess.GDBAccessObj.SelectDT("SELECT * FROM PUB_a_currency", "a_currency", null);

            return((TServerManager)TServerManager.TheServerManager);
        }
コード例 #7
0
        /// <summary>
        /// Initialize the Petra server and connect to the database
        /// </summary>
        /// <param name="AConfigName">just provide the server config file, plus AutoLogin and AutoLoginPasswd</param>
        public static TServerManager Connect(string AConfigName)
        {
            TDBTransaction LoginTransaction;
            bool           CommitLoginTransaction = false;
            bool           SystemEnabled;
            string         WelcomeMessage;
            Int32          ClientID;
            Int64          SiteKey;

            if (File.Exists(AConfigName))
            {
                new TAppSettingsManager(AConfigName);
            }
            else if (AConfigName.Length > 0)
            {
                TLogging.Log("cannot find config file " + Path.GetFullPath(AConfigName));
                Environment.Exit(-1);
            }
            else
            {
                new TAppSettingsManager();
            }

            new TLogging(TAppSettingsManager.GetValue("Server.LogFile"));

            TSession.InitThread();

            CommonNUnitFunctions.InitRootPath();

            Catalog.Init();
            TServerManager.TheServerManager = new TServerManager();

            ErrorCodeInventory.Init();

            // initialise the cached tables and the delegates
            TSetupDelegates.Init();

            TDataBase db = DBAccess.Connect(
                "Ict.Testing.NUnitPetraServer.TPetraServerConnector.Connect DB Connection");

            // we need a serializable transaction, to store the session
            LoginTransaction = db.BeginTransaction(IsolationLevel.Serializable);

            try
            {
                TClientManager.PerformLoginChecks(TAppSettingsManager.GetValue("AutoLogin").ToUpper(),
                                                  TAppSettingsManager.GetValue("AutoLoginPasswd"),
                                                  "NUNITTEST", "127.0.0.1", out SystemEnabled, LoginTransaction);

                CommitLoginTransaction = true;
            }
            catch (EPetraSecurityException)
            {
                // We need to set this flag to true here to get the failed login to be stored in the DB!!!
                CommitLoginTransaction = true;
            }
            finally
            {
                if (CommitLoginTransaction)
                {
                    LoginTransaction.Commit();
                }
                else
                {
                    LoginTransaction.Rollback();
                }
            }

            TConnectedClient CurrentClient = TClientManager.ConnectClient(
                TAppSettingsManager.GetValue("AutoLogin").ToUpper(),
                TAppSettingsManager.GetValue("AutoLoginPasswd"),
                "NUNITTEST", "127.0.0.1",
                TFileVersionInfo.GetApplicationVersion().ToVersion(),
                TClientServerConnectionType.csctLocal,
                out ClientID,
                out WelcomeMessage,
                out SystemEnabled,
                out SiteKey,
                db);

            // the following values are stored in the session object
            DomainManager.GClientID     = ClientID;
            DomainManager.CurrentClient = CurrentClient;
            DomainManager.GSiteKey      = SiteKey;

            TSetupDelegates.Init();

            db.CloseDBConnection();

            return((TServerManager)TServerManager.TheServerManager);
        }
コード例 #8
0
        /// <summary>
        /// Initialises Logging and parses Server settings from different sources.
        /// </summary>
        public TServerManager() : base()
        {
            // Create SystemDefaults Cache
            FSystemDefaultsCache = new TSystemDefaultsCache();

            TRemoteLoader.CLIENTDOMAIN_DLLNAME   = "Ict.Petra.Server.app.Core";
            TRemoteLoader.CLIENTDOMAIN_CLASSNAME = "Ict.Petra.Server.App.Core.TClientDomainManager";
            TClientAppDomainConnectionBase.ClientAppDomainConnectionType = typeof(TClientAppDomainConnection);

            TCacheableTablesManager.InitializeUnit();
            TCacheableTablesManager.GCacheableTablesManager = new TCacheableTablesManager(new TDelegateSendClientTask(TClientManager.QueueClientTask));

            Assembly SysManAssembly   = Assembly.Load("Ict.Petra.Server.lib.MSysMan");
            Type     ImportExportType = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.ImportExport.TImportExportManager");

            FImportExportManager = (IImportExportManager)Activator.CreateInstance(ImportExportType,
                                                                                  (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                                  null,
                                                                                  null,
                                                                                  null);

            Type UserManagement = SysManAssembly.GetType("Ict.Petra.Server.MSysMan.Maintenance.UserManagement.TUserManager");

            FUserManager = (IUserManager)Activator.CreateInstance(UserManagement,
                                                                  (BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod),
                                                                  null,
                                                                  null,
                                                                  null);

            TClientManager.InitializeStaticVariables(FSystemDefaultsCache,
                                                     TCacheableTablesManager.GCacheableTablesManager,
                                                     FUserManager,
                                                     new TErrorLog(),
                                                     new TMaintenanceLogonMessage(),
                                                     new TClientAppDomainConnection());

            TTimedProcessing.DailyStartTime24Hrs = TAppSettingsManager.GetValue("Server.Processing.DailyStartTime24Hrs", "00:30");

            if (TAppSettingsManager.GetBoolean("Server.Processing.PartnerReminders.Enabled", true))
            {
                Assembly PartnerProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MPartner.processing");
                Type     PartnerReminderClass      = PartnerProcessingAssembly.GetType("Ict.Petra.Server.MPartner.Processing.TProcessPartnerReminders");
                TTimedProcessing.AddProcessingJob(
                    "TProcessPartnerReminders",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        PartnerReminderClass,
                        "Process"));
            }

            if (TAppSettingsManager.GetBoolean("Server.Processing.AutomatedIntranetExport.Enabled", false))
            {
                Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing");
                Type     IntranetExportClass      = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessAutomatedIntranetExport");
                TTimedProcessing.AddProcessingJob(
                    "TProcessAutomatedIntranetExport",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        IntranetExportClass,
                        "Process"));
            }

            if (TAppSettingsManager.GetBoolean("Server.Processing.DataChecks.Enabled", false))
            {
                Assembly CommonProcessingAssembly = Assembly.Load("Ict.Petra.Server.lib.MCommon.processing");
                Type     ProcessDataChecksClass   = CommonProcessingAssembly.GetType("Ict.Petra.Server.MCommon.Processing.TProcessDataChecks");
                TTimedProcessing.AddProcessingJob(
                    "TProcessDataChecks",
                    (TTimedProcessing.TProcessDelegate)Delegate.CreateDelegate(
                        typeof(TTimedProcessing.TProcessDelegate),
                        ProcessDataChecksClass,
                        "Process"));
            }
        }