/// <summary>Creates a useable dictionary of Field ID and Status from the given list of Workflow Fields.</summary> /// <param name="workflowFields">A list of Workflow Fields</param> /// <returns>A dictionary of FieldId and current Status.</returns> private Dictionary <int, WorkflowField.WorkflowStatusEnum> workflow_LoadFieldStatus(List <RemoteWorkflowIncidentFields> workflowFields) { string METHOD = CLASS + "workflow_SetEnabledFields(std)"; Logger.LogTrace_EnterMethod(METHOD); Dictionary <int, WorkflowField.WorkflowStatusEnum> retList = new Dictionary <int, WorkflowField.WorkflowStatusEnum>(); try { //Go through each known field, and see if it exists in the data we got from the server. foreach (KeyValuePair <int, WorkflowField> kvpField in this._WorkflowFields) { WorkflowField.WorkflowStatusEnum status = WorkflowField.WorkflowStatusEnum.Normal; List <RemoteWorkflowIncidentFields> wkfFields = workflowFields.Where(wkf => wkf.FieldId == kvpField.Key).ToList(); if (wkfFields.Count > 0) { //The order of statuses is: Required above Hidden above Disabled. if (wkfFields.Count(wkf => wkf.FieldStateId == (int)WorkflowField.WorkflowStatusEnum.Required) == 1) { status = WorkflowField.WorkflowStatusEnum.Required; } else if (wkfFields.Count(wkf => wkf.FieldStateId == (int)WorkflowField.WorkflowStatusEnum.Hidden) == 1) { status = WorkflowField.WorkflowStatusEnum.Hidden; } else if (wkfFields.Count(wkf => wkf.FieldStateId == (int)WorkflowField.WorkflowStatusEnum.Inactive) == 1) { status = WorkflowField.WorkflowStatusEnum.Inactive; } } //If it's the 'Name' field, they cannot hide that, change it to 'Disabled' instead. if (kvpField.Key == 10 && status == WorkflowField.WorkflowStatusEnum.Hidden) { status = WorkflowField.WorkflowStatusEnum.Inactive; } retList.Add(kvpField.Key, status); } return(retList); } catch (Exception ex) { Logger.LogMessage(ex, "workflow_LoadFieldStatus()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); retList = new Dictionary <int, WorkflowField.WorkflowStatusEnum>(); } Logger.LogTrace_ExitMethod(METHOD); return(retList); }
/// <summary>Creates a useable dictionary of Field ID and Status from the given list of Workflow Custom Fields.</summary> /// <param name="workflowFields">A list of Workflow Fields</param> /// <returns>A dictionary of FieldId and current Status.</returns> private Dictionary <int, WorkflowField.WorkflowStatusEnum> workflow_LoadFieldStatus(List <RemoteWorkflowIncidentCustomProperties> workflowFields) { string METHOD = CLASS + "workflow_SetEnabledFields(cust)"; Logger.LogTrace_EnterMethod(METHOD); Dictionary <int, WorkflowField.WorkflowStatusEnum> retList = new Dictionary <int, WorkflowField.WorkflowStatusEnum>(); try { //Go through each workflow entry.. foreach (RemoteWorkflowIncidentCustomProperties prop in workflowFields) { WorkflowField.WorkflowStatusEnum status = WorkflowField.WorkflowStatusEnum.Normal; try { status = (WorkflowField.WorkflowStatusEnum)prop.FieldStateId; } catch (Exception ex) { } //Add it to the list, if there isn't a higher one already in there. if (retList.ContainsKey(prop.CustomPropertyId)) { status = WorkflowField.GetHigherImportance(status, retList[prop.CustomPropertyId]); retList[prop.CustomPropertyId] = status; } else { retList.Add(prop.CustomPropertyId, status); } } } catch (Exception ex) { Logger.LogMessage(ex, "workflow_LoadFieldStatus()"); MessageBox.Show(StaticFuncs.getCultureResource.GetString("app_General_UnexpectedError"), StaticFuncs.getCultureResource.GetString("app_General_ApplicationShortName"), MessageBoxButton.OK, MessageBoxImage.Error); retList = new Dictionary <int, WorkflowField.WorkflowStatusEnum>(); } Logger.LogTrace_ExitMethod(METHOD); return(retList); }