Exemple #1
0
        /// <summary>Hit when we're authenticated to the server.</summary>
        /// <param name="sender">ImportExportClient</param>
        /// <param name="e">Connection_Authenticate2CompletedEventArgs</param>
        private void clientSave_Connection_Authenticate2Completed(object sender, Connection_Authenticate2CompletedEventArgs e)
        {
            const string METHOD = CLASS + "clientSave_Connection_Authenticate2Completed()";

            Logger.LogTrace_EnterMethod(METHOD + "  " + this._clientNumSaving.ToString() + " clients running.");

            try
            {
                ImportExportClient client = (sender as ImportExportClient);
                this._clientNumSaving--;
                this.barSavingReq.Value++;

                if (!e.Cancelled)
                {
                    if (e.Error == null)
                    {
                        if (e.Result)
                        {
                            //Connect to the progect ID.
                            this._clientNumSaving++;
                            client.Connection_ConnectToProjectAsync(((SpiraProject)this._ArtifactDetails.ArtifactParentProject.ArtifactTag).ProjectID, this._clientNum++);
                        }
                        else
                        {
                            //TODO: Show Error.
                            //Cancel calls.
                            this._clientNumSaving++;
                            client.Connection_DisconnectAsync(this._clientNum++);
                        }
                    }
                    else
                    {
                        //TODO: Show Error.
                        //Cancel calls.
                        this._clientNumSaving++;
                        client.Connection_DisconnectAsync(this._clientNum++);
                    }
                }

                //See if it's okay to reload.
                this.save_CheckIfOkayToLoad();
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, METHOD);
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
            Logger.LogTrace_ExitMethod(METHOD + "  " + this._clientNumSaving.ToString() + " clients left.");
        }
        /// <summary>Hit when we've successfully connected to the server.</summary>
        /// <param name="sender">ImportExporClient</param>
        /// <param name="e">Connection_Authenticate2CompletedEventArgs</param>
        private void wkfClient_Connection_Authenticate2Completed(object sender, Connection_Authenticate2CompletedEventArgs e)
        {
            try
            {
                const string METHOD = CLASS + "wkfClient_Connection_Authenticate2Completed()";
                Logger.LogTrace(METHOD + " ENTER.");

                this._clientNumRunning--;
                this.barLoadingIncident.Value++;

                if (sender is ImportExportClient)
                {
                    ImportExportClient client = sender as ImportExportClient;

                    if (!e.Cancelled)
                    {
                        if (e.Error == null && e.Result)
                        {
                            //Connect to our project.
                            this._clientNumRunning++;
                            client.Connection_ConnectToProjectAsync(((SpiraProject)this._ArtifactDetails.ArtifactParentProject.ArtifactTag).ProjectID, this._clientNum++);
                        }
                        else
                        {
                            if (e.Error != null)
                            {
                                Logger.LogMessage(e.Error);
                            }
                            else
                            {
                                Logger.LogMessage(METHOD, "Could not log in.", System.Diagnostics.EventLogEntryType.Error);
                            }
                        }
                    }
                }

                Logger.LogTrace_ExitMethod(METHOD + "  Clients - Running: " + this._clientNumRunning.ToString() + ", Total: " + this._clientNum.ToString());
            }
            catch (Exception ex)
            {
                Logger.LogMessage(ex, "wkfClient_Connection_Authenticate2Completed()");
                MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }