/home/coin/SVN-release/OS-1.1.1/OS/applications/fileUpload/OSFileUpload.cpp

Go to the documentation of this file.
00001 
00028 //#include "OSResult.h"
00029 //#include "OSiLReader.h"
00030 //#include "OSiLWriter.h"
00031 //#include "OSrLReader.h"
00032 //#include "OSrLWriter.h"
00033 //#include "OSInstance.h"
00034 //#include "OSnLNode.h"
00035 
00036 #include "OSParameters.h"
00037 #include "OSFileUtil.h"
00038 #include "OSErrorClass.h"
00039 #include "OSWSUtil.h" 
00040 #include "OSSolverAgent.h" 
00041 #include "CoinHelperFunctions.hpp"  
00042 //
00043 
00044 #ifdef HAVE_CTIME
00045 # include <ctime>
00046 #else
00047 # ifdef HAVE_TIME_H
00048 #  include <time.h>
00049 # else
00050 #  error "don't have header file for time"
00051 # endif
00052 #endif
00053 
00054 
00055 #include <sstream>
00056 #include <vector>
00057 //#include <asl.h>
00058 
00059 int main(int argC, char* argV[])
00060 {
00061         WindowsErrorPopupBlocker();
00062         FileUtil *fileUtil = NULL;  
00063         try{
00064                 if( argC != 2) throw ErrorClass( "there must be exactly one command line argument which should be the file name");
00065                 fileUtil = new FileUtil(); 
00066                 time_t start, finish, tmp;
00067                 std::string osilFileNameWithPath;
00068                 std::string osilFileName;
00069                 std::string osil;
00070                 std::string uploadResult;
00071                 const char dirsep =  CoinFindDirSeparator();
00072                 osilFileNameWithPath = argV[ 1];
00073                 std::cout << "FILE NAME = " << argV[1] << std::endl;
00074                 std::cout << "Read the file into a string" << std::endl; 
00075                 osil = fileUtil->getFileAsString( osilFileNameWithPath.c_str() ); 
00076                 OSSolverAgent* osagent = NULL;
00077                 //
00078                 // kipp-- you have changed the path name on the server
00079                 //
00080                 throw ErrorClass( "please go in and put in a valid server URL and recompile \n  see line 81" );
00081                 // put in a valid URL below
00082                 osagent = new OSSolverAgent("http://***/os/servlet/OSFileUpload");
00083                 // put in a valid URL above
00084                 //
00085                 //
00086                 // strip off just the file name
00087                 // modify to into a file C:filename
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                 //std::cout << "osilFileName =  " << osilFileName << std::endl;
00094                 //std::cout << "osil =  " << osil << std::endl;
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                 //return 0;
00101                 // now tell solve the problem remotely with cbc
00102                 //osagent = new OSSolverAgent("http://128.135.130.17:8080/os/OSSolverService.jws");
00103                 // the osil comes from the remote location
00104                 //osil = "";
00105                 //std::string osol = "<osol><general><instanceLocation locationType=\"local\">" + remoteFileLocation + osilFileName + "</instanceLocation></general> </osol>";
00106                 //std::string osrl = osagent->solve(osil, osol);
00107                 //std::cout << osrl << std::endl;
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 

Generated on Tue Sep 30 03:01:24 2008 by  doxygen 1.4.7