/// <summary> /// Retrieves list of EmailTemplate objects from SqlCommand, after database query /// number of rows retrieved and returned depends upon the rows field value /// </summary> /// <param name="cmd">The command object to use for query</param> /// <param name="rows">Number of rows to process</param> /// <returns>A list of EmailTemplate objects</returns> private EmailTemplateList GetList(SqlCommand cmd, long rows) { // Select multiple records SqlDataReader reader; long result = SelectRecords(cmd, out reader); //EmailTemplate list EmailTemplateList list = new EmailTemplateList(); using ( reader ) { // Read rows until end of result or number of rows specified is reached while (reader.Read() && rows-- != 0) { EmailTemplate emailTemplateObject = new EmailTemplate(); FillObject(emailTemplateObject, reader); list.Add(emailTemplateObject); } // Close the reader in order to receive output parameters // Output parameters are not available until reader is closed. reader.Close(); } return(list); }
/// <summary> /// To fetch details from database /// </summary> /// <returns></returns> public EmailTemplateList GetAllOverdueApprovals() { OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString); OracleCommand cmd; string proc = "USP_NOTIF_OVERDUE_APPROVAL"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); EmailTemplateBO EmailTemplateBOobj = null; EmailTemplateList EmailTemplateListobj = new EmailTemplateList(); while (dr.Read()) { EmailTemplateBOobj = new EmailTemplateBO(); if (!dr.IsDBNull(dr.GetOrdinal("DESCRIPTION"))) { EmailTemplateBOobj.Description = (dr.GetString(dr.GetOrdinal("DESCRIPTION"))); } if (!dr.IsDBNull(dr.GetOrdinal("WORKFLOWCODE"))) { EmailTemplateBOobj.Workflowcode = (dr.GetString(dr.GetOrdinal("WORKFLOWCODE"))); } if (!dr.IsDBNull(dr.GetOrdinal("EMAILID"))) { EmailTemplateBOobj.EmailID = (dr.GetString(dr.GetOrdinal("EMAILID"))); } if (!dr.IsDBNull(dr.GetOrdinal("cellnumber"))) { EmailTemplateBOobj.Cellnumber = (dr.GetString(dr.GetOrdinal("cellnumber"))); } if (!dr.IsDBNull(dr.GetOrdinal("triggertype"))) { EmailTemplateBOobj.Triggertype = (dr.GetString(dr.GetOrdinal("triggertype"))); } if (!dr.IsDBNull(dr.GetOrdinal("DISPLAYNAME"))) { EmailTemplateBOobj.ApproverUserName = (dr.GetString(dr.GetOrdinal("DISPLAYNAME"))); } if (!dr.IsDBNull(dr.GetOrdinal("PROJECTCODE"))) { EmailTemplateBOobj.ProjectCode = (dr.GetString(dr.GetOrdinal("PROJECTCODE"))); } if (!dr.IsDBNull(dr.GetOrdinal("PROJECTNAME"))) { EmailTemplateBOobj.ProjectName = (dr.GetString(dr.GetOrdinal("PROJECTNAME"))); } if (!dr.IsDBNull(dr.GetOrdinal("REQUESTDATE"))) { EmailTemplateBOobj.Requestdate = Convert.ToString(dr.GetValue(dr.GetOrdinal("REQUESTDATE"))); } if (!dr.IsDBNull(dr.GetOrdinal("DUEDATE"))) { EmailTemplateBOobj.Duedate = Convert.ToString(dr.GetValue(dr.GetOrdinal("DUEDATE"))); } EmailTemplateListobj.Add(EmailTemplateBOobj); } dr.Close(); return(EmailTemplateListobj); }