Commit a98c8cce authored by 刘乐's avatar 刘乐

1, 转inp文件逻辑漏洞修复

parent cc3a6693
......@@ -5,7 +5,7 @@
int main(int argc, char* argv[])
{
const char* uri = "host=192.168.12.7 port=5432 dbname=2222 user=postgres password=admin";
const char* uri = "host=192.168.12.7 port=5432 dbname=liulele user=postgres password=admin";
char* findUri = const_cast<char*>(uri);
char net[128];
......
#include "CivHydrCalc.h"
#include "CivDbConnection.h"
#include "CivTypes.h"
#include "CivCommonUtils.h"
#include "Epanet2.h"
#include "CivInp.h"
......@@ -113,15 +112,15 @@ bool CivHydrCalc::exportInp(char* fileName)
assemble(PIPELINE, civInp);
// 设置模式
Componets comps = mDbConn->getComponets(PATTERNTABLE);
size_t total = comps.size();
for (int i = 0; i < total; i++)
Componets patterns = mDbConn->getComponets(PATTERNTABLE);
size_t patternSize = patterns.size();
for (int i = 0; i < patternSize; i++)
{
}
// 设置曲线
Componets comps = mDbConn->getComponets(CURVETABLE);
Componets curves = mDbConn->getComponets(CURVETABLE);
// 初始化参数
Options options;
......@@ -172,10 +171,14 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
// 过滤掉与阀门和水泵连接的管线
Str number = comp.find("id")->second;
FiledFilter filter = mDbConn->getFilter();
auto lineFilter = filter.find(PIPELINE)->second;
if (lineFilter.count(number) > 0)
continue;
auto iter = filter.find(PIPELINE);
if (iter != filter.end())
{
auto lineFilter = filter.find(PIPELINE)->second;
if (lineFilter.count(number) > 0)
continue;
}
Str id = comp.find(pipes.ID)->second;
Str startNode = comp.find(pipes.Node1)->second;
Str endNode = comp.find(pipes.Node2)->second;
......@@ -187,6 +190,8 @@ void CivHydrCalc::assemble(const std::string& table, CivInp& inp)
// 注意顺序
CivItem civItem;
if(id==""||id.empty())
id = "GD" + comp.find("id")->second;
civItem.push_back(id);
civItem.push_back(startNode);
civItem.push_back(endNode);
......
#include "CivInp.h"
#include "CivCommonUtils.h"
#include<time.h>
CivInp::CivInp(TimeUnit timetype):mTimeUnit(timetype)
......@@ -253,7 +252,7 @@ void CivInp::writeTitles()
{
writeString("[TITLE]"); // дǩ
writeString("Scenario: Base");
writeString("Date:"+CivCommonUtils::currentTime());
writeString("Date:");
writeString("");
writeString("");
}
......
......@@ -152,7 +152,6 @@
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp" />
<ClCompile Include="CivComponent.cpp" />
<ClCompile Include="CivHydrCalc.cpp" />
<ClCompile Include="CivHydrFuncInter.cpp" />
......
......@@ -21,9 +21,6 @@
<ClCompile Include="CivInp.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="..\pandaDbManager\CivCommonUtils.cpp">
<Filter>源文件</Filter>
</ClCompile>
<ClCompile Include="CivComponent.cpp">
<Filter>源文件</Filter>
</ClCompile>
......
......@@ -47,6 +47,13 @@ std::string CivCommonUtils::UTF8_To_string(const std::string& str)
return strRet;
}
//std::map<std::string, std::string> CivCommonUtils::parseJson(std::string jsonStr)
//{
// std::map<std::string, std::string> map;
//
// return map;
//}
std::string CivCommonUtils::currentTime()
{
return std::string();
......
#pragma once
#include<string>
#include<map>
// #include<json/reader.h>
class CivCommonUtils
{
public:
// std:string转UTF8
......@@ -22,4 +23,9 @@ public:
*@brief 获取系统当前时间
*/
static std::string currentTime();
///**
//*@brief 将json字符串解析为
//*/
//static std::map<std::string, std::string> parseJson(std::string jsonStr);
};
......@@ -143,7 +143,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpq.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>libpq.lib;json_vc71_libmt.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OUTDIR)..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ImportLibrary>$(OutDir)..\lib\$(TargetName).lib</ImportLibrary>
</Link>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment