Commit a98c8cce authored by 刘乐's avatar 刘乐

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

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