正在显示
4 个修改的文件
包含
114 行增加
和
8 行删除
@@ -11,6 +11,7 @@ | @@ -11,6 +11,7 @@ | ||
11 | #include "dmpvectorlayerrenderer.h" | 11 | #include "dmpvectorlayerrenderer.h" |
12 | #include "dmpproviderregistry.h" | 12 | #include "dmpproviderregistry.h" |
13 | #include "libpq-fe.h" | 13 | #include "libpq-fe.h" |
14 | +#include "clsUtil.h" | ||
14 | 15 | ||
15 | DmpVectorLayer::DmpVectorLayer(const std::string &path, | 16 | DmpVectorLayer::DmpVectorLayer(const std::string &path, |
16 | const std::string &baseName, | 17 | const std::string &baseName, |
@@ -139,9 +140,11 @@ bool DmpVectorLayer::writejson(std::string& json) | @@ -139,9 +140,11 @@ bool DmpVectorLayer::writejson(std::string& json) | ||
139 | } | 140 | } |
140 | //Display scale setting type="1" geometry="Point" alwaysShow="true" maxScale="0" maxScale="50000"> | 141 | //Display scale setting type="1" geometry="Point" alwaysShow="true" maxScale="0" maxScale="50000"> |
141 | char resultbuff[1000]; | 142 | char resultbuff[1000]; |
143 | + string json_source = this->source(); | ||
144 | + DmapCore_30::clsUtil::ToJSONString(json_source); | ||
142 | sprintf(resultbuff, | 145 | sprintf(resultbuff, |
143 | - R"({"workspace":"","type":"1","dbsourceid":"%s","data":"","schema":"%s","alias":"%s","name":"%s","id":"%s","filter":"%s","visible":"%s","tag":"","minScale":"%s","maxScale":"%s","geometry":"%s","alwaysShow":"%s")", | ||
144 | - this->source().c_str(), | 146 | + R"({"workspace":"","type":"1","dbsource":"%s","data":"","schema":"%s","alias":"%s","name":"%s","id":"%s","filter":"%s","visible":"%s","tag":"","minScale":"%s","maxScale":"%s","geometry":"%s","alwaysShow":"%s")", |
147 | + json_source.c_str(), | ||
145 | this->schema().c_str(), | 148 | this->schema().c_str(), |
146 | this->title().c_str(), | 149 | this->title().c_str(), |
147 | this->name().c_str(), | 150 | this->name().c_str(), |
@@ -587,6 +587,104 @@ namespace DmapCore_30 | @@ -587,6 +587,104 @@ namespace DmapCore_30 | ||
587 | *bValue = false; | 587 | *bValue = false; |
588 | } | 588 | } |
589 | 589 | ||
590 | + | ||
591 | + void clsUtil::ToXMLString(std::string &s) | ||
592 | + { | ||
593 | + const char *str1 = s.c_str(); | ||
594 | + if (strstr(str1, "&")) | ||
595 | + { | ||
596 | + s = clsUtil::CharReplace(s, "&", "&"); | ||
597 | + str1 = s.c_str(); | ||
598 | + } | ||
599 | + if (strstr(str1, "<")) | ||
600 | + { | ||
601 | + s = clsUtil::CharReplace(s, "<", "<"); | ||
602 | + str1 = s.c_str(); | ||
603 | + } | ||
604 | + if (strstr(str1, ">")) | ||
605 | + { | ||
606 | + s = clsUtil::CharReplace(s, ">", ">"); | ||
607 | + str1 = s.c_str(); | ||
608 | + } | ||
609 | + if (strstr(str1, "\"")) | ||
610 | + { | ||
611 | + s = clsUtil::CharReplace(s, "\"", """); | ||
612 | + str1 = s.c_str(); | ||
613 | + } | ||
614 | + if (strstr(str1, "\r")) | ||
615 | + { | ||
616 | + s = clsUtil::CharReplace(s, "\r", ""); | ||
617 | + str1 = s.c_str(); | ||
618 | + } | ||
619 | + if (strstr(str1, "\n")) | ||
620 | + { | ||
621 | + s = clsUtil::CharReplace(s, "\n", ""); | ||
622 | + str1 = s.c_str(); | ||
623 | + } | ||
624 | + if (strstr(str1, "'")) | ||
625 | + { | ||
626 | + s = clsUtil::CharReplace(s, "'", "'"); | ||
627 | + //str1=s.c_str(); | ||
628 | + } | ||
629 | + return; | ||
630 | + } | ||
631 | + | ||
632 | + void clsUtil::ToJSONString(std::string &s) | ||
633 | + { | ||
634 | + const char *str1 = s.c_str(); | ||
635 | + if (strstr(str1, "\\")) | ||
636 | + { | ||
637 | + s = clsUtil::CharReplace(s, "\\", "\\\\"); | ||
638 | + str1 = s.c_str(); | ||
639 | + } | ||
640 | + if (strstr(str1, "/")) | ||
641 | + { | ||
642 | + s = clsUtil::CharReplace(s, "/", "\\/"); | ||
643 | + str1 = s.c_str(); | ||
644 | + } | ||
645 | + if (strstr(str1, "\"")) | ||
646 | + { | ||
647 | + s = clsUtil::CharReplace(s, "\"", "\\\""); | ||
648 | + str1 = s.c_str(); | ||
649 | + } | ||
650 | + if (strstr(str1, "\\r")) | ||
651 | + { | ||
652 | + s = clsUtil::CharReplace(s, "\\r", ""); | ||
653 | + str1 = s.c_str(); | ||
654 | + } | ||
655 | + if (strstr(str1, "\\n")) | ||
656 | + { | ||
657 | + s = clsUtil::CharReplace(s, "\\n", ""); | ||
658 | + str1 = s.c_str(); | ||
659 | + } | ||
660 | + if (strstr(str1, "\r")) | ||
661 | + { | ||
662 | + s = clsUtil::CharReplace(s, "\r", ""); | ||
663 | + str1 = s.c_str(); | ||
664 | + } | ||
665 | + if (strstr(str1, "\n")) | ||
666 | + { | ||
667 | + s = clsUtil::CharReplace(s, "\n", ""); | ||
668 | + str1 = s.c_str(); | ||
669 | + } | ||
670 | + if (strstr(str1, "\t")) | ||
671 | + { | ||
672 | + s = clsUtil::CharReplace(s, "'", "\\t"); | ||
673 | + //str1=s.c_str(); | ||
674 | + } | ||
675 | + return; | ||
676 | + } | ||
677 | + | ||
678 | + string clsUtil::CharReplace(string strsrc, string strfind, string strrep) | ||
679 | + { | ||
680 | + for(string::size_type pos(0); pos!=string::npos; pos+=strrep.length()) { | ||
681 | + if( (pos=strsrc.find(strfind,pos))!=string::npos ) | ||
682 | + strsrc.replace(pos,strfind.length(),strrep); | ||
683 | + else break; | ||
684 | + } | ||
685 | + return strsrc; | ||
686 | + } | ||
687 | + | ||
590 | std::string clsUtil::fmt(char* fmt, ...) | 688 | std::string clsUtil::fmt(char* fmt, ...) |
591 | { | 689 | { |
592 | va_list argptr; | 690 | va_list argptr; |
@@ -73,7 +73,11 @@ else { to[index]->Release(); to[index] = from; }\ | @@ -73,7 +73,11 @@ else { to[index]->Release(); to[index] = from; }\ | ||
73 | 73 | ||
74 | static void GetFiles(string path, string exd, vector<string> & files); | 74 | static void GetFiles(string path, string exd, vector<string> & files); |
75 | static int ParseStringTok(char * sz, char toK, char ** szPtr, int maxPtr); | 75 | static int ParseStringTok(char * sz, char toK, char ** szPtr, int maxPtr); |
76 | - | 76 | + |
77 | + static void ToJSONString(std::string &s); | ||
78 | + static void ToXMLString(std::string &s); | ||
79 | + static string CharReplace(string strsrc, string strfind, string strrep); | ||
80 | + | ||
77 | static std::string fmt(char *, ...); | 81 | static std::string fmt(char *, ...); |
78 | static std::string fmt(const char*, ...); | 82 | static std::string fmt(const char*, ...); |
79 | static void ValueString(string * s, bool* bValue); | 83 | static void ValueString(string * s, bool* bValue); |
@@ -22,10 +22,9 @@ namespace DmpMapping | @@ -22,10 +22,9 @@ namespace DmpMapping | ||
22 | bool loadService(const DmpServerContext &context, ProjectMap& vectorMappingProjects) | 22 | bool loadService(const DmpServerContext &context, ProjectMap& vectorMappingProjects) |
23 | { | 23 | { |
24 | const char *data = (char *)(context.request()->GetData()); | 24 | const char *data = (char *)(context.request()->GetData()); |
25 | - std::string name = context.serverProject()->name(); | ||
26 | - std::string title = context.serverProject()->title(); | 25 | + |
27 | 26 | ||
28 | - if(data== nullptr || *data == '\0') | 27 | + if(data== nullptr || *data == '\0' || context.request()->method() != DmpServerRequest::Method::POST_METHOD ) |
29 | { | 28 | { |
30 | LOGGER_ERROR("post 参数错误"); | 29 | LOGGER_ERROR("post 参数错误"); |
31 | context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); | 30 | context.response()->writeJson("{\"status\":\"false\",\"message\":\"post 参数错误!\"}"); |
@@ -35,12 +34,14 @@ namespace DmpMapping | @@ -35,12 +34,14 @@ namespace DmpMapping | ||
35 | if(!context.serverProject()) | 34 | if(!context.serverProject()) |
36 | { | 35 | { |
37 | LOGGER_ERROR("加载服务信息失败,服务名称是否错误"); | 36 | LOGGER_ERROR("加载服务信息失败,服务名称是否错误"); |
38 | - context.response()->writeJson("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称是否错误!\"}"); | 37 | + context.response()->writeJson("{\"status\":\"false\",\"message\":\"加载服务信息失败,服务名称错误!\"}"); |
39 | return false; | 38 | return false; |
40 | } | 39 | } |
41 | 40 | ||
42 | try | 41 | try |
43 | { | 42 | { |
43 | + std::string name = context.serverProject()->name(); | ||
44 | + std::string title = context.serverProject()->title(); | ||
44 | std::stringstream stream(data); | 45 | std::stringstream stream(data); |
45 | boost::property_tree::ptree pt; | 46 | boost::property_tree::ptree pt; |
46 | boost::property_tree::read_json(stream, pt); | 47 | boost::property_tree::read_json(stream, pt); |
@@ -105,7 +106,7 @@ namespace DmpMapping | @@ -105,7 +106,7 @@ namespace DmpMapping | ||
105 | 106 | ||
106 | json.append("]}"); | 107 | json.append("]}"); |
107 | 108 | ||
108 | - context.response()->write( project->WriteJson()); | 109 | + context.response()->writeJson( json); |
109 | return true; | 110 | return true; |
110 | } | 111 | } |
111 | else | 112 | else |
请
注册
或
登录
后发表评论