/// <summary> /// The overloaded Load method that will return a <see cref="JobCollection"/>. /// </summary> /// <param name="aUserKey">A <see cref="UserKey"/> object.</param> /// <param name="aJobCollection">A <see cref="JobCollection"/> object.</param> /// <exception cref="ArgumentNullException">If <c>aJobCollection</c> argument is <c>null</c>.</exception> public static void Load(UserKey aUserKey, JobCollection aJobCollection) { if (aJobCollection == null) { throw new ArgumentNullException("Load Job Business"); } //if (!UserFunctionAccessData.HasModeAccess(aUserKey, "Job", AccessMode.List)) //{ // throw new ZpAccessException("Access Denied", String.Format("{0}", aUserKey.UsrKey), AccessMode.List, "Job"); //} JobData.Load(aJobCollection); }
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="JobCollection"/>. /// </summary> /// <param name="aUserToken">A <see cref="UserToken"/> object used for Access Control.</param> /// <param name="aJobCollection"><see cref="Job"/>Collection object.</param> public static void GetJobCollection(UserToken aUserToken, JobCollection aJobCollection) { UserCallHandler.ServiceCall<JobCollection>(aUserToken, "GetJobCollection", aJobCollection); }
/// <summary> /// The <c>GetJobCollection</c> implementation method deserializes an incoming XML Argument <see cref="string"/> as a new <see cref="JobCollection"/> object. /// It invokes the <c>Insert</c> method of <see cref="JobBusiness"/> with the newly deserialized <see cref="JobCollection"/> 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="JobCollection"/> as XML <see cref="string"/>.</returns> /// <exception cref="ArgumentNullException">If <c>aXmlArgument</c> is <c>null</c>.</exception> public static string GetJobCollection(UserKey aUserKey, string aXmlArgument) { if (aXmlArgument == null) { throw new ArgumentNullException("aXmlArgument of GetJobCollection"); } JobCollection vJobCollection = new JobCollection(); vJobCollection = XmlUtils.Deserialize<JobCollection>(aXmlArgument); JobBusiness.Load(aUserKey, vJobCollection); return XmlUtils.Serialize<JobCollection>(vJobCollection, true); }
/// <summary> /// The overloaded Load method that will fill the <c>JobList</c> property a <see cref="JobCollection"/> object as an /// ordered <c>List</c> of <see cref="Job"/>, filtered by the filter properties of the passed <see cref="JobCollection"/>. /// </summary> /// <param name="aJobCollection">The <see cref="JobCollection"/> object that must be filled.</param> /// <remarks> /// The filter properties of the <see cref="JobCollection"/> must be correctly completed by the calling application. /// </remarks> /// <exception cref="ArgumentNullException">If <c>aJobCollection</c> argument is <c>null</c>.</exception> public static void Load(JobCollection aJobCollection) { if (aJobCollection == null) { throw new ArgumentNullException("aJobCollection"); } using (var vSqlCommand = new SqlCommand() { CommandType = CommandType.Text, Connection = new SqlConnection(Connection.Instance.SqlConnectionString) }) { var vStringBuilder = BuildSQL(); if (aJobCollection.JobFilter.IsFiltered) { if (aJobCollection.JobFilter.ClientKeyFilter > 0) { vStringBuilder.AppendLine("and t1.CLN_Key = @CLNKey"); vSqlCommand.Parameters.AddWithValue("@CLNKey", aJobCollection.JobFilter.ClientKeyFilter); } } vStringBuilder.AppendLine("order by t2.JOB_Name"); vSqlCommand.CommandText = vStringBuilder.ToString(); vSqlCommand.Connection.Open(); using (SqlDataReader vSqlDataReader = vSqlCommand.ExecuteReader()) { while (vSqlDataReader.Read()) { var vJob = new Job(); DataToObject(vJob, vSqlDataReader); aJobCollection.JobList.Add(vJob); } vSqlDataReader.Close(); } vSqlCommand.Connection.Close(); } }