private void loadItem_displayInformation(Spira_ImportExport.RemoteIncident incident)
 {
     try
     {
         //Load information:
         // - Name
         this.cntrlIncidentName.Text = incident.Name;
         // - Users
         this.loadItem_PopulateUser(this.cntrlDetectedBy, incident.OpenerId, incident.OpenerName, this._Client);
         this.loadItem_PopulateUser(this.cntrlOwnedBy, incident.OwnerId, incident.OwnerName, this._Client);
         ((ComboBoxItem)this.cntrlDetectedBy.Items[0]).IsEnabled = false;
         // - Releases
         this.loadItem_PopulateReleaseControl(this.cntrlDetectedIn, incident.DetectedReleaseId);
         this.loadItem_PopulateReleaseControl(this.cntrlResolvedIn, incident.ResolvedReleaseId);
         this.loadItem_PopulateReleaseControl(this.cntrlVerifiedIn, incident.VerifiedReleaseId);
         // - Priority & Severity
         this.loadItem_PopulatePriority(this.cntrlPriority, incident.PriorityId);
         this.loadItem_PopulateSeverity(this.cntrlSeverity, incident.SeverityId);
         // - Type & Status
         this.loadItem_PopulateType(this.cntrlType, incident.IncidentTypeId);
         this.loadItem_PopulateStatus(this.cntrlStatus, incident.IncidentStatusId);
         // - Description
         this.cntrlDescription.HTMLText = incident.Description;
         // - History
         //TODO: History (need API update)
         // - Schedule
         this.cntrlStartDate.SelectedDate = incident.StartDate;
         this.cntrlEndDate.SelectedDate   = incident.ClosedDate;
         this.cntrlPerComplete.Text       = incident.CompletionPercent.ToString();
         this.cntrlEstEffortH.Text        = ((incident.EstimatedEffort.HasValue) ? Math.Floor(((double)incident.EstimatedEffort / (double)60)).ToString() : "");
         this.cntrlEstEffortM.Text        = ((incident.EstimatedEffort.HasValue) ? ((double)incident.EstimatedEffort % (double)60).ToString() : "");
         this.cntrlActEffortH.Text        = ((incident.ActualEffort.HasValue) ? Math.Floor(((double)incident.ActualEffort / (double)60)).ToString() : "");
         this.cntrlActEffortM.Text        = ((incident.ActualEffort.HasValue) ? ((double)incident.ActualEffort % (double)60).ToString() : "");
         // - Custom Properties
         //TODO: Custom Props (need API update on workflow for field statuses)
     }
     catch (Exception ex)
     {
         Connect.logEventMessage("wpfDetailsIncident::loadItem_displayInformation", 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);
            }
        }
예제 #3
0
        /// <summary>Uses the specified concurrency incident to determine the status of a field, and highlight that field for the user to take action on.</summary>
        /// <param name="ConcurrencyIncident">The reloaded incident that has concurrency differences.</param>
        private void concurrency_HighlightFields(Spira_ImportExport.RemoteIncident ConcurrencyIncident)
        {
            try
            {
                #region Standard Fields
                // - Name
                if (this._Incident.Name != ConcurrencyIncident.Name)
                {
                    if (this._Incident.Name != this.cntrlIncidentName.Text)
                    {
                        this.cntrlIncidentName.Tag = "2";
                    }
                    else
                    {
                        this.cntrlIncidentName.Tag = "1";
                    }
                }
                // - Type
                if (this._Incident.IncidentTypeId != ConcurrencyIncident.IncidentTypeId)
                {
                    if (this._Incident.IncidentTypeId != ((Spira_ImportExport.RemoteIncidentType) this.cntrlType.SelectedItem).IncidentTypeId)
                    {
                        this.cntrlType.Tag = "2";
                    }
                    else
                    {
                        this.cntrlType.Tag = "1";
                    }
                }
                // - Status
                if (this._Incident.IncidentStatusId != ConcurrencyIncident.IncidentStatusId)
                {
                    this.cntrlStatus.Tag = this.cntrlStatus.Background.Clone();

                    int numSelected = -1;
                    if (this.cntrlStatus.SelectedItem.GetType() == typeof(Spira_ImportExport.RemoteWorkflowIncidentTransition))
                    {
                        numSelected = ((Spira_ImportExport.RemoteWorkflowIncidentTransition) this.cntrlStatus.SelectedItem).IncidentStatusID_Output;
                    }
                    else if (this.cntrlStatus.SelectedItem.GetType() == typeof(Spira_ImportExport.RemoteIncidentStatus))
                    {
                        numSelected = ((Spira_ImportExport.RemoteIncidentStatus) this.cntrlStatus.SelectedItem).IncidentStatusId.Value;
                    }

                    if (this._Incident.IncidentStatusId != numSelected)
                    {
                        this.cntrlStatus.Tag = "2";
                    }
                    else
                    {
                        this.cntrlStatus.Tag = "1";
                    }
                }
                // - Detected By
                if (this._Incident.OpenerId != ConcurrencyIncident.OpenerId)
                {
                    if (this._Incident.OpenerId != ((Spira_ImportExport.RemoteUser) this.cntrlDetectedBy.SelectedItem).UserId)
                    {
                        this.cntrlDetectedBy.Tag = "2";
                    }
                    else
                    {
                        this.cntrlDetectedBy.Tag = "1";
                    }
                }
                // - Assigned To
                if (this._Incident.OwnerId != ConcurrencyIncident.OwnerId)
                {
                    if (this._Incident.OwnerId != ((Spira_ImportExport.RemoteUser) this.cntrlOwnedBy.SelectedItem).UserId)
                    {
                        this.cntrlOwnedBy.Tag = "2";
                    }
                    else
                    {
                        this.cntrlOwnedBy.Tag = "1";
                    }
                }
                // - Priority
                if (this._Incident.PriorityId != ConcurrencyIncident.PriorityId)
                {
                    if (this._Incident.PriorityId != ((Spira_ImportExport.RemoteIncidentPriority) this.cntrlPriority.SelectedItem).PriorityId)
                    {
                        this.cntrlPriority.Tag = "2";
                    }
                    else
                    {
                        this.cntrlPriority.Tag = "1";
                    }
                }
                // - Severity
                if (this._Incident.SeverityId != ConcurrencyIncident.SeverityId)
                {
                    if (this._Incident.SeverityId != ((Spira_ImportExport.RemoteIncidentSeverity) this.cntrlSeverity.SelectedItem).SeverityId)
                    {
                        this.cntrlSeverity.Tag = "2";
                    }
                    else
                    {
                        this.cntrlSeverity.Tag = "1";
                    }
                }
                // - Detected In
                if (this._Incident.DetectedReleaseId != ConcurrencyIncident.DetectedReleaseId)
                {
                    if (this._Incident.DetectedReleaseId != ((Spira_ImportExport.RemoteRelease) this.cntrlDetectedIn.SelectedItem).ReleaseId)
                    {
                        this.cntrlDetectedIn.Tag = "2";
                    }
                    else
                    {
                        this.cntrlDetectedIn.Tag = "1";
                    }
                }
                // - Resolved In
                if (this._Incident.ResolvedReleaseId != ConcurrencyIncident.ResolvedReleaseId)
                {
                    if (this._Incident.ResolvedReleaseId != ((Spira_ImportExport.RemoteRelease) this.cntrlResolvedIn.SelectedItem).ReleaseId)
                    {
                        this.cntrlResolvedIn.Tag = "2";
                    }
                    else
                    {
                        this.cntrlResolvedIn.Tag = "1";
                    }
                }
                // - Verified In
                if (this._Incident.VerifiedReleaseId != ConcurrencyIncident.VerifiedReleaseId)
                {
                    if (this._Incident.VerifiedReleaseId != ((Spira_ImportExport.RemoteRelease) this.cntrlVerifiedIn.SelectedItem).ReleaseId)
                    {
                        this.cntrlVerifiedIn.Tag = "2";
                    }
                    else
                    {
                        this.cntrlVerifiedIn.Tag = "1";
                    }
                }
                // - Description
                if (this._Incident.Description.Trim() != ConcurrencyIncident.Description.Trim())
                {
                    if (this._isDescChanged)
                    {
                        this.grpDescription.Tag = "2";
                    }
                    else
                    {
                        this.grpDescription.Tag = "1";
                    }
                }
                #endregion
                #region Schedule Fields
                // - Start Date
                int schHead = 0;
                if (this._Incident.StartDate != ConcurrencyIncident.StartDate)
                {
                    if (this._Incident.StartDate != this.cntrlStartDate.SelectedDate)
                    {
                        this.cntrlStartDate.Tag = "2";
                        schHead = 2;
                    }
                    else
                    {
                        this.cntrlStartDate.Tag = "1";
                        if (schHead < 1)
                        {
                            schHead = 1;
                        }
                    }
                }
                // - End Date
                if (this._Incident.ClosedDate != ConcurrencyIncident.ClosedDate)
                {
                    if (this._Incident.ClosedDate != this.cntrlEndDate.SelectedDate)
                    {
                        this.cntrlEndDate.Tag = "2";
                        schHead = 2;
                    }
                    else
                    {
                        this.cntrlEndDate.Tag = "1";
                        if (schHead < 1)
                        {
                            schHead = 1;
                        }
                    }
                }
                // - Percent Complete
                if (this._Incident.CompletionPercent != ConcurrencyIncident.CompletionPercent)
                {
                    if (this._Incident.CompletionPercent.ToString() != this.cntrlPerComplete.Text)
                    {
                        this.cntrlPerComplete.Tag = "2";
                        schHead = 2;
                    }
                    else
                    {
                        this.cntrlPerComplete.Tag = "1";
                        if (schHead < 1)
                        {
                            schHead = 1;
                        }
                    }
                }
                // - Estimated Effort
                if (this._Incident.EstimatedEffort != ConcurrencyIncident.EstimatedEffort)
                {
                    //Need to do several comparisons.
                    bool isSame = true;
                    if (!this._Incident.EstimatedEffort.HasValue && !string.IsNullOrEmpty(this.cntrlEstEffortH.Text) && !string.IsNullOrEmpty(this.cntrlEstEffortM.Text))
                    {
                        isSame = false;
                    }
                    if (this._Incident.EstimatedEffort.HasValue &&
                        ((Math.Floor(((double)this._Incident.EstimatedEffort / (double)60)).ToString() != this.cntrlEstEffortH.Text.Trim()) ||
                         (((double)this._Incident.EstimatedEffort % (double)60).ToString() != this.cntrlEstEffortM.Text.Trim())))
                    {
                        isSame = false;
                    }

                    if (!isSame)
                    {
                        this.cntrlEstEffortH.Tag = this.cntrlEstEffortM.Tag = "2";
                        schHead = 2;
                    }
                    else
                    {
                        this.cntrlEstEffortH.Tag = this.cntrlEstEffortM.Tag = "1";
                        if (schHead < 1)
                        {
                            schHead = 1;
                        }
                    }
                }
                // - Actual Effort
                if (this._Incident.ActualEffort != ConcurrencyIncident.ActualEffort)
                {
                    //Need to do several comparisons.
                    bool isSame = true;
                    if (!this._Incident.ActualEffort.HasValue && !string.IsNullOrEmpty(this.cntrlActEffortH.Text) && !string.IsNullOrEmpty(this.cntrlActEffortM.Text))
                    {
                        isSame = false;
                    }
                    if (this._Incident.ActualEffort.HasValue &&
                        ((Math.Floor(((double)this._Incident.ActualEffort / (double)60)).ToString() != this.cntrlActEffortH.Text.Trim()) ||
                         (((double)this._Incident.ActualEffort % (double)60).ToString() != this.cntrlActEffortM.Text.Trim())))
                    {
                        isSame = false;
                    }

                    if (!isSame)
                    {
                        this.cntrlActEffortH.Tag = this.cntrlActEffortM.Tag = "2";
                        schHead = 2;
                    }
                    else
                    {
                        this.cntrlActEffortH.Tag = this.cntrlActEffortM.Tag = "1";
                        if (schHead < 1)
                        {
                            schHead = 1;
                        }
                    }
                }
                if (schHead > 0)
                {
                    this.cntrlTabSchedule.Tag = schHead.ToString();
                }
                #endregion
            }
            catch (Exception ex)
            {
                Connect.logEventMessage("wpfDetailsIncident::concurrency_HighlightFields", ex, System.Diagnostics.EventLogEntryType.Error);
            }
        }