📄 bugdb.cpp
字号:
"<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; } 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->pWorkArounds = 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>Work around " << date << "</TITLE></HEAD>" BODY "<H2>Work around " << date << "</H2>" "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">" "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << "\"><INPUT TYPE=hidden " "NAME=\"page\" VALUE=\"updateWorkAround\">" "<INPUT TYPE=hidden NAME=\"bug\" VALUE=" << bugStr << ">" "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << myself << "\"><INPUT TYPE=hidden NAME=\"workaround\" 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 updateReport(WWWconnection& con){ bugId = atoi(con.get("bug")); if (bugs.select(qBug) == 0) { error(con, "No such bug"); return true; } reportId = atoi(con.get("report")); firstReport = bugs->pReportHistory; if (reports.select(qReport) == 0) { error(con, "No report was selected"); return true; } reports->sDescription = con.get("description"); reports->status = atoi(con.get("status")); reports.update(); con.addPair("action", "Select"); return bugForm(con);}bool updateWorkAround(WWWconnection& con){ bugId = atoi(con.get("bug")); if (bugs.select(qBug) == 0) { error(con, "No such bug"); return true; } reportId = atoi(con.get("workaround")); firstReport = bugs->pWorkArounds; if (reports.select(qReport) == 0) { error(con, "No report was selected"); return true; } reports->sDescription = con.get("description"); reports->status = atoi(con.get("status")); reports.update(); con.addPair("action", "Select"); return bugForm(con);}bool attachToProject(WWWconnection& con){ key = con.get("name"); if (persons.select(qPerson) == 0 || persons->status == Person::isUser) { error(con, "No such engineer"); } else { key = con.get("software"); if (products.select(qSoftware) == 0) { error(con, "No such software product"); } else { if (rindex(products->setEngineers, persons.currentId()) >= 0) { error(con, "Engineer already attached to the project"); } else { products->setEngineers.append(persons.currentId()); products.update(); return userForm(con); } } } return true;}bool registerSoftware(WWWconnection& con){ key = con.get("name"); if (persons.select(qPerson) == 0) { error(con, "No such person"); } else { key = con.get("software"); if (products.select(qSoftware) == 0) { error(con, "No such software product"); } else { if (rindex(products->setUsers, persons.currentId()) >= 0) { error(con, "User already registered this software"); } else { products->setUsers.append(persons.currentId()); products.update(); return userForm(con); } } } return true;}bool softwareForm(WWWconnection& con){ char* software = con.get("software"); if (software == NULL) { error(con, "No software product was selected"); return true; } key = software; if (products.select(qSoftware) == 0) { error(con, "No such software product"); return true; } if (strcmp(con.get("action"), "Detach") == 0) { key = con.get("name"); if (persons.select(qPerson) == 0) { error(con, "No such person"); return true; } int i = rindex(persons->setProjects, products.currentId()); if (i < 0) { error(con, "Person was not attached to the project"); return true; } persons->setProjects.remove(i); persons.update(); return userForm(con); } if (strcmp(con.get("action"), "Unregister") == 0) { key = con.get("name"); if (persons.select(qPerson) == 0) { error(con, "No such person"); return true; } int i = rindex(persons->setUsedSoftware, products.currentId()); if (i < 0) { error(con, "Person was not registered"); return true; } persons->setProjects.remove(i); persons.update(); return userForm(con); } char* myself = con.get("myself"); key = myself; if (persons.select(qPerson) == 0) { error(con, "No such person"); return true; } int personStatus = persons->status; con << TAG << HTML_HEAD "<TITLE>" << software << "</T
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -