18#if __DCL_HAVE_THIS_FILE__
29EShopServlet::EShopServlet()
31 __pSQLConnPool =
NULL;
35 __pViewProduct =
NULL;
36 __pViewShoppingBasket =
NULL;
44#define INI_FILENAME L"HSAEShop_w.ini"
46#define INI_FILENAME L"HSAEShop.ini"
50 if (strIniFile.isEmpty()) {
55 String strSQLDriverName;
56 String strSQLConnectionString;
62 String strEnableDebugOut = ini.getString(L
"DEBUG", L
"ENABLE_DEBUG_OUT");
63 if (strEnableDebugOut.compareNoCase(L
"FALSE") == 0)
64 HttpServletEx::__enableDebugOut =
false;
67 strSQLDriverName = ini.getString(L
"DATABASE", L
"DRIVER");
68 strSQLConnectionString = ini.getString(L
"DATABASE", L
"CONNECT");
72 strSQLDriverName.data(),
73 strSQLConnectionString.data()
76 __strTemplateDir = ini.getString(L
"HTML_TEMPLATE", L
"DIR");
79 strSQLConnectionString,
100 delete __pSQLConnPool;
101 __pSQLConnPool =
NULL;
119 if (__pViewProduct) {
120 delete __pViewProduct;
121 __pViewProduct =
NULL;
124 if (__pViewShoppingBasket) {
125 delete __pViewShoppingBasket;
126 __pViewShoppingBasket =
NULL;
150 printError(ctx, L
"데이터베이스 서버에 연결할 수 없습니다.");
163 if (session.
login(ctx.__formMap))
177 printPageHeader(out, session);
181 onViewProduct(ctx, session);
189 onViewShoppingBasket(ctx, session);
194 onViewOrder(ctx, session);
204 printFile(out, L
"notfound.html");
210 onViewSalesReport(ctx, session);
227 printFile(out, L
"about.html");
231 printFile(out, L
"notfound.html");
238 __pSQLConnPool->release(pSQLConn);
244 ctx.setContentType(L
"text/html");
252 __pSQLConnPool->release(pSQLConn);
263 "<html lang=\"ko-KR\">\n"
265 "<meta charset=\"UTF-8\">\n"
266 "<title>에러!</title>\n"
269 "<h3>에러가 발생하여 요청을 완료할 수 없습니다.</h3>\n"
273 << L
"</body>\n</html>\n";
275 ctx.setContentType(L
"text/html", L
"utf-8");
279void EShopServlet::printLoginForm(
285 tpl.assign(L
"HREF_LOGIN_ACTION", strHREF);
310void EShopServlet::printPageHeader(
315 TextTemplate tplHeader = *__pHead;
318 StringBuilder str = L
"<strong>" + session.
userName();
320 str += L
"<span style=\"color:red\">";
321 str += L
"(관리자 권한)</span>";
323 str += L
"</strong> 님 로그인 하셨습니다";
324 tplHeader.assign(L
"USER_HELLO", str);
327 tplHeader.assign(L
"USER_HELLO", L
" ");
331 for(
unsigned int i = 0; i < (
sizeof(menus) /
sizeof(MAIN_MENU)); i++) {
332 if (menus[i].bAdminOnly) {
338 tplHeader.append(L
"HREF", L
"<span style=\"color: red\"> | </span>");
341 if (menus[i].nCmd == session.
command()) {
342 StringBuilder strHREF = L
"<span style=\"color:blue\">";
343 strHREF += menus[i].
psz;
344 strHREF += L
"</span>\n";
346 tplHeader.append(L
"HREF", strHREF);
347 strTitle = menus[i].
psz;
350 String strHREF = String::format(L
"<a class=\"menu\" href=\"?%ls=%d\">%ls</a>\n",
352 tplHeader.append(L
"HREF", strHREF);
356 tplHeader.append(L
"HREF", L
"<span style=\"color: red\"> | </span>");
360 StringBuilder strHREF = L
"<span style=\"color:blue\">";
362 strHREF += L
"</span>\n";
363 tplHeader.append(L
"HREF", strHREF);
367 String strHREF = String::format(L
"<a class=\"menu\" href=\"?%ls=%d\">%ls</a>\n",
369 tplHeader.append(L
"HREF", strHREF);
373 String strHREF = String::format(L
"<a class=\"menu\" href=\"?%ls=%d\">%ls</a>",
375 tplHeader.append(L
"HREF", strHREF);
378 if (strTitle.isEmpty())
379 tplHeader.erase(L
"TITLE");
381 tplHeader.assign(L
"TITLE", strTitle);
386void EShopServlet::printFile(
388 const wchar_t* _filename
397 String path = __strTemplateDir;
398 if (!path.endsWith(L
"/")) {
401 path = path + _filename;
411#ifdef __WINNT_NEW_DELETE_OVERRIDE
413__WINNT_NEW_DELETE_OVERRIDE
@ CM_VIEW_SHOPPING_BASKET
@ HTTP_STATUS_METHOD_NOT_ALLOWED
#define HTTP_SERVLET_INSTANCE(ServletClass, Description)
#define __DCL_TRACE0(psz)
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_TRACE3(fmt, arg1, arg2, arg3)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
virtual void onInitialize() __DCL_THROWS1(Exception *)
virtual void onCleanup() __DCL_THROWS1(Exception *)
String readTemplate(const wchar_t *filename) const __DCL_THROWS1(IOException *)
virtual void onService(HttpServletContextEx &ctx) __DCL_THROWS1(Exception *)
const String & userName() const
bool login(ListedStringToStringArrayMap ¶ms)
void onViewSessions(ListedStringToStringArrayMap ¶ms, Writer &out, const String &strMainCommand, int nMainCommandID, const String &strCommandID, const EShopServlet &_servlet)
String toStringAll() const
static String readText(const String &_filename) __DCL_THROWS1(IOException *)
static String format(const String &_str, int _tab2Space, const String &_beginOfLine, const String &_endOfLine)
virtual void onInitialize() __DCL_THROWS1(Exception *)
virtual void onCleanup() __DCL_THROWS1(Exception *)
void rollbackTrans() __DCL_THROWS1(SQLException *)
bool inTransaction() const
void commitTrans() __DCL_THROWS1(SQLException *)
void startTrans() __DCL_THROWS1(SQLException *)
bool onVisitorBook(HttpServletContextEx &ctx, Writer &out, SQLConnection *pSQLConn)