Пример #1
0
        private static void Main(string[] args)
        {
            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);

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            TPetraClientMain.StartUp();
        }
Пример #2
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;
            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;
        }