00001
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "OSConfig.h"
00037 #include "OSParameters.h"
00038 #include "OSFileUtil.h"
00039 #include "OSErrorClass.h"
00040 #include "OSWSUtil.h"
00041 #include "OSSolverAgent.h"
00042 #include "CoinHelperFunctions.hpp"
00043
00044
00045 #ifdef HAVE_CTIME
00046 # include <ctime>
00047 #else
00048 # ifdef HAVE_TIME_H
00049 # include <time.h>
00050 # else
00051 # error "don't have header file for time"
00052 # endif
00053 #endif
00054
00055
00056 #include <sstream>
00057 #include <vector>
00058
00059
00060 int main(int argC, char* argV[])
00061 {
00062 WindowsErrorPopupBlocker();
00063 FileUtil *fileUtil = NULL;
00064 try{
00065 if( argC != 2) throw ErrorClass( "there must be exactly one command line argument which should be the file name");
00066 fileUtil = new FileUtil();
00067 time_t start, finish, tmp;
00068 std::string osilFileNameWithPath;
00069 std::string osilFileName;
00070 std::string osil;
00071 std::string uploadResult;
00072 const char dirsep = CoinFindDirSeparator();
00073 osilFileNameWithPath = argV[ 1];
00074 std::cout << "FILE NAME = " << argV[1] << std::endl;
00075 std::cout << "Read the file into a string" << std::endl;
00076 osil = fileUtil->getFileAsString( osilFileNameWithPath.c_str() );
00077 OSSolverAgent* osagent = NULL;
00078
00079
00080
00081
00082 osagent = new OSSolverAgent("http://*****/os/servlet/OSFileUpload");
00083
00084
00085
00086
00087
00088 int index = osilFileNameWithPath.find_last_of( dirsep);
00089 int slength = osilFileNameWithPath.size();
00090 osilFileName = osilFileNameWithPath.substr( index + 1, slength) ;
00091 std::cout << std::endl << std::endl;
00092 std::cout << "Place remote synchronous call" << std::endl;
00093
00094
00095 start = time( &tmp);
00096 uploadResult = osagent->fileUpload(osilFileName, osil);
00097 finish = time( &tmp);
00098 std::cout << "File Upload took (seconds): "<< difftime(finish, start) << std::endl;
00099 std::cout << uploadResult << std::endl;
00100
00101
00102
00103
00104
00105
00106
00107
00108 if(fileUtil != NULL) delete fileUtil;
00109 return 0;
00110 }
00111 catch( const ErrorClass& eclass){
00112 std::cout << eclass.errormsg << std::endl;
00113 if(fileUtil != NULL) delete fileUtil;
00114 return 0;
00115 }
00116 }
00117