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 const char dirsep = CoinFindDirSeparator();
00065 std::string osilFileNameWithPath;
00066 std::string osilFileName;
00067 std::string osil;
00068 std::string uploadResult;
00069 std::string actualServer;
00070
00071
00072 std::string defaultServer = "http://128.135.130.17:8080/os/servlet/OSFileUpload";
00073
00074 try{
00075 if( argC == 1 || argC > 3 || argV[1] == "-?")
00076 throw ErrorClass( "usage: OSFileUpload <filename> [<serverURL>]");
00077 fileUtil = new FileUtil();
00078 time_t start, finish, tmp;
00079 osilFileNameWithPath = argV[ 1];
00080 std::cout << "FILE NAME = " << argV[1] << std::endl;
00081 std::cout << "Read the file into a string" << std::endl;
00082 osil = fileUtil->getFileAsString( osilFileNameWithPath.c_str() );
00083 OSSolverAgent* osagent = NULL;
00084 if (argC == 2)
00085 actualServer = defaultServer;
00086 else
00087 actualServer = argV[2];
00088 osagent = new OSSolverAgent(actualServer);
00089
00090
00091
00092 int index = osilFileNameWithPath.find_last_of( dirsep);
00093 int slength = osilFileNameWithPath.size();
00094 osilFileName = osilFileNameWithPath.substr( index + 1, slength) ;
00095 std::cout << std::endl << std::endl;
00096 std::cout << "Place remote synchronous call" << std::endl;
00097
00098 start = time( &tmp);
00099 uploadResult = osagent->fileUpload(osilFileName, osil);
00100 finish = time( &tmp);
00101 std::cout << "File Upload took (seconds): "<< difftime(finish, start) << std::endl;
00102 std::cout << uploadResult << std::endl;
00103
00104 if(fileUtil != NULL) delete fileUtil;
00105 return 0;
00106 }
00107 catch( const ErrorClass& eclass){
00108 std::cout << eclass.errormsg << std::endl;
00109 if(fileUtil != NULL) delete fileUtil;
00110 return 0;
00111 }
00112 }
00113