Question

Automatic connect photo to an IFS Object

  • 18 May 2021
  • 4 replies
  • 514 views

Userlevel 7
Badge +21

Hello,

Is there anybody that has the following in place: user takes a picture and the photo is automatically uploaded to a server. Some script runs frequently and scans the photo (its name) and connects it automatically to an object in IFS.

I know it is not easy, but have an idea how to connect the photo to the correct object, if the name of the photo contains the key of the object (think of a project number in the name of the photo to know the project is the object in IFS).

Problem that I face is that the name of the photo needs to change on a regular base. Today project 23, the next day project 2998. 

I’m thinking of a camera with FTP or iPad with photo link to directory that IFS can read one way or the other. Still the name of the photo is a sequence number that is hard to change automatically.

AI might help, I think, but have no idea how (maybe barcode in photo??)

Any idea is helpful.

Thanks


This topic has been closed for comments

4 replies

Userlevel 7
Badge +20

Hi @eqbstal ,

 

We had similar requirement with a manufacturing customer where they want to add pictures of the finished product as media items in IFS automatically and connect to shop order so I  sense of deja vu :sunglasses: 

In our scenario images are saved in a folder accessible by IFS where we can identify the shop order by picture name.

Tricky part was to read and attach the image when a shop order is created rather than putting file into Connect IN folder.

Method we used was, first checked in image into  DOCMAN using Batch_Transfer_Handler_API.Upload_To_Db and then create media library and insert the image from docman.

It’s not simpler to summarize is few words but hope you get the idea :)

 

Regarding the name change of the photo and mapping to IFS project id: I didn’t understand the requirement well but I assume it’s related to the name sequence of photo is different from project IDs? For such uses data Migration conversion lists works well, where you can map the relations between different entities.

 

Hope it helps!

Damith

Userlevel 7
Badge +18

Here's how I'd do it. It's crude, but crude things are easier to debug.

1. You'd have a folder where the pictures would get dumped off as soon as they're taken.
2. You'd OCR those files and put them into either an error queue or an IFS queue.
3. A process in IFS would read the files in its queue and process them from there.

 

The hardest part is probably reading the directory listing from IFS. Oracle doesn’t make that easy.

 

 

 

 

You need not use a schedule to look for new files if you use the .NET class FileSystemWatcher: https://docs.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher?redirectedfrom=MSDN&view=net-5.0

 

You’d probably also want an error queue where IFS can dump bad files so the whole process doesn’t choke on one bad file.

Userlevel 4
Badge +7

Agree with what @durette has mentioned. You will need an OCR software to rename the file so that it has a match to IFS part name. I have many processes set up that are utilizing Oracle’s utl_file package to read external files and write their content back to IFS, so reckon you could use something similar.

The only drawback is as it cannot read the file listing as @durette has indicated. Utl_file.fopen() procedure requires you pass a specific file name to read. What you can do is try something similar to an old school brute forcing. Its effectiveness will largely depending on the number  of parts in your system and the performance impact.

I’d loop through a cursor having a select of all parts applicable, and construct a dynamic file name, such as <part_no>.jpg, and then use utl_file package to check if this file exists. If it doesn’t, move to the next part. If the file exists, then attach the file to a business object in IFS using standard IFS method. See snippet below:

 

FOR rec1 IN all_parts LOOP
    
    utl_file.fgetattr('FILE_DIRECTORY',
                      rec1.constructed_file_name,
                      l_exists,
                      l_size,
                      l_block_size);
    IF (l_exists) THEN

 --do processes to import files

    END IF;

END LOOP;

Userlevel 7
Badge +18

You don’t need to fetch ALL the files. You can just grab the first file, move it out when you’re done, and recursively search until you run out of files.

 

Here’s the piece of the solution to retrieve the first file in a folder:

DECLARE
tmp_ VARCHAR2(32767);
BEGIN
tmp_ := dbms_java.endsession_and_related_state;
END;
/


CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "CDirectoryListing"
AS
import java.io.*;
public class CDirectoryListing {
public static String getFirstFile(String absoluteDirectory) {
File file = new File(absoluteDirectory.replace("\\", "/"));
String[] allFiles = file.list();
if (allFiles.length == 0) {
return "";
}
return allFiles[0];
}
}
/

CREATE OR REPLACE PACKAGE c_directory_listing_api IS
/*
module_ CONSTANT VARCHAR2(25) := 'FNDBAS';
lu_name_ CONSTANT VARCHAR(25) := 'CDirectoryListing';
*/
FUNCTION get_first_file(
absolute_directory_ IN VARCHAR2) RETURN VARCHAR2;

PROCEDURE init;

END c_directory_listing_api;
/

CREATE OR REPLACE PACKAGE BODY c_directory_listing_api IS

FUNCTION get_first_file(
absolute_directory_ IN VARCHAR2) RETURN VARCHAR2
IS
LANGUAGE JAVA
NAME 'CDirectoryListing.getFirstFile(java.lang.String) return java.lang.String';

PROCEDURE init IS BEGIN NULL; END init;

END c_directory_listing_api;
/

GRANT EXECUTE ON c_directory_listing_api TO ifssys;

EXEC dictionary_sys.rebuild_dictionary_storage_(0, 'PACKAGES');

SELECT c_directory_listing_api.get_first_file('\\some_server\some_share\some_subfolder\') AS first_file
FROM DUAL;