¶Ô±ÈÐÂÎļþ |
| | |
| | | Quintiq file version 2.0 |
| | | #parent: #root |
| | | StaticMethod Archive ( |
| | | JSON respJSON, |
| | | Archive archive, |
| | | String archiveType |
| | | ) |
| | | { |
| | | TextBody: |
| | | [* |
| | | code := respJSON.Get( "code" ).GetNumber(); |
| | | archiveFileJSONs := respJSON.Get( "archiveFiles" ); |
| | | info( archiveFileJSONs.AsString() ); |
| | | if ( code = 200 ) { |
| | | for ( i := 0; i < archiveFileJSONs.Size(); i++ ) { |
| | | archiveFileJSON := archiveFileJSONs.Get( i ); |
| | | |
| | | fileName := archiveFileJSON.Get( "fileName" ).GetString(); |
| | | filePath := archiveFileJSON.Get( "fileFullPath" ).GetString(); |
| | | |
| | | if ( archiveType = "PR" ) { |
| | | apr := select( archive, ArchivePR, tempAPR, tempAPR.Name() = fileName ); |
| | | if ( not isnull( apr ) ) { |
| | | apr.FilePath( filePath ); |
| | | } else { |
| | | archive.ArchivePR( relnew, Name := fileName, FilePath := filePath ); |
| | | } |
| | | } else if ( archiveType = "PP" ) { |
| | | app := select( archive, ArchivePP, tempAPP, tempAPP.Name() = fileName ); |
| | | if ( not isnull( app ) ) { |
| | | app.FilePath( filePath ); |
| | | } else { |
| | | archive.ArchivePP( relnew, Name := fileName, FilePath := filePath ); |
| | | } |
| | | } else if ( archiveType = "Budget" ) { |
| | | ab := select( archive, ArchiveBudget, tempAB, tempAB.Name() = fileName ); |
| | | if ( not isnull( ab ) ) { |
| | | ab.FilePath( filePath ); |
| | | } else { |
| | | archive.ArchiveBudget( relnew, Name := fileName, FilePath := filePath ); |
| | | } |
| | | } else if ( archiveType = "PPA" ) { |
| | | appa := select( archive, ArchivePPA, tempAPPA, tempAPPA.Name() = fileName ); |
| | | if ( not isnull( appa ) ) { |
| | | appa.FilePath( filePath ); |
| | | } else { |
| | | archive.ArchivePPA( relnew, Name := fileName, FilePath := filePath ); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | *] |
| | | } |
| | |
| | | BinaryValue curveBinaryValue, |
| | | String idsFileName, |
| | | BinaryValue idsBinaryValue, |
| | | String filePath |
| | | ) |
| | | String filePath, |
| | | Boolean isOverwriteFile |
| | | ) as stream[JSON] |
| | | { |
| | | TextBody: |
| | | [* |
| | | // 请æ±åæ° |
| | | pathPPA := filePath + ppaFileName; |
| | | pathCurve := filePath + curveFileName; |
| | | pathIDS := filePath + idsFileName; |
| | | //isArchive := ifexpr( isPRArchive, "true", "false" ); |
| | | minorKey := [String]macroPlan.MDSID().MinorKey(); |
| | | json := JSON::Object() |
| | | .Add( "pathPPA", pathPPA ) |
| | | .Add( "pathCurve", pathCurve ) |
| | | .Add( "pathIDS", pathIDS ) |
| | | .Add( "minorKey", minorKey ).Build().AsString(); |
| | | pathPPA := filePath + ppaFileName; |
| | | pathCurve := filePath + curveFileName; |
| | | pathIDS := filePath + idsFileName; |
| | | info( pathPPA ); |
| | | info( pathCurve ); |
| | | isArchivePPA := ifexpr( isPPAArchive, "true", "false" ); |
| | | isOverridePPA := ifexpr( isOverwriteFile, "true", "false" ); |
| | | minorKey := [String]macroPlan.MDSID().MinorKey(); |
| | | json := JSON::Object() |
| | | .Add( "pathPPA", pathPPA ) |
| | | .Add( "isArchivePPA", isArchivePPA ) |
| | | .Add( "pathCurve", pathCurve ) |
| | | .Add( "pathIDS", pathIDS ) |
| | | .Add( "minorKey", minorKey ) |
| | | .Add( "isOverridePPA", isOverridePPA ).Build().AsString(); |
| | | |
| | | // åå
¥ä¸´æ¶æä»¶ |
| | | Archive::WriteTempFile( pathPPA, ppaBinaryValue ); |
| | |
| | | info( json ); |
| | | |
| | | // è°ç¨æ¥å£ |
| | | //url := "/PR/Import"; |
| | | //i := HTTPInterface::Create( archive.JavaInterfaceAddress(), archive.JavaInterfacePort() ); |
| | | //i.URL( url ); |
| | | //i.PostMethod( true ); |
| | | // |
| | | //try { |
| | | // i.Call( json ); |
| | | // |
| | | // htmlresult := i.Result(); |
| | | //} onerror { |
| | | // |
| | | //} |
| | | url := "/IDSPPACurve/Import"; |
| | | |
| | | i := HTTPInterface::Create( archive.JavaInterfaceAddress(), archive.JavaInterfacePort() ); |
| | | i.URL( url ); |
| | | i.PostMethod( true ); |
| | | i.MediaType( "application/json" ); |
| | | i.TimeOut( Duration::Minutes( 5 ) ); |
| | | |
| | | i.Call( json ); |
| | | |
| | | htmlresult := i.Result(); |
| | | |
| | | respJSON := JSON::Parse( htmlresult ); |
| | | |
| | | return emit( respJSON ); |
| | | *] |
| | | } |
| | |
| | | TextBody: |
| | | [* |
| | | // 请æ±åæ° |
| | | pathPR := filePath + prFileName; |
| | | isArchive := ifexpr( isPRArchive, "true", "false" ); |
| | | isOverride := ifexpr( isOverwriteFile, "true", "false" ); |
| | | minorKey := [String]macroPlan.MDSID().MinorKey(); |
| | | json := JSON::Object() |
| | | .Add( "pathPR", pathPR ) |
| | | .Add( "isArchive", isArchive ) |
| | | .Add( "isOverride", isOverride ) |
| | | .Add( "minorKey", minorKey ).Build().AsString(); |
| | | pathPR := filePath + prFileName; |
| | | isArchive := ifexpr( isPRArchive, "true", "false" ); |
| | | isOverride := ifexpr( isOverwriteFile, "true", "false" ); |
| | | macroPlanKey := [String]macroPlan.MDSID().MinorKey(); |
| | | json := JSON::Object() |
| | | .Add( "pathPR", pathPR ) |
| | | .Add( "isArchive", isArchive ) |
| | | .Add( "isOverride", isOverride ) |
| | | .Add( "minorKey", macroPlanKey ).Build().AsString(); |
| | | |
| | | // åå
¥ä¸´æ¶æä»¶ |
| | | Archive::WriteTempFile( pathPR, prBinaryValue ); |
| | |
| | | { |
| | | TextBody: |
| | | [* |
| | | // æ¸
ç©ºä¸´æ¶æ°æ®åº |
| | | archiveExecutionStatus.AES_TemporaryDemandData().Source().FlatQuery( "truncate table A_Forecasts" ); |
| | | |
| | | archiveExecutionStatus.RequirementImportExecutionStatus( relnew, |
| | | ExecutionCode := 500, |
| | | ExecutionIsSuccess := false, |
| | |
| | | |
| | | if ( prBinaryValue.Size() > 0 ) { |
| | | archive -> Archive::HandlePR( macroPlan, userName, prFileName, prBinaryValue, isPRArchive, filePath, isOverwriteFile ) |
| | | -> Archive::Success( macroPlan, archiveExecutionStatus, userName ) |
| | | -> Archive::Success( macroPlan, archiveExecutionStatus, userName ) |
| | | -> Archive::Archive( archive, "PR" ) |
| | | -> Exception() |
| | | -> Archive::OnException( archiveExecutionStatus, userName ); |
| | | } else if ( ppBinaryValue.Size() > 0 ) { |
| | | archive -> Archive::HandlePP( macroPlan, userName, ppFileName, ppBinaryValue, isPPArchive, filePath, isOverwriteFile ) |
| | | -> Archive::Success( macroPlan, archiveExecutionStatus, userName ) |
| | | -> Archive::Success( macroPlan, archiveExecutionStatus, userName ) |
| | | -> Archive::Archive( archive, "PP" ) |
| | | -> Exception() |
| | | -> Archive::OnException( archiveExecutionStatus, userName ); |
| | | } else if ( budgetBinaryValue.Size() > 0 ) { |
| | | archive -> Archive::HandleBudget( macroPlan, userName, budgetFileName, budgetBinaryValue, isBudgetArchive, filePath, isOverwriteFile ) |
| | | -> Archive::Success( macroPlan, archiveExecutionStatus, userName ) |
| | | -> Exception() |
| | | -> Archive::Success( macroPlan, archiveExecutionStatus, userName ) |
| | | -> Archive::Archive( archive, "Budget" ) |
| | | -> Exception() |
| | | -> Archive::OnException( archiveExecutionStatus, userName ); |
| | | } else { |
| | | Archive::HandlePPA_Curve_IDS( archive, macroPlan, userName, ppaFileName, ppaBinaryValue, isPPAArchive, curveFileName, curveBinaryValue, idsFileName, idsBinaryValue, filePath ); |
| | | archive -> Archive::HandlePPA_Curve_IDS( macroPlan, userName, ppaFileName, ppaBinaryValue, isPPAArchive, curveFileName, curveBinaryValue, idsFileName, idsBinaryValue, filePath, isOverwriteFile ) |
| | | -> Archive::Success( macroPlan, archiveExecutionStatus, userName ) |
| | | -> Archive::Archive( archive, "PPA" ) |
| | | -> Exception() |
| | | -> Archive::OnException( archiveExecutionStatus, userName ); |
| | | } |
| | | *] |
| | | } |
| | |
| | | MacroPlan macroPlan, |
| | | ArchiveExecutionStatus archiveExecutionStatus, |
| | | String userName |
| | | ) |
| | | ) as stream[JSON] |
| | | { |
| | | TextBody: |
| | | [* |
| | |
| | | } else { |
| | | RequirementImportExecutionStatus::Create( archiveExecutionStatus, code, "Complete", userName, message, false ); |
| | | } |
| | | |
| | | return emit( respJSON ); |
| | | *] |
| | | } |
| | |
| | | { |
| | | TextBody: |
| | | [* |
| | | file := OSFile::Construct(); |
| | | |
| | | file.Open( filePath, "Write", false ); |
| | | file.WriteBinary( binaryValue ); |
| | | |
| | | file.Close(); |
| | | if ( binaryValue.Size() > 0 ) { |
| | | file := OSFile::Construct(); |
| | | |
| | | file.Open( filePath, "Write", false ); |
| | | file.WriteBinary( binaryValue ); |
| | | |
| | | file.Close(); |
| | | } |
| | | *] |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | Quintiq file version 2.0 |
| | | #parent: #root |
| | | Attribute SourceFileBinaryValue |
| | | { |
| | | #keys: '3[414996.0.408054600][414996.0.408054599][414996.0.408054601]' |
| | | ValueType: BinaryValue |
| | | } |
| | |
| | | efPR.Text() , guard( dhBinaryDataPR.Data().AsBinaryValue(), BinaryValue::Construct( 0 ) ), cPR.Checked(), |
| | | efPP.Text() , guard( dhBinaryDataPP.Data().AsBinaryValue(), BinaryValue::Construct( 0 ) ), cPP.Checked(), |
| | | efBudget.Text() , guard( dhBinaryDataBudget.Data().AsBinaryValue(), BinaryValue::Construct( 0 ) ), cBudget.Checked(), |
| | | ifexpr( cPPAPPAArchiveEnable.Checked(), ddlPPAArchive.Data().Name(), efCurve.Text() ), guard( dhBinaryDataPPA.Data().AsBinaryValue(), BinaryValue::Construct( 0 ) ), cPPA.Checked(), |
| | | efCurve.Text() , guard( dhBinaryDataCurve.Data().AsBinaryValue(), BinaryValue::Construct( 0 ) ), |
| | | dhOriginalFileNamePPA.Data() , guard( dhBinaryDataPPA.Data().AsBinaryValue(), BinaryValue::Construct( 0 ) ), cPPA.Checked(), |
| | | dhOriginalFileNameCurve.Data() , guard( dhBinaryDataCurve.Data().AsBinaryValue(), BinaryValue::Construct( 0 ) ), |
| | | efIDS.Text() , guard( dhBinaryDataIDS.Data().AsBinaryValue(), BinaryValue::Construct( 0 ) ), |
| | | false ); |
| | | |