Commit bf9e12d883f6e4ce2880356a367c5aeee913f772
0 parents
Exists in
master
devcarlendar
Showing
17 changed files
with
595 additions
and
0 deletions
Show diff stats
| 1 | +++ a/.classpath | |
| ... | ... | @@ -0,0 +1,26 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<classpath> | |
| 3 | + <classpathentry kind="src" output="target/classes" path="src/main/java"> | |
| 4 | + <attributes> | |
| 5 | + <attribute name="optional" value="true"/> | |
| 6 | + <attribute name="maven.pomderived" value="true"/> | |
| 7 | + </attributes> | |
| 8 | + </classpathentry> | |
| 9 | + <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | |
| 10 | + <attributes> | |
| 11 | + <attribute name="optional" value="true"/> | |
| 12 | + <attribute name="maven.pomderived" value="true"/> | |
| 13 | + </attributes> | |
| 14 | + </classpathentry> | |
| 15 | + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jdk1.8.0_161"> | |
| 16 | + <attributes> | |
| 17 | + <attribute name="maven.pomderived" value="true"/> | |
| 18 | + </attributes> | |
| 19 | + </classpathentry> | |
| 20 | + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | |
| 21 | + <attributes> | |
| 22 | + <attribute name="maven.pomderived" value="true"/> | |
| 23 | + </attributes> | |
| 24 | + </classpathentry> | |
| 25 | + <classpathentry kind="output" path="target/classes"/> | |
| 26 | +</classpath> | ... | ... |
| 1 | +++ a/.project | |
| ... | ... | @@ -0,0 +1,23 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<projectDescription> | |
| 3 | + <name>DevCalendar</name> | |
| 4 | + <comment></comment> | |
| 5 | + <projects> | |
| 6 | + </projects> | |
| 7 | + <buildSpec> | |
| 8 | + <buildCommand> | |
| 9 | + <name>org.eclipse.jdt.core.javabuilder</name> | |
| 10 | + <arguments> | |
| 11 | + </arguments> | |
| 12 | + </buildCommand> | |
| 13 | + <buildCommand> | |
| 14 | + <name>org.eclipse.m2e.core.maven2Builder</name> | |
| 15 | + <arguments> | |
| 16 | + </arguments> | |
| 17 | + </buildCommand> | |
| 18 | + </buildSpec> | |
| 19 | + <natures> | |
| 20 | + <nature>org.eclipse.jdt.core.javanature</nature> | |
| 21 | + <nature>org.eclipse.m2e.core.maven2Nature</nature> | |
| 22 | + </natures> | |
| 23 | +</projectDescription> | ... | ... |
| 1 | +++ a/.settings/org.eclipse.jdt.core.prefs | |
| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | +eclipse.preferences.version=1 | |
| 2 | +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | |
| 3 | +org.eclipse.jdt.core.compiler.compliance=1.5 | |
| 4 | +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | |
| 5 | +org.eclipse.jdt.core.compiler.source=1.5 | ... | ... |
No preview for this file type
| 1 | +++ a/conf/config | |
| ... | ... | @@ -0,0 +1,5 @@ |
| 1 | +<configuration> | |
| 2 | + <connection value="jdbc:mysql://202.162.79.195/devcalendar?user=devcalendar&password=9iwK8Fm801yLbWRP&useSSL=false&serverTimezone=UTC"/> | |
| 3 | + <linetoken value="2mQSvqy17d0Dodi6fENsaUcSVKY2Xhh5FQ2aKLuE396"/> | |
| 4 | +</configuration> | |
| 5 | + | ... | ... |
| 1 | +++ a/pom.xml | |
| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 2 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 3 | + <modelVersion>4.0.0</modelVersion> | |
| 4 | + | |
| 5 | + <groupId>bas.sourcecode</groupId> | |
| 6 | + <artifactId>DevCalendar</artifactId> | |
| 7 | + <version>0.0.1-SNAPSHOT</version> | |
| 8 | + <packaging>jar</packaging> | |
| 9 | + | |
| 10 | + <name>DevCalendar</name> | |
| 11 | + <url>http://maven.apache.org</url> | |
| 12 | + | |
| 13 | + <properties> | |
| 14 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
| 15 | + </properties> | |
| 16 | + | |
| 17 | + <dependencies> | |
| 18 | + <dependency> | |
| 19 | + <groupId>junit</groupId> | |
| 20 | + <artifactId>junit</artifactId> | |
| 21 | + <version>3.8.1</version> | |
| 22 | + <scope>test</scope> | |
| 23 | + </dependency> | |
| 24 | + <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> | |
| 25 | + <dependency> | |
| 26 | + <groupId>mysql</groupId> | |
| 27 | + <artifactId>mysql-connector-java</artifactId> | |
| 28 | + <version>8.0.8-dmr</version> | |
| 29 | + </dependency> | |
| 30 | + <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> | |
| 31 | + <dependency> | |
| 32 | + <groupId>org.apache.httpcomponents</groupId> | |
| 33 | + <artifactId>httpclient</artifactId> | |
| 34 | + <version>4.5.4</version> | |
| 35 | + </dependency> | |
| 36 | + | |
| 37 | + </dependencies> | |
| 38 | +</project> | ... | ... |
| 1 | +++ a/src/main/java/bas/sourcecode/DevCalendar/App.java | |
| ... | ... | @@ -0,0 +1,377 @@ |
| 1 | +package bas.sourcecode.DevCalendar; | |
| 2 | + | |
| 3 | +import java.io.BufferedReader; | |
| 4 | +import java.io.File; | |
| 5 | +import java.io.FileReader; | |
| 6 | +import java.io.IOException; | |
| 7 | +import java.io.InputStreamReader; | |
| 8 | +import java.net.MalformedURLException; | |
| 9 | +import java.sql.Connection; | |
| 10 | +import java.sql.DriverManager; | |
| 11 | +import java.sql.ResultSet; | |
| 12 | +import java.sql.SQLException; | |
| 13 | +import java.text.SimpleDateFormat; | |
| 14 | +import java.util.ArrayList; | |
| 15 | +import java.util.Arrays; | |
| 16 | +import java.util.Calendar; | |
| 17 | +import java.util.Collections; | |
| 18 | +import java.util.Date; | |
| 19 | +import java.util.GregorianCalendar; | |
| 20 | +import java.util.HashSet; | |
| 21 | +import java.util.LinkedHashSet; | |
| 22 | + | |
| 23 | +import org.apache.http.Consts; | |
| 24 | +import org.apache.http.HttpResponse; | |
| 25 | +import org.apache.http.NameValuePair; | |
| 26 | +import org.apache.http.client.HttpClient; | |
| 27 | +import org.apache.http.client.entity.UrlEncodedFormEntity; | |
| 28 | +import org.apache.http.client.methods.HttpPost; | |
| 29 | +import org.apache.http.impl.client.DefaultHttpClient; | |
| 30 | +import org.apache.http.message.BasicHeader; | |
| 31 | +import org.apache.http.message.BasicNameValuePair; | |
| 32 | +import org.apache.http.protocol.HTTP; | |
| 33 | + | |
| 34 | +import com.mysql.cj.api.jdbc.Statement; | |
| 35 | + | |
| 36 | +import obj.DevInfo; | |
| 37 | + | |
| 38 | +public class App { | |
| 39 | + | |
| 40 | + private static String Connection = "jdbc:mysql://202.162.79.195/devcalendar?user=devcalendar&password=9iwK8Fm801yLbWRP&useSSL=false&serverTimezone=UTC"; | |
| 41 | + private static String Token = "2mQSvqy17d0Dodi6fENsaUcSVKY2Xhh5FQ2aKLuE396"; //s4MVB0CjPyRfoxE7DFOkFgr2TR2CZy1qt6N8Bylnrpf //per | |
| 42 | + private static LinkedHashSet<String> Person = new LinkedHashSet<String>(); //2mQSvqy17d0Dodi6fENsaUcSVKY2Xhh5FQ2aKLuE396 | |
| 43 | + private static String IgnorePerson = "karun,nungp,nutthaphons,patcharin,piyapongs,pla,sasawatt,siwatchl,sukrit,top,voravuts,wanida"; | |
| 44 | + | |
| 45 | + public static void main(String[] args) { | |
| 46 | + | |
| 47 | + | |
| 48 | + // read config | |
| 49 | +// File file = new File("conf/config"); | |
| 50 | +// try { | |
| 51 | +// BufferedReader br = new BufferedReader(new FileReader(file)); | |
| 52 | +// String line; | |
| 53 | +// while ((line = br.readLine()) != null) | |
| 54 | +// { | |
| 55 | +//// System.out.println(line); | |
| 56 | +// if (line.contains("connection")) | |
| 57 | +// Connection = (line.substring(line.indexOf("\"") + 1, line.lastIndexOf("\""))); | |
| 58 | +// else if(line.contains("linetoken")) | |
| 59 | +// Token = (line.substring(line.indexOf("\"") + 1, line.lastIndexOf("\""))); | |
| 60 | +// | |
| 61 | +// } | |
| 62 | +// br.close(); | |
| 63 | +// } catch (IOException e) { | |
| 64 | +// // TODO Auto-generated catch block | |
| 65 | +// e.printStackTrace(); | |
| 66 | +// } | |
| 67 | + | |
| 68 | + | |
| 69 | + HashSet<Integer> ignoreDay = getWeekendDays(); | |
| 70 | + ignoreDay = getHoliday(ignoreDay); | |
| 71 | + Connection connect = null; | |
| 72 | + ArrayList<DevInfo> personList = new ArrayList<DevInfo>(); | |
| 73 | + | |
| 74 | + | |
| 75 | + try { | |
| 76 | + Class.forName("com.mysql.cj.jdbc.Driver"); | |
| 77 | + connect = DriverManager.getConnection(Connection); | |
| 78 | + | |
| 79 | + if (connect != null) { | |
| 80 | + System.out.println("Database Connected."); | |
| 81 | + | |
| 82 | + Statement s = (Statement) connect.createStatement(); | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + String sql2 = "SELECT username,user_id "; | |
| 87 | + sql2 = sql2+" FROM devcalendar.dev_work "; | |
| 88 | + sql2 = sql2+" where 1 = 1 "; | |
| 89 | + sql2 = sql2+" group by username "; | |
| 90 | + sql2 = sql2+" order by username,worked_on desc "; | |
| 91 | + | |
| 92 | + ResultSet rec2 = s.executeQuery(sql2); | |
| 93 | + while((rec2!=null) && (rec2.next())) | |
| 94 | + { | |
| 95 | + Person.add(rec2.getString("username")); | |
| 96 | + } | |
| 97 | + | |
| 98 | + String sql = "SELECT username,DAY(worked_on) as worked_on FROM devcalendar.dev_work "; | |
| 99 | + sql = sql+" where 1 = 1 "; | |
| 100 | + sql = sql+" AND MONTH(worked_on) = MONTH(CURRENT_DATE()) "; | |
| 101 | + sql = sql+" AND YEAR(worked_on) = YEAR(CURRENT_DATE()) "; | |
| 102 | + sql = sql+" order by username,worked_on desc "; | |
| 103 | + | |
| 104 | + System.out.println(sql); | |
| 105 | + | |
| 106 | + ResultSet rec = s.executeQuery(sql); | |
| 107 | + String tempName = ""; | |
| 108 | + int tempDay = 0; | |
| 109 | + DevInfo person = new DevInfo(); | |
| 110 | + person.setDays(new HashSet()); | |
| 111 | + while((rec!=null) && (rec.next())) | |
| 112 | + { | |
| 113 | + if(tempName.equals(rec.getString("username")) || tempName.equals("")) | |
| 114 | + { | |
| 115 | + //same person | |
| 116 | + person.setName(rec.getString("username")); | |
| 117 | + if(!ignoreDay.contains(Integer.parseInt(rec.getString("worked_on"))) && Integer.parseInt(rec.getString("worked_on")) != tempDay) | |
| 118 | + person.getDays().add(Integer.parseInt(rec.getString("worked_on"))); | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + }else | |
| 123 | + { | |
| 124 | + //change person | |
| 125 | + if(person.getName() == null) | |
| 126 | + person.setName(tempName); | |
| 127 | + personList.add(person); | |
| 128 | + person = new DevInfo(); | |
| 129 | + person.setDays(new HashSet()); | |
| 130 | + } | |
| 131 | + | |
| 132 | + tempName = rec.getString("username"); | |
| 133 | + tempDay = Integer.parseInt(rec.getString("worked_on")); | |
| 134 | + } | |
| 135 | + if(person.getName() == null) | |
| 136 | + person.setName(tempName); | |
| 137 | + personList.add(person); | |
| 138 | + | |
| 139 | + Calendar mycal = new GregorianCalendar(); | |
| 140 | + int toDay = mycal.get(Calendar.DAY_OF_MONTH); | |
| 141 | + | |
| 142 | + if(Person.size() != personList.size()) | |
| 143 | + { | |
| 144 | +// System.out.println(Person.size()); | |
| 145 | +// System.out.println(personList.size()); | |
| 146 | + for(DevInfo dev : personList) | |
| 147 | + { | |
| 148 | + Person.remove(dev.name); | |
| 149 | + } | |
| 150 | + String[] ignore = IgnorePerson.split(","); | |
| 151 | + for(int i=0;i<ignore.length;i++) | |
| 152 | + { | |
| 153 | + Person.remove(ignore[i]); | |
| 154 | + } | |
| 155 | + | |
| 156 | + } | |
| 157 | + for(String noDataPerson: Person) | |
| 158 | + { | |
| 159 | + DevInfo personData = new DevInfo(); | |
| 160 | + personData.setName(noDataPerson); | |
| 161 | + personData.setDays(new HashSet<Integer>()); | |
| 162 | + personList.add(personData); | |
| 163 | + } | |
| 164 | + | |
| 165 | + String[] sortData = new String[personList.size()]; | |
| 166 | + | |
| 167 | + for(int i=0;i<personList.size();i++) | |
| 168 | + { | |
| 169 | + | |
| 170 | + if((toDay-(personList.get(i).getDays().size()+ignoreDay.size())-2) <= 0) | |
| 171 | + sortData[i] = ""; | |
| 172 | + else | |
| 173 | + { | |
| 174 | + sortData[i] = (toDay-(personList.get(i).getDays().size()+ignoreDay.size())-2) +" วัน "+personList.get(i).getName(); | |
| 175 | +// System.out.println(sortData[i]); | |
| 176 | +// System.out.println(sortData[i]); | |
| 177 | + if(personList.get(i).getName().equals("anans")) | |
| 178 | + sortData[i] = (toDay-(personList.get(i).getDays().size()+ignoreDay.size())-1) +" วัน "+personList.get(i).getName(); | |
| 179 | + } | |
| 180 | + | |
| 181 | +// System.out.println(toDay); | |
| 182 | +// System.out.println(personList.get(i).getDays().size()); | |
| 183 | +// System.out.println(ignoreDay.size()); | |
| 184 | + | |
| 185 | + } | |
| 186 | + | |
| 187 | + String notiMsg = ""; | |
| 188 | + Arrays.sort(sortData,Collections.reverseOrder()); | |
| 189 | + int rating = 1; | |
| 190 | + for(String info : sortData) | |
| 191 | + { | |
| 192 | + if(!info.equals("")) | |
| 193 | + { | |
| 194 | + switch (rating) { | |
| 195 | + case 1: notiMsg = notiMsg + info +" \uDBC0\uDCAD\uDBC0\uDCAD\uDBC0\uDCAD\r\n"; rating=rating+1; break; | |
| 196 | + case 2: notiMsg = notiMsg + info +" \uDBC0\uDCAD\uDBC0\uDCAD\r\n"; rating=rating+1; break; | |
| 197 | + case 3: notiMsg = notiMsg + info +" \uDBC0\uDCAD\r\n"; rating=rating+1; break; | |
| 198 | + default : notiMsg = notiMsg + info +" \r\n"; break; | |
| 199 | + } | |
| 200 | + | |
| 201 | + System.out.println(info); | |
| 202 | + } | |
| 203 | + } | |
| 204 | + | |
| 205 | + | |
| 206 | + if(Person.size()>0) | |
| 207 | + { | |
| 208 | + String personMsg = "\r\nคนไม่บันทึกงานเดือนนี้!!!\r\n"; | |
| 209 | + personMsg = personMsg + "Time : " + getCurrentTimeStamp("MM/dd HH:mm") +"\r\n"; | |
| 210 | + | |
| 211 | + for(String noDataPerson: Person) | |
| 212 | + { | |
| 213 | + personMsg = personMsg + noDataPerson +" \r\n"; | |
| 214 | + } | |
| 215 | + | |
| 216 | + | |
| 217 | +// sendNoti(personMsg); | |
| 218 | + } | |
| 219 | + | |
| 220 | + | |
| 221 | + if(!notiMsg.equals("")) | |
| 222 | + { | |
| 223 | + notiMsg = "\r\nคนไม่บันทึกงาน!!!\r\n" + notiMsg; | |
| 224 | + notiMsg = "Time : " + getCurrentTimeStamp("MM/dd HH:mm") + notiMsg + "\r\n"; | |
| 225 | + sendNoti(notiMsg); | |
| 226 | + }else | |
| 227 | + { | |
| 228 | + notiMsg = "\uDBC0\uDC33\uDBC0\uDC33\uDBC0\uDC33"; | |
| 229 | + notiMsg = "\r\nทุกคนบันทึกงานเยี่ยมมาก!!!\r\n" + notiMsg; | |
| 230 | + notiMsg = "Time : " + getCurrentTimeStamp("MM/dd HH:mm") + notiMsg + "\r\n"; | |
| 231 | + sendNoti(notiMsg); | |
| 232 | + } | |
| 233 | + | |
| 234 | + | |
| 235 | + } else { | |
| 236 | + System.out.println("Database Connect Failed."); | |
| 237 | + } | |
| 238 | + | |
| 239 | + } catch (Exception e) { | |
| 240 | + // TODO Auto-generated catch block | |
| 241 | + e.printStackTrace(); | |
| 242 | + } | |
| 243 | + | |
| 244 | + // Close | |
| 245 | + try { | |
| 246 | + if (connect != null) { | |
| 247 | + connect.close(); | |
| 248 | + } | |
| 249 | + } catch (SQLException e) { | |
| 250 | + // TODO Auto-generated catch block | |
| 251 | + e.printStackTrace(); | |
| 252 | + } | |
| 253 | + | |
| 254 | + } | |
| 255 | + | |
| 256 | + public static HashSet<Integer> getWeekendDays() { | |
| 257 | + | |
| 258 | + HashSet<Integer> returnData = new HashSet<Integer>(); | |
| 259 | + | |
| 260 | + Calendar calendar = Calendar.getInstance(); | |
| 261 | + int toDay = calendar.get(Calendar.DAY_OF_MONTH); | |
| 262 | + int year = calendar.get(Calendar.YEAR); | |
| 263 | + int month = calendar.get(Calendar.MONTH)+1; | |
| 264 | +// System.out.println(year+" "+month); | |
| 265 | + // Note that month is 0-based in calendar, bizarrely. | |
| 266 | + calendar.set(year, month - 1, 1); | |
| 267 | + int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); | |
| 268 | + | |
| 269 | +// int count = 0; | |
| 270 | + for (int day = 1; day <= daysInMonth; day++) { | |
| 271 | + calendar.set(year, month - 1, day); | |
| 272 | + int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK); | |
| 273 | + if (dayOfWeek == Calendar.SUNDAY || dayOfWeek == Calendar.SATURDAY) { | |
| 274 | +// count++; | |
| 275 | + if(day <= toDay) | |
| 276 | + { | |
| 277 | + returnData.add(day); | |
| 278 | +// System.out.println("day :" +(day)); | |
| 279 | + } | |
| 280 | + // Or do whatever you need to with the result. | |
| 281 | + } | |
| 282 | + } | |
| 283 | + return returnData; | |
| 284 | + } | |
| 285 | + | |
| 286 | + | |
| 287 | + public static HashSet<Integer> getHoliday(HashSet<Integer> ignoreDay) { | |
| 288 | + | |
| 289 | + Connection connect = null; | |
| 290 | + try { | |
| 291 | + Class.forName("com.mysql.cj.jdbc.Driver"); | |
| 292 | + connect = DriverManager.getConnection(Connection); | |
| 293 | + | |
| 294 | + if (connect != null) { | |
| 295 | + System.out.println("Database Connected."); | |
| 296 | + | |
| 297 | + Statement s = (Statement) connect.createStatement(); | |
| 298 | + | |
| 299 | + String sql = "SELECT DAY(holiday) as holiday FROM holidays "; | |
| 300 | + sql = sql+" where 1 = 1 "; | |
| 301 | + sql = sql+" AND MONTH(holiday) = MONTH(CURRENT_DATE()) "; | |
| 302 | + sql = sql+" AND YEAR(holiday) = YEAR(CURRENT_DATE()) "; | |
| 303 | + sql = sql+" AND holiday <= CURRENT_DATE() "; | |
| 304 | + | |
| 305 | + ResultSet rec = s.executeQuery(sql); | |
| 306 | + | |
| 307 | + while((rec!=null) && (rec.next())) | |
| 308 | + { | |
| 309 | +// System.out.print(rec.getString("holiday")); | |
| 310 | + ignoreDay.add(Integer.parseInt(rec.getString("holiday"))); | |
| 311 | + } | |
| 312 | + | |
| 313 | + | |
| 314 | + } else { | |
| 315 | + System.out.println("Database Connect Failed."); | |
| 316 | + } | |
| 317 | + | |
| 318 | + } catch (Exception e) { | |
| 319 | + // TODO Auto-generated catch block | |
| 320 | + e.printStackTrace(); | |
| 321 | + } | |
| 322 | + | |
| 323 | + return ignoreDay; | |
| 324 | + } | |
| 325 | + | |
| 326 | + private static void sendNoti(String msg) | |
| 327 | + { | |
| 328 | + | |
| 329 | + try { | |
| 330 | + | |
| 331 | + HttpClient httpClient = new DefaultHttpClient(); | |
| 332 | + HttpPost postRequest = new HttpPost("https://notify-api.line.me/api/notify"); | |
| 333 | + // StringEntity input = new StringEntity(msg,"UTF-8"); | |
| 334 | + ArrayList<NameValuePair> form = new ArrayList<NameValuePair>(); | |
| 335 | + form.add(new BasicNameValuePair("message", msg)); | |
| 336 | + UrlEncodedFormEntity input = new UrlEncodedFormEntity(form, Consts.UTF_8); | |
| 337 | + | |
| 338 | + input.setContentType("application/json;charset=UTF-8"); | |
| 339 | + postRequest.setEntity(input); | |
| 340 | + input.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE, "application/json;charset=UTF-8")); | |
| 341 | + postRequest.setHeader("Content-Type", "application/x-www-form-urlencoded"); | |
| 342 | + postRequest.setHeader("Authorization", "Bearer " + Token); | |
| 343 | + postRequest.setHeader("Accept", "application/json"); | |
| 344 | + postRequest.setEntity(input); | |
| 345 | + | |
| 346 | + HttpResponse response = httpClient.execute(postRequest); | |
| 347 | + | |
| 348 | + BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent()))); | |
| 349 | + | |
| 350 | + String output; | |
| 351 | + | |
| 352 | + while ((output = br.readLine()) != null) { | |
| 353 | + System.out.println(output); | |
| 354 | + } | |
| 355 | + | |
| 356 | + httpClient.getConnectionManager().shutdown(); | |
| 357 | + | |
| 358 | + } catch (MalformedURLException e) { | |
| 359 | + | |
| 360 | + e.printStackTrace(); | |
| 361 | + | |
| 362 | + } catch (IOException e) { | |
| 363 | + | |
| 364 | + e.printStackTrace(); | |
| 365 | + | |
| 366 | + } | |
| 367 | + | |
| 368 | + } | |
| 369 | + | |
| 370 | + private static String getCurrentTimeStamp(String format) { | |
| 371 | + // "MM/dd HH:mm" | |
| 372 | + SimpleDateFormat sdfDate = new SimpleDateFormat(format);// dd/MM/yyyy | |
| 373 | + Date now = new Date(); | |
| 374 | + String strDate = sdfDate.format(now); | |
| 375 | + return strDate; | |
| 376 | + } | |
| 377 | +} | ... | ... |
| 1 | +++ a/src/main/java/obj/DevInfo.java | |
| ... | ... | @@ -0,0 +1,25 @@ |
| 1 | +package obj; | |
| 2 | + | |
| 3 | +import java.util.HashSet; | |
| 4 | + | |
| 5 | +public class DevInfo { | |
| 6 | + | |
| 7 | + public String name; | |
| 8 | + public HashSet<Integer> days; | |
| 9 | + | |
| 10 | + public String getName() { | |
| 11 | + return name; | |
| 12 | + } | |
| 13 | + public void setName(String name) { | |
| 14 | + this.name = name; | |
| 15 | + } | |
| 16 | + public HashSet<Integer> getDays() { | |
| 17 | + return days; | |
| 18 | + } | |
| 19 | + public void setDays(HashSet<Integer> days) { | |
| 20 | + this.days = days; | |
| 21 | + } | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | +} | ... | ... |
| 1 | +++ a/src/test/java/bas/sourcecode/DevCalendar/AppTest.java | |
| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | +package bas.sourcecode.DevCalendar; | |
| 2 | + | |
| 3 | +import junit.framework.Test; | |
| 4 | +import junit.framework.TestCase; | |
| 5 | +import junit.framework.TestSuite; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * Unit test for simple App. | |
| 9 | + */ | |
| 10 | +public class AppTest | |
| 11 | + extends TestCase | |
| 12 | +{ | |
| 13 | + /** | |
| 14 | + * Create the test case | |
| 15 | + * | |
| 16 | + * @param testName name of the test case | |
| 17 | + */ | |
| 18 | + public AppTest( String testName ) | |
| 19 | + { | |
| 20 | + super( testName ); | |
| 21 | + } | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * @return the suite of tests being tested | |
| 25 | + */ | |
| 26 | + public static Test suite() | |
| 27 | + { | |
| 28 | + return new TestSuite( AppTest.class ); | |
| 29 | + } | |
| 30 | + | |
| 31 | + /** | |
| 32 | + * Rigourous Test :-) | |
| 33 | + */ | |
| 34 | + public void testApp() | |
| 35 | + { | |
| 36 | + assertTrue( true ); | |
| 37 | + } | |
| 38 | +} | ... | ... |
target/classes/META-INF/maven/bas.sourcecode/DevCalendar/pom.properties
0 → 100644
| 1 | +++ a/target/classes/META-INF/maven/bas.sourcecode/DevCalendar/pom.properties | |
| ... | ... | @@ -0,0 +1,7 @@ |
| 1 | +#Generated by Maven Integration for Eclipse | |
| 2 | +#Thu Mar 15 14:21:23 ICT 2018 | |
| 3 | +version=0.0.1-SNAPSHOT | |
| 4 | +groupId=bas.sourcecode | |
| 5 | +m2e.projectName=DevCalendar | |
| 6 | +m2e.projectLocation=C\:\\myWork\\eclipseCode\\DevCalendar | |
| 7 | +artifactId=DevCalendar | ... | ... |
target/classes/META-INF/maven/bas.sourcecode/DevCalendar/pom.xml
0 → 100644
| 1 | +++ a/target/classes/META-INF/maven/bas.sourcecode/DevCalendar/pom.xml | |
| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| 2 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
| 3 | + <modelVersion>4.0.0</modelVersion> | |
| 4 | + | |
| 5 | + <groupId>bas.sourcecode</groupId> | |
| 6 | + <artifactId>DevCalendar</artifactId> | |
| 7 | + <version>0.0.1-SNAPSHOT</version> | |
| 8 | + <packaging>jar</packaging> | |
| 9 | + | |
| 10 | + <name>DevCalendar</name> | |
| 11 | + <url>http://maven.apache.org</url> | |
| 12 | + | |
| 13 | + <properties> | |
| 14 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |
| 15 | + </properties> | |
| 16 | + | |
| 17 | + <dependencies> | |
| 18 | + <dependency> | |
| 19 | + <groupId>junit</groupId> | |
| 20 | + <artifactId>junit</artifactId> | |
| 21 | + <version>3.8.1</version> | |
| 22 | + <scope>test</scope> | |
| 23 | + </dependency> | |
| 24 | + <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> | |
| 25 | + <dependency> | |
| 26 | + <groupId>mysql</groupId> | |
| 27 | + <artifactId>mysql-connector-java</artifactId> | |
| 28 | + <version>8.0.8-dmr</version> | |
| 29 | + </dependency> | |
| 30 | + <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> | |
| 31 | + <dependency> | |
| 32 | + <groupId>org.apache.httpcomponents</groupId> | |
| 33 | + <artifactId>httpclient</artifactId> | |
| 34 | + <version>4.5.4</version> | |
| 35 | + </dependency> | |
| 36 | + | |
| 37 | + </dependencies> | |
| 38 | +</project> | ... | ... |
No preview for this file type
No preview for this file type
No preview for this file type