/// <summary> /// List requests /// </summary> /// <param name="StatusIn"></param> /// <returns></returns> public static List <ProcessRequest> List(ProcessRequest.StatusValue StatusIn) { var result = new List <ProcessRequest>(); var checktype = " WHERE Status = '" + StatusIn.ToString() + "'"; if (StatusIn == ProcessRequest.StatusValue.ALL) { checktype = ""; } using (var connection = new MySqlConnection(ConnString.ConnectionString)) { var commandString = string.Format( " SELECT " + FieldString() + " FROM ProcessRequest " + checktype + " ORDER BY 1 DESC " ); using (var command = new MySqlCommand( commandString, connection)) { connection.Open(); using (MySqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { var _ProcessRequest = new ProcessRequest(); ProcessRequest.LoadFromReader(_ProcessRequest, reader); // Load Arguments // _ProcessRequest.argumentList = ProcessRequestArguments.List(_ProcessRequest.UID); result.Add(_ProcessRequest); } } } } return(result); }
/// <summary> /// Load from Reader /// </summary> /// <param name="processRequest"></param> /// <param name="tablePrefix"></param> /// <param name="reader"></param> public static void LoadFromReader( ProcessRequest processRequest, MySqlDataReader reader) { processRequest.UID = Convert.ToInt32(reader[FieldName.UID].ToString()); try { processRequest.FKClientUID = Convert.ToInt32(reader[FieldName.FKClientUID].ToString()); } catch (Exception ex) { processRequest.FKClientUID = 0; } processRequest.Description = reader[FieldName.Description].ToString(); processRequest.Status = reader[FieldName.Status].ToString(); processRequest.Type = reader[FieldName.Type].ToString(); processRequest.WhenToProcess = reader[FieldName.WhenToProcess].ToString(); processRequest.RequestedByUser = reader[FieldName.RequestedByUser].ToString(); processRequest.PlannedDateTime = Convert.ToDateTime(reader[FieldName.PlannedDateTime]); processRequest.CreationDateTime = Convert.ToDateTime(reader[FieldName.CreationDateTime]); processRequest.StatusDateTime = Convert.ToDateTime(reader[FieldName.StatusDateTime]); return; }