// BsRangeQueryByPage get >= startkey && <= endkey có chia page theo begin and end==============================
        public bool BsRangeQueryByPage(string bsKey, string startItemKey, string endItemKey, long begin, long end,
                                       ref TItemSetResult itemSetResult, ref long total)
        {
            lock (_object)
            {
                TClientInfo clientInfo = _setClient.getClient();
                if (!clientInfo.isOpen())
                {
                    clientInfo.doOpen();
                }
                if (!clientInfo.sureOpen())
                {
                    Thread.Sleep(1 * 100);
                    if (!clientInfo.sureOpen())
                    {
                        Console.WriteLine("Can't open");
                        return(false);
                    }
                }
                _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();

                byte[] BstartItemKey;
                byte[] BendItemKey;
                try
                {
                    BstartItemKey = Encoding.UTF8.GetBytes(startItemKey);
                    BendItemKey   = Encoding.UTF8.GetBytes(endItemKey);
                }
                catch (Exception e)
                {
                    Console.WriteLine("error " + e.ToString());
                    clientInfo.cleanUp();
                    return(false);
                }

                var bsRangeQueryAsync = _aClient.bsRangeQueryAsync(bsKey, BstartItemKey, BendItemKey);

                if (bsRangeQueryAsync.Result.Items.Items.Count < 1)
                {
                    clientInfo.cleanUp();
                    return(false);
                }

                if (begin < 0)
                {
                    begin = 0;
                }

                if (end > bsRangeQueryAsync.Result.Items.Items.Count)
                {
                    end = bsRangeQueryAsync.Result.Items.Items.Count;
                }

                total = bsRangeQueryAsync.Result.Items.Items.Count;

                itemSetResult.Items.Items.CopyTo(Convert.ToInt32(begin), bsRangeQueryAsync.Result.Items.Items.ToArray(), 0, Convert.ToInt32(end - begin));
                clientInfo.cleanUp();
                return(false);
            }
        }
        // BsGetSliceByArray get by position begin -> end
        public bool BsGetSliceByArray(string bsKey, int begin, int count, ref TItemSetResult itemSetResult)
        {
            TClientInfo clientInfo = _setClient.getClient();

            if (!clientInfo.isOpen())
            {
                clientInfo.doOpen();
            }
            if (!clientInfo.sureOpen())
            {
                Thread.Sleep(1 * 100);
                if (!clientInfo.sureOpen())
                {
                    Console.WriteLine("Can't open");
                    return(false);
                }
            }
            _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();
            var bsGetSliceRAsync = _aClient.bsGetSliceRAsync(bsKey, begin, count);

            if (bsGetSliceRAsync.IsCanceled || bsGetSliceRAsync.IsFaulted)
            {
                Console.WriteLine("bsGetSliceRAsync.IsCanceled || bsGetSliceRAsync.IsFaulted");
                clientInfo.cleanUp();
                return(false);
            }
            if (bsGetSliceRAsync.Result.Items.Items.Count < 1)
            {
                clientInfo.cleanUp();
                return(false);
            }
            itemSetResult = bsGetSliceRAsync.Result;
            clientInfo.cleanUp();
            return(true);
        }
Esempio n. 3
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"));
        }
 //BsRemoveKeyBs=================================================================================================
 public bool BsRemoveKeyBs(string bsKey, ref long totalCount)
 {
     lock (_object)
     {
         TClientInfo clientInfo = _setClient.getClient();
         if (!clientInfo.isOpen())
         {
             clientInfo.doOpen();
         }
         if (!clientInfo.sureOpen())
         {
             Thread.Sleep(1 * 100);
             if (!clientInfo.sureOpen())
             {
                 Console.WriteLine("Can't open");
                 return(false);
             }
         }
         _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();
         var removeAllAsync = _aClient.removeAllAsync(bsKey);
         if (removeAllAsync.IsCanceled || removeAllAsync.IsFaulted)
         {
             clientInfo.cleanUp();
             return(false);
         }
         totalCount = removeAllAsync.Result;
         clientInfo.cleanUp();
         return(true);
     }
 }
        //TotalStringKeyCount ==========================================================================================
        public bool TotalStringKeyCount(ref long count)
        {
            lock (_object)
            {
                TClientInfo clientInfo = _setClient.getClient();
                if (!clientInfo.isOpen())
                {
                    clientInfo.doOpen();
                }
                if (!clientInfo.sureOpen())
                {
                    Thread.Sleep(1 * 100);
                    if (!clientInfo.sureOpen())
                    {
                        Console.WriteLine("Can't open");
                        return(false);
                    }
                }
                _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();

                var totalStringKeyCountAsync = _aClient.totalStringKeyCountAsync();
                if (totalStringKeyCountAsync.IsFaulted || totalStringKeyCountAsync.IsCanceled)
                {
                    Console.WriteLine("totalStringKeyCountAsync.IsFaulted");
                    count = 0;
                    clientInfo.cleanUp();
                    return(false);
                }
                count = totalStringKeyCountAsync.Result;
                clientInfo.cleanUp();
                return(true);
            }
        }
        // BsRangeQuery get >= startkey && <= endkey
        public bool BsRangeQuery(string bsKey, string startItemKey, string endItemKey, ref TItemSetResult itemSetResult)
        {
            lock (_object)
            {
                TClientInfo clientInfo = _setClient.getClient();
                if (!clientInfo.isOpen())
                {
                    clientInfo.doOpen();
                }
                if (!clientInfo.sureOpen())
                {
                    Thread.Sleep(1 * 100);
                    if (!clientInfo.sureOpen())
                    {
                        Console.WriteLine("Can't open");
                        return(false);
                    }
                }
                _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();

                byte[] BstartItemKey;
                byte[] BendItemKey;
                try
                {
                    BstartItemKey = Encoding.UTF8.GetBytes(startItemKey);
                    BendItemKey   = Encoding.UTF8.GetBytes(endItemKey);
                }
                catch (Exception e)
                {
                    Console.WriteLine("error " + e.ToString());
                    clientInfo.cleanUp();
                    return(false);
                }


                var bsRangeQueryAsync = _aClient.bsRangeQueryAsync(bsKey, BstartItemKey, BendItemKey);
                if (bsRangeQueryAsync.IsCanceled || bsRangeQueryAsync.IsFaulted)
                {
                    Console.WriteLine("bsRangeQueryAsync.IsCanceled || bsRangeQueryAsync.IsFaulted");
                    clientInfo.cleanUp();
                    return(false);
                }


                itemSetResult = bsRangeQueryAsync.Result;
                if (itemSetResult.Items.Items.Count < 1)
                {
                    clientInfo.cleanUp();
                    return(false);
                }
                clientInfo.cleanUp();
                return(true);
            }
        }
        // BsGetSlice get all
        public bool BsGetSlice(string bsKey, ref TItemSetResult itemSetResult)
        {
            lock (_object){
                TClientInfo clientInfo = _setClient.getClient();
                if (!clientInfo.isOpen())
                {
                    clientInfo.doOpen();
                }

                if (!clientInfo.sureOpen())
                {
                    Thread.Sleep(1 * 100);
                    if (!clientInfo.sureOpen())
                    {
                        Console.WriteLine("Can't open");
                        return(false);
                    }
                }
                _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();

                var getTotalCountAsync = _aClient.getTotalCountAsync(bsKey);
                if (getTotalCountAsync.IsCanceled || getTotalCountAsync.IsFaulted)
                {
                    Console.WriteLine("getTotalCountAsync.IsCanceled || getTotalCountAsync.IsFaulted");
                    clientInfo.cleanUp();
                    return(false);
                }
                long totalCount = getTotalCountAsync.Result;
                //Console.WriteLine("Count "+totalCount);
                int count = Convert.ToInt32(totalCount);
                if (count < 1)
                {
                    clientInfo.cleanUp();
                    return(false);
                }
                var bsGetSliceRAsync = _aClient.bsGetSliceRAsync(bsKey, 0, count);
                if (bsGetSliceRAsync.IsCanceled || bsGetSliceRAsync.IsFaulted)
                {
                    Console.WriteLine("bsGetSliceRAsync.IsCanceled || bsGetSliceRAsync.IsFaulted");
                    clientInfo.cleanUp();
                    return(false);
                }
                itemSetResult = bsGetSliceRAsync.Result;

                clientInfo.cleanUp();
                return(true);
            }
        }
Esempio n. 8
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);
        }
 //CheckBsExisted================================================================================================
 public bool CheckBsExisted(string bsKey, string itemKey)
 {
     lock (_object)
     {
         TClientInfo clientInfo = _setClient.getClient();
         if (!clientInfo.isOpen())
         {
             clientInfo.doOpen();
         }
         if (!clientInfo.sureOpen())
         {
             Thread.Sleep(1 * 100);
             if (!clientInfo.sureOpen())
             {
                 Console.WriteLine("Can't open");
                 return(false);
             }
         }
         _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();
         byte[] bitemKey;
         try
         {
             bitemKey = Encoding.UTF8.GetBytes(itemKey);
         }
         catch (Exception e)
         {
             Console.WriteLine(e);
             clientInfo.cleanUp();
             return(false);
         }
         var bsExistedAsyncs = _aClient.bsExistedAsync(bsKey, bitemKey);
         if (bsExistedAsyncs.IsCanceled || bsExistedAsyncs.IsFaulted)
         {
             Console.WriteLine("bsExistedAsyncs.IsFaulted");
             clientInfo.cleanUp();
             return(false);
         }
         clientInfo.cleanUp();
         return(bsExistedAsyncs.Result.Existed);
     }
 }
        //g// GetTotalCount return number item of bskey
        public bool GetTotalCount(string bsKey, ref long count)
        {
            lock (_object)
            {
                count = 0;
                TClientInfo clientInfo = _setClient.getClient();
                if (!clientInfo.isOpen())
                {
                    clientInfo.doOpen();
                }
                if (!clientInfo.sureOpen())
                {
                    Thread.Sleep(1 * 100);
                    if (!clientInfo.sureOpen())
                    {
                        Console.WriteLine("Can't open");
                        return(false);
                    }
                }
                _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();

                var getTotalCountAsync = _aClient.getTotalCountAsync(bsKey);
                if (getTotalCountAsync.IsFaulted || getTotalCountAsync.IsCanceled)
                {
                    Console.WriteLine("getTotalCountAsync.IsFaulted");
                    clientInfo.cleanUp();
                    return(false);
                }

                long totalCount = getTotalCountAsync.Result;
                if (totalCount < 1)
                {
                    clientInfo.cleanUp();
                    return(false);
                }
                count = totalCount;
                clientInfo.cleanUp();
                return(true);
            }
        }
        // BsGetItem get item by bskey and itemkey
        public bool BsGetItem(string bsKey, string key, ref TItem item)
        {
            lock (_object)
            {
                TClientInfo clientInfo = _setClient.getClient();
                if (!clientInfo.isOpen())
                {
                    clientInfo.doOpen();
                }

                if (!clientInfo.sureOpen())
                {
                    Thread.Sleep(1 * 100);
                    if (!clientInfo.sureOpen())
                    {
                        Console.WriteLine("Can't open");
                        return(false);
                    }
                }
                _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();

                var bsGetItemAsync = _aClient.bsGetItemAsync(bsKey, Encoding.ASCII.GetBytes(key));
                if (bsGetItemAsync.IsCanceled || bsGetItemAsync.IsCanceled)
                {
                    clientInfo.cleanUp();
                    return(false);
                }
                if (bsGetItemAsync.Result.Item == null)
                {
                    Console.WriteLine("Item not exists");
                    return(false);
                }
                item = bsGetItemAsync.Result.Item;

                clientInfo.cleanUp();
                return(true);
            }
        }
        public bool BsgMultiPutItem(string[] keys, TItem item)
        {
            lock (_object)
            {
                TClientInfo clientInfo = _setClient.getClient();
                if (!clientInfo.isOpen())
                {
                    clientInfo.doOpen();
                }

                if (!clientInfo.sureOpen())
                {
                    Thread.Sleep(1 * 100);
                    if (!clientInfo.sureOpen())
                    {
                        Console.WriteLine("Can't open");
                        return(false);
                    }
                }

                _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();

                foreach (var key in keys)
                {
                    var bsPutItemAsync = _aClient.bsPutItemAsync(key, item);
                    if (bsPutItemAsync.IsCompleted == false)
                    {
                        bsPutItemAsync.Wait();
                        if (bsPutItemAsync.IsCompleted == false)
                        {
                            return(false);
                        }
                    }
                }
                clientInfo.cleanUp();
                return(true);
            }
        }
        //GetListKey ==================================================================================================
        public bool GetListKey(long fromIndex, int count, List <String> listKey)
        {
            lock (_object)
            {
                TClientInfo clientInfo = _setClient.getClient();
                if (!clientInfo.isOpen())
                {
                    clientInfo.doOpen();
                }
                if (!clientInfo.sureOpen())
                {
                    Thread.Sleep(1 * 100);
                    if (!clientInfo.sureOpen())
                    {
                        Console.WriteLine("Can't open");
                        return(false);
                    }
                }
                _aClient = (TStringBigSetKVService.Client)clientInfo.getClient();
                var getListKeyAsync = _aClient.getListKeyAsync(fromIndex, count);
                if (getListKeyAsync.IsCanceled || getListKeyAsync.IsFaulted)
                {
                    Console.WriteLine("getListKeyAsync.IsCanceled || getListKeyAsync.IsFaulted");
                    clientInfo.cleanUp();
                    return(false);
                }

                if (getListKeyAsync.Result.Count < 1)
                {
                    clientInfo.cleanUp();
                    return(false);
                }
                listKey = getListKeyAsync.Result;
                clientInfo.cleanUp();
                return(true);
            }
        }
 public MessageData(TClientInfo clientInfo)
 {
     this.ClientInfo = clientInfo;
 }
Esempio n. 15
0
        static void Main(string[] args)
        {
            new TLogging("../../log/TestRemotingClient.log");

            try
            {
                new TAppSettingsManager("../../etc/Client.config");

                TLogging.DebugLevel = Convert.ToInt32(TAppSettingsManager.GetValue("Client.DebugLevel", "0"));

                new TClientSettings();

                // initialize the client
                TConnectionManagementBase.ConnectorType         = typeof(TConnector);
                TConnectionManagementBase.GConnectionManagement = new TConnectionManagement();

                TClientInfo.InitializeUnit();

                Catalog.Init("en-GB", "en-GB");

                string error;
                ConnectToTestServer("DEMO", "DEMO", out error);

                IMyUIConnector MyUIConnector = TRemote.MyService.SubNamespace.MyUIConnector();
                TEnsureKeepAlive.Register(MyUIConnector);
                IMySubNamespace test = TRemote.MyService.SubNamespace;

                while (true)
                {
                    try
                    {
                        TLogging.Log(TRemote.MyService.HelloWorld("Hello World"));
                    }
                    catch (Exception e)
                    {
                        TLogging.Log("problem with MyService HelloWorld: " + Environment.NewLine + e.ToString());
                    }

                    try
                    {
                        TLogging.Log(test.HelloSubWorld("Hello SubWorld"));
                    }
                    catch (Exception e)
                    {
                        TLogging.Log("problem with sub namespace HelloSubWorld: " + Environment.NewLine + e.ToString());
                    }

                    try
                    {
                        TLogging.Log(MyUIConnector.HelloWorldUIConnector());
                    }
                    catch (Exception e)
                    {
                        TLogging.Log("problem with HelloWorldUIConnector: " + Environment.NewLine + e.ToString());
                    }

                    Console.WriteLine("Press ENTER to say Hello World again... ");
                    Console.WriteLine("Press CTRL-C to exit ...");
                    Console.ReadLine();
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
                Console.ReadLine();
            }
        }
 public MessageData(int id, TClientInfo clientInfo)
 {
     this.Id         = id;
     this.ClientInfo = clientInfo;
 }
Esempio n. 17
0
        static void Main(string[] args)
        {
            new TLogging("../../log/TestRemotingClient.log");

            try
            {
                new TAppSettingsManager("../../etc/Client.config");

                TLogging.DebugLevel = Convert.ToInt32(TAppSettingsManager.GetValue("Client.DebugLevel", "0"));

                new TClientSettings();

                // initialize the client
                new TRemoteTest();

                // need to call this as well to make the progress dialog work
                new TRemote();

                // allow self signed ssl certificate for test purposes
                ServicePointManager.ServerCertificateValidationCallback = delegate {
                    return(true);
                };

                THttpConnector.InitConnection(TAppSettingsManager.GetValue("OpenPetra.HTTPServer"));

                TClientInfo.InitializeUnit();

                Catalog.Init("en-GB", "en-GB");

                SortedList <string, object> Parameters = new SortedList <string, object>();
                Parameters.Add("username", "demo");
                Parameters.Add("password", "demo");
                Parameters.Add("version", TFileVersionInfo.GetApplicationVersion().ToString());

                List <object> ResultList = THttpConnector.CallWebConnector("SessionManager", "LoginClient", Parameters, "list");
                eLoginEnum    Result     = (eLoginEnum)ResultList[0];

                if (Result != eLoginEnum.eLoginSucceeded)
                {
                    // failed login
                    return;
                }

                IMyUIConnector MyUIConnector = TRemoteTest.MyService.SubNamespace.MyUIConnector();
                TRemoteTest.TMyService.TMySubNamespace test = TRemoteTest.MyService.SubNamespace;

                while (true)
                {
                    try
                    {
                        TLogging.Log("before call");
                        TLogging.Log(TRemoteTest.MyService.HelloWorld("Hello World"));
                        TLogging.Log("after call");
                    }
                    catch (Exception e)
                    {
                        TLogging.Log("problem with MyService HelloWorld: " + Environment.NewLine + e.ToString());
                    }

                    try
                    {
                        DateTime DateTomorrow;
                        TLogging.Log("should show today's date: " + TRemoteTest.MyService.TestDateTime(DateTime.Today,
                                                                                                       out DateTomorrow).ToShortDateString());
                        TLogging.Log("should show tomorrow's date: " + DateTomorrow.ToShortDateString());
                    }
                    catch (Exception e)
                    {
                        TLogging.Log("problem with TestDateTime: " + Environment.NewLine + e.ToString());
                    }

                    try
                    {
                        TLogging.Log(test.HelloSubWorld("Hello SubWorld"));
                    }
                    catch (Exception e)
                    {
                        TLogging.Log("problem with sub namespace HelloSubWorld: " + Environment.NewLine + e.ToString());
                    }

                    try
                    {
                        TLogging.Log(MyUIConnector.HelloWorldUIConnector());
                    }
                    catch (Exception e)
                    {
                        TLogging.Log("problem with HelloWorldUIConnector: " + Environment.NewLine + e.ToString());
                    }

                    // start long running job
                    Thread t = new Thread(() => TRemoteTest.MyService.LongRunningJob());

                    using (TProgressDialog dialog = new TProgressDialog(t))
                    {
                        if (dialog.ShowDialog() == DialogResult.Cancel)
                        {
                            return;
                        }
                    }

                    Console.WriteLine("Press ENTER to say Hello World again... ");
                    Console.WriteLine("Press CTRL-C to exit ...");
                    Console.ReadLine();
                }
            }
            catch (Exception e)
            {
                TLogging.Log(e.ToString());
                Console.ReadLine();
            }
        }
Esempio n. 18
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);
            };
        }
Esempio n. 19
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;
        }