Pascal Script

  • 20 Mar

    Q&A 48: Get an actual Rule Report for all Rules we currently have

    Q: I have been asked the second time now if it is possible that I got out an actual Rule Report for all Rules we currently have in Limagito. It`s just all the reporting and documentation obligations our company has to follow. Of course it would be possible to print that on a per Rule-Basis. It would be great if there is an option to generate all Rule-Reports for all Rules at once
    A: Yes this is possible using some Pascal Script. We added some screenshots to get you started.

    1. Add the following Pascal Script as Source (do not forget to adjust the ctDestPath). Our Report output path will be C:\Test\Reports\.

    Var
      tmpInfo: String;
    Const
      ctDestPath = 'C:\Test\Reports\';
    Begin
      psExitCode:= 1;
      // ... add your code here
      tmpInfo := psSaveRuleReportsAsHTML(ctDestPath);
      psLogWrite(1, '', tmpInfo);
    End.

    Limagito File Mover Pascal Script as Source

    2. In this example we disabled the scan timers because we will trigger the rule manually:

    Limagito File Mover Schedule Setup

    3. No Destinations are needed:

    Limagito File Mover Destination Setup

    4. We enabled the Rule and clicked the trigger button (small green arrow on he right of the enable/status button):

    Limagito File Mover trigger rule

    5. Result in the output folder, all the rule reports are saved as html:

    Limagito File Mover Rule Report for all Rules

    #Filetransfer

    If you need any info about this ‘Rule Report for all Rules’ option, please let us know.

    Best regards,

    Limagito Team

  • 19 Mar

    Notificate the windows application log if a certain error occurs?

    Q: is it possible notificate in the windows application log if the following error occurs?

    17.03.2022 14:29:35 Connect IMAP4, OAuth2 Authorization Failed, Error:

      RefreshAccessToken:

       ..

        fullRequestGetResponse:

          Reading response header…

          responseStatusCode: 400

          Reading response body …

        –fullRequestGetResponse

        finalResponse: {“error”:”invalid_grant”,”error_description”:”AADSTS700082: The refresh token has expired due to inactivity. The token was issued on 2021-11-18T10:09:31.0508889Z and was inactive for 90.00:00:00.\..

      –RefreshAccessToken

    17.03.2022 14:29:35 Connect IMAP4, CK Login to outlook.office365.com Error:

      Connect_Imap:

    A: Yes this is possible using the following setup.

    1. Open ‘Logging’ setup and enable the ‘Clear Log at Rule Begin’ option in the ‘RunTime Log’ tab. Since we are going to use the RunTime log as content to check, we want to keep it unique for each time the Rule is started.

    Limagito File Mover Logging Setup

    Limagito File Mover RunTime Log Setup

    2. Open ‘Rule Events’

    Limagito File Mover Rule Events

    3. Enable the ‘On .. Error’ event and enable the ‘Enable Event Log’ option. Add %VSE ( Var String E ) to the ‘Event Log’ setup. Be sure the ‘On Error’ event stays selected during the setup of the other options.

    Limagito File Mover windows application log

    Important, in the ‘Options’ tab:

    • Enable ‘Include connect errors in on error event’
    • Enable ‘Use Pascal Script as Event Precondition’

    Limagito File Mover Rule Events Common Options

    4. Enable ‘Enable Pascal Script’ for the ‘On Error’ event. Add the following ‘Pascal Script’.

    Const
      ctErrorToFind = 'AADSTS700082';
    Begin
      // ... add your code here
      psExitCode := 0;
      If Pos(ctErrorToFind, psLRT) <> 0 Then
      Begin
        psLogWrite(1, '', 'Write Error To Event Log, ' + ctErrorToFind);
        psExitCode := 1;
      End  
      Else
        psExitCode := 0;
      // Put LogRunTime information in psVSE var 
      psVSE := psLRT;
    End.

    Limagito File Mover Rule Events Pascal Script option

    Summary:

    • The RunTime Log is cleared each time the Rule is triggered/started.
    • If an error (connect or others) occurs then we’ll use the Pascal Script option of the Rule Events to check if the content of the RunTime Log includes a certain text ( ‘AADSTS700082’ ).
    • If this text is available then we’ll put the RunTime Log content into the Windows Application Log.

    #Filetransfer

    If you need any info about this ‘windows application log’ request, please let us know.

    Best regards,

    Limagito Team

     

  • 19 Mar

    Move a file and send email with filename and line count

    Q: Move a file and send email with filename and line count.

    Can you help me with the following question.

    I want to move a file and in an email state the file name (always a text file .csv, .txt) and a line count
    Test.txt – 12 lines

    Can this be done?

    A: Yes this is possible. We have created a Pascal Script for you to achieve this.

    1. It is important that you’ll only handle txt and csv files (text based files). We added a File Name Include File Filter, just to be sure:

    Limagito File Mover Filename Filter

    2. Open our ‘Pascal Script’ option:

    Limagito File Mover Pascal Script option

    Add and enable the following ‘On Destination’ Pascal Script. This script will load the txt/csv file and will put the line count information into our %VSA parameter which can be use within our notification email.

    Var
      tmpCount: Integer;
      tmpList: TStringList;
    Begin
      psExitCode:= 0;
      // ... add your code here
      tmpList := TStringList.Create;
      Try
        Try
          // Load Source File
          tmpList.LoadFromFile(psFilePath + psFileName);
          // Count Lines
          tmpCount := tmpList.Count;
          // Info to be used in email
          psVSA := psFileName + ' - ' + IntToStr(tmpCount) + ' lines';
          psLogWrite(1, '', 'Information: ' + psVSA);    
          // Set Result OK
          psExitCode := 1;
        Except
          psLogWrite(1, '', 'Error loading: ' + psFilePath + psFileName);
        End;
      Finally
        tmpList.Free;
      End;  
    End.

    Limagito File Mover Pascal Script option

    3. Now you can use the %VSA as parameter within the email setup:

    Limagito File Mover Email Notification Setup

    Limagito File Mover Email setup

    4. Email Result:

    Limagito File Mover Email result

     

    #Filetransfer

    If you need any info about this option, please let us know.

    Best regards,

    Limagito Team

    By Limagito-Team Email Pascal Script
1 12 13 14 15 16 17 18 26
SEARCH