prashanth ponugoti · Oct 13, 2023 go to post

I have got an answer while searching in community pages.

I have written below code , reading all text from pdf

Class PRASHANTHNSPKG.ReadPDF Extends %RegisteredObject

{

/// zw ##class(User.PDF).GetText("/tmp/example.pdf", .text)

ClassMethod GetText(file, Output text) As %Status

{

  Try {

    #dim sc As %Status = $$$OK

    Kill text

    Set dir = $SYSTEM.Util.ManagerDirectory()_ "python"

    Do ##class(%File).CreateDirectoryChain(dir)

   

    /// C:\InterSystems\IRISHealth\bin>irispip install --target C:\InterSystems\IRISHealth\mgr\python PyPDF2

    Try {

      Set pypdf2 = $SYSTEM.Python.Import("PyPDF2")

    } Catch {

      Set cmd = "irispip"

      Set args($INCREMENT(args)) = "install"

      Set args($INCREMENT(args)) = "--target"

      Set args($INCREMENT(args)) = dir

      Set args($INCREMENT(args)) = "PyPDF2"

      Set sc = $ZF(-100,"", cmd, .args)

      Set pypdf2 = $SYSTEM.Python.Import("PyPDF2")

    }

    Return:'$DATA(pypdf2) $$$ERROR($$$GeneralError, "Unable to load PyPDF2")

    Kill pypdf2

    Set text = ..GetTextPy(file)

  } Catch ex {

    Set sc = ex.AsStatus()

  }

  Quit sc

}

ClassMethod GetTextPy(file) [ Language = python ]

{

  from PyPDF2 import PdfReader

  reader = PdfReader(file)

  text = ""

  for page in reader.pages:

    text += page.extract_text() + "\n"

  return text

}

}

I am getting error , where can I find cterm?

C:\InterSystems\IRISHealth\bin>cterm /console=cn_ap:ENSEMBLE[USER]
'cterm' is not recognized as an internal or external command,
operable program or batch file.

Thanks,

Prashanth

prashanth ponugoti · Oct 20, 2022 go to post

Thanks, Julius Kavay

ENCODE to base64 is working for me now as per your suggested code snippet.

Here I have another issue after the conversation.

I need to send the converted string in the JSON property "Filecontent" to the REST outbound.

FilecontentdataType is String, which exceeds the size when I assign this converted stream to String.

I have changed the Filecontent dataType to Stream, but when I convert the object to JSON ,  it is ignoring this property.

could you please any suggestions will be very much helpful?

thanks,

Prashanth

thanks Robert ,

seems scope is not a problem , just I have changed in where condition Status='5'  

sql(SELECT count(ID) into :suspendedCount FROM Ens.MessageHeader where TargetQueueName not like '_S%' and TargetQueueName not like 'ENS%' and Status='5')

working fine

but same query  resulting 0 records in sql explorer, and revert the where condition working fine in sql explorer

why the difference where condition requiring for @sql ,sql explorer

thanks a lot,

Prashanth

prashanth ponugoti · Feb 25, 2022 go to post

Thanks a lot, Roger,  yes working fine. 

thanks for your time and effort to share the code snippet.

prashanth ponugoti · Feb 25, 2022 go to post

Hi Utsavi,

It is possible by implementing monitoring integration (business service, business Process as Router, Business Operation as rest call) and deploying in the same production.

1) Implement Customised Business service which triggers by every 5 min (this you can configure) to call methods fr each of your requirement and get the data from cache and prepare the respective type of message and call Business Rules engine.

Example Methods:

1)getHeartbeat()  method  fetch the currently running version of production and namespace and prepared customised heartbeat message and send to the Rules engine

2) getQueuestatus() this method fetches the interested queues info from the cache and prepare the new message for each queue and send it to the business rules engine

3)getInactivity() this method gets all inactive processes and prepares the new message for each process and sends them to the rules engine.

create as many methods as per your requirement.

Now in business service write rules for each type of message, and check respective values are reaching threshold value (if needed ) then send message to Rest endpoint using Business Operation.

This rest service will read the messages and stored them in a web application database.

Web application Shows the summary of the data and refreshes every 5 minutes.

This way, whatever monitoring values using ENSLIB class methods you can read using cache script by calling embedded SQL, All readings you can show in your web page.

If production is down, As this integration is the same production, your heartbeat messages also missing in next 5 min with other messages. You can build logic in a webpage, if the heartbeat is older than 5 min, shows in the web app as Production down.

Hope this idea helpful to you , we did the same way for our monitoring requirement

Thanks,

Prashanth P

Thanks a lot Ben , 

yes it is overwhelm moment , When I saw my name with Legends . Thanks community for encouraging me.

Thanks a lot Steve ,For this migration we have different teams (vendors) working. My team is responsible for lift and shift and make sure all integrations should work fine.

I will make use of your valuable inputs.

Thanks,

Prashanth

could you give me object script code snippet for wait /sleep for given seconds.

because same code i want to use wherever i need to wait intentionally

Thanks,

Prashanth

Thanks Eduard ,

I can see extraction logic in above code but final step is how to write the data into file.

Yes csv file also fine , I want to store this file in file system like d://sample/history.csv

I did not see file path in the attached code.

Thanks a lot

prashanth ponugoti · Jan 26, 2022 go to post

Hi 

you can take any text editor and replace " with ""_" 

Example:

"<book id="""_"bk105"""_"><author type="""_"old"""_">Corets, Eva</author><title>The Sundered Grail</title><genre>Fantasy</genre></book>"