コード例 #1
0
        /// <summary>
        /// Sets up .NET Remoting Lifetime Services and TCP Channel for this AppDomain.
        ///
        /// @comment WARNING: If you need to change the parameters of the Constructor,
        /// you also need to change the parameters in the .NET Reflection call in
        /// TClientAppDomainConnection!
        ///
        /// </summary>
        /// <param name="AClientID">ClientID as assigned by the ClientManager</param>
        /// <param name="AClientServerConnectionType">Tells in which way the Client connected
        /// to the PetraServer</param>
        /// <param name="AClientManagerRef">A reference to the ClientManager object
        /// (Note: .NET Remoting will be working behind the scenes since calls to
        /// this Object will cross AppDomains!)</param>
        /// <param name="ASystemDefaultsCacheRef">A reference to the SystemDefaultsCache object
        /// (Note: .NET Remoting will be working behind the scenes since calls to
        /// this Object will cross AppDomains!)</param>
        /// <param name="ACacheableTablesManagerRef"></param>
        /// <param name="AUserInfo">An instantiated PetraPrincipal Object, containing User
        /// information
        /// </param>
        public TClientDomainManager(String AClientID,
                                    TClientServerConnectionType AClientServerConnectionType,
                                    TClientManagerCallForwarder AClientManagerRef,
                                    TSystemDefaultsCache ASystemDefaultsCacheRef,
                                    TCacheableTablesManager ACacheableTablesManagerRef,
                                    IPrincipal AUserInfo) :
            base(AClientID,
                 AClientServerConnectionType, AClientManagerRef,
                 ((TPetraPrincipal)AUserInfo).UserID)
        {
            TCacheableTablesManager.GCacheableTablesManager = ACacheableTablesManagerRef;
            TSystemDefaultsCache.GSystemDefaultsCache       = ASystemDefaultsCacheRef;

            TLanguageCulture.Init();

            UserInfo.GUserInfo     = (TPetraPrincipal)AUserInfo;
            DomainManager.GSiteKey = TSystemDefaultsCache.GSystemDefaultsCache.GetInt64Default(SharedConstants.SYSDEFAULT_SITEKEY);

            if (DomainManager.GSiteKey <= 0)
            {
                // this is for connecting to legacy database format
                // we cannot add SiteKey to SystemDefaults, because Petra 2.3 would have a conflict since it adds it on startup already to the in-memory defaults, but not to the database
                // see also https://sourceforge.net/apps/mantisbt/openpetraorg/view.php?id=114
                DomainManager.GSiteKey = TSystemDefaultsCache.GSystemDefaultsCache.GetInt64Default("SiteKeyPetra2");
            }

            if (DomainManager.GSiteKey <= 0)
            {
                // this can happen either with a legacy Petra 2.x database or with a fresh OpenPetra database without any ledger yet
                Console.WriteLine("there is no SiteKey or SiteKeyPetra2 record in s_system_defaults");
                DomainManager.GSiteKey = 99000000;
            }
        }
コード例 #2
0
        /// connect to the server
        public static void Connect(string AConfigName)
        {
            TUnhandledThreadExceptionHandler UnhandledThreadExceptionHandler;

            // Set up Handlers for 'UnhandledException'
            // Note: BOTH handlers are needed for a WinForms Application!!!
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler);
            UnhandledThreadExceptionHandler             = new TUnhandledThreadExceptionHandler();

            Application.ThreadException += new ThreadExceptionEventHandler(UnhandledThreadExceptionHandler.OnThreadException);

            new TAppSettingsManager(AConfigName);

            CommonNUnitFunctions.InitRootPath();

            Catalog.Init();
            TClientTasksQueue.ClientTasksInstanceType       = typeof(TClientTaskInstance);
            TConnectionManagementBase.ConnectorType         = typeof(TConnector);
            TConnectionManagementBase.GConnectionManagement = new TConnectionManagement();

            new TClientSettings();
            TClientInfo.InitializeUnit();
            TCacheableTablesManager.InitializeUnit();

            // Set up Data Validation Delegates
            TSharedValidationHelper.SharedGetDataDelegate                   = @TServerLookup.TMCommon.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate            = @TServerLookup.TMPartner.VerifyPartner;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate = @TServerLookup.TMFinance.GetCurrentPostingRangeDates;
            TSharedFinanceValidationHelper.GetValidPeriodDatesDelegate      = @TServerLookup.TMFinance.GetCurrentPeriodDates;

            Connect(TAppSettingsManager.GetValue("AutoLogin"), TAppSettingsManager.GetValue("AutoLoginPasswd"),
                    TAppSettingsManager.GetInt64("SiteKey"));
        }
コード例 #3
0
        /// <summary>
        /// Initialize the static variables.
        /// Set up Error Codes and Data Validation Delegates for a Web Request.
        /// This setting-up makes use of the fact that this Method is called only once,
        /// at the start of each Web Request in TOpenPetraOrgSessionManager.Init()
        /// </summary>
        public static void Init()
        {
            TSharedValidationHelper.SharedGetDataDelegate                           = @TCommonDataReader.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate                    = @TPartnerServerLookups.VerifyPartner;
            TSharedPartnerValidationHelper.PartnerHasActiveStatusDelegate           = @TPartnerServerLookups.PartnerHasActiveStatus;
            TSharedPartnerValidationHelper.PartnerIsLinkedToCCDelegate              = @TPartnerServerLookups.PartnerIsLinkedToCC;
            TSharedPartnerValidationHelper.PartnerOfTypeCCIsLinkedDelegate          = @TPartnerServerLookups.PartnerOfTypeCCIsLinked;
            TSharedPartnerValidationHelper.PartnerHasCurrentGiftDestinationDelegate = @TPartnerServerLookups.PartnerHasCurrentGiftDestination;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate         = @TFinanceServerLookupWebConnector.GetCurrentPostingRangeDates;
            TSharedFinanceValidationHelper.GetValidPeriodDatesDelegate              = @TAccountingPeriodsWebConnector.GetPeriodDates;
            TSharedFinanceValidationHelper.GetFirstDayOfAccountingPeriodDelegate    = @TAccountingPeriodsWebConnector.GetFirstDayOfAccountingPeriod;
            TMonthEnd.StewardshipCalculationDelegate = @TStewardshipCalculationWebConnector.PerformStewardshipCalculation;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on server side
            CachePopulatorCommon        = new Ict.Petra.Server.MCommon.Cacheable.TCacheable();
            CachePopulatorConference    = new Ict.Petra.Server.MConference.Cacheable.TCacheable();
            CachePopulatorFinance       = new Ict.Petra.Server.MFinance.Cacheable.TCacheable();
            CachePopulatorMailing       = new Ict.Petra.Server.MPartner.Mailing.Cacheable.TPartnerCacheable();
            CachePopulatorPartner       = new Ict.Petra.Server.MPartner.Partner.Cacheable.TPartnerCacheable();
            CachePopulatorSubscriptions = new Ict.Petra.Server.MPartner.Subscriptions.Cacheable.TPartnerCacheable();
            CachePopulatorPersonnel     = new Ict.Petra.Server.MPersonnel.Person.Cacheable.TPersonnelCacheable();
            CachePopulatorUnits         = new Ict.Petra.Server.MPersonnel.Unit.Cacheable.TPersonnelCacheable();
            CachePopulatorSysMan        = new Ict.Petra.Server.MSysMan.Cacheable.TCacheable();

            Ict.Petra.Server.MCommon.Cacheable.WebConnectors.TCommonCacheableWebConnector.Init();
            Ict.Petra.Server.MConference.Cacheable.WebConnectors.TConferenceCacheableWebConnector.Init();
            Ict.Petra.Server.MFinance.Cacheable.WebConnectors.TFinanceCacheableWebConnector.Init();
            Ict.Petra.Server.MPartner.Mailing.Cacheable.WebConnectors.TMailingCacheableWebConnector.Init();
            Ict.Petra.Server.MPartner.Partner.Cacheable.WebConnectors.TPartnerCacheableWebConnector.Init();
            Ict.Petra.Server.MPartner.Subscriptions.Cacheable.WebConnectors.TSubscriptionsCacheableWebConnector.Init();
            Ict.Petra.Server.MPersonnel.Person.Cacheable.WebConnectors.TPersonCacheableWebConnector.Init();
            Ict.Petra.Server.MPersonnel.Unit.Cacheable.WebConnectors.TUnitCacheableWebConnector.Init();
            Ict.Petra.Server.MSysMan.Cacheable.WebConnectors.TSysManCacheableWebConnector.Init();

            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate         = @CachePopulatorCommon.GetCacheableTable;
            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate       = @CachePopulatorFinance.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate       = @CachePopulatorPartner.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate       = @CachePopulatorMailing.GetCacheableTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @CachePopulatorSubscriptions.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate   = @CachePopulatorPersonnel.GetCacheableTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate       = @CachePopulatorUnits.GetCacheableTable;
            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @CachePopulatorConference.GetCacheableTable;
            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate         = @CachePopulatorSysMan.GetCacheableTable;

            TSharedDataCache.TMPartner.GetPartnerCalculationsSystemCategoryAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineSystemCategoryAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPartnerContactDetailAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePartnerContactDetailAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsEmailPartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineEmailPartnerAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPhonePartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePhonePartnerAttributeTypes;

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

            TSmtpSender.GetSmtpSettings = @TSmtpSender.GetSmtpSettingsFromAppSettings;
        }
コード例 #4
0
        /// connect to the server
        public static eLoginEnum Connect(string AConfigName, bool AThrowExceptionOnLoginFailure = true)
        {
            TUnhandledThreadExceptionHandler UnhandledThreadExceptionHandler;

            // Set up Handlers for 'UnhandledException'
            // Note: BOTH handlers are needed for a WinForms Application!!!
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandling.UnhandledExceptionHandler);
            UnhandledThreadExceptionHandler             = new TUnhandledThreadExceptionHandler();

            Application.ThreadException += new ThreadExceptionEventHandler(UnhandledThreadExceptionHandler.OnThreadException);

            new TAppSettingsManager(AConfigName);

            CommonNUnitFunctions.InitRootPath();

            Catalog.Init();
            TClientTasksQueue.ClientTasksInstanceType       = typeof(TClientTaskInstance);
            TConnectionManagementBase.GConnectionManagement = new TConnectionManagement();

            new TClientSettings();
            TClientInfo.InitializeUnit();
            TCacheableTablesManager.InitializeUnit();

            // Set up Data Validation Delegates
            TSharedValidationHelper.SharedGetDataDelegate                           = @TServerLookup.TMCommon.GetData;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate                    = @TServerLookup.TMPartner.VerifyPartner;
            TSharedPartnerValidationHelper.PartnerIsLinkedToCCDelegate              = @TServerLookup.TMPartner.PartnerIsLinkedToCC;
            TSharedPartnerValidationHelper.PartnerOfTypeCCIsLinkedDelegate          = @TServerLookup.TMPartner.PartnerOfTypeCCIsLinked;
            TSharedPartnerValidationHelper.PartnerHasCurrentGiftDestinationDelegate = @TServerLookup.TMPartner.PartnerHasCurrentGiftDestination;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate         = @TServerLookup.TMFinance.GetCurrentPostingRangeDates;
            TSharedFinanceValidationHelper.GetValidPeriodDatesDelegate              = @TServerLookup.TMFinance.GetCurrentPeriodDates;

            // Ensure we throw away the previous client session cookies!
            THTTPUtils.ResetSession();

            eLoginEnum Result = Connect(TAppSettingsManager.GetValue("AutoLogin"), TAppSettingsManager.GetValue("AutoLoginPasswd"),
                                        TAppSettingsManager.GetInt64("SiteKey"));

            if ((Result != eLoginEnum.eLoginSucceeded) && AThrowExceptionOnLoginFailure)
            {
                throw new Exception("login failed");
            }

            return(Result);
        }
コード例 #5
0
        /// <summary>
        /// Perform necessary initializations of Classes
        /// </summary>
        /// <returns>void</returns>
        private static void InitialiseClasses()
        {
            TClientInfo.InitializeUnit();
            TCacheableTablesManager.InitializeUnit();
            new TIconCache();

            // Set up Delegates for forwarding of calls for security-related Exceptions
            ExceptionHandling.ProcessSecurityAccessDeniedException = TMessages.MsgSecurityException;
            TUnhandledThreadExceptionHandler.ProcessSecurityAccessDeniedException = TMessages.MsgSecurityException;

            // Set up Delegates for forwarding of calls to Screens in various Assemblies
            TCommonScreensForwarding.OpenPartnerFindScreen = @TPartnerFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenPartnerFindByBankDetailsScreen = @TPartnerFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenBankFindDialog              = @TBankFindDialogManager.OpenModalForm;
            TCommonScreensForwarding.OpenConferenceFindScreen        = @TConferenceFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenEventFindScreen             = @TEventFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenExtractFindScreen           = @TExtractFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenExtractMasterScreen         = @TExtractMasterScreenManager.OpenForm;
            TCommonScreensForwarding.OpenDonorRecipientHistoryScreen = @TDonorRecipientHistoryScreenManager.OpenForm;
            TCommonScreensForwarding.OpenPartnerEditScreen           = @TPartnerEditScreenManager.OpenForm;
            TCommonScreensForwarding.OpenExtractMasterScreenHidden   = @TExtractMasterScreenManager.OpenFormHidden;
            TCommonScreensForwarding.OpenRangeFindScreen             = @TPostcodeRangeSetupManager.OpenModalForm;
            TCommonScreensForwarding.OpenOccupationCodeFindScreen    = @TOccupationCodeSetupManager.OpenModalForm;
            TCommonScreensForwarding.OpenGetMergeDataDialog          = @TGetMergeDataManager.OpenModalForm;
            TCommonScreensForwarding.OpenPrintPartnerDialog          = @TPrintPartnerModal.OpenModalForm;

            // Set up Delegate for the opening of Forms from the Main Menu
            Ict.Common.Controls.TLstTasks.OpenNewOrExistingForm = @Ict.Petra.Client.CommonForms.TFormsList.OpenNewOrExistingForm;

            // Set up Delegate for the retrieval of the list of Currencies from the Cache
            Ict.Common.Controls.TTxtCurrencyTextBox.RetrieveCurrencyList = @Ict.Petra.Client.CommonControls.TControlExtensions.RetrieveCurrencyList;

            // Set up Delegate for the set-up of various Colours of all SourceGrid DataGrid instances from UserDefaults
            Ict.Common.Controls.TSgrdDataGrid.SetColourInformation = @SetDataGridColoursFromUserDefaults;

            // Set up Delegate for the set-up of various Colours of all Filter and Find instances from UserDefaults
            Ict.Petra.Client.CommonControls.TUcoFilterAndFind.SetColourInformation = @SetFilterFindColoursFromUserDefaults;

            // Set up Data Validation Delegates
            TSharedValidationHelper.SharedGetDataDelegate = @TServerLookup.TMCommon.GetData;
            TSharedValidationControlHelper.SharedGetDateVerificationResultDelegate = @TtxtPetraDate.GetDateVerificationResult;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate            = @TServerLookup.TMPartner.VerifyPartner;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate = @TServerLookup.TMFinance.GetCurrentPostingRangeDates;
            TSharedFinanceValidationHelper.GetValidPeriodDatesDelegate      = @TServerLookup.TMFinance.GetCurrentPeriodDates;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on client side
            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate = @TDataCache.TMCommon.GetCacheableCommonTable;

            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate = @TDataCache.TMFinance.GetCacheableFinanceTable;

            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate       = @TDataCache.TMPartner.GetCacheablePartnerTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate       = @TDataCache.TMPartner.GetCacheableMailingTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @TDataCache.TMPartner.GetCacheableSubscriptionsTable;

            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate = @TDataCache.TMPersonnel.GetCacheablePersonnelTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate     = @TDataCache.TMPersonnel.GetCacheableUnitsTable;

            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @TDataCache.TMConference.GetCacheableConferenceTable;

            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate = @TDataCache.TMSysMan.GetCacheableSysManTable;

            // I18N: assign proper font which helps to read asian characters
            // this is the first place where it is called, and we need to initialize the TAppSettingsManager
            TAppSettingsManager.InitFontI18N();

            TCommonControlsHelper.SetInactiveIdentifier += delegate {
                return(SharedConstants.INACTIVE_VALUE_WITH_QUALIFIERS);
            };
        }
コード例 #6
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"));
            }
        }
コード例 #7
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"));
            }
        }
コード例 #8
0
        /// <summary>
        /// Perform necessary initializations of Classes
        /// </summary>
        /// <returns>void</returns>
        private static void InitialiseClasses()
        {
            TClientInfo.InitializeUnit();
            TCacheableTablesManager.InitializeUnit();
            new TIconCache();

            // Set up Delegates for forwarding of calls for security-related Exceptions
            ExceptionHandling.ProcessSecurityAccessDeniedException = TMessages.MsgSecurityException;
            TUnhandledThreadExceptionHandler.ProcessSecurityAccessDeniedException   = TMessages.MsgSecurityException;
            Ict.Common.Controls.TCommonControlsSecurity.SecurityAccessDeniedMessage = TMessages.MsgSecurityException;

            // Delegate for an extended message box
            TClientTaskInstance.ShowExtendedMessageBox = @TFrmExtendedMessageBoxManager.Create;

            // Set up Delegates for forwarding of calls to Screens in various Assemblies
            TCommonScreensForwarding.OpenPartnerFindScreen = @TPartnerFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenPartnerFindByBankDetailsScreen = @TPartnerFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenBankFindDialog              = @TBankFindDialogManager.OpenModalForm;
            TCommonScreensForwarding.OpenConferenceFindScreen        = @TConferenceFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenEventFindScreen             = @TEventFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenExtractFindScreen           = @TExtractFindScreenManager.OpenModalForm;
            TCommonScreensForwarding.OpenExtractMasterScreen         = @TExtractMasterScreenManager.OpenForm;
            TCommonScreensForwarding.OpenDonorRecipientHistoryScreen = @TDonorRecipientHistoryScreenManager.OpenForm;
            TCommonScreensForwarding.OpenPartnerEditScreen           = @TPartnerEditScreenManager.OpenForm;
            TCommonScreensForwarding.OpenExtractMasterScreenHidden   = @TExtractMasterScreenManager.OpenFormHidden;
            TCommonScreensForwarding.OpenRangeFindScreen             = @TPostcodeRangeSetupManager.OpenModalForm;
            TCommonScreensForwarding.OpenOccupationCodeFindScreen    = @TOccupationCodeSetupManager.OpenModalForm;
            TCommonScreensForwarding.OpenGetMergeDataDialog          = @TGetMergeDataManager.OpenModalForm;
            TCommonScreensForwarding.OpenPrintPartnerDialog          = @TPrintPartnerModal.OpenModalForm;
            TCommonScreensForwarding.TaxDeductiblePctAdjust          = @TFrmGiftTaxDeductiblePctAdjustment.TaxDeductiblePctAdjustment;
            TCommonScreensForwarding.OpenPrintUnitHierarchy          = @TPrintUnitHierarchy.OpenModalForm;

            // Set up Delegate for the opening of Forms from the Main Menu
            Ict.Common.Controls.TLstTasks.OpenNewOrExistingForm = @Ict.Petra.Client.CommonForms.TFormsList.OpenNewOrExistingForm;

            // Set up Delegate for the retrieval of the list of Currencies from the Cache
            Ict.Common.Controls.TTxtCurrencyTextBox.RetrieveCurrencyList = @Ict.Petra.Client.CommonControls.TControlExtensions.RetrieveCurrencyList;

            // Set up Delegate for checking the real module access permissions (rather than the ones in the XML)
            Ict.Common.Controls.TCommonControlsSecurity.CheckUserModulePermissions =
                @Ict.Petra.Shared.Security.TSecurityChecks.CheckUserModulePermissions;

            // Set up Delegate for the retrieval of the user defaults
            Ict.Common.Controls.TTxtNumericTextBox.RetrieveUserDefaultBoolean =
                @Ict.Petra.Client.CommonControls.TControlExtensions.RetrieveUserDefaultBoolean;
            Ict.Common.TypeConverter.TCurrencyConverter.RetrieveUserDefaultBoolean =
                @Ict.Petra.Client.CommonControls.TControlExtensions.RetrieveUserDefaultBoolean;
            Ict.Common.TypeConverter.TDecimalConverter.RetrieveUserDefaultBoolean =
                @Ict.Petra.Client.CommonControls.TControlExtensions.RetrieveUserDefaultBoolean;
            Ict.Common.IO.TTextFileEncoding.RetrieveUserDefaultBoolean =
                @Ict.Petra.Client.CommonControls.TControlExtensions.RetrieveUserDefaultBoolean;

            // Set up Delegate for the set-up of various Colours of all SourceGrid DataGrid instances from UserDefaults
            Ict.Common.Controls.TSgrdDataGrid.SetColourInformation = @SetDataGridColoursFromUserDefaults;

            // Set up Delegate for the set-up of various Colours of all Filter and Find instances from UserDefaults
            Ict.Petra.Client.CommonControls.TUcoFilterAndFind.SetColourInformation = @SetFilterFindColoursFromUserDefaults;

            // Set up Data Validation Delegates
            TSharedValidationHelper.SharedGetDataDelegate = @TServerLookup.TMCommon.GetData;
            TSharedValidationControlHelper.SharedGetDateVerificationResultDelegate = @TtxtPetraDate.GetDateVerificationResult;
            TSharedPartnerValidationHelper.VerifyPartnerDelegate                    = @TServerLookup.TMPartner.VerifyPartner;
            TSharedPartnerValidationHelper.PartnerHasActiveStatusDelegate           = @TServerLookup.TMPartner.PartnerHasActiveStatus;
            TSharedPartnerValidationHelper.PartnerIsLinkedToCCDelegate              = @TServerLookup.TMPartner.PartnerIsLinkedToCC;
            TSharedPartnerValidationHelper.PartnerOfTypeCCIsLinkedDelegate          = @TServerLookup.TMPartner.PartnerOfTypeCCIsLinked;
            TSharedPartnerValidationHelper.PartnerHasCurrentGiftDestinationDelegate = @TServerLookup.TMPartner.PartnerHasCurrentGiftDestination;
            TSharedFinanceValidationHelper.GetValidPostingDateRangeDelegate         = @TServerLookup.TMFinance.GetCurrentPostingRangeDates;
            TSharedFinanceValidationHelper.GetValidPeriodDatesDelegate              = @TServerLookup.TMFinance.GetCurrentPeriodDates;

            // Set up Delegates for retrieval of cacheable tables when called from Shared directories on client side
            TSharedDataCache.TMCommon.GetCacheableCommonTableDelegate = @TDataCache.TMCommon.GetCacheableCommonTable;

            TSharedDataCache.TMFinance.GetCacheableFinanceTableDelegate = @TDataCache.TMFinance.GetCacheableFinanceTable;

            TSharedDataCache.TMPartner.GetCacheablePartnerTableDelegate       = @TDataCache.TMPartner.GetCacheablePartnerTable;
            TSharedDataCache.TMPartner.GetCacheableMailingTableDelegate       = @TDataCache.TMPartner.GetCacheableMailingTable;
            TSharedDataCache.TMPartner.GetCacheableSubscriptionsTableDelegate = @TDataCache.TMPartner.GetCacheableSubscriptionsTable;
            TSharedDataCache.TMPartner.GetPartnerCalculationsSystemCategoryAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineSystemCategoryAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPartnerContactDetailAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePartnerContactDetailAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsEmailPartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DetermineEmailPartnerAttributeTypes;
            TSharedDataCache.TMPartner.GetPartnerCalculationsPhonePartnerAttributeTypesDelegate =
                @Ict.Petra.Shared.MPartner.Calculations.DeterminePhonePartnerAttributeTypes;

            TSharedDataCache.TMPersonnel.GetCacheablePersonnelTableDelegate = @TDataCache.TMPersonnel.GetCacheablePersonnelTable;
            TSharedDataCache.TMPersonnel.GetCacheableUnitsTableDelegate     = @TDataCache.TMPersonnel.GetCacheableUnitsTable;

            TSharedDataCache.TMConference.GetCacheableConferenceTableDelegate = @TDataCache.TMConference.GetCacheableConferenceTable;

            TSharedDataCache.TMSysMan.GetCacheableSysManTableDelegate = @TDataCache.TMSysMan.GetCacheableSysManTable;

            // I18N: assign proper font which helps to read asian characters
            // this is the first place where it is called, and we need to initialize the TAppSettingsManager
            TAppSettingsManager.InitFontI18N();

            TCommonControlsHelper.SetInactiveIdentifier += delegate {
                return(SharedConstants.INACTIVE_VALUE_WITH_QUALIFIERS);
            };

            TSmtpSender.GetSmtpSettings = @TServerLookup.TMSysMan.GetServerSmtpSettings;
        }
コード例 #9
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"));
            }
        }