Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - hnmdijkema

Pages: [1]
1
Hi Peterc,

All of that is valuable info, but it all requires an active user session.
Guillaume is looking for a way to run automated tasks (such as backups etc) without an active user session.

Geert

There's software on the market that creates a service that can run your own batch files or powershell scripts with desktop and that works with EA is my experience, e.g. FireDaemonPro.

2
Have you tried using absolute paths for the export file and log files? e.g., using this powershell script:

Code: [Select]
$connection_string = "testhd --- DBType=4;Connect=Provider=MSDASQL.1;Password=<password>;Persist Security Info=True;User ID=postgres;Data Source=testhd;LazyLoad=1;";
$eap = "e:\sparx\testhd.eapx";
$log = "e:\sparx\testhd.log";

Write-Output "----------------------------------------------------------"
Get-Date
Write-Output "----------------------------------------------------------"

add-type -path "D:\progs\sparxea\Interop.EA.dll"

Write-Output "EA: App Maken..."
$ea = new-object -ComObject "EA.App" -ErrorAction Stop #-Strict

Write-Output "EA: Repository verkrijgen..."
$eaRep = $ea.Repository;

Write-Output "EA: Project Interface verkrijgen..."
$eaProject = $ea.Project;

Write-Output "Export van model";
$eaProject.projectTransfer($connection_string, $eap, $log);

Write-Output ""
Write-Output "EA: klaar, exit"

$eaRep.Exit()

Get-Date

This works at our site

3
I've found a way to influence the image size. It needs some scripting though, so you'll need a custom template fragment with a call to a script to create the diagram image.

Here's what I've done:

1. Create a User Template Fragment for a diagram with a call to a script: documentDiagram(#DIAGRAMID#, "DiagramTemplate")

2. Create the documentDiagram() function...

function documentUPPDiagram(diagramId, diagramTemplate)
    (...)
       set docG = Repository.CreateDocumentGenerator
   if (docG.NewDocument("")) then
      docG.DocumentDiagram diagramId, 1, diagramTemplate
   DIM rtf
   rtf = docG.GetDocumentAsRTF()
   rtf = maximizeDiagramImageHeightInCm(rtf, 14.6)
   
   documentDiagram = rtf
end function


And, I used these functions to influence the RTF.

function getRtfValue(rtf, entry)
   DIM i1, i2, l
   DIM e
   i1 = InStr(rtf, entry)
   if (i1 > 0) then
      i2 = InStr(i1 + 1, rtf, "\")
      if (i2 > 0) then
         l = i2 - i1 - Len(entry)
         e = Mid(rtf, i1 + Len(entry), l)
         getRtfValue = e
      end if
   end if
end function

function rtfReplace(rtf, entry, new_value)
   DIM i1, i2
   i1 = InStr(rtf, entry)
   if (i1 > 0) then
      i2 = InStr(i1 + 1, rtf, "\")
      if (i2 > 0) then
         rtfReplace = Left(rtf, i1 - 1) & entry & new_value & Mid(rtf, i2)
      end if
   end if
end function

function maximizeDiagramImageHeightInCm(rtf, max_height_in_cm)
   DIM w_goal, h_goal
   DIM scale_w, scale_h
   DIM factor
   DIM max_height_in_twips
   
   max_height_in_twips = Round((max_height_in_cm / 2.54) * 1440)
   scale_h = CInt(getRtfValue(rtf, "\picscaley"))
   max_height_in_twips = Round((1.0 / (scale_h / 100.0)) * max_height_in_twips)
   
   w_goal = getRtfValue(rtf, "\picwgoal")
   h_goal = getRtfValue(rtf, "\pichgoal")
   LOGDebug("\picwgoal = " & w_goal & ", \pichgoal = " & h_goal)
   h_goal = CInt(h_goal)
   
   if (h_goal > max_height_in_twips) then
      factor = max_height_in_twips / h_goal
      h_goal = Round(h_goal * factor)
      w_goal = CInt(w_goal)
      w_goal = Round(w_goal * factor)
      
      LOGDebug("Scaled to: \picwgoal = " & w_goal & ", \pichgoal = " & h_goal)
      
      rtf = rtfReplace(rtf, "\picwgoal", w_goal)
      rtf = rtfReplace(rtf, "\pichgoal", h_goal)
   end if
   
   maximizeDiagramImageHeightInCm = rtf
end function


Oke, it's a dirty hack, but it works.

Pages: [1]