コード例 #1
0
        public static CustCollection LoadCust(CustCollection cc, int ViewerType = 1)
        {
            // Called to Load/reload the One & Only Bankcollection data source
            if (dtCust.Rows.Count > 0)
            {
                dtCust.Clear( );
            }
            if (cc != null)
            {
                Custinternalcollection = cc;
            }
            else
            {
                Custinternalcollection = new CustCollection( );
            }

            if (Custinternalcollection.Count > 0)
            {
                Custinternalcollection.ClearItems( );
            }

            CustCollection c = new CustCollection();

            c.LoadCustDataSql( );

            if (dtCust.Rows.Count > 0)
            {
                Custinternalcollection = LoadCustomerTest( );
            }
            // We now have the ONE AND ONLY pointer the the Bank data in variable Bankcollection
            Flags.CustCollection    = Custinternalcollection;
            SqlViewerCustcollection = Custinternalcollection;
            if (Flags.IsMultiMode == false)
            {
                // Finally fill and return The global Dataset
                SelectViewer(ViewerType, Custinternalcollection);
                return(Custinternalcollection);
            }
            else
            {
                // return the "working  copy" pointer, it has  filled the relevant collection to match the viewer
                return(Custinternalcollection);
            }
        }
コード例 #2
0
        //**************************************************************************************************************************************************************//
        // Entry point for all data load/Reload
        //**************************************************************************************************************************************************************//
        public static async Task <bool> LoadCustomerTaskInSortOrderAsync(bool isOriginator, int mode = -1)
        {
            try
            {
                if (dtCust.Rows.Count > 0)
                {
                    dtCust.Clear( );
                }

                if (Custcollection.Items.Count > 0)
                {
                    Custcollection.ClearItems( );
                }

                Custcollection = new CustCollection( );

                Console.WriteLine($"Calling Task.Run in custcollection ....");

                await Task.Run(async( ) =>
                {
                    Console.WriteLine($"Calling LoadCustDataSql in Task.Run in Bankcollection ....");
                    try
                    {
                        await LoadCustDataSql( );
                        Console.WriteLine($"Returned from LoadCustDataSql in Task.Run in Custcollection ....");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine($"ERROR in LoadCustData Task{ex.Message}, {ex.Data}....");
                    }

                    Application.Current.Dispatcher.Invoke(
                        async( ) =>
                    {
                        Console.WriteLine($"Calling LoadCustomerCollection in Task.Run in Custcollection ....");
                        try
                        {
                            await LoadCustomerCollection( );
                            Console.WriteLine($"Returned from LoadCustmerCollection Task.Run in Custcollection ....");
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine($"ERROR in LoadCustomerCollection Task {ex . Message}, {ex . Data}....");
                        }
                    });
                });

                Console.WriteLine($"**** END **** OF ASYNC CALL METHOD {dtCust . Rows . Count} records in DataTable, {Custcollection . Count} in Custcollection ....");
                Console.WriteLine($"**** END **** SENDING CALLBACK MESSAGE TO SQLDBVIEWER WINDOW TO LOAD THEIR DATAGRID !!!");

                if (CustDataLoaded != null)
                {
                    CustDataLoaded.Invoke(Custcollection, new LoadedEventArgs {
                        CallerDb = "CUSTOMER", DataSource = Custcollection
                    });
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"ERROR in LoadCustomerTaskInSortOrderAsync() : {ex . Message}, : {ex . Data}");
                return(false);
            }
            return(true);
        }