private void LoadItem_Task3(object sender, EventArgs e) { try { bool isErrorThrown = false; string strErrMsg = ""; string EventType = e.GetType().ToString().Substring(e.GetType().ToString().LastIndexOf('.') + 1); switch (EventType) { case "Task_RetrieveByIdCompletedEventArgs": { Spira_ImportExport.Task_RetrieveByIdCompletedEventArgs evt = (Spira_ImportExport.Task_RetrieveByIdCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { if (this._isInConcurrency) { this._TaskConcurrent = evt.Result; } else { this._Task = evt.Result; } this._NumRunning--; System.Diagnostics.Debug.WriteLine("» Retreive Task Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = this.getErrorMessage(evt.Error); } } } break; case "Requirement_RetrieveCompletedEventArgs": { Spira_ImportExport.Requirement_RetrieveCompletedEventArgs evt = (Spira_ImportExport.Requirement_RetrieveCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._Requirements = evt.Result; this._NumRunning--; System.Diagnostics.Debug.WriteLine("» Retreive Requirements Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = this.getErrorMessage(evt.Error); } } } break; case "Project_RetrieveUserMembershipCompletedEventArgs": { Spira_ImportExport.Project_RetrieveUserMembershipCompletedEventArgs evt = (Spira_ImportExport.Project_RetrieveUserMembershipCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._ProjectUsers = evt.Result; this._NumRunning--; System.Diagnostics.Debug.WriteLine("» Retreive Project Users Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = this.getErrorMessage(evt.Error); } } } break; case "Release_RetrieveCompletedEventArgs": { Spira_ImportExport.Release_RetrieveCompletedEventArgs evt = (Spira_ImportExport.Release_RetrieveCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._ProjectReleases = evt.Result; this._NumRunning--; System.Diagnostics.Debug.WriteLine("» Retreive Project Releases Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = this.getErrorMessage(evt.Error); } } } break; } if (isErrorThrown) { for (int i = 0; i <= this._NumCount; i++) { try { this._Client.CancelAsync(i); } catch { } } //Display error information. this.panelLoading.Visibility = Visibility.Collapsed; this.panelLoadingError.Visibility = Visibility.Visible; this.panelForm.Visibility = Visibility.Collapsed; this.msgLoadingErrorMsg.Text = strErrMsg; this._isInLoadMode = false; } else { if (this._NumRunning == 0) { //Populate fields. this.LoadItem_PopulateFields(); //Show loading complete. this.panelLoading.Visibility = Visibility.Collapsed; this.panelForm.Visibility = Visibility.Visible; this._isInLoadMode = false; this._isInConcurrency = false; } } } catch (Exception ex) { Connect.logEventMessage("wpfDetailsTask::LoadItem_Task3", ex, System.Diagnostics.EventLogEntryType.Error); } }
/// <summary>Hit when any ASync call for data is completed.</summary> /// <param name="sender">ImportExport</param> /// <param name="e">Event Args</param> private void loadItem_Incident_4(object sender, EventArgs e) { try { bool isErrorThrown = false; string strErrMsg = ""; string EventType = e.GetType().ToString().Substring(e.GetType().ToString().LastIndexOf('.') + 1); switch (EventType) { #region Incident Complete case "Incident_RetrieveByIdCompletedEventArgs": { //Incident is loaded. Save data, fire off the dependant one. Spira_ImportExport.Incident_RetrieveByIdCompletedEventArgs evt = (Spira_ImportExport.Incident_RetrieveByIdCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { if (this.isInConcMode) { // It's a data concurrency load. We're only looking for Incident information. this._IncidentConcurrency = evt.Result; // Pass it to the flagging function. this.concurrency_HighlightFields(this._IncidentConcurrency); } else { // It's not a data concurrency load. this._Incident = evt.Result; this._NumRunning++; this._Client.Incident_RetrieveResolutionsAsync(this._Incident.IncidentId.Value, this._NumAsync++); if (this.hasWorkFlow_Avail) { this._NumRunning += 2; this._Client.Incident_RetrieveWorkflowFieldsAsync(this._Incident.IncidentTypeId, this._Incident.IncidentStatusId, this._NumAsync++); this._Client.Incident_RetrieveWorkflowTransitionsAsync(this._Incident.IncidentTypeId, this._Incident.IncidentStatusId, (this._Incident.OpenerId == this._Project.UserID), (this._Incident.OwnerId == this._Project.UserID), this._NumAsync++); } } //Subtract one because the one that started this is finished. this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Incident Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion #region Project User Membership Complete case "Project_RetrieveUserMembershipCompletedEventArgs": { Spira_ImportExport.Project_RetrieveUserMembershipCompletedEventArgs evt = (Spira_ImportExport.Project_RetrieveUserMembershipCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._ProjUsers = evt.Result; this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Project User Membership Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion #region Workflow Fields Complete case "Incident_RetrieveWorkflowFieldsCompletedEventArgs": { Spira_ImportExport.Incident_RetrieveWorkflowFieldsCompletedEventArgs evt = (Spira_ImportExport.Incident_RetrieveWorkflowFieldsCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._IncWkfFields_Current = scanWorkFlowFields(evt.Result); this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Workflow Fields Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion #region Workflow Transisions Complete case "Incident_RetrieveWorkflowTransitionsCompletedEventArgs": { Spira_ImportExport.Incident_RetrieveWorkflowTransitionsCompletedEventArgs evt = (Spira_ImportExport.Incident_RetrieveWorkflowTransitionsCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._IncWkfTransision = evt.Result; this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Workflow Transitions Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion #region Releases Complete case "Release_RetrieveCompletedEventArgs": { Spira_ImportExport.Release_RetrieveCompletedEventArgs evt = (Spira_ImportExport.Release_RetrieveCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._ProjReleases = evt.Result; this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Releases Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion #region Incident Priorities Complete case "Incident_RetrievePrioritiesCompletedEventArgs": { Spira_ImportExport.Incident_RetrievePrioritiesCompletedEventArgs evt = (Spira_ImportExport.Incident_RetrievePrioritiesCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._IncPriority = evt.Result; this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Incident Priorities Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion #region Incident Severites Complete case "Incident_RetrieveSeveritiesCompletedEventArgs": { Spira_ImportExport.Incident_RetrieveSeveritiesCompletedEventArgs evt = (Spira_ImportExport.Incident_RetrieveSeveritiesCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._IncSeverity = evt.Result; this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Incident Severities Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion #region Incident Types Complete case "Incident_RetrieveTypesCompletedEventArgs": { Spira_ImportExport.Incident_RetrieveTypesCompletedEventArgs evt = (Spira_ImportExport.Incident_RetrieveTypesCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._IncType = evt.Result; this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Incident Types Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion #region Incident Statuses Complete case "Incident_RetrieveStatusesCompletedEventArgs": { Spira_ImportExport.Incident_RetrieveStatusesCompletedEventArgs evt = (Spira_ImportExport.Incident_RetrieveStatusesCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._IncStatus = evt.Result; this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Incident Statuses Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion #region Resolutions Complete case "Incident_RetrieveResolutionsCompletedEventArgs": { Spira_ImportExport.Incident_RetrieveResolutionsCompletedEventArgs evt = (Spira_ImportExport.Incident_RetrieveResolutionsCompletedEventArgs)e; if (!evt.Cancelled) { if (evt.Error == null) { this._IncResolutions = evt.Result; this._NumRunning -= 1; //DEBUG: Logit. System.Diagnostics.Debug.WriteLine("» Resolutions Complete. " + this._NumRunning.ToString() + " left."); } else { isErrorThrown = true; strErrMsg = getErrorMessage(evt.Error); } } } break; #endregion } //If all of them have completed, load the form. if (isErrorThrown) { //Kill all Async calls. try { for (int I = 0; I <= this._NumAsync; I++) { this._Client.CancelAsync(I); } } finally { //Display error information. this.panelLoading.Visibility = Visibility.Collapsed; this.panelLoadingError.Visibility = Visibility.Visible; this.panelForm.Visibility = Visibility.Collapsed; this.msgLoadingErrorMsg.Text = strErrMsg; } } else if (this._NumRunning == 0) { // Load data into fields. if (this.isInConcMode) { this.loadItem_displayInformation(this._IncidentConcurrency); this._Incident = this._IncidentConcurrency; } else { this.loadItem_displayInformation(this._Incident); } this.loadItem_PopulateDiscussion(this._IncResolutions); //Set Workflow Data. (To disable Fields) this.loadItem_SetEnabledFields(this._IncWkfFields_Current); this.panelContents.IsEnabled = this.hasWorkFlow_Avail; //Update screen. if (this.isInSaveMode) { if (this.isInConcMode) { this.isInConcMode = false; this.isInSaveMode = false; this.panelWarning.Visibility = Visibility.Collapsed; this.panelInfo.Visibility = Visibility.Collapsed; this.panelError.Visibility = Visibility.Visible; this.msgErrMessage.Text = "This incident was modified by another user. New data has been loaded." + Environment.NewLine + "Yellow fields were modified by the other user. Red fields were both modified by you and the other user."; } else { this.isInSaveMode = false; this.panelWarning.Visibility = Visibility.Collapsed; this.panelError.Visibility = Visibility.Collapsed; this.panelInfo.Visibility = Visibility.Visible; this.msgInfMessage.Text = "Incident saved."; this.concurrency_ResetHighlightFields(); } } else { this.panelLoading.Visibility = Visibility.Collapsed; this.panelLoadingError.Visibility = Visibility.Collapsed; this.panelForm.Visibility = Visibility.Visible; this.concurrency_ResetHighlightFields(); } //Finished loading. this.isInLoadMode = false; this._isFieldChanged = false; this._btnSave.IsEnabled = false; this._isDescChanged = false; this._isResChanged = false; this._DetailsWindow.Caption = this._DetailsWindowTitle; } } catch (Exception ex) { Connect.logEventMessage("wpfDetailsIncident::loadItem_Incident_4", ex, System.Diagnostics.EventLogEntryType.Error); } }