public static string LoadEntityFields(string entityType) { DataTable dtNew = new DataTable(); DataColumnCollection DCC; Dictionary <string, GridColsColumn> _gridColumns = new Dictionary <string, GridColsColumn>(); GridCols _columnData = new GridCols(); DataTable dt = new DataTable(); int AOR_ID = 0; bool isVisible = false; string dbName = string.Empty, displayName = string.Empty, idField = string.Empty; var ordered = _gridColumns.Keys.OrderBy(k => _gridColumns[k].DisplayName).ToList(); try { switch (entityType.ToUpper()) { case "AOR": dt = AOR.AORList_Get(AORID: AOR_ID); _gridColumns = new Dictionary <string, GridColsColumn>(); GridColsColumn column = new GridColsColumn(); dbName = string.Empty; displayName = string.Empty; idField = string.Empty; isVisible = false; foreach (DataColumn gridColumn in dt.Columns) { column = new GridColsColumn(); displayName = gridColumn.ColumnName; idField = gridColumn.ColumnName; isVisible = false; switch (gridColumn.ColumnName) { //case "Current Release": // displayName = "Current Release"; // idField = "ProductVersion_ID"; // isVisible = true; // break; case "Workload Allocation": displayName = "Workload Allocation"; idField = "WorkloadAllocation_ID"; isVisible = true; break; } if (isVisible) { column.ColumnName = gridColumn.ColumnName; column.DisplayName = displayName; column.Visible = isVisible; column.SortName = idField; _gridColumns.Add(column.DisplayName, column); } } //Initialize the columnData _columnData.Initialize(ref dt, ";", "~", "|"); dtNew.Columns.Add("valueField"); dtNew.Columns.Add("textField"); dtNew.Columns.Add("id_field"); ordered = _gridColumns.Keys.OrderBy(k => _gridColumns[k].DisplayName).ToList(); foreach (string key in ordered) { GridColsColumn col = _gridColumns[key]; if (col.Visible) { DataRow dr = dtNew.NewRow(); dr[0] = col.ColumnName; dr[1] = col.DisplayName; dr[2] = col.SortName; dtNew.Rows.Add(dr); } } break; case "CR": dt = AOR.AORCRList_Get(AORID: AOR_ID, AORReleaseID: 0, CRID: 0); _gridColumns = new Dictionary <string, GridColsColumn>(); column = new GridColsColumn(); dbName = string.Empty; displayName = string.Empty; idField = string.Empty; isVisible = false; foreach (DataColumn gridColumn in dt.Columns) { column = new GridColsColumn(); displayName = gridColumn.ColumnName; idField = gridColumn.ColumnName; isVisible = false; switch (gridColumn.ColumnName) { case "Contract": displayName = "Contract"; idField = "Contract_ID"; isVisible = true; break; case "Websystem": displayName = "Websystem"; idField = "Websystem_ID"; isVisible = false; break; case "Related Release": displayName = "Related Release"; idField = "RelatedRelease_ID"; isVisible = false; break; case "Status": displayName = "CR Coordination"; idField = "Status_ID"; isVisible = true; break; case "CyberISMT": displayName = "Cyber/ISMT"; idField = "CyberISMT_ID"; isVisible = false; break; } if (isVisible) { column.ColumnName = gridColumn.ColumnName; column.DisplayName = displayName; column.Visible = isVisible; column.SortName = idField; _gridColumns.Add(column.DisplayName, column); } } //Initialize the columnData _columnData.Initialize(ref dt, ";", "~", "|"); dtNew.Columns.Add("valueField"); dtNew.Columns.Add("textField"); dtNew.Columns.Add("id_field"); ordered = _gridColumns.Keys.OrderBy(k => _gridColumns[k].DisplayName).ToList(); foreach (string key in ordered) { GridColsColumn col = _gridColumns[key]; if (col.Visible) { DataRow dr = dtNew.NewRow(); dr[0] = col.ColumnName; dr[1] = col.DisplayName; dr[2] = col.SortName; dtNew.Rows.Add(dr); } } break; case "PRIMARYTASK": dt = AOR.AORTaskList_Get(AORID: AOR_ID, AORReleaseID: 0); // dt = WorkloadItem.WorkItemList_Get(workRequestID: 0 //, showArchived: 0 //, columnListOnly: 0 //, myData: false); _gridColumns = new Dictionary <string, GridColsColumn>(); column = new GridColsColumn(); dbName = string.Empty; displayName = string.Empty; idField = string.Empty; isVisible = false; foreach (DataColumn gridColumn in dt.Columns) { column = new GridColsColumn(); displayName = gridColumn.ColumnName; idField = gridColumn.ColumnName; isVisible = false; switch (gridColumn.ColumnName) { case "System(Task)": displayName = "System(Task)"; idField = "WTS_SYSTEM_ID"; isVisible = true; break; case "Production Status": displayName = "Production Status"; idField = "ProductionStatus_ID"; isVisible = true; break; //case "Product Version": // displayName = "Product Version"; // idField = "ProductVersion_ID"; // isVisible = true; // break; case "Priority": displayName = "Priority"; idField = "PRIORITY_ID"; isVisible = true; break; case "Primary Resource": displayName = "Primary Resource"; idField = "PrimaryTechResource_ID"; isVisible = true; break; case "Assigned To": displayName = "Assigned To"; idField = "AssignedTo_ID"; isVisible = true; break; case "Status": displayName = "Status"; idField = "STATUS_ID"; isVisible = true; break; case "Percent Complete": displayName = "Percent Complete"; idField = "PercentComplete_ID"; isVisible = false; break; } if (isVisible) { column.ColumnName = gridColumn.ColumnName; column.DisplayName = displayName; column.Visible = isVisible; column.SortName = idField; _gridColumns.Add(column.DisplayName, column); } } //Initialize the columnData _columnData.Initialize(ref dt, ";", "~", "|"); dtNew.Columns.Add("valueField"); dtNew.Columns.Add("textField"); dtNew.Columns.Add("id_field"); ordered = _gridColumns.Keys.OrderBy(k => _gridColumns[k].DisplayName).ToList(); foreach (string key in ordered) { GridColsColumn col = _gridColumns[key]; if (col.Visible) { DataRow dr = dtNew.NewRow(); dr[0] = col.DisplayName; dr[1] = col.ColumnName; dr[2] = col.SortName; dtNew.Rows.Add(dr); } } break; case "SUBTASK": //dt = AOR.AORTaskList_Get(AORID: AOR_ID, AORReleaseID: 0); dt = WorkloadItem.WorkItem_GetTaskList(workItemID: 0, showArchived: 0, showBacklog: false); _gridColumns = new Dictionary <string, GridColsColumn>(); column = new GridColsColumn(); dbName = string.Empty; displayName = string.Empty; idField = string.Empty; isVisible = false; foreach (DataColumn gridColumn in dt.Columns) { column = new GridColsColumn(); displayName = gridColumn.ColumnName; idField = gridColumn.ColumnName; isVisible = false; switch (gridColumn.ColumnName) { case "AssignedResource": displayName = "Assigned To"; idField = "ASSIGNEDRESOURCEID"; isVisible = true; break; case "Production Status": displayName = "Production Status"; idField = "ProductionStatus_ID"; isVisible = true; break; //case "Product Version": // displayName = "Product Version"; // idField = "ProductVersion_ID"; // isVisible = true; // break; case "Priority": displayName = "Priority"; idField = "PRIORITY_ID"; isVisible = true; break; case "Primary Resource": displayName = "Primary Resource"; idField = "PrimaryTechResource_ID"; isVisible = true; break; case "Assigned To": displayName = "Assigned To"; idField = "AssignedTo_ID"; isVisible = true; break; case "Status": displayName = "Status"; idField = "STATUS_ID"; isVisible = true; break; case "Percent Complete": displayName = "Percent Complete"; idField = "PercentComplete_ID"; isVisible = false; break; } if (isVisible) { column.ColumnName = gridColumn.ColumnName; column.DisplayName = displayName; column.Visible = isVisible; column.SortName = idField; _gridColumns.Add(column.DisplayName, column); } } //Initialize the columnData _columnData.Initialize(ref dt, ";", "~", "|"); dtNew.Columns.Add("valueField"); dtNew.Columns.Add("textField"); dtNew.Columns.Add("id_field"); ordered = _gridColumns.Keys.OrderBy(k => _gridColumns[k].DisplayName).ToList(); foreach (string key in ordered) { GridColsColumn col = _gridColumns[key]; if (col.Visible) { DataRow dr = dtNew.NewRow(); dr[0] = col.ColumnName; dr[1] = col.DisplayName; dr[2] = col.SortName; dtNew.Rows.Add(dr); } } break; } } catch (Exception ex) { LogUtility.LogException(ex); } return(JsonConvert.SerializeObject(dtNew, Newtonsoft.Json.Formatting.None)); }