⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bugdb.cpp

📁 俄罗斯牛人KK的作品,著名的ORDBMS,这里上传最新的3.39版本源代码.希望了解对象关系数据库的同好,请不要错过.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">"
        "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << 
        "\"><INPUT TYPE=hidden NAME=\"page\" VALUE=\"userForm\">"
        "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << con.get("myself") << 
        "\"><SELECT SIZE=20 NAME=\"name\">";
    if (persons.select() != 0) { 
        print(con, persons);
        con << TAG << "</SELECT><BR><INPUT TYPE=submit VALUE=\"Select\">";
    } else { 
        con << TAG << EMPTY_LIST;
    }
    con << TAG << "</FORM>";
    mainMenuReference(con);
    return true;
}

bool removePersonForm(WWWconnection& con)
{
    con << TAG << 
        HTML_HEAD "<TITLE>Remove a person</TITLE></HEAD>"
        BODY
        "<H2>Remove a person</H2>"
        "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">"
        "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << 
        "\"><INPUT TYPE=hidden NAME=\"page\" VALUE=\"removePerson\">"
        "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << con.get("myself") << 
        "\"><SELECT SIZE=20 NAME=\"name\">";
    if (persons.select() != 0) { 
        print(con, persons);
        con << TAG << "</SELECT><BR><INPUT TYPE=submit VALUE=\"Remove\">";
    } else { 
        con << TAG << EMPTY_LIST;
    }
    con << TAG << "</FORM>";
    mainMenuReference(con);
    return true;
}

bool selectBugForm(WWWconnection& con)
{
    con << TAG << 
        HTML_HEAD "<TITLE>Select a bug</TITLE></HEAD>"
        BODY
        "<H2>Select a bug</H2>"
        "<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=\"" << con.get("myself") << 
        "\"><SELECT SIZE=15 NAME=\"bug\">";
    if (bugs.select() != 0) { 
        print(con, bugs);
        con << TAG << 
           "</SELECT><BR><INPUT TYPE=submit NAME=\"action\" VALUE=\"Select\">";
    } else { 
        con << TAG << EMPTY_LIST;
    }
    con << TAG << "</FORM>";
    mainMenuReference(con);
    return true;
}

bool removeBugForm(WWWconnection& con)
{
    con << TAG << 
        HTML_HEAD "<TITLE>Remove a bug</TITLE></HEAD>"
        BODY
        "<H2>Remove a bug</H2>"
        "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">"
        "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << 
        "\"><INPUT TYPE=hidden NAME=\"page\" VALUE=\"removeBug\">"
        "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << con.get("myself") << 
        "\"><SELECT SIZE=15 NAME=\"bug\">";
    if (bugs.select() != 0) { 
        print(con, bugs);
        con << TAG << "</SELECT><BR><INPUT TYPE=submit VALUE=\"Remove\">";
    } else { 
        con << TAG << EMPTY_LIST;
    }
    con << TAG << "</FORM>";
    mainMenuReference(con);
    return true;
}

bool changePasswordForm(WWWconnection& con)
{
    con << TAG << 
        HTML_HEAD "<TITLE>Change password</TITLE></HEAD>"
        BODY
        "<H2>Change password</H2>"
        "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">"
        "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << 
        "\"><INPUT TYPE=hidden NAME=\"page\" VALUE=\"changePassword\">"
        "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << con.get("myself") << 
        "\"><INPUT TYPE=hidden NAME=\"name\" VALUE=\"" << con.get("name") << 
        "\"><TABLE>"
        "<TR><TH ALIGN=LEFT>New password:</TH>"
        "<TD><INPUT TYPE=password NAME=\"password\" SIZE=20</TD></TR>"
        "<TR><TH ALIGN=LEFT>Re-type password:</TH>"
        "<TD><INPUT TYPE=password NAME=\"password2\" SIZE=20</TD></TR>"
        "</TABLE><P>"
        "<INPUT TYPE=submit VALUE=\"Change\">&nbsp;"
        "<INPUT TYPE=reset VALUE=\"Reset\">"
        "</FORM>";
    con << TAG << "</FORM>";
    mainMenuReference(con);
    return true;
}
        
bool shutdown(WWWconnection& con)
{
    con << TAG << 
        HTML_HEAD "<TITLE>BUGDB message</TITLE></HEAD><BODY>"
        "<H1>BUGDB server is terminated</H1></BODY></HTML>";
    return false;
}

bool userForm(WWWconnection& con);
bool userGroupForm(WWWconnection& con);
bool softwareForm(WWWconnection& con);

bool addUser(WWWconnection& con)
{
    Person person;
    person.sName = key = con.get("name");   
    person.sEmailAddress = con.get("email");
    person.sPassword = "";
    person.status = Person::isUser;
    person.nReports = 0;
    if (persons.select(qPerson) != 0) { 
        error(con, "Person already exists");
        return true;
    }
    insert(person);
    return userForm(con);
}

bool addEngineer(WWWconnection& con)
{
    Person person;
    person.sName = key = con.get("name");   
    person.sEmailAddress = con.get("email");
    person.sPassword = "";
    person.status = Person::isEngineer;
    person.nReports = 0;
    if (persons.select(qPerson) != 0) { 
        error(con, "Person already exists");
        return true;
    }
    insert(person);
    return userForm(con);
}

bool removePerson(WWWconnection& con)
{
    key = con.get("name");
    if (key == NULL) { 
        error(con, "No person was selected");
        return true;
    }
    if (persons.select(qPerson) == 0) { 
        error(con, "No such person");
    } else if (persons->nReports > 0 
               || persons->setReportedBugs.length() > 0) 
    {
        error(con, "It is not possible to delete person who is author "
              "of existed bug reports");
    } else {
        persons.remove();
        message(con, "Person is removed");
    }
    return true;
}

bool addSoftware(WWWconnection& con)
{
    Software software;
    Version  version;
    software.sName = key = con.get("software");
    if (products.select(qSoftware) != 0) { 
        error(con, "Software product already exists");
        return true;
    }
    char* versionStr = con.get("version");
    if (sscanf(versionStr, "%d.%d", &version.majorVersionNumber, 
               &version.minorVersionNumber) != 2) 
    { 
        error(con, "Bad version number (MAJOR.MINOR expected)");
        return true;
    }  
    version.sComment = con.get("comment");
    version.sLabel = con.get("label");
    version.released = dbDateTime::current();
    software.pVersions = insert(version);
    insert(software);
    con.addPair("action", "Select");
    return softwareForm(con);
}
                
bool removeSoftware(WWWconnection& con)
{
    key = con.get("software");
    if (products.select(qSoftware) == 0) { 
        error(con, "No such software product");
        return true;
    }
    if (products->setBugs.length() != 0) { 
        error(con, "Can not remove software with non-empty reported bug list");
        return true;
    }
    products.remove();
    message(con, "Software product is removed");
    return true;
}

bool removeBug(WWWconnection& con)
{
    char* bug = con.get("bug");
    if (bug == NULL) { 
        error(con, "No bug was selected");
    } else { 
        bugId = atoi(bug);
        if (bugs.select(qBug) == 0) { 
            error(con, "No such bug");
        } else { 
            if (bugs->pReportHistory != null ||
                bugs->pWorkArounds != null)
            {
                error(con, "Can not remove bug with existed reports");
                return true;
            }
            bugs.remove();
            message(con, "Bug is removed");
        }
    }
    return true;
}

bool changePassword(WWWconnection& con)
{
    char* password = con.get("password");
    char* password2 = con.get("password2");
    if (strcmp(password, password2) != 0) { 
        error(con, "Passwords are not equal");
    } else { 
        key = con.get("name");
        if (persons.select(qPerson) == 0) { 
            error(con, "No such person");
        } else { 
            persons->sPassword = password;
            persons.update();
            message(con, "Password changed");
        }
    }
    return true;
}

bool updatePerson(WWWconnection& con)
{
    char* name = con.get("name");
    key = name;
    if (persons.select(qPerson) == 0) { 
        error(con, "No such person");
        return true;
    } else { 
        char* newName = con.get("newname");
        char* eMail = con.get("email");
        if (eMail != NULL) { 
            persons->sEmailAddress = eMail;
        }
        if (newName != NULL) { 
            persons->sName = newName;
            con.addPair("name", newName);
            if (strcmp(name, con.get("myself")) == 0) { 
                con.addPair("myself", newName);
            }
        }
        persons.update();
    }
    return userForm(con);
}

bool login(WWWconnection& con)
{
    char* name = con.get("name");
    key = con.get("name");
    if (persons.select(qPerson) == 0) { 
        error(con, "No such person");
        return true;
    } 
    if (!persons->checkPassword(con.get("password"))) { 
        error(con, "Incorrect password");
        return true;
    } 
    con.addPair("myself", name);    
    return userForm(con);
}

bool bugQueryForm(WWWconnection& con)
{
    int i;
    con << TAG << 
        HTML_HEAD "<TITLE>Query to locate bug</TITLE></HEAD>"
        BODY
        "<H2>Bug query</H2>"
        "<FORM METHOD=POST ACTION=\"" << con.getStub() << "\">"
        "<INPUT TYPE=HIDDEN NAME=\"socket\" VALUE=\"" << con.getAddress() << 
        "\"><INPUT TYPE=hidden NAME=\"page\" VALUE=\"bugQuery\">"
        "<INPUT TYPE=hidden NAME=\"myself\" VALUE=\"" << con.get("myself") << 
        "\"><TABLE>"
        "<TR><TH ALIGN=LEFT>Description substring:</TH>"
        "<TD><INPUT TYPE=text NAME=\"summary\" SIZE=30</TD></TR>"
        "<TR><TH ALIGN=LEFT>Category:</TH>"
        "<TD><SELECT NAME=\"category\" SIZE=1>"
        "<OPTION VALUE=0 SELECTED></OPTION>";
    for (i = 1; eCATEGORY_STRING[i] != NULL; i++) { 
        con << TAG << "<OPTION VALUE=" << i << ">"
            << eCATEGORY_STRING[i] << "</OPTION>";
    }
    con << TAG << "</SELECT></TD></TR>"
        "<TR><TH ALIGN=LEFT>Severity:</TH>"
        "<TD><SELECT NAME=\"severity\" SIZE=1>"
        "<OPTION VALUE=0 SELECTED></OPTION>";
    for (i = 1; eSEVERITY_STRING[i] != NULL; i++) { 
        con << TAG << "<OPTION VALUE=" << i << ">"
            << eSEVERITY_STRING[i] << "</OPTION>";
    }
    con << TAG << "</SELECT></TD></TR>"
        "<TR><TH ALIGN=LEFT>Fixing priority:</TH>"
        "<TD><SELECT NAME=\"priority\" SIZE=1>"
        "<OPTION VALUE=0 SELECTED></OPTION>";
    for (i = 1; eFIXING_PRIORITY_STRING[i] != NULL; i++) { 
        con << TAG << "<OPTION VALUE=" << i << ">"
            << eFIXING_PRIORITY_STRING[i] << "</OPTION>";
    }
    con << TAG << 
        "</SELECT></TD></TR>"
        "<TR><TH ALIGN=LEFT>Platform:</TH>"
        "<TD><INPUT TYPE=text NAME=\"platform\"</TD></TR>"
        "<TR><TH ALIGN=LEFT>OS</TH>"
        "<TD><INPUT TYPE=text NAME=\"os\"</TD></TR>"
        "<TR><TH ALIGN=LEFT>Software:</TH>"
        "<TD><INPUT TYPE=text NAME=\"software\"</TD></TR>"
        "<TR><TH ALIGN=LEFT>Assigned to:</TH>"
        "<TD><INPUT TYPE=text NAME=\"engineer\"</TD></TR>"
        "<TR><TH ALIGN=LEFT>Reported by:</TH>"
        "<TD><INPUT TYPE=text NAME=\"user\"</TD></TR>"
        "<TR><TH ALIGN=LEFT>Major version number:</TH>"
        "<TD>from <INPUT TYPE=text NAME=\"minmajor\" SIZE=4>"
        " to <INPUT TYPE=text NAME=\"maxmajor\" SIZE=4</TD></TR>"
        "<TR><TH ALIGN=LEFT>Minor version number:</TH>"
        "<TD>from <INPUT TYPE=text NAME=\"minminor\" SIZE=4</TD>"
        " to <INPUT TYPE=text NAME=\"maxminor\" SIZE=4</TD></TR></TABLE><P>"
        "<INPUT TYPE=submit VALUE=\"Search\">&nbsp;"
        "<INPUT TYPE=reset VALUE=\"Reset\">"
        "</FORM></BODY></HTML>";
    return true;
}


bool bugQuery(WWWconnection& con) 
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -