/// <summary> /// The overloaded Load method that will return a <see cref="WorkItemCollection"/>. /// </summary> /// <param name="aUserKey">A <see cref="UserKey"/> object.</param> /// <param name="aWorkItemCollection">A <see cref="WorkItemCollection"/> object.</param> /// <exception cref="ArgumentNullException">If <c>aWorkItemCollection</c> argument is <c>null</c>.</exception> public static void Load(UserKey aUserKey, WorkItemCollection aWorkItemCollection) { if (aWorkItemCollection == null) { throw new ArgumentNullException("Load WorkItem Business"); } if (!UserFunctionAccessData.HasModeAccess(aUserKey, "WorkItem", AccessMode.List)) { throw new ZpAccessException("Access Denied", String.Format("{0}", aUserKey.UsrKey), AccessMode.List, "WorkItem"); } WorkItemData.Load(aWorkItemCollection); }
public static List<Client> AjaxClnJobCollection() { if (ServerSession.GetUserToken(HttpContext.Current.Session) == null) { setUserToken(); } UserToken vUserToken = new UserToken(); vUserToken.AssignFromSource(ServerSession.GetUserToken(HttpContext.Current.Session)); ClientCollection vClientCollection = new ClientCollection(); UserServiceConsumer.GetClientCollection(vUserToken, vClientCollection); foreach (Client vClient in vClientCollection.ClientList) { JobCollection vJobCollection = new JobCollection(); vJobCollection.JobFilter.IsFiltered = true; vJobCollection.JobFilter.ClientKeyFilter = vClient.ClnKey; UserServiceConsumer.GetJobCollection(vUserToken, vJobCollection); foreach (Job vJob in vJobCollection.JobList) { WorkItemCollection vWorkItemCollection = new WorkItemCollection(); vWorkItemCollection.WorkItemFilter.IsFiltered = true; vWorkItemCollection.WorkItemFilter.ClientKeyFilter = vJob.ClnKey; vWorkItemCollection.WorkItemFilter.JobKeyFilter = vJob.JobbKey; UserServiceConsumer.GetWorkItemCollection(vUserToken, vWorkItemCollection); foreach (WorkItem vWorkItem in vWorkItemCollection.WorkItemList) { vJob.children.Add(vWorkItem); } vJob.value = vJob.children.Count(); if (vClient.ClnKey == vJob.ClnKey) vClient.children.Add(vJob); } vClient.value = vClient.children.Count(); } return vClientCollection.ClientList; }
/// <summary> /// Gets a specified <see cref="WorkItemCollection"/>. /// </summary> /// <param name="aUserToken">A <see cref="UserToken"/> object used for Access Control.</param> /// <param name="aWorkItemCollection"><see cref="WorkItem"/>Collection object.</param> public static void GetWorkItemCollection(UserToken aUserToken, WorkItemCollection aWorkItemCollection) { UserCallHandler.ServiceCall<WorkItemCollection>(aUserToken, "GetWorkItemCollection", aWorkItemCollection); }
/// <summary> /// The <c>GetWorkItemCollection</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="WorkItemCollection"/> object. /// It invokes the <c>Insert</c> method of <see cref="WorkItemBusiness"/> with the newly deserialized <see cref="WorkItemCollection"/> object. /// Finally, it returns the collection object as a serialized <see cref="string"/> of XML. /// </summary> /// <param name="aXmlArgument">XML Argument <see cref="string"/>.</param> /// <returns><see cref="WorkItemCollection"/> as XML <see cref="string"/>.</returns> /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception> public static string GetWorkItemCollection(UserKey aUserKey, string aXmlArgument) { if (aXmlArgument == null) { throw new ArgumentNullException("aXmlArgument of GetWorkItemCollection"); } WorkItemCollection vWorkItemCollection = new WorkItemCollection(); vWorkItemCollection = XmlUtils.Deserialize<WorkItemCollection>(aXmlArgument); WorkItemBusiness.Load(aUserKey, vWorkItemCollection); return XmlUtils.Serialize<WorkItemCollection>(vWorkItemCollection, true); }
/// <summary> /// The overloaded Load method that will fill the <c>WorkItemList</c> property a <see cref="WorkItemCollection"/> object as an /// ordered <c>List</c> of <see cref="WorkItem"/>, filtered by the filter properties of the passed <see cref="WorkItemCollection"/>. /// </summary> /// <param name="aWorkItemCollection">The <see cref="WorkItemCollection"/> object that must be filled.</param> /// <remarks> /// The filter properties of the <see cref="WorkItemCollection"/> must be correctly completed by the calling application. /// </remarks> /// <exception cref="ArgumentNullException">If <c>aWorkItemCollection</c> argument is <c>null</c>.</exception> public static void Load(WorkItemCollection aWorkItemCollection) { if (aWorkItemCollection == null) { throw new ArgumentNullException("aWorkItemCollection"); } using (var vSqlCommand = new SqlCommand() { CommandType = CommandType.Text, Connection = new SqlConnection(Connection.Instance.SqlConnectionString) }) { var vStringBuilder = BuildSQL(); if (aWorkItemCollection.WorkItemFilter.IsFiltered) { if (aWorkItemCollection.WorkItemFilter.ClientKeyFilter > 0) { vStringBuilder.AppendLine("and t1.CLN_Key = @CLNKey"); vSqlCommand.Parameters.AddWithValue("@CLNKey", aWorkItemCollection.WorkItemFilter.ClientKeyFilter); } if (aWorkItemCollection.WorkItemFilter.JobKeyFilter > 0) { vStringBuilder.AppendLine("and t2.JOB_Key = @JOBKey"); vSqlCommand.Parameters.AddWithValue("@JOBKey", aWorkItemCollection.WorkItemFilter.JobKeyFilter); } } vStringBuilder.AppendLine("order by t2.JOB_Name"); vSqlCommand.CommandText = vStringBuilder.ToString(); vSqlCommand.Connection.Open(); using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader()) { while (vSqlDataReader.Read()) { var vWorkItem = new WorkItem(); DataToObject(vWorkItem, vSqlDataReader); aWorkItemCollection.WorkItemList.Add(vWorkItem); } vSqlDataReader.Close(); } vSqlCommand.Connection.Close(); } }