Go Back   Maryland Shooters > The Arsenal > Curio and Relic (C&R)
Don't Have An Account? Register Here

Join MD Shooters

Reply
 
Thread Tools Display Modes
Old January 19th, 2019, 03:27 PM #181
Orlando Orlando is offline
Member
 
Join Date: Apr 2013
Location: 2 1/2 hours from the North Store
Posts: 357
Orlando Orlando is offline
Member
 
Join Date: Apr 2013
Location: 2 1/2 hours from the North Store
Posts: 357
Does it matter what your number is? When they get to you then you will be notified. Numbers are being assigned to all 19000 orders. When yours comes up you will be notified. If your number is above the allotment of the years 1911's you be in line for next year
Orlando is offline   Reply With Quote
Old January 19th, 2019, 04:40 PM #182
dreadpirate's Avatar
dreadpirate dreadpirate is offline
Senior Member
 
Join Date: Mar 2010
Location: Cuba on the Chesapeake
Posts: 5,490
dreadpirate dreadpirate is offline
Senior Member
dreadpirate's Avatar
 
Join Date: Mar 2010
Location: Cuba on the Chesapeake
Posts: 5,490
OK CMP, here you go.
This Java code will read in a file of customers emails, assign randomly, numbers starting at 1000, write the results to a CSV like that can be read by a spreadsheet, and email these out to everyone.

/*
*
*/
package com.siriusjava.cmprng.cmprng;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Random;

import javax.mail.Session;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;

/**
*
* @author dreadpirate
*/
public class ProcessCustomers {

private class Customer {

private String customerNumber;
private String customerEmail;
private int randomNumber;

public String getCustomerNumber() {
return customerNumber;
}

public void setCustomerNumber(String customerNumber) {
this.customerNumber = customerNumber;
}

public String getCustomerEmail() {
return customerEmail;
}

public void setCustomerEmail(String customerEmail) {
this.customerEmail = customerEmail;
}

public int getRandomNumber() {
return randomNumber;
}

public void setRandomNumber(int randomNumber) {
this.randomNumber = randomNumber;
}

public String getDataLine() {
return customerEmail + "," + customerNumber + "," + randomNumber;
}

@Override
public String toString() {
return "Customer{" + "customerNumber=" + customerNumber + ", customerEmail=" + customerEmail + ", randomNumber=" + randomNumber + '}';
}
}

private List<Customer> customerData = new ArrayList<Customer>();
private String dataFileInName;
private String dataFileOutName;
private Properties prop = new Properties();
private Session session;

private ProcessCustomers() {
}

public static void main(String[] args) {
int statusCode = 0;
ProcessCustomers instance = new ProcessCustomers();

try {
System.out.println("Start ...");
instance.processArgs(args);
instance.readNamesFromFile();
instance.assignRandomNumbers();
instance.writeResults();
instance.emailOutNotice();
} catch (Exception e) {
statusCode = 1;
e.printStackTrace();
}

System.out.println("Done");
System.exit(statusCode);
}

public void processArgs(String[] args) {
dataFileInName = args[0];
dataFileOutName = args[1];
}

public void readNamesFromFile() {

try ( BufferedReader objReader = new BufferedReader(new FileReader(dataFileInName))) {
String strCurrentLine = null;
while ((strCurrentLine = objReader.readLine()) != null) {
String[] fields = strCurrentLine.split(",");
String email = fields[0];
String customerNumber = fields[1];
Customer customer = new Customer();
customer.setCustomerEmail(email.trim());
customer.setCustomerNumber(customerNumber.trim());

customerData.add(customer);
}
} catch (IOException e) {
throw new RuntimeException(e);
}

}

public void assignRandomNumbers() {
assignRandom();
for (Customer c : customerData) {
System.out.println(c);
}
}

public void writeResults() {
try ( FileWriter writer = new FileWriter(dataFileOutName, true); BufferedWriter bufferedWriter = new BufferedWriter(writer) {
for (Customer c : customerData) {
String lineOut = c.getDataLine();
bufferedWriter.write(lineOut);
bufferedWriter.newLine();
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public void emailOutNotice() {
setupEmailProps();
createEmailSession("myEmailUser", "myEmailPass");
for (Customer c : customerData) {
sendEmail(c);
}
}

private void assignRandom() {
Random rand = new Random();
List<Customer> givenList = new ArrayList(customerData);
int randomNumber = 1000;
int numberOfElements = customerData.size();

for (int i = 0; i < numberOfElements; i++) {
int randomIndex = rand.nextInt(givenList.size());
Customer randomCustomer = givenList.get(randomIndex);
randomCustomer.setRandomNumber(randomNumber++);
givenList.remove(randomIndex);
}
}

private void createEmailSession(String username, String password) {
session = Session.getInstance(prop, new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
});
}

private void setupEmailProps() {
prop.put("mail.smtp.auth", true);
prop.put("mail.smtp.starttls.enable", "true");
prop.put("mail.smtp.host", "smtp.mailtrap.io");
prop.put("mail.smtp.port", "25");
prop.put("mail.smtp.ssl.trust", "smtp.mailtrap.io");
}

private void sendEmail(Customer customer) {
try {
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress("nobody@cmp.org"));
message.setRecipients(
Message.RecipientType.TO, InternetAddress.parse(customer.getCustomerEmail()) );
message.setSubject("CMP 1911 Random Number Assignment");

String msg = "Your random number assigment is " + customer.getRandomNumber();

MimeBodyPart mimeBodyPart = new MimeBodyPart();
mimeBodyPart.setContent(msg, "text/html");

Multipart multipart = new MimeMultipart();
multipart.addBodyPart(mimeBodyPart);

message.setContent(multipart);

Transport.send(message);
} catch (Exception e) {
throw new RuntimeException(e);
}

}
}
__________________
US Army Veteran 82 - 92
NRA Life Member
Maryland Shall Issue Executive Member
SOTAR Alumnus
dreadpirate is offline   Reply With Quote
Old January 19th, 2019, 05:10 PM #183
Mark75H's Avatar
Mark75H Mark75H is online now
HVAC Expert
 
Join Date: Sep 2011
Location: Outside the Gates
Posts: 11,174
Mark75H Mark75H is online now
HVAC Expert
Mark75H's Avatar
 
Join Date: Sep 2011
Location: Outside the Gates
Posts: 11,174
Which grade are purchasers selecting?
__________________
2A ... Federal Preemption

Thus, the only inquiry that this Court should conduct is to determine whether the firearms prohibited by the Act are protected by the Second Amendment. Because they are, the Act is simply unconstitutional.
Mark75H is online now   Reply With Quote
Old January 19th, 2019, 05:15 PM #184
Oldcarjunkie's Avatar
Oldcarjunkie Oldcarjunkie is offline
Heavy weight
 
Join Date: Jan 2009
Location: A.A county
Posts: 11,433
Images: 4
Oldcarjunkie Oldcarjunkie is offline
Heavy weight
Oldcarjunkie's Avatar
 
Join Date: Jan 2009
Location: A.A county
Posts: 11,433
Images: 4
I havent heard anything. I guess we will see.
Oldcarjunkie is offline   Reply With Quote
Old January 19th, 2019, 07:04 PM #185
Orlando Orlando is offline
Member
 
Join Date: Apr 2013
Location: 2 1/2 hours from the North Store
Posts: 357
Orlando Orlando is offline
Member
 
Join Date: Apr 2013
Location: 2 1/2 hours from the North Store
Posts: 357
only grade available now is Service Grade
Orlando is offline   Reply With Quote
Old January 19th, 2019, 07:21 PM #186
Mark75H's Avatar
Mark75H Mark75H is online now
HVAC Expert
 
Join Date: Sep 2011
Location: Outside the Gates
Posts: 11,174
Mark75H Mark75H is online now
HVAC Expert
Mark75H's Avatar
 
Join Date: Sep 2011
Location: Outside the Gates
Posts: 11,174
Quote:
Originally Posted by Orlando View Post
only grade available now is Service Grade
Thank you.
__________________
2A ... Federal Preemption

Thus, the only inquiry that this Court should conduct is to determine whether the firearms prohibited by the Act are protected by the Second Amendment. Because they are, the Act is simply unconstitutional.
Mark75H is online now   Reply With Quote
Old January 20th, 2019, 09:22 AM #187
TheRealJimDavis TheRealJimDavis is offline
Member
 
Join Date: Jan 2013
Location: The Burnie
Posts: 387
TheRealJimDavis TheRealJimDavis is offline
Member
 
Join Date: Jan 2013
Location: The Burnie
Posts: 387
They did. All the packets have numbers. When they get to the packet, in that numerical order, they check it, then send out the email telling you what your number is and if the packet is good to go or not. Or at least that’s the impression I got reading their forum from the admins.
TheRealJimDavis is offline   Reply With Quote
Old January 20th, 2019, 09:23 AM #188
TheRealJimDavis TheRealJimDavis is offline
Member
 
Join Date: Jan 2013
Location: The Burnie
Posts: 387
TheRealJimDavis TheRealJimDavis is offline
Member
 
Join Date: Jan 2013
Location: The Burnie
Posts: 387
It’s not that your packet doesn’t have a number yet. It’s that they haven’t gotten to that number of checking packets yet.
TheRealJimDavis is offline   Reply With Quote
Old January 20th, 2019, 03:05 PM #189
Orlando Orlando is offline
Member
 
Join Date: Apr 2013
Location: 2 1/2 hours from the North Store
Posts: 357
Orlando Orlando is offline
Member
 
Join Date: Apr 2013
Location: 2 1/2 hours from the North Store
Posts: 357
exactly, some people just don't understand
Orlando is offline   Reply With Quote
Old January 20th, 2019, 03:10 PM #190
Matlack's Avatar
Matlack Matlack is offline
Scribe
 
Join Date: Dec 2008
Posts: 4,681
Matlack Matlack is offline
Scribe
Matlack's Avatar
 
Join Date: Dec 2008
Posts: 4,681
Quote:
Originally Posted by Orlando View Post
exactly, some people just don't understand
And apparently the whole lottery is at fault and they should have been first.
Matlack is offline   Reply With Quote
Reply

  Home Page > Forum List > The Arsenal > Curio and Relic (C&R)


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:14 PM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2019, vBulletin Solutions, Inc.
2019, Congregate Media, LP Privacy Policy Terms of Service