public AssignmentDetailsCollection GetAssignedInstances() { AssignmentDetailsCollection lReturn = new AssignmentDetailsCollection(); if (this.Instances != null) { foreach (AssignmentDetails item in this.Instances) { if (item.Workers != null && item.Workers.Count > 0) { lReturn.Add(item); break; } } } return lReturn; }
public static AssignmentDetailsCollection GetAssignments(int[] sourceIDs) { AssignmentDetailsCollection assignments = new AssignmentDetailsCollection(); DataSet dsResults = null; FinalBuild.DataAccess objADO = Domain.GetADOInstance(); System.Data.SqlClient.SqlParameter[] arrParameters; System.Collections.ArrayList colParameters = new System.Collections.ArrayList(); DataAccess.ArrayListParameter objParameter = null; DataRow[] filteredRows = null; string strStoredProcedure = "selAssignmentsByJobAndUser"; // Assemble Parameters objParameter = new DataAccess.ArrayListParameter("WMSourceIDs", sourceIDs); //colParameters.Add(new SqlParameter("@UserID", userID)); arrParameters = (SqlParameter[])colParameters.ToArray(typeof(SqlParameter)); dsResults = objADO.GetDataSet(strStoredProcedure, objParameter, arrParameters); dsResults.Tables[0].TableName = "Assignments"; dsResults.Tables[1].TableName = "Assignees"; dsResults.Tables[2].TableName = "Appointments"; foreach (DataRow drAssignment in dsResults.Tables["Assignments"].Rows) { assignments.Add(new AssignmentDetails()); assignments[assignments.Count - 1].ID = int.Parse(drAssignment["WMSourceID"].ToString()); assignments[assignments.Count - 1].SourceSystem = (eWMSourceSystem)Enum.Parse(typeof(eWMSourceSystem), drAssignment["WMSourceSystem"].ToString()); if (!drAssignment["DueDate"].Equals(DBNull.Value)) { assignments[assignments.Count - 1].DueDate = (DateTime)drAssignment["DueDate"]; } assignments[assignments.Count - 1].Status = (eJobStatus)Enum.Parse(typeof(eJobStatus), drAssignment["JobStatus"].ToString()); filteredRows = dsResults.Tables["Assignees"].Select(string.Format("WMSourceID='{0}'", assignments[assignments.Count - 1].ID)); if (filteredRows.Length > 0) { int userIDJobInstanceNumber = 0; assignments[assignments.Count - 1].Workers = new WorkerCollection(); for (int assigneeIndex = 0; assigneeIndex < filteredRows.Length; assigneeIndex++) { assignments[assignments.Count - 1].Workers.Add(new Worker()); assignments[assignments.Count - 1].Workers[assigneeIndex].LoginName = filteredRows[assigneeIndex]["UserID"].ToString(); if (!filteredRows[assigneeIndex]["EmpSurname"].Equals(DBNull.Value)) { assignments[assignments.Count - 1].Workers[assigneeIndex].Surname = filteredRows[assigneeIndex]["EmpSurname"].ToString(); } if (!filteredRows[assigneeIndex]["EmpForenames"].Equals(DBNull.Value)) { assignments[assignments.Count - 1].Workers[assigneeIndex].Forenames = filteredRows[assigneeIndex]["EmpForenames"].ToString(); } if (!filteredRows[assigneeIndex]["EmpNo"].Equals(DBNull.Value)) { assignments[assignments.Count - 1].Workers[assigneeIndex].EmpNo = filteredRows[assigneeIndex]["EmpNo"].ToString(); } //if (filteredRows[assigneeIndex]["UserID"].ToString().ToUpper() == userID.ToUpper()) //{ userIDJobInstanceNumber = int.Parse(filteredRows[assigneeIndex]["JobInstanceNumber"].ToString()); //} } assignments[assignments.Count - 1].InstanceNumber = userIDJobInstanceNumber; } filteredRows = dsResults.Tables["Appointments"].Select(string.Format("WMSourceID={0}", assignments[assignments.Count - 1].ID)); if (filteredRows.Length > 0) { foreach (DataRow drSerializedInstance in filteredRows) { if (!drSerializedInstance["Appointment"].Equals(DBNull.Value)) { System.Xml.XmlDocument objDOM = new System.Xml.XmlDocument(); objDOM.LoadXml(drSerializedInstance["Appointment"].ToString()); //.Replace(" xmlns=\"http://FinalBuild.co.uk/BusinessObjects.WorkManagement\"", string.Empty)); assignments[assignments.Count - 1].Appointment = (Appointment)BusinessObjects.Base.Deserialize(typeof(Appointment), objDOM); } } } } return assignments; }
private static AssignmentDetailsCollection Populate(DataTable collectionMembers) { AssignmentDetailsCollection colMembers = new AssignmentDetailsCollection(); AssignmentDetails obj = null; foreach (DataRow drMember in collectionMembers.Rows) { obj = new AssignmentDetails(); obj.ID = (int)drMember["WMSourceID"]; obj.InstanceNumber = (int)drMember["JobInstanceNumber"]; obj.Workers = new WorkerCollection(); Worker objWorker = new Worker(); objWorker.UserID = drMember["UserID"].ToString(); obj.Workers.Add(objWorker); obj.DueDate = (DateTime)drMember["DateChangeDetected"]; colMembers.Add(obj); } return colMembers; }