Exemple #1
0
        void refreshCatalogues_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker bkgWork = sender as BackgroundWorker;

            try
            {
                bkgWork.ReportProgress(0);

                List <Catalogues> activeConnections = new List <Catalogues>();

                for (int i = 0; i < globalCataloguesCollection.Count; i++)
                {
                    activeConnections.Add(globalCataloguesCollection[i]);
                }

                globalCataloguesCollection.Clear();

                for (int i = 0; i < activeConnections.Count; i++)
                {
                    TDSettings.ConnectionRow connRow = _appSettings.GetConnectionById(activeConnections [i].ConnectionId);

                    Catalogues newCatalogue = null;
                    try
                    {
                        newCatalogue = CatalogueManager.GetCataloguesForUser(connRow, bkgWork);
                    }
                    catch (Exception)
                    {
                        // login failed or another exception
                        // old collection are kept.
                    }

                    // add catalogues per user
                    if (newCatalogue != null)
                    {
                        globalCataloguesCollection.Add(newCatalogue);
                    }
                    else
                    {
                        // keep the old collections
                        globalCataloguesCollection.Add(activeConnections[i]);
                    }

                    string connectionInfo = _appSettings.GetConnectionInfo(connRow.ConnectionId);

                    bkgWork.ReportProgress(1 + i * 90 / activeConnections.Count, connectionInfo);
                }

                bkgWork.ReportProgress(100);
            }
            catch (Exception ex)
            {
                MyLogger.Write(ex, "refreshCatalogues_DoWork", LoggingCategory.Exception);

                bkgWork.ReportProgress(100);

                throw;
            }
        }
Exemple #2
0
        void bkgCatalogues_DoWork(object sender, DoWorkEventArgs e)
        {
            SavingData       sp = null;
            BackgroundWorker backgroundWorker = sender as BackgroundWorker;
            ArrayList        result           = new ArrayList();

            try
            {
                ArrayList al = e.Argument as ArrayList;

                TDSettings.ConnectionRow currentConnection = al[0] as TDSettings.ConnectionRow;

                sp = al[1] as SavingData;

                Catalogues cataloguesPerUser = CatalogueManager.GetCataloguesForUser(currentConnection, backgroundWorker);

                result.Add(cataloguesPerUser);

                result.Add(sp);

                e.Result = result;
            }
            catch (Exception ex)
            {
                sp.ErrorMessage = ex.Message;

                sp.Operation = OperationType.LogOnFailed;

                MyLogger.Write(ex, "bkgCatalogues_DoWork", LoggingCategory.Exception);

                SplashManager.Close(); // just in case

                backgroundWorker.ReportProgress(100);

                throw new CustomException(sp, String.Empty, ex);
            }
        }