Skip to content

Commit

Permalink
hotfix write issue
Browse files Browse the repository at this point in the history
  • Loading branch information
HLWeil committed Oct 29, 2023
1 parent c4366a4 commit a259bdb
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions src/ArcCommander/ArcConfiguration.fs
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,37 @@ open ARCtrl.NET

[<AutoOpen>]
module ARCExtensions =

open Contract
open FsSpreadsheet
open FsSpreadsheet.ExcelIO

let myWrite basePath (c : Contract) =
let log = Logging.createLogger("WriteContractHandler")
match c.DTO with
| Some (DTO.Spreadsheet wb) ->
let path = System.IO.Path.Combine(basePath, c.Path)
Path.ensureDirectory path
FsWorkbook.toFile path (wb :?> FsWorkbook)
| Some (DTO.Text t) ->
let path = System.IO.Path.Combine(basePath, c.Path)
Path.ensureDirectory path
if System.IO.File.Exists path |> not then
System.IO.File.WriteAllText(path,t)
| None ->
let path = System.IO.Path.Combine(basePath, c.Path)
Path.ensureDirectory path
if System.IO.File.Exists path |> not then
System.IO.File.Create(path).Close()
| _ ->
log.Info(sprintf "Contract %s is not an ISA contract" c.Path)

type ARC with

member this.Write(arcPath) =
this.GetWriteContracts()
|> Array.iter (myWrite arcPath)

static member load(config : ArcConfiguration) =
ARC.load(GeneralConfiguration.getWorkDirectory config)

Expand Down

0 comments on commit a259bdb

Please sign in to comment.