Day22--任务三总结
首先是根据要求,做任务三的设计,有过课设教务系统的经验,把账户设计迁移就可,做的事过去了,但经验留下了。
登录页面花了不少时间,因为htmlayout很不熟,前端的经验并不多。但后来没有用单独的登录界面,出于设计和用户的考虑。希望主页展现所有的员工信息,登陆后在展现下属和任务。
一共做了四天,第一天扩展数据库,登录页面和主页。第二天 重做登录和主页,及1,2,3员工主页,admin管理主页。第三天 日志,导出。第四天 导入。
前面主要是对任务二的扩展,日志和导入的部分花的时间更多。
日志:新建日志表,每对任务做处理,就插入日志,查看日志表时显示全部日志。
主要代码:
std::wstring wsOperatorName; //添加日志
std::wstring taskTheme;
std::wstring wsAccount=GetValue("[field='account']",L"");
CDB::Sql()<<"select empName from g_demo_employee_yxm where account=:account",
soci::use(wsAccount),soci::into(wsOperatorName);
CDB::Sql()<<"select taskTheme from g_demo_task_yxm where taskID=:taskID",
soci::use(taskID),soci::into(taskTheme);
std::wstring wslog=wsOperatorName+L"将"+taskTheme+L"改为审核通过";
CDB::Execute("insertLog",taskTheme,wsOperatorName,wslog);
导出,使用库里边的函数即可,很方便。
导入花了不少时间:
const std::function<std::wstring (std::map<std::wstring, std::wstring> )> cb = [this](std::map<std::wstring, std::wstring> mapFieldValue) -> std::wstring
{
std::wstring wsOperName = mapFieldValue[L"operatorName"]; //从excel中取值
std::wstring wsOperTime = mapFieldValue[L"operatorTime"];
std::wstring wsOperTheme = mapFieldValue[L"taskTheme"];
std::wstring wsLog = mapFieldValue[L"operatorLog"];
const wchar_t * pszRowTemplate = this ->m_elList.get_attribute("row_template");//处理该行
dom::root_element elRoot(this->m_elList);
dom::element elRowTemp=elRoot.find_first(pszRowTemplate);
dom::element elNewRow=elRowTemp.clone();
m_elList.append(elNewRow);
SetElementValue(elNewRow,"[field='operatorName']",wsOperName.c_str());
SetElementValue(elNewRow,"[field='operatorTime']",wsOperTime.c_str());
SetElementValue(elNewRow,"[field='taskTheme']",wsOperTheme.c_str());
SetElementValue(elNewRow,"[field='operatorLog']",wsLog.c_str());
CDB::Execute("importLog",wsOperTheme,wsOperName,wsLog,wsOperTime);
return L"";
};
if(CFileManage::ImportFile(m_hWnd,
L"(operatorName,操作人员)(operatorTime,操作时间)(taskTheme,任务主题)(operatorLog,日志内容)",
L"operatorName,operatorLog",
cb))
{
m_elList.xcall("page_bind","task_log_list");
SysUtils::Alert(L"导入成功", m_hWnd);
}
其实不需要理解,也可以做好。但手误敲错符号后,功能不正常,迫使我不得不弄懂每行代码的作用,包括C++中的function,map,库里边ImportFile函数的使用。如果静下心来分析,弄清楚每行代码的作用,每个参数的含义,其实并不难,关键是要能抓住重点,不被表面很多很大的代码迷惑。从繁重中找到关键的地方,需要冷静和历练。
错误是很好的老师。
遇到问题,给自己更多的时间去思考和尝试。很多操作经验和技巧都是在实际操作经过思考总结积累的。很多问题或功能看起来复杂,可以分解之后,一点一点,处理每个小问题。

浙公网安备 33010602011771号