MyExport.java 43.3 KB
Newer Older
TongZuu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281
package com.csc.library.cscexport;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.rmi.RemoteException;
import java.text.DecimalFormat;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.ListIterator;
import java.util.Properties;
import java.util.StringTokenizer;
import java.util.Vector;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import com.csc.library.database.StaticProperties;
import com.csc.library.session.DbInquiry;
import com.csc.library.session.DbRecord;
import com.csc.library.session.InitialEnvironment;
import com.csc.library.session.InitialRecord;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.CurrencyToEng;
import com.csc.library.utilities.CurrencyToThai;
import com.csc.library.utilities.DbXml;
import com.csc.library.utilities.DynamicJava;
import com.csc.library.utilities.FileString;
import com.csc.library.utilities.MmInquiry;
import com.csc.library.utilities.MyLog;
import com.csc.library.utilities.ReadFile;
import com.csc.library.utilities.StrReplace;
import com.csc.library.utilities.UProfile;
import com.csc.library.utilities.WriteFile;
/**
 * @author @SoCool@
 *
 * <PRE>
 * Base Cls 㹡 export 
 * ¡ҹҹк кӡ絤 condition Ѻ Cls ҹʹ setCondition 
 * ֧зӡ¡ʹ process 
 * ¡ҹҹкͧӡ set  init 鹡͹
 * </PRE>
 */
public class MyExport {
	private ExportXml expXml;
	private DbInquiry dbInq;
	private final String newLine = "\15\12"; // constant for new line
	private String exportPath = "";
	private String exportFile = "";
	private String exportXml = "";
	private String outFile = "";
	private String factory = "fact1";
	private String defaultPattern = "#,###,###,##0.00";
	private FileString fs = new FileString();
	private String conid = "";
	private UProfile up = null;
	private Properties filter;
	private HashMap error = new HashMap();
	protected HashMap condition;
	private String fileType = "";
	private String subFolder="";
	private String remark="";
	private String charSet="UTF-8";
	/**
	 *  Constructor 
	 * */
	public MyExport() {
	}
	/**
	 * <PRE>
	 * 㹡 export ŵ parameter 
	 * </PRE>
	 *  @param parameter  HashMap 纤ҷͧ㹡 export Ť
	 *  					-  EXPPATH  path зӡ export
	 *  					-  EXPFILE  file зӡ export
	 *  					-  EXPXML  xml ͧ export
	 *  @param inq  DbInquiry 㹡 ֧
	 * */
	public MyExport(HashMap parameter, DbInquiry inq) {
		this.setCondition(parameter);
		this.setExportPath(this.getCondition().containsKey("EXPPATH") ? (String) this.getCondition().get("EXPPATH") : "");
		this.setExportFile(this.getCondition().containsKey("EXPFILE") ? (String) this.getCondition().get("EXPFILE") : "");
		this.setExportXml(this.getCondition().containsKey("EXPXML") ? (String) this.getCondition().get("EXPXML") : "");
		this.checkXml();
		this.setDbInq(inq);
		try {
			this.process(false);
		} catch (Exception e) {
            MyLog.error(this,this.up, e);
		}
	}
	/**
	 * <PRE>
	 * 㹡 int  ͹ӡ export  
	 * 		- Path  path зӡ xport ҹʹ setExportPath
	 * 		- Xml  xml ͧ export зӡ xport ҹʹ setExpXml
	 * 		- File  зӡ xport ҹʹ setExportFile
	 * 		- Out File  path  зӡ export
	 * </PRE>
	 * @param conid   condition id
	 * @return boolean flag success
	 */
	protected boolean initValue(String conid) {
		try {
			this.setConid(conid);
            MyLog.debug(this,this.up, "!!!!!!!!!!!!!!!!!!!!!!! PARAM BEFORE EXPORT IS:" + this.getCondition() + "!!!!!!!!!!!!!!!!!!!!!!!");
			this.setUp((UProfile) this.getCondition().get("CONDITION"));
			this.setFilter((Properties) this.getCondition().get("FILTER"));
			HashMap param=((HashMap)this.getCondition().clone());
			param.remove("CONDITION");
			this.setDbInq(new DbXml(this.getUp(), (String) this.getCondition().get("SCREEN"), "", "", "",param).getInquiry());
			this.setInquiryFilter();
			this.setOrderBy();
			this.getDbInq().refresh();
			this.setExportPath(new InitialEnvironment("GLOBAL").getValue("export-dir"));
			this.setExpXml(new ExportXml(this.getExportPath() + "EXPORTXML/" + (String) this.getCondition().get("EXPXML")));
			this.setExportFile(conid + "." + this.getExpXml().getFileType()); // follow by report id
			this.setOutFile(this.getExportPath() + this.getExportFile());
			return true;
		} catch (RemoteException e) {
            MyLog.error(this,this.up, e);
			return false;
		}
	}
	/**
	 * 㹡õǨͺ xml ͹зӡ process
	 * @return boolean flag success
	 */
	private boolean checkXml() {
		try {
			if (!this.getExportXml().equals("")) {
				this.setExpXml(new ExportXml(this.getExportXml()));
			} else {
				return false;
			}
			if (this.getExportPath().equals("")) {
				this.setExportPath(this.getExpXml().getFileOut());
				this.setOutFile(this.getExportPath());
			} else {
				String tmp = this.getExportPath() + ((this.getExportFile().indexOf(".") > -1) ? this.getExportFile() : this.getExportFile() + ".txt");
				this.setOutFile(tmp);
			}
			return true;
		} catch (Exception e) {
            MyLog.error(this,this.up, e);
			return false;
		}
	}
	/**
	 * <PRE>
	 *  set ٻẺͧŢ property  tag COL 
	 * 		<COL type="data" width="15" decimalformat="###.00" blank="0" align="right">sum</COL>
	 * աкؤҨ default ҡ defaultPattern
	 * </PRE>
	 * @param config  Hash 纤 property ͧ tag COL
	 * @param data  Ũҡäӹǹ͹絤 ٻẺͧŢ
	 * @return String ѾѧҡèѴٻẺ
	 */
	private String setDecimalPattern(HashMap config, String data) {
		String result = "";
		if (config.containsKey("decimalformat")) {
			DecimalFormat decFormat = new DecimalFormat(this.defaultPattern);
			String patternValue = (String) config.get("decimalformat");
			if (patternValue.equalsIgnoreCase("default") || patternValue.equalsIgnoreCase("")) {
				result= decFormat.format(Double.parseDouble(data));
			} else {
				decFormat.applyPattern(patternValue);
				result = decFormat.format(Double.parseDouble(data));
			}
			if (config.containsKey("amtformat")){
				if (config.get("amtformat").equals("true")){
					StrReplace re = new StrReplace();
					result =  re.replace(result,".","");
				}
			}
			return result;
		} else {
			return data;
		}
	}
	/**
	 * <PRE>
	 *  set ٻẺͧѹ property  tag COL 
	 * 		<COL type="data" width="8" dateformat="DDMMYYYY">dbInq.getString("birthday")</COL>
	 * </PRE>
	 * @param config  Hash 纤 property ͧ tag COL
	 * @param data  Ũҡäӹǹ͹ѴٻẺ
	 * @return  (ѹ) ѧҡèѴٻẺ 
	 */
	private String setFomat(HashMap config, String data) {
		if (config.containsKey("dateformat")) {
			CscCalendar calendar = new CscCalendar(data);
			data = calendar.getCustomFormat((String) config.get("dateformat"));
		}
		if (config.containsKey("numberformat")){
			if (config.get("numberformat").toString().equalsIgnoreCase("nodot")){
				StrReplace xx = new StrReplace();
				data= xx.replace(data,".","");
			}
			return data;
		}
		if (config.containsKey("width")) { // have attribute width
			int width = Integer.parseInt((String) config.get("width"));
			if (config.containsKey("align")) {
				String align = (String) config.get("align");
				if (config.containsKey("blank")) {
					String blank = (String) config.get("blank");
					return fs.addBlank(width, blank, align, data);
				} else {
					return fs.addBlank(width, " ", align, data);
				}
			} else if (config.containsKey("blank")) {
				String blank = (String) config.get("blank");
				return fs.addBlank(width, blank, "left", data);
			} else if (data.length() == width) {
				return data;
			} else {
				return fs.addBlank(width, " ", data);
			}
		} else {
			return data;
		}
	}
	/**
	 * <PRE>
	 * 㹡äӹǹҤ ´֧ҢŨҡ export xml
	 *  run ҼѾ ͹觤ҡѺ
	 * </PRE>
	 * @param config  Hash 纤 property ͧ tag COL
	 * @param dj  environment ͧ Dynamic Java 㹡÷ӧҹ
	 * @param xmlData ͢ŷ export xml зӡҼѾ
	 * @return String  Ѿҡûż
	 * @throws Exception
	 */
	private String getResult(HashMap config, DynamicJava dj, String xmlData) throws Exception {
		String result = "";		
		MyLog.debug(this, this.up, "Interpret data is:" + xmlData);
		if (config.get("type").toString().equalsIgnoreCase("data")) {
			CscCalendar cal = new CscCalendar();
			if(xmlData.equalsIgnoreCase("username")){
				String tmp,commandfs="",size,chr,align="";
				size = config.get("size").toString();
				chr = config.get("char").toString();
				if (chr.equalsIgnoreCase("")){
					chr = " ";
				}
				align = config.get("align").toString();
				commandfs = " fs.addBlank("+size+","+"\""+chr+"\""+","+"\""+align+"\""+","+"\""+this.up.get("username").toString()+"\""+")";
				try {
					MyLog.debug(this, this.up, ">>>>>>>>    Username ::          commandfs =    "+commandfs);
						tmp = (String) dj.interpret("tmpResult = String.valueOf(" + commandfs + ");",this.factory);
				} catch (Exception e) {
		            MyLog.error(this,this.up, e);
					this.setError(commandfs, e.getMessage());
					return "";
				}
				MyLog.info(this, this.up, ">>>>>>>>>:::  Export  :::     Username = "+tmp);
				result = tmp;
			}else if(xmlData.equalsIgnoreCase("currenttime")){
				result = cal.getTimeShort();
			}else if(xmlData.equalsIgnoreCase("currentdate")){
				result = cal.getEngYYYY()+cal.getMM()+cal.getDD();
			}else{
				String tmp = "";
				try {
					if (xmlData == null || xmlData.equals("")) {
						MyLog.info(this, this.up, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Xml Data is Null Or blank !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
						result = "";
					}
					dj.setVariable("tmpResult"," ");
					dj.interpret("fs.clearData();",this.factory);
					tmp = (String) dj.interpret("tmpResult = String.valueOf(" + xmlData + ");",this.factory);
				
					result = this.setDecimalPattern(config, tmp);
					MyLog.debug(this, this.up,">>>>>>>>>> Result after set decimal format is:" + result + "<<<<<<<<<<");
					result = this.setFomat(config, result);
					MyLog.debug(this, this.up,">>>>>>>>>>Result after set format is:" + result + "<<<<<<<<<<");
				} catch (Exception e) {
		            MyLog.error(this,this.up, e);
					this.setError(xmlData, e.getMessage());
					return "";
				}
			}
			return result;
		} else if (config.get("type").toString().equalsIgnoreCase("formula")) {
			if (xmlData.indexOf(";") > -1) {
				dj.interpret(xmlData, this.factory);
			} else {
				dj.interpret(xmlData + ";",this.factory);
			}
			return "";
		} else if (config.get("type").toString().equalsIgnoreCase("string")) {
			if (xmlData.equalsIgnoreCase("newline")) {
				result = this.newLine;
			} else {
				result = xmlData;
			}
			return result;
		} else if (config.get("type").toString().equalsIgnoreCase("variable")) {
			result = dj.getVariable(xmlData).toString();
			//result = (String) dj.interpret("String.valueOf(" + xmlData + ");", this.factory);
			result = this.setDecimalPattern(config, result);
			MyLog.debug(this, this.up,">>>>>>>>>> Result after set decimal format is:" + result + "<<<<<<<<<<");
			result = this.setFomat(config, result);
			MyLog.debug(this, this.up,">>>>>>>>>>Result after set format is:" + result + "<<<<<<<<<<");
			return result;
		} else if (config.get("type").toString().equalsIgnoreCase("command")){  //  ˹÷ӧҹ  µͧ¹ Type  Commnad 
						if (config.get("function").toString().equalsIgnoreCase("checkamount")){	//  ӡ  Amount  Tacc_tran0 繽 Debit    Credit  ( DB Ẻ¡)
								String getat = "";
								if(Double.parseDouble(this.dbInq.getString("debit"))>0){
										getat = "dbInq.getString("+"\""+"debit"+"\""+")";
										//  Set    Status = D
										dj.interpret("status=\"D\";", this.factory);
								}else if(Double.parseDouble(this.dbInq.getString("credit"))>0){
										getat =  "dbInq.getString("+"\""+"credit"+"\""+")";
										//  Set    Status = C
										dj.interpret("status=\"C\";", this.factory);
							    }
								if (!getat.equalsIgnoreCase("")){
										String tmp,commandfs="",size,chr,align="";
										DecimalFormat dc = new DecimalFormat("0.00");
										tmp = (String) dj.interpret("tmpResult = String.valueOf(" + getat + ");",this.factory);
										tmp = dc.format(Double.parseDouble(tmp)).toString();
										StrReplace sr = new StrReplace();
										tmp = sr.replace(tmp,".","");
										size = config.get("size").toString();
										chr = config.get("char").toString();   
										align = config.get("align").toString();
										commandfs = " fs.addBlank("+size+","+"\""+chr+"\""+","+"\""+align+"\""+","+tmp+")";
										try {
											MyLog.debug(this, this.up,">>>>>>>>    command :: function = checkamount              ::>>>           commandfs =    "+commandfs);
												tmp = (String) dj.interpret("tmpResult = String.valueOf(" + commandfs + ");",this.factory);
										} catch (Exception e) {
								            MyLog.error(this,this.up, e);
											this.setError(commandfs, e.getMessage());
											return "";
										}
										result = this.setDecimalPattern(config, tmp);
										MyLog.debug(this, this.up,">>>>>>>>>> Result after set decimal format is:" + result + "<<<<<<<<<<");
										result = this.setFomat(config, result);
										MyLog.debug(this, this.up,">>>>>>>>>>Result after set format is:" + result + "<<<<<<<<<<");
										
										return result;
					 
								}else{
									MyLog.debug(this, this.up,"!!!!!!!!!!!!!!          Error      !!!!!!!!!!!!!!!      in Checkamount  >>>  no value  in credti or debit   ");
										return "";
								}
					} else return "";
		}else {
			MyLog.error(this, this.up,"No such type in Export XML Element DATA ");
			return  "";
		}
	}
	/**
	 * ӡ process  write element data ŧ
	 * @param dj  DynamicJava
	 * @param wf  Cls  write 
	 * @return boolean flag success
	 */
	private boolean processInFile(DynamicJava dj, WriteFile wf) {
		String result = "";
		HashMap hmap = new HashMap();
		try {
			for (int i = 0; i < expXml.getData().size(); i++) {
				hmap = (HashMap) expXml.getConfigData(i);
				String data = expXml.getData().get(i).toString();
				dj.setVariable("tmpResult", "");
				result = this.getResult(hmap, dj, data);
				if (result != null && !result.equals(""))
					wf.writeString(result);
			}
		} catch (Exception e) {
            MyLog.error(this,this.up, e);
			wf.closeFile();
			return false;
		}
		return true;
	}
	
	/*
	 * private boolean processInCsvFile(DynamicJava dj, WriteFile wf) {
	 
		String result = "";
		HashMap hmap = new HashMap();
//		wf.write("\n"); comment ҧ blank line  1 record
			try {
				for(int i=0; i< expXml.getData().size(); i++){
					hmap = expXml.getConfigData(i);
					String data = expXml.getData().get(i).toString();
					result = this.getResult(hmap, dj, data);
					if( result != null && !result.equals(""))
						wf.writeString(result);
					if(i != (expXml.getData().size()-1))
						wf.writeString(",");
					else
						wf.write("\n");
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		return false;		
	}
	*/
	
	private boolean processInCsvFile(DynamicJava dj, WriteFile wf) {
		String result = "";
		HashMap hmap = new HashMap();
//		wf.write("\n"); comment ҧ blank line  1 record
			try {
				for(int i=0; i< expXml.getData().size(); i++){
					hmap = expXml.getConfigData(i);					
					String data = expXml.getData().get(i).toString();
					result = this.getResult(hmap, dj, data);
					if( result != null && !result.equals(""))
						wf.writeString(result);
					if(i != (expXml.getData().size()-1)){
						if(hmap.containsKey("type")&& !hmap.get("type").equals("formula")){
							wf.writeString(",");
						}						
					}else{
						wf.write("\n");
					}
				}
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		return false;		
	}	
	/**	
	 * ӡ process »ż红 memory
	 * @param dj  DynamicJava
	 * @param dataVec  Vector 红ŷзӡûż
	 * @param configData  Vector 纤 config ͧ dataVec 
	 * @return String  Ѿҡû
	 * @throws Exception
	 */
	private String processInMem(DynamicJava dj, Vector dataVec, Vector configData) throws Exception {
		String result = "", data = "";
		HashMap hmap = new HashMap();
		for (int i = 0; i < dataVec.size(); i++) { // Loop for get data in  element DATA ,HEAD, FOOT
			hmap = (HashMap) configData.get(i);
			data = dataVec.get(i).toString(); // Get data from vector(XML) to store in String
			dj.setVariable("tmpResult", ""); // Clear tmpResult for saving result
			result += this.getResult(hmap, dj, data);
		}
		return result;
	}
	/**
	 * <PRE>
	 *  process ¨ write Ţͧ tag data ŧ
	 * ExportTmp.txt ҡ鹨֧зӡҹ ҡ tmp
	 * ͻТŷǹ  ǹзӡ
	 * generate   parameter 絤
	 * </PRE>
	 * @param dj  DynamicJava
	 * @return boolean flag success
	 */
	private boolean txtProcessInFile(DynamicJava dj) {
		String tmpFile = this.getExportPath() + conid+".tmp";
		String head = "", foot = "";
		WriteFile wf = new WriteFile();
		wf.setFileName(tmpFile);
		if(this.getCharSet().length()>0){
			wf.setCharSet(this.getCharSet());
		}
		System.out.println("PATH>>>>>>>>>>>>>>>>>>"+wf.getPathName());
		int recCount = 0;
		String processID = this.getUp().get("processID").toString();
		try {
			while (dbInq.next() && !StaticProperties.serverManager.isCancle(processID)) {
				this.processInFile(dj, wf);
            	recCount++;
            	StaticProperties.serverManager.aliveProcess(processID, "Exporting record number : "+recCount);	
			}
			wf.closeFile();
			if (!StaticProperties.serverManager.isCancle(processID)) {
				ReadFile r = new ReadFile(tmpFile);
				//System.out.println("PATH>>>>>>>>>>>>>>>>>>"+r.g);
				WriteFile w = new WriteFile();
				w.setFileName(this.getOutFile());
				if(this.getCharSet().length()>0){
					w.setCharSet(this.getCharSet());
				}
				head = this.processInMem(dj, expXml.getHead(), expXml.getConfig(1));
				foot = this.processInMem(dj, expXml.getFoot(), expXml.getConfig(2));
				MyLog.debug(this, this.up,"...... Writing Head Data ......");
				w.writeString(head);
				int i = 1;
				int data;
				char[]  ch = new char[128];
				data=  r.read(ch);
				while (data!=-1) {
					w.write(ch, 0, data);
					i++;
					data= r.read(ch);
				}
				w.writeString(foot);
				MyLog.debug(this, this.up,"...... Writing Foot Data ......");
				r.closeFile();
				w.closeFile();
			}
			return true;
		} catch (Exception e) {
            MyLog.error(this,this.up, e);
			return false;
		}finally{
			this.removeFile(tmpFile);
		}
	}
	/**
	 * <PRE>
	 * 㹡 process  export 
	 *  parameter  ¨зӧҹ
	 * memory
	 * </PRE>
	 * @param dj  DynamicJava
	 * @return boolean flag success
	 * @throws Exception
	 */
	private boolean txtProcessInMem(DynamicJava dj) throws Exception {
		String head = "", detail = "", foot = "";
		FileString fs = new FileString();
		boolean outHead = false, outDetail = false, outFoot = false;
		int recCount = 0;
		String processID = this.getUp().get("processID").toString();
		while (dbInq.next()  && !StaticProperties.serverManager.isCancle(processID)) {
			detail += this.processInMem(dj, expXml.getData(), expXml.getConfig(0));
        	recCount++;
        	StaticProperties.serverManager.aliveProcess(processID, "Exporting record number : "+recCount);	
		}
		if (!StaticProperties.serverManager.isCancle(processID)) {
			head = this.processInMem(dj, expXml.getHead(), expXml.getConfig(1));
			foot = this.processInMem(dj, expXml.getFoot(), expXml.getConfig(2));
			if (!expXml.getAttrHead("fileout").equals(""))
				outHead = true;
			if (!expXml.getAttrData("fileout").equals(""))
				outDetail = true;
			if (!expXml.getAttrFoot("fileout").equals(""))
				outFoot = true;
			if (outHead && outDetail && outFoot) {
				fs.outFile(head, expXml.getAttrHead("fileout"), true);
				fs.outFile(detail, expXml.getAttrData("fileout"), true);
				fs.outFile(foot, expXml.getAttrFoot("fileout"), true);
			} else if (outHead == false && outDetail == false && outFoot == false) {
				fs.outFile(head + detail + foot, this.getOutFile(), false);
			} else if (outHead && outDetail == false && outFoot) {
				fs.outFile(head, expXml.getAttrHead("fileout"), true);
				fs.outFile(detail, this.getOutFile(), true);
				fs.outFile(foot, expXml.getAttrFoot("fileout"), true);
			} else if (outHead && outDetail == false && outFoot == false) {
				fs.outFile(head, expXml.getAttrHead("fileout"), true);
				fs.outFile(detail + foot, this.getOutFile(), true);
			} else if (outHead && outDetail && outFoot == false) {
				fs.outFile(head, expXml.getAttrHead("fileout"), true);
				fs.outFile(detail, expXml.getAttrData("fileout"), true);
				fs.outFile(foot, this.getOutFile(), true);
			}
		}
		//fs.outFile(expXml.getFileOut());
		return true;
	}
	/**
	 * <PRE>
	 * ʹ¡Ҩ process export text file 
	 * Ըա˹ mem  file
	 * </PRE> 
	 * @param dj  DynamicJava
	 * @return boolean flag success
	 * @throws Exception
	 */
	protected boolean txtProcess(DynamicJava dj) throws Exception {
		if (expXml.getProcessType().equalsIgnoreCase("mem")) {
			this.txtProcessInMem(dj);
		} else if (expXml.getProcessType().equalsIgnoreCase("file")) {
			this.txtProcessInFile(dj);
		} else {
			MyLog.debug(this, this.up, "No such process type please check your XML file");
			return false;
		}
		return true;
	}
	/**
	 * <PRE>
	 * ʹ 㹡 process  export ŷ xml 
	 * </PRE>
	 * @param dj  DynamicJava
	 * @return boolean flag success
	 * @throws Exception
	 */
	protected boolean xmlProcess(DynamicJava dj) throws Exception {
		String tmpFile = this.getExportPath() + conid+".tmp";
		String head = "", detail = "", foot = "";
		FileString fs = new FileString();
		String headXml = "<?xml version='1.0' encoding='TIS-620' ?>" + this.newLine; // insert tag for encoding thai language
		int recCount = 0;
		String processID = this.getUp().get("processID").toString();
		if (expXml.getProcessType().equalsIgnoreCase("mem")) { // process in memory
			try {
				while (dbInq.next()  && !StaticProperties.serverManager.isCancle(processID)) {
					detail += "<DETAIL>" + this.processInMem(dj, expXml.getData(), expXml.getConfig(0)) + "</DETAIL>" + this.newLine;
		        	recCount++;
		        	StaticProperties.serverManager.aliveProcess(processID, "Exporting record number : "+recCount);	
				}
				head = this.processInMem(dj, expXml.getHead(), expXml.getConfig(1));
				foot = this.processInMem(dj, expXml.getFoot(), expXml.getConfig(2));
				fs.setData(headXml + "<EXPXML>" + this.newLine + "<HEAD>" + head + "</HEAD>" + this.newLine + "<DATA>" + this.newLine + detail + "</DATA>" + this.newLine + "<FOOT>" + foot + "</FOOT>" + this.newLine + "</EXPXML>");
				//fs.outFile(expXml.getFileOut());
				fs.outFile(this.exportPath);
			} catch (Exception e) {
	            MyLog.error(this,this.up, e);
			}
		} else if (expXml.getProcessType().equalsIgnoreCase("file")) { // process in file
			//logger.info("LOOP Processtype  = file");
			WriteFile wf = new WriteFile(tmpFile);
			wf.setFileName(tmpFile);
			if(this.getCharSet().length()>0){
				wf.setCharSet(this.getCharSet());
			}
			try {
				while (dbInq.next()  && !StaticProperties.serverManager.isCancle(processID)) {
					wf.writeString("<DETAIL>");
					this.processInFile(dj, wf);
					wf.writeString("</DETAIL>" + this.newLine);
		        	recCount++;
		        	StaticProperties.serverManager.aliveProcess(processID, "Exporting record number : "+recCount);	
				}
				wf.closeFile();
			} catch (Exception e) {
	            MyLog.error(this,this.up, e);
			}
			if (!StaticProperties.serverManager.isCancle(processID)) {
				ReadFile r = new ReadFile(tmpFile);
				//WriteFile w = new WriteFile(expXml.getFileOut());				
				WriteFile w = new WriteFile();
				w.setFileName(this.exportPath + this.exportFile + ".xml");
				if(this.getCharSet().length()>0){
					w.setCharSet(this.getCharSet());
				}				
				head = this.processInMem(dj, expXml.getHead(), expXml.getConfig(1));
				foot = this.processInMem(dj, expXml.getFoot(), expXml.getConfig(2));
				head = "<HEAD>" + head + "</HEAD>" + this.newLine;
				foot = "<FOOT>" + foot + "</FOOT>" + this.newLine + "</EXPXML>";
				w.writeString(headXml + "<EXPXML>" + this.newLine + head);
				try {
					w.writeString("<DATA>" + this.newLine);
					while (r.hasMoreData()) {
						w.writeString(String.valueOf((char) r.read()));
					}
					w.writeString("</DATA>" + this.newLine);
				} catch (Exception e) {
		            MyLog.error(this,this.up, e);
				}
				w.writeString(foot);
				w.closeFile();
			}
		} else {
			MyLog.error(this, this.up,"No such process type");
		}
		return true;
	}
	/**
	 * <PRE>
	 * ʹ 㹡 process  export ŷ exel 
	 * </PRE>
	 * @param dj  DynamicJava
	 * @return boolean flag success
	 */
	protected boolean exelProcess(DynamicJava dj) {
		try {
			/** add ա write file ͹й ҷӡ add data  file 2014-06-05 **/
			WriteFile wf = new WriteFile(this.getOutFile());
			wf.closeFile();
			/**  **/
			FileOutputStream fout = new FileOutputStream(this.outFile);
			HSSFWorkbook wb = new HSSFWorkbook(); // create a new workbook
			HSSFSheet s = wb.createSheet(); // create a new sheet
			HSSFRow r = null; // declare a row object reference
			HSSFCell c = null; // declare a cell object reference
			wb.setSheetName(0, "Export", HSSFWorkbook.ENCODING_UTF_16);
			DbRecord rec = dbInq.getCurrentDbRecord();
			r = s.createRow(0); // Create header
			short fieldCount = 0, rowNum = 0;
			Vector vKey = new Vector();
			vKey =  expXml.getHead();
			StringTokenizer sz = null;
			ListIterator iter = vKey.listIterator();
			while (iter.hasNext()){
				sz = new StringTokenizer((String)iter.next(), ",");
			}
						
			while (sz.hasMoreTokens() && sz!=null) {
				String key = sz.nextToken();
				vKey.add(key);
				c = r.createCell(fieldCount);
				// do some goofy math to demonstrate decimals
				c.setEncoding(HSSFCell.ENCODING_UTF_16);
				c.setCellValue(key);
				fieldCount++;
			}		
			short recCount = new Integer(dbInq.recCount()).shortValue();
			String data, result;
			HashMap hmap;
			for (rowNum = (short) 1; rowNum <= recCount; rowNum++) {
				dbInq.next();
				r = s.createRow(rowNum); // create a row
				for(int i=0; i<expXml.getData().size() ;i++){
					hmap = (HashMap) expXml.getConfigData(i);
					data = expXml.getData().get(i).toString();
					c = r.createCell((short) i); // create a numeric cell
					c.setEncoding(HSSFCell.ENCODING_UTF_16);
					result = this.getResult(hmap, dj, data);
					if (result != null && !result.equals(""))
						c.setCellValue( result ); // do some goofy math to demonstrate decimals
					
				}
				/*for (short cellnum = (short) 0; cellnum < fieldCount; cellnum++) { // run for fields
					c = r.createCell(cellnum); // create a numeric cell
					c.setEncoding(HSSFCell.ENCODING_UTF_16);
					c.setCellValue(dbInq.getString(vKey.get(cellnum).toString())); // do some goofy math to demonstrate decimals
				}*/
			}
			wb.write(fout);
			fout.close();
			return true;
		} catch (Exception e) {
            MyLog.error(this,this.up, e);
			return false;
		}
	}
	/**
	 * <PRE>
	 * 㹡 initial ҵ÷Ҩҡ param
	 *   Hash param յ÷鹵鹴
	 * VARIABLE$  VARIABLE$DATE = "01-01-2000"
	 * зӡõѴҢѧҡ VARIABLE$ ҧ
	 * 繵  DynamicJava ЩҨ
	 *  DATE դ 01-01-2000  environment
	 * ͧ DynamicJava 
	 * </PRE>
	 * @param dj  DynamicJava
	 * @param param   parameter ͧõǨͺ
	 */
	private void initialVariable(DynamicJava dj, HashMap param) {
		
		Iterator it = param.keySet().iterator();
		String key = "";
		while (it.hasNext()) {
			key = it.next().toString();
			if (key.indexOf("VARIABLE$") > -1) {
				String var = key.substring(9, key.length());
				dj.defineVariable(var, param.get(key));
			}
		}
	}
	/**
	 * ʹѡ㹡 process
	 * @param conid   condition id
	 * @return boolean flag success
	 * @throws Exception
	 */
	public boolean process(String conid) throws Exception {
		this.initValue(conid);
		this.process(true);
		return true;
	}
	protected boolean process() throws Exception {
		return this.process(true);
	}
	/**
	 * <PRE>
	 * ʹ㹡 process ѧҡӡ initial 
	 * Step 㹡÷ӧҹ
	 * 		- intial ҵ DynamicJava ҡ parameter (Condition)
	 * 		- define Ѻ DynamicJava  
	 * 				- dbInq (DbInquiry  get ) 
	 * 				- calendar (CscCalendar)
	 * 				- curEng (CurrencyToEng) 
	 * 				- curThai (CurrencyToThai)
	 * 				- tmpResult (String  process)
	 * 				- fs (FileString  string utility)
	 * 				- df (DecimalFormat)
	 * 		- Interpret tag INIT
	 * 		- Ǩͺҵͧӡ export 쪹Դ (txt , dat , xml , xls)
	 * 		- ӡ export 
	 * </PRE>
	 * @return boolean flag success
	 * @throws Exception
	 */
	protected boolean process(boolean updateLog) throws Exception {
		boolean result = false;
		String type = "";
		String processID = this.getUp().get("processID").toString();
		this.setExportPath(new InitialEnvironment("GLOBAL").getValue("export-dir") +"REPORT/");
		if (!this.fileType.equals("")) {
			type = this.fileType;
		} else if (this.getExpXml()==null || this.getExpXml().getFileType().equals("")) {
			type = "txt";
		} else { 
			type = expXml.getFileType();
		}
		String filename=this.getExportFile().substring(0,this.getExportFile().indexOf("."));
		this.setExportFile(filename+"."+type.toLowerCase());
		this.setOutFile(this.getExportPath() + this.getExportFile());
		DynamicJava dj = new DynamicJava();
		CscCalendar calendar = new CscCalendar();
		CurrencyToEng curEng = null;
		CurrencyToThai curThai = new CurrencyToThai(100);
		DecimalFormat df = new DecimalFormat(this.defaultPattern);		
		this.initialVariable(dj, this.getCondition());
		// INIT Data
		dj.defineVariable("dbInq", (MmInquiry) this.dbInq);
		dj.defineVariable("calendar", calendar);
		dj.defineVariable("curEng", curEng);
		dj.defineVariable("curThai", curThai);
		dj.defineVariable("tmpResult", new String());
		dj.defineVariable("ie", new InitialEnvironment("GLOBAL"));
		dj.defineVariable("fs", this.fs);
		dj.defineVariable("df", df);
		dj.interpret(expXml.getInitData(), factory);		
		String fullMsg = "";		
		String exportType = "";
		if (type.equalsIgnoreCase("xml")) { // if type to export file is xml
			result = this.xmlProcess(dj);
			if (updateLog)
				this.updateFile(this.getConid(), "xml");
			exportType = "EXPORT_XML";
		} else if (type.equalsIgnoreCase("xls")) { // if type to export file is xml
			result = this.exelProcess(dj);
			if (updateLog)
				this.updateFile(this.getConid(), "xls");
			exportType = "EXPORT_XLS";
		} else if (type.equalsIgnoreCase("csv")) { // if type to export file is xml
			result = this.csvProcess(dj);
			if (updateLog)
				this.updateFile(this.getConid(), "csv");
			exportType = "EXPORT_CSV_COM";
		} else {
			//comment by pas commemt by pas ա export Ẻ蹷͡˹ͨҡҹ˹ export Ẻ text 
			//if (type.equalsIgnoreCase("txt") || type.equalsIgnoreCase("dat")) { // if type to export is text
				result = this.txtProcess(dj);
				if (updateLog) {// check shall we update lreport_log
					this.updateFile(this.getConid(), type);
//					comment by pas 20101022
//					if (type.equalsIgnoreCase("txt")) {
//						this.updateFile(this.getConid(), "txt");					
//					} 	else {
//						this.updateFile(this.getConid(), "dat");
//					}
				}		
				exportType = "EXPORTFILE";
			//}			
			//MyLog.debug(this, this.up,"No such File Type please check your xml file");
			return result;
		}
		if (result) {
			fullMsg = "\nSuccessful Export File";			
		} else {
			fullMsg = "\nUnsuccessful Export File";
		}
		//StaticProperties.serverManager.writeFileResultProcess(processID, fullMsg , exportType);
		return result;
	}
	/**
	 * <PRE>
	 * ʹ 㹡 process  export ŷ csv 
	 * </PRE>
	 * @param dj  DynamicJava
	 * @return boolean flag success
	 */
	protected boolean csvProcess(DynamicJava dj) {
		try {
			String tmpFile = this.getExportPath() + conid+".tmp";
			String head = "", foot = "";
			WriteFile wf = new WriteFile(tmpFile);
			wf.setFileName(tmpFile);
			if(this.getCharSet().length()>0){
				wf.setCharSet(this.getCharSet());
			}			
			System.out.println("PATH>>>>>>>>>>>>>>>>>>"+wf.getPathName());
			int recCount = 0;
			String processID = this.getUp().get("processID").toString();
				while (dbInq.next() && !StaticProperties.serverManager.isCancle(processID)) {
					this.processInCsvFile(dj, wf);
	            	recCount++;
	            	StaticProperties.serverManager.aliveProcess(processID, "Exporting record number : "+recCount);	
				}
				wf.closeFile();
				if (!StaticProperties.serverManager.isCancle(processID)) {
					ReadFile r = new ReadFile(tmpFile);
					//System.out.println("PATH>>>>>>>>>>>>>>>>>>"+r.g);
					WriteFile w = new WriteFile(this.getOutFile());
					if(this.getCharSet().length()>0){
						w.setCharSet(this.getCharSet());
					}
					head = this.processInMem(dj, expXml.getHead(), expXml.getConfig(1));
					foot = this.processInMem(dj, expXml.getFoot(), expXml.getConfig(2));
					MyLog.debug(this, this.up,"...... Writing Head Data ......");
					w.writeString(head);
					int i = 1;
					int data;
					char[]  ch = new char[128];
					data=  r.read(ch);
					while (data!=-1) {
						w.write(ch, 0, data);
						i++;
						data= r.read(ch);
					}
					w.writeString(foot);
					MyLog.debug(this, this.up,"...... Writing Foot Data ......");
					r.closeFile();
					w.closeFile();
				}
				return true;
		} catch (Exception e) {
            MyLog.error(this,this.up, e);
			return false;
		}	
	}
	/**
	 *  standdard С˹ path ͧ export ǡѹ 
	 * 觤 export path Ѻ
	 * @return String
	 */
	public String getExportPath() {
		this.exportPath=new InitialEnvironment("GLOBAL").getValue("export-dir") +"REPORT/";
		return exportPath;
	}
	/**
	 * @deprecated ҹ
	 * 絤 export path
	 * @param exportPath The exportPath to set
	 */
	protected void setExportPath(String exportPath) {
//		this.exportPath = exportPath;
	}
	/**
	 * <PRE>
	 * 㹡絤ҿѺ inquiry
	 * ´֧Ҩҡ Hash Condition
	 * </PRE>
	 */
	protected void setInquiryFilter() {
		try {
//			Hashtable h = this.getDbInq().getChildTable();
//			Enumeration em = h.keys();
			String tableName = this.getDbInq().getTableName();
			String fixpFilter = "", rFilter = "";
			if (filter.get(tableName) != null || this.getCondition().get("FIXFILTER" + tableName.toUpperCase()) != null) {
				fixpFilter = (String) this.getCondition().get("FIXFILTER" + tableName.toUpperCase());
				if (fixpFilter != null && !fixpFilter.equals("")) {
					rFilter += fixpFilter;
					if (filter.get(tableName) != null && !filter.get(tableName).equals("")){
						rFilter += "  AND  " + (String) filter.get(tableName);
					}
				} else{
					rFilter = (String) filter.get(tableName);
				}
				this.dbInq.setFilter(rFilter);
			}
			setChildFilter(this.getDbInq().getChildTable(),this.getDbInq());
		} catch (Exception e) {
            MyLog.error(this,this.up, e);
		}
	}
	
	private void setChildFilter(Hashtable child,DbInquiry inqParent){
		Enumeration em = child.keys();
		DbInquiry inq = null;
		String tableName ="";
		String fixpFilter = "", rFilter = "";
		try{
		while (em.hasMoreElements()) {
			tableName = (String) em.nextElement();
			fixpFilter = "";
			rFilter = "";
			try {
				inq = (DbInquiry) inqParent.getChild(tableName);
				if(inq.getChildTable().size() > 0){
					this.setChildFilter(inq.getChildTable(),inq);
				}
			} catch (Exception e) {
	            MyLog.error(this,this.up, e);
	            MyLog.error(this, this.up,"Object not instance Inquiry Can not set Filter");
			}
			if (filter.get(tableName) != null || this.getCondition().get("FIXFILTER" + tableName.toUpperCase()) != null) {
				fixpFilter = (String) this.getCondition().get("FIXFILTER" + tableName.toUpperCase());
				if (fixpFilter != null && !fixpFilter.equals("")) {
					rFilter += fixpFilter;
					if (filter.get(tableName) != null && !filter.get(tableName).equals(""))
						rFilter += "  AND  " + (String) filter.get(tableName);
				} else{
					rFilter = (String) filter.get(tableName);
				}
				inq.setFilter(rFilter);
			}
		}
		}catch(Exception ex){
			MyLog.error(this,this.up, ex);
		}
	}
	/**
	 *   get  DbRecord ͧ Lreport_log
	 * @return
	 */
	private DbRecord getReportRecord() {
		return new InitialRecord(this.getUp()).getDbRecord("lreport_log");
	}
	@Deprecated
	private void updateFile(String reportid, String data) {
/*		DbRecord db = this.getReportRecord();
		try {
			db.setGroupfield("update_file");
			db.set("reportid", reportid);
			db.set("file_type", data);
			db.save();
		} catch (RemoteException e) {
            MyLog.error(this,this.up, e);
		}
*/	}
	/**
	 * 觤 condition id Ѻ
	 * @return String
	 */
	public String getConid() {
		return conid;
	}
	/**
	 * 觤 DbInquiry ֧šѺ
	 * @return DbInquiry
	 */
	public DbInquiry getDbInq() {
		return dbInq;
	}
	/**
	 * 觤 Pattern  default Ѻ
	 * @return String
	 */
	public String getDefaultPattern() {
		return defaultPattern;
	}
	/**
	 * Returns the exportFile.
	 * @return String
	 */
	public String getExportFile() {
		String path=new InitialEnvironment("Global").getValue("export-dir")+"/REPORT/";
		return exportFile;
	}
	/**
	 * Returns the exportXml.
	 * @return String
	 */
	public String getExportXml() {
		return exportXml;
	}
	/**
	 * Returns the expXml.
	 * @return ExportXml
	 */
	public ExportXml getExpXml() {
		return expXml;
	}
	/**
	 * Returns the factory.
	 * @return String
	 */
	public String getFactory() {
		return factory;
	}
	/**
	 * Returns the filter.
	 * @return Properties
	 */
	public Properties getFilter() {
		return filter;
	}
	/**
	 * Returns the up.
	 * @return UProfile
	 */
	public UProfile getUp() {
		return up;
	}
	/**
	 * Sets the conid.
	 * @param conid The conid to set
	 */
	protected void setConid(String conid) {
		this.conid = conid;
	}
	/**
	 * Sets the dbInq.
	 * @param dbInq The dbInq to set
	 */
	protected void setDbInq(DbInquiry dbInq) {
		this.dbInq = dbInq;
	}
	/**
	 * Sets the defaultPattern.
	 * @param defaultPattern The defaultPattern to set
	 */
	protected void setDefaultPattern(String defaultPattern) {
		this.defaultPattern = defaultPattern;
	}
	/**
	 * Sets the exportFile.
	 * @param exportFile The exportFile to set
	 */
	protected void setExportFile(String exportFile) {
		this.exportFile = exportFile;
	}
	/**
	 * Sets the exportXml.
	 * @param exportXml The exportXml to set
	 */
	protected void setExportXml(String exportXml) {
		this.exportXml = exportXml;
	}
	/**
	 * Sets the expXml.
	 * @param expXml The expXml to set
	 */
	protected void setExpXml(ExportXml expXml) {
		this.expXml = expXml;
	}
	/**
	 * Sets the factory.
	 * @param factory The factory to set
	 */
	protected void setFactory(String factory) {
		this.factory = factory;
	}
	/**
	 * Sets the filter.
	 * @param filter The filter to set
	 */
	protected void setFilter(Properties filter) {
		this.filter = filter;
	}
	/**
	 * Sets the up.
	 * @param up The up to set
	 */
	protected void setUp(UProfile up) {
		this.up = up;
	}
	/**
	 * Returns the error.
	 * @return HashMap
	 */
	public HashMap getError() {
		return error;
	}
	/**
	 * Returns the error.
	 * @return HashMap
	 */
	public String getError(String key) {
		return (String) error.get(key);
	}
	/**
	 * Sets the error.
	 * @param error The error to set
	 */
	public void setError(HashMap error) {
		this.error = error;
	}
	/**
	 * Puts the error.
	 * @param key and value of error
	 */
	public void setError(Object key, Object error) {
		this.error.put(key, error);
	}
	/**
	 * Returns the condition.
	 * @return HashMap
	 */
	public HashMap getCondition() {
		return condition;
	}
	/**
	 * Sets the condition.
	 * @param condition The condition to set
	 */
	public void setCondition(HashMap condition) {
		this.condition = condition;
	}
	protected String getOutFile() {
		outFile=this.getExportPath()+this.getExportFile();
		if(this.getSubFolder().trim().length()>0){
			outFile=this.getExportPath()+this.getSubFolder()+"/"+this.getExportFile();
		}
		return outFile;
	}
	/**
	 * @Deprecated ҹͧШС˹ path export  ҵͧ  path  setSubFlder( folder) ᷹
	 * ǹ path ͧ export д  payrollweb->export-dir
	 * @param outFile
	 */	
	@Deprecated
	protected void setOutFile(String outFile) {
//		String exppath=outFile.substring(0, outFile.lastIndexOf(this.getExportFile()));
//		this.setExportPath(exppath);
//		this.outFile = outFile;
	}
	
	public String getFileType() {
		return fileType;
	}
	
	protected void setFileType(String fileType) {
		this.fileType = fileType;
	}	
	
	/**
	 * ѺҨҡ Condition  ordertext
	 * 
	 */
	protected void setOrderBy(){
		if(this.condition.containsKey("ORDERTEXT")&&((String)this.condition.get("ORDERTEXT")).length()>0){
			try {
				this.dbInq.setOrderBy((String)this.condition.get("ORDERTEXT"));
			} catch (RemoteException e) {
				MyLog.error(this,this.getUp(),e.getMessage());
			}
		}
	}
	
	
	
	public String getExportFileName() {
		return exportFile;
	}

	public void setExportFileName(String expName) {
		this.setExportFile(expName);
	}

	public String getSubFolder() {
		return subFolder;
	}

	public void setSubFolder(String folder) {
		this.subFolder = folder;
	}
	
	public String getRemark() {
		return remark;
	}
	public void setRemark(String remark) {
		this.remark = remark;
	}
	
	private void removeFile(String filepath){
		try{
			File f=new File(filepath);
			if(f.exists()&&f.isFile()){
				f.delete();
			}
		}catch(Exception ex){
			MyLog.warn("Fil not found : "+filepath);
		}
	}
	
    public String getCharSet() {
        return charSet;
    }
    public void setCharSet(String charSet) {
        this.charSet = charSet;
    }	
	
}