29EShopServlet::EShopServlet()
31 m_pSQLConnPool =
NULL;
35 m_pViewProduct =
NULL;
36 m_pViewShoppingBasket =
NULL;
44#define INI_FILENAME L"HSAEShop_w.ini"
46#define INI_FILENAME L"HSAEShop.ini"
50 if (strIniFile.isEmpty())
56 String strSQLDriverName;
57 String strSQLConnectionString;
64 String strEnableDebugOut = ini.getString(L
"DEBUG", L
"ENABLE_DEBUG_OUT");
65 if (strEnableDebugOut.compareNoCase(L
"FALSE") == 0)
66 HttpServletEx::m_bEnableDebugOut =
false;
69 strSQLDriverName = ini.getString(L
"DATABASE", L
"DRIVER");
70 strSQLConnectionString = ini.getString(L
"DATABASE", L
"CONNECT");
74 strSQLDriverName.data(),
75 strSQLConnectionString.data()
78 __strTemplateDir = ini.getString(L
"HTML_TEMPLATE", L
"DIR");
81 strSQLConnectionString,
101 if (m_pSQLConnPool) {
102 delete m_pSQLConnPool;
103 m_pSQLConnPool =
NULL;
121 if (m_pViewProduct) {
122 delete m_pViewProduct;
123 m_pViewProduct =
NULL;
126 if (m_pViewShoppingBasket) {
127 delete m_pViewShoppingBasket;
128 m_pViewShoppingBasket =
NULL;
153 printError(ctx, L
"데이터베이스 서버에 연결할 수 없습니다.");
167 if (session.
login(ctx.__formMap))
179 printPageHeader(out, session);
183 onViewProduct(ctx, session);
191 onViewShoppingBasket(ctx, session);
196 onViewOrder(ctx, session);
206 printFile(out, L
"notfound.html");
212 onViewSalesReport(ctx, session);
229 printFile(out, L
"about.html");
233 printFile(out, L
"notfound.html");
240 m_pSQLConnPool->release(pSQLConn);
246 ctx.setContentType(L
"text/html");
254 m_pSQLConnPool->release(pSQLConn);
265 "<html lang=\"ko-KR\">\n"
267 "<meta charset=\"UTF-8\">\n"
268 "<title>에러!</title>\n"
271 "<h3>에러가 발생하여 요청을 완료할 수 없습니다.</h3>\n"
275 << L
"</body>\n</html>\n";
277 ctx.setContentType(L
"text/html", L
"utf-8");
281void EShopServlet::printLoginForm(
287 tpl.assign(L
"HREF_LOGIN_ACTION", strHREF);
312void EShopServlet::printPageHeader(
317 TextTemplate tplHeader = *m_pHead;
321 StringBuilder str = L
"<strong>" + session.
userName();
324 str += L
"<span style=\"color:red\">";
325 str += L
"(관리자 권한)</span>";
327 str += L
"</strong> 님 로그인 하셨습니다";
328 tplHeader.assign(L
"USER_HELLO", str);
331 tplHeader.assign(L
"USER_HELLO", L
" ");
335 for(
unsigned int i = 0; i < (
sizeof(menus) /
sizeof(MAIN_MENU)); i++)
337 if (menus[i].bAdminOnly)
344 tplHeader.append(L
"HREF", L
"<span style=\"color: red\"> | </span>");
346 if (menus[i].nCmd == session.
command())
348 StringBuilder strHREF = L
"<span style=\"color:blue\">";
349 strHREF += menus[i].
psz;
350 strHREF += L
"</span>\n";
352 tplHeader.append(L
"HREF", strHREF);
353 strTitle = menus[i].
psz;
357 String strHREF = String::format(L
"<a class=\"menu\" href=\"?%ls=%d\">%ls</a>\n",
359 tplHeader.append(L
"HREF", strHREF);
363 tplHeader.append(L
"HREF", L
"<span style=\"color: red\"> | </span>");
369 StringBuilder strHREF = L
"<span style=\"color:blue\">";
371 strHREF += L
"</span>\n";
372 tplHeader.append(L
"HREF", strHREF);
377 String strHREF = String::format(L
"<a class=\"menu\" href=\"?%ls=%d\">%ls</a>\n",
379 tplHeader.append(L
"HREF", strHREF);
384 String strHREF = String::format(L
"<a class=\"menu\" href=\"?%ls=%d\">%ls</a>",
386 tplHeader.append(L
"HREF", strHREF);
389 if (strTitle.isEmpty())
390 tplHeader.erase(L
"TITLE");
392 tplHeader.assign(L
"TITLE", strTitle);
396void EShopServlet::printFile(
398 const wchar_t* _filename
407 String path = __strTemplateDir;
408 if (!path.endsWith(L
"/")) {
411 path = path + _filename;
@ 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 *)
String CharsetConvertException *bool canTransact() const
void rollbackTrans() __DCL_THROWS1(SQLException *)
bool inTransaction() const
void commitTrans() __DCL_THROWS1(SQLException *)
void CharsetConvertException *void startTrans() __DCL_THROWS1(SQLException *)
bool onVisitorBook(HttpServletContextEx &ctx, Writer &out, SQLConnection *pSQLConn)