bugdb.cpp
来自「一个功能强大的内存数据库源代码,c++编写,有详细的注释」· C++ 代码 · 共 2,061 行 · 第 1/5 页
CPP
2,061 行
"<TD><INPUT TYPE=text NAME=\"platform\" VALUE=\"" << bugs->sHardwarePlatform << "\"></TD></TR>" "<TR><TH ALIGN=LEFT>OS:</TH>" "<TD><INPUT TYPE=text NAME=\"os\"VALUE=\"" << bugs->sOperatingSystem << "\"></TD></TR>" "<TR><TH ALIGN=LEFT>Assigned to:</TH>" "<TD><SELECT SIZE=1 NAME=\"name\">"; if (bugs->pAssignedTo != null) { persons.at(bugs->pAssignedTo); con << TAG << "<OPTION SELECTED VALUE=\"" << persons->sName << "\">" << persons->sName << "</OPTION>"; } else { con << TAG << "<OPTION SELECTED VALUE=\"\"></OPTION>"; } print(con, products->setEngineers); con << TAG << "</SELECT></TD></TR>" "<TR><TH ALIGN=LEFT>Similar with:</TH>" "<TD><SELECT NAME=\"similar\" SIZE=1>" "<OPTION SELECTED VALUE=\"\"></OPTION>"; allBugs.select(); print(con, allBugs); con << TAG << "</SELECT></TD></TR></TABLE><BR>"; if (personStatus != Person::isUser) { con << TAG << "<INPUT TYPE=submit NAME=\"action\" VALUE=\"Update\"> " "<INPUT TYPE=reset VALUE=\"Reset\">"; } con << TAG << "</FORM><P><FORM METHOD=POST ACTION=\"" << con.getStub() << "\"><INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << "\">" "<INPUT TYPE=hidden NAME=\"page\" VALUE=\"updateReportForm\">" "<INPUT TYPE=hidden NAME=\"bug\" VALUE=" << bugStr << ">" "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << myself << "\">" "<B>Report history:</B><BR><SELECT NAME=\"report\" SIZE=5>"; firstReport = bugs->pReportHistory; if (reports.select(qAllReports) != 0) { print(con, reports); con << TAG << "</SELECT><BR><INPUT TYPE=submit NAME=\"action\" VALUE=\"Select\">" " <INPUT TYPE=submit NAME=\"action\" VALUE=\"Add\">"; if (personStatus == Person::isAdministrator) { con << TAG << " <INPUT TYPE=submit NAME=\"action\" VALUE=\"Remove\">"; } } else { con << TAG << EMPTY_LIST "<BR><INPUT TYPE=submit NAME=\"action\" VALUE=\"Add\">"; } con << TAG << "</FORM><P>"; con << TAG << "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">" "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << "\"><INPUT TYPE=hidden " "NAME=\"page\" VALUE=\"updateWorkAroundForm\">" "<INPUT TYPE=hidden NAME=\"bug\" VALUE=" << bugStr << ">" "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << myself << "\">" "<B>Work arounds:</B><BR><SELECT NAME=\"workaround\" SIZE=5>"; firstReport = bugs->pWorkArounds; if (reports.select(qAllReports) != 0) { print(con, reports); con << TAG << "</SELECT><BR><INPUT TYPE=submit NAME=\"action\" VALUE=\"Select\">" " <INPUT TYPE=submit NAME=\"action\" VALUE=\"Add\">"; if (personStatus == Person::isAdministrator) { con << TAG << " <INPUT TYPE=submit NAME=\"action\" VALUE=\"Remove\">"; } } else { con << TAG << EMPTY_LIST "<BR><INPUT TYPE=submit NAME=\"action\" VALUE=\"Add\">"; } con << TAG << "</FORM><P>"; if (bugs->setSimilarBugs.length() != 0) { con << TAG << "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">" "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << "\"><INPUT TYPE=hidden " "NAME=\"page\" VALUE=\"bugForm\">" "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << myself << "\">" "<INPUT TYPE=hidden NAME=\"relatedbug\" VALUE=" << bugStr << ">" "<B>Similar bugs:</B><BR><SELECT NAME=\"bug\" SIZE=1>"; print(con, bugs->setSimilarBugs); con << TAG << "</SELECT><INPUT TYPE=submit NAME=\"action\" VALUE=\"Select\">"; if (personStatus == Person::isAdministrator) { con << TAG << " <INPUT TYPE=submit NAME=\"action\" VALUE=\"Remove\">"; } con << TAG << "</FORM><P>"; } con << TAG << "</FORM><P>" "<FONT SIZE=\"+1\"><UL>"; if (personStatus == Person::isUser) { if (bugs->pAssignedTo != null) { persons.at(bugs->pAssignedTo); con << TAG << "<LI>Assigned to <A HREF=\"mailto:" << persons->sEmailAddress << "\">" << persons->sName << "</A>"; } persons.at(bugs->pReportedBy); con << TAG << "<LI>Reported by <A HREF=\"mailto:" << persons->sEmailAddress << "\">" << persons->sName << "</A></OL></FONT>"; } else { if (bugs->pAssignedTo != null) { persons.at(bugs->pAssignedTo); con << TAG << "<LI>Assigned to <A HREF=\"" << con.getStub() << "?socket=" << con.getAddress() << "&page=userForm&myself=" << URL << myself << "&name=" << URL << persons->sName << "\">" << persons->sName << "</A>"; } persons.at(bugs->pReportedBy); con << TAG << "<LI>Reported by <A HREF=\"" << con.getStub() << "?socket=" << con.getAddress() << "&page=userForm&myself=" << URL << myself << "&name=" << URL << persons->sName << "\">" << persons->sName << "</A></OL></FONT>"; } mainMenuReference(con); return true;}bool updateBug(WWWconnection& con){ char* bugStr = con.get("bug"); bugId = atoi(bugStr); if (bugs.select(qBug) == 0) { error(con, "No such bug"); return true; } char* similar = con.get("similar"); if (*similar != '\0') { int id = atoi(similar); if (id != bugId) { bugId = id; if (allBugs.select(qBug) != 0) { if (rindex(bugs->setSimilarBugs, allBugs.currentId()) < 0) { bugs->setSimilarBugs.append(allBugs.currentId()); } } } } key = con.get("name"); if (*key != '\0') { if (persons.select(qPerson) == 0 || persons->status == Person::isUser) { error(con, "No such engineer"); return true; } bugs->pAssignedTo = persons.currentId(); } bugs.update(); return bugForm(con);}bool addReportForm(WWWconnection& con){ char* bugStr = con.get("bug"); bugId = atoi(bugStr); if (bugs.select(qBug) == 0) { error(con, "No such bug"); return true; } con << TAG << HTML_HEAD "<TITLE>Bug report</TITLE></HEAD>" BODY "<H2>Bug report</H2>" "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">" "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << "\"><INPUT TYPE=hidden " "NAME=\"page\" VALUE=\"addReport\">" "<INPUT TYPE=hidden NAME=\"bug\" VALUE=" << bugStr << ">" "<INPUT TYPE=hidden NAME=\"index\" VALUE=" << ++bugs->nReports << "><INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << con.get("myself") << "\"><B>Status: </B><SELECT SIZE=1 NAME=\"status\">"; for (int i = 1; eSTATUS_STRING[i] != NULL; i++) { con << TAG << "<OPTION VALUE=" << i << ">" << eSTATUS_STRING[i] << "</OPTION>"; } con << TAG << "</SELECT><P>" "<B>Bug description:</B><P>" "<TEXTAREA COLS=40 ROWS=5 NAME=\"description\"></TEXTAREA><P>" "<INPUT TYPE=submit VALUE=\"Add\"> " "<INPUT TYPE=reset VALUE=\"Reset\"></FORM>"; bugs.update(); mainMenuReference(con); return true;}bool addReport(WWWconnection& con){ bugId = atoi(con.get("bug")); if (bugs.select(qBug) == 0) { error(con, "No such bug"); return true; } key = con.get("myself"); if (persons.select(qPerson) == 0) { error(con, "No such person"); return true; } reportId = atoi(con.get("index")); firstReport = bugs->pReportHistory; if (reports.select(qReport) == 0) { Report report; report.pAuthor = persons.currentId(); persons->nReports += 1; report.sDescription = con.get("description"); report.index = reportId; report.pNext = bugs->pReportHistory; report.status = atoi(con.get("status")); report.creationDate = dbDateTime::current(); bugs->pReportHistory = insert(report); persons.update(); bugs.update(); } con.addPair("action", "Select"); return bugForm(con);}bool addWorkAroundForm(WWWconnection& con){ char* bugStr = con.get("bug"); bugId = atoi(bugStr); if (bugs.select(qBug) == 0) { error(con, "No such bug"); return true; } con << TAG << HTML_HEAD "<TITLE>Work around</TITLE></HEAD>" BODY "<H2>Work around</H2>" "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">" "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << "\"><INPUT TYPE=hidden " "NAME=\"page\" VALUE=\"addWorkAround\">" "<INPUT TYPE=hidden NAME=\"bug\" VALUE=" << bugStr << ">" "<INPUT TYPE=hidden NAME=\"index\" VALUE=" << ++bugs->nReports << "><INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << con.get("myself") << "\"><B>Status: </B><SELECT SIZE=1 NAME=\"status\">"; for (int i = 1; eSTATUS_STRING[i] != NULL; i++) { con << TAG << "<OPTION VALUE=" << i << ">" << eSTATUS_STRING[i] << "</OPTION>"; } con << TAG << "</SELECT><P>" "<B>Description:</B><P>" "<TEXTAREA COLS=40 ROWS=5 NAME=\"description\"></TEXTAREA><P>" "<INPUT TYPE=submit VALUE=\"Add\"> " "<INPUT TYPE=reset VALUE=\"Reset\"></FORM>"; bugs.update(); mainMenuReference(con); return true;}bool addWorkAround(WWWconnection& con){ bugId = atoi(con.get("bug")); if (bugs.select(qBug) == 0) { error(con, "No such bug"); return true; } key = con.get("myself"); if (persons.select(qPerson) == 0) { error(con, "No such person"); return true; } reportId = atoi(con.get("index")); firstReport = bugs->pWorkArounds; if (reports.select(qReport) == 0) { Report report; report.pAuthor = persons.currentId(); persons->nReports += 1; report.sDescription = con.get("description"); report.index = reportId; report.pNext = bugs->pWorkArounds; report.status = atoi(con.get("status")); report.creationDate = dbDateTime::current(); bugs->pWorkArounds = insert(report); persons.update(); bugs.update(); } con.addPair("action", "Select"); return bugForm(con);}bool updateReportForm(WWWconnection& con){ if (strcmp(con.get("action"), "Add") == 0) { return addReportForm(con); } char* bugStr = con.get("bug"); bugId = atoi(bugStr); if (bugs.select(qBug) == 0) { error(con, "No such bug"); return true; } char* report = con.get("report"); if (report == NULL) { error(con, "No report was selected"); return true; } int index = atoi(report); dbReference<Report> prev, curr = null, next = bugs->pReportHistory; do { prev = curr; if (next == null) { error(con, "No such report"); return true; } reports.at(next); curr = next; next = reports->pNext; } while (reports->index != index); if (strcmp(con.get("action"), "Remove") == 0) { reports.remove(); bugs->nReports -= 1; if (prev == null) { bugs->pReportHistory = next; } else { reports.at(prev); reports->pNext = next; reports.update(); } bugs.update(); con.addPair("action", "Select"); return bugForm(con); } char date[64]; reports->creationDate.asString(date, sizeof date); char* myself = con.get("myself"); key = myself; if (persons.select(qPerson) == 0) { error(con, "No such person"); return true; } int personStatus = persons->status; persons.at(reports->pAuthor); con << TAG << HTML_HEAD "<TITLE>Bug report from " << date << "</TITLE></HEAD>" BODY "<H2>Bug report from " << date << "</H2>" "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">" "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << "\"><INPUT TYPE=hidden " "NAME=\"page\" VALUE=\"updateReport\">" "<INPUT TYPE=hidden NAME=\"bug\" VALUE=" << bugStr << ">" "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << myself << "\"><INPUT TYPE=hidden NAME=\"report\" VALUE=" << index << ">" "<B>Created by "; if (personStatus == Person::isUser) { con << TAG << "<A HREF=\"mailto:" << persons->sEmailAddress << "\">" << persons->sName << "</A>"; } else { con << TAG << "<A HREF=\"" << con.getStub() << "?socket=" << con.getAddress() << "&page=userForm&myself=" << URL << myself << "&name=" << URL << persons->sName << "\">" << persons->sName << "</A>"; } con << TAG << "<P>Status: </B><SELECT SIZE=1 NAME=\"status\">" "<OPTION SELECTED VALUE=" << reports->status << ">" << eSTATUS_STRING[reports->status] << "</OPTION>"; for (int i = 1; eSTATUS_STRING[i] != NULL; i++) { con << TAG << "<OPTION VALUE=" << i << ">" << eSTATUS_STRING[i] << "</OPTION>"; } con << TAG << "</SELECT><P>" "<B>Bug description:</B><BR>" "<TEXTAREA COLS=40 ROWS=5 NAME=\"description\">" << reports->sDescription << "</TEXTAREA><P>"; if (personStatus != Person::isUser) { con << TAG << "<INPUT TYPE=submit VALUE=\"Update\"> " "<INPUT TYPE=reset VALUE=\"Reset\">"; } con << TAG << "</FORM>"; mainMenuReference(con); return true;}bool updateWorkAroundForm(WWWconnection& con){ if (strcmp(con.get("action"), "Add") == 0) { return addWorkAroundForm(con); } char* bugStr = con.get("bug"); bugId = atoi(bugStr); if (bugs.select(qBug) == 0) { error(con, "No such bug"); return true; } char* workaround = con.get("workaround"); int index = atoi(workaround); dbReference<Report> prev, curr = null, next = bugs->pWorkArounds; do { prev = curr; if (next == null) { error(con, "No such report"); return true;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?