131{
132
133 std::ifstream
outfile(
m_outFileName.value().c_str(), std::ifstream::in | std::ifstream::binary);
134
135 std::vector<std::string> newoutfilelines;
136 std::string outfileline;
137 while( getline(outfile, outfileline) )
138 if( outfileline != "\n" && outfileline != "\r" && !outfileline.empty() )
139 {
140 const auto strBegin = outfileline.find_first_not_of(" \t");
141 const auto strEnd = outfileline.find_last_not_of(" \t");
142 const auto strRange = strEnd - strBegin + 1;
143 if (strBegin != std::string::npos) outfileline = outfileline.substr(strBegin, strRange);
144 newoutfilelines.push_back(outfileline);
145 }
147
148 std::ofstream newoutfile(
m_outFileName.value().c_str(), std::ofstream::out | std::ofstream::trunc);
149 for(auto it = newoutfilelines.begin(); it != newoutfilelines.end(); ++it)
150 {
151 if(it != newoutfilelines.begin()) newoutfile << "\n";
153 }
154 newoutfile.close();
156
157 int fileSize = 0;
159 {
160 outfile.seekg(0, std::ios::end);
163 }
164 else {
166 return false;
167 }
168
169 std::ofstream prefile;
171 prefile << "insert into NSWD_data (\n";
172 prefile << "NSWD_data_id,\n";
173 prefile << "ACTVERS,\n";
174 prefile << "ACTVNAME,\n";
175 prefile << "ALGVERS,\n";
176 prefile << "ALGVNAME,\n";
177 prefile << "PASVERS,\n";
178 prefile << "PASVNAME,\n";
179 prefile << "FORMAT,\n";
180 prefile << "FNAME,\n";
181 prefile << "LENNSW,\n";
182 prefile << "NLINE,\n";
183 prefile << "data\n";
184 prefile << ") values (XXX_DATA_ID_KOUNTER,\n";
189 prefile << "empty_clob()\n";
190 prefile << ");\n";
191 prefile << "insert into NSWD_data2tag values (XXX_DATA2TAG_KOUNTER,XXX_DATA_ID_KOUNTER);\n";
192 prefile << "DECLARE\n";
193 prefile << " lobloc CLOB;\n";
194 prefile << " req utl_http.req;\n";
195 prefile << " resp utl_http.resp;\n";
196 prefile << " text VARCHAR2(32767);\n";
197 prefile << " amount INTEGER(10) := 0;\n";
198 prefile << " offset INTEGER(10) := 0;\n";
199 prefile << " TRUE BOOLEAN;\n";
200 prefile << "BEGIN\n";
201 prefile << " SELECT data INTO lobloc\n";
202 prefile << " FROM NSWD_data\n";
203 prefile << " WHERE NSWD_data_id = XXX_DATA_ID_KOUNTER FOR UPDATE;\n";
204 prefile << " offset := DBMS_LOB.GETLENGTH(lobloc)+2;\n";
205 prefile << " req := utl_http.begin_request(\n";
206 prefile << " 'WEB_ADDRESS_FOR_TEMP_DATA_FILENSWDtemp.data');\n";
207 prefile << " resp := utl_http.get_response(req);\n";
208 prefile << " LOOP\n";
209 prefile << " text := ' ';\n";
210 prefile << " UTL_HTTP.READ_TEXT(resp, text, NULL);\n";
211 prefile << " /* DBMS_OUTPUT.PUT_LINE(text); */\n";
212 prefile << " amount := length(text);\n";
213 prefile << " DBMS_LOB.WRITEAPPEND(lobloc,amount,text);\n";
214 prefile << " END LOOP;\n";
215 prefile << " utl_http.end_response(resp);\n";
216 prefile << " EXCEPTION\n";
217 prefile << " WHEN utl_http.end_of_body\n";
218 prefile << " THEN utl_http.end_response(resp);\n";
219 prefile << "END;\n";
220 prefile << "/\n";
221 prefile.close();
222
223 return true;
224
225}