How to import Cronjob using impexes? - sap-commerce-cloud

I have written the following impexes in:
trainingcore/resources/trainingcore/import/common/cronjob.impex
The impexes are :
INSERT_UPDATE ServicelayerJob;code[unique=true];springId;
;myJob;myJob;
INSERT_UPDATE
MyCronJob;code[unique=true];job(code);sessionLanguage(isocode);categoryCode;thresholdTime;
;myCronJob;myJob;en;xyz;5;
# Fires every 1 minute
INSERT_UPDATE Trigger;cronJob(code)[unique=true];active;cronExpression;
;myCronJob;true;0 0/1 * 1/1 * ? *
But when I'm updating the system, the impexes are not being loaded. Can someone please help?

These impexes are not picked up automatically. You need to have a System setup in your project where you need to add a link to the file.
From the location of your file, I assume you started from the starter template for a core project. In that case, there should be a file CoreSystemSetup in your core project. Somewhere in the location <classpathprefix/>setup/CoreSystemSetup
You need to add your file here as a new line in this file.
This will be something like this
#SystemSetup(extension = TrainingCoreCoreConstants.EXTENSIONNAME)
public class CoreSystemSetup extends AbstractSystemSetup
{
public static final String IMPORT_ACCESS_RIGHTS = "accessRights";
#SystemSetup(type = Type.ESSENTIAL, process = Process.ALL)
public void createEssentialData(final SystemSetupContext context)
{
importImpexFile(context, "/trainingcore/import/common/essential-data.impex");
importImpexFile(context, "/trainingcore/import/common/cronjob.impex");
}
}
You can also add this file in the project data part of this setup file. Depending on your needs.

Related

Custom Module is being used by batch classes and cannot be removed

I would like to remove my custom module from the Kofax administration module but I can't because I get the following error
Using the module multiple times increases the amount of batch classes listed there. But there is only one batch class so this can't be.
I removed the module from the batch class queue, stopped all background services and have no forms app running. The only way to remove this module is to export the batch class, delete it in the administration module, delete the custom module and reimport the batch class.
Maybe I don't exit the application properly?
My session management:
public void LoginToRuntimeSession()
{
login = new Login();
login.EnableSecurityBoost = true;
login.Login();
login.ApplicationName = Resources.CUSTOM_MODULE_ID;
login.Version = "1.0";
login.ValidateUser($"{Resources.CUSTOM_MODULE_ID}.exe", false);
session = login.RuntimeSession;
}
public void Logout()
{
session.Dispose();
login.Logout();
}
I get a new active batch with this code
public IBatch GetNextBatch()
{
return session.NextBatchGet(login.ProcessID);
}
and this is how I process the batch after polling for new ones
public void ProcessBatch(IBatch batch)
{
// ... IACDataElement stuff
batch.BatchClose(KfxDbState.KfxDbBatchReady, KfxDbQueue.KfxDbQueueNext, 0, "");
}
Any ideas how to fix this "bug"? Please let me know if you need more information!
The message you are seeing is only referring to the configuration in the Administration module. Therefore it is not related to what your module actually does when it is running or closing (no problem in your code can cause this).
If you are using Kofax Capture 11, previous published versions of the batch class remain in the system, so these probably still count as references to the module. If you go to the Publish dialog window, you can click the "Versions..." button to see and delete older versions. Try to remove your module again after you have deleted all the older versions that were still using it.
Additionally, you can look through the batch class properties to make sure that this module isn't set in one of the other settings, such as the module to start foldering on the Foldering tab, or the module to start Partial Batch Export on the Advanced tab.
If neither of those suggestions work, then you may want to open a case with Kofax Technical Support. One thing that either they or you can do is open the admin.xml file in the exported batch class cab file and see where your module ID is found. That will give context for finding out what is still referencing the module.

kofax export script project setup

For my first export script I took the KCEC example and the APIRefExport.chm documentation to create my project by replacing the example code with my own.
I would like to create a clean export script from scratch.
I created a new class library project and called it EmptyExportScript (placeholder). The target framework is .Net 4. The platform target is x86 and the output path is .....\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\. When debugging I would like to start the administration module so I set this path .......\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\.
The option "Make assembly COM-Visible" is checked and I added the Kofax.ReleaseLib.Interop.dll to the references.
For the KfxReleaseScript.cs I added this code
[ClassInterface(ClassInterfaceType.None)]
[ProgId("KFXTS.EmptyExportScript.KfxReleaseScript")]
public class KfxReleaseScript
{
public ReleaseData documentData;
// public KfxReturnValue OpenScript()
// public KfxReturnValue ReleaseDoc()
// public KfxReturnValue CloseScript()
}
For the KfxReleaseScriptSetup.cs I added this code
[ClassInterface(ClassInterfaceType.None)]
[ProgId("KFXTS.EmptyExportScript.KfxReleaseScriptSetup")]
public class KfxReleaseScriptSetup
{
public ReleaseSetupData setupData;
// public KfxReturnValue OpenScript()
// public KfxReturnValue CloseScript()
// public KfxReturnValue RunUI()
// public KfxReturnValue ActionEvent(KfxActionValue actionID, string data1, string data2)
}
Lastly I added a Form to the project when running the UI.
For registration I added a EmptyExportScript.inf with this content
[Scripts]
Empty Export
[Empty Export]
SetupModule=EmptyExportScript.dll
SetupProgID=KFXTS.EmptyExportScript.KfxReleaseScriptSetup
SetupVersion=10.2
ReleaseModule=EmptyExportScript.dll
ReleaseProgID=KFXTS.EmptyExportScript.KfxReleaseScript
ReleaseVersion=10.2
SupportsNonImageFiles=True
SupportsKofaxPDF=True
RemainLoaded=True
SupportsOriginalFileName=False
When building the project .dll and .inf file get placed into the kofax bin directory.
I recognized that other scripts have a .pdb and .dll.config file in there too.
How do I get them?
When trying to install the custom script, I can add it to the script installation manager but I can't install it. There is nothing to install so I think I'm missing the .pdb and .dll.config file.
Is anything else missing?
Thanks for help :)
Kofax does not need a pdb file, but they are handy if you want to debug your connector and attach it to the release.exe process (learn more about them here).
I would not recommend changing the output path itself to Capture\Bin, but rather create a post-build event:
For example, the following line copies all required files to a separate folder under the CaptureSS\Bin folder:
xcopy "$(TargetDir)*" "C:\Program Files (x86)\Kofax\CaptureSS\ServLib\Bin\SmartCAP\kec\SmartCAP.KEC.Template\" /Y /S
Having a dll.config file is possible, but rare. I would rather recommend storing process-specific data in a custom storage string object of the respective batch class definition (which has the added benefit that you can just import/export the definition along with the batch class, and that you can display and have it changed it in setup form). Having said all that, back to your initial issue - the connector can't be installed.
COM visibility
The assembly needs to be COM-visible, but you mentioned that it was. For the sake of completeness, here's what you will need to do. Note that the GUID must be unique (only relevant if you copied an existing solution):
If you're installing the connector on a different machine, you will need to register it first using regasm.exe - here's an example:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" SampleExport.dll /codebase /tlb:SampleExport.tlb
ProgIds
Then, your .inf file needs to contain the precise ProgIDs:
[Scripts]
SampleExport
[SampleExport]
SetupModule=SampleExport.dll
SetupProgID=SampleExport.Setup
SetupVersion=11.0
ReleaseModule=SampleExport.dll
ReleaseProgID=SampleExport
ReleaseVersion=11.0
SupportsNonImageFiles=True
SupportsKofaxPDF=True
Both your ReleaseScript.cs and ReleaseSetupScript.cs files need the correct attribute, for example:
[ProgId("SampleExport")]
public class ReleaseScript
If that all still does not work, please provide us with the detailed error message (to be found at CaptureSV\Logs).
I had to change the file format from UTF-8 to UTF-8 without BOM.
This worked for me.

How to run a cli script in pimcore

till Now I have been placing all my code within pimcore\cli\startup.php and it's run fine but when I'am trying in another way I getting error like
Class 'Website\ObjectExporter' not found in C:\xampp\htdocs\pimcore\website\var\cli\export-objects.php on line 7
How to run code in this way
For example create an ObjectExporter.php under /website/lib/Website folder with this content:
<?php
namespace Website;
class ObjectExporter
{
public function exportObjects()
{
// Your code
}
}
Then you can either instantiate this class in your controller action or in a CLI script. Controller actions are within /website/controllers folder and they need to be called through http: http://localhost?controller=default&action=default
Example: /website/controllers/DefaultController.php
<?php
class DefaultController extends Website_Controller_Action {
public function defaultAction () {
$this->disableViewAutoRender();
$objectExporter = new Website\ObjectExporter();
$objectExporter->exportObjects();
}
}
(You could also add your whole code directly into action, but that would be a bit ugly solution, it of course depends)
But better and quickest way to approach such tasks is with the CLI scripts.
I like to use the /website/var/cli folder (you need to create it manually, but the /website/var folder is excluded in .htaccess by default which makes it practical for such use cases).
Example: /website/var/cli/export-objects.php
<?php
$workingDirectory = getcwd();
chdir(__DIR__);
include_once("../../../pimcore/cli/startup.php");
chdir($workingDirectory);
$objectExporter = new Website\ObjectExporter();
$objectExporter->exportObjects();
Then just run it by issuing this command in your command line:
php website/var/cli/export-objects.php
This is the standard way of creating CLI scripts in pimcore:
https://www.pimcore.org/wiki/pages/viewpage.action?pageId=16854341
Basically it's just Symfony/Console, which is documented in here detail:
http://symfony.com/doc/current/components/console/introduction.html

Using $safeitemname$ in VS2012 Item Template causes value to appear as inheriting class also

Inside my template file I use the safeitemname template variable to define my class name. The Item Template is intended to create a class that subclasses MXApplication. The result after exporting the template and utilizing it to create a new class is essentially the class inherits from itself. If I try adding a namespace to the class, I just get the namespace prefixed before the value substituted for safeitemname.
Here is the Template class (trimmed for explanation purposes):
namespace $rootnamespace$
{
public class $safeitemname$ : MonoCross.Navigation.MXApplication
{
public override void OnAppLoad()
{
//Do the work
}
}
}
The result when I use the template to create MyApp is:
namespace MyNameSpace
{
public class MyApp : MonoCross.Navigation.MyApp
{
public override void OnAppLoad()
{
//Do the work
}
}
}
I've tried to export this template using VS2012 (and VS2013).
Any advice would be much appreciated. I've been trying to update my Item Templates in Visual Studio 2012 (they worked in 2010) but I keep running into this issue. I've tried it on several of my existing templates; and even tried recreating the .csproj and adding my existing templates to the .csprog file created using Visual Studio 2012. All of my attempts result in the same class inheritance issue.
This is the MSDN Doc I've been using for reference:
http://msdn.microsoft.com/en-us/library/vstudio/tsyyf0yh.aspx
The issue was apparent when looking at the .zip file created by the Export Template command. The .cs file contained within the template .zip read:
namespace $rootnamespace$
{
class $safeitemname$ : MonoCross.Navigation.$safeitemname$
{
public override void OnAppLoad()
{
//Do the work
}
}
}
The fix to get my template working was to edit the .cs file manually and replace the last $safeitemname$ with MXApplication and then stick the .cs file back in the .zip file where it came from.

Need a working example of configuring log4j RollingFileAppender via properties

I am using log4j for logging, and a property file for configuration. Currently, my log files are too big (3.5 GB is too large for a log file). So think I need to use RollingFileAppender - but when I do so the log file continues to grow overly large. I believe I have just misconfigured it; does anyone have a working example of configuring RollingFileAppender?
For the record, my current configuration looks like this:
log4j.appender.MAIN_LOG.File=${catalina.base}/logs/webtop.log
log4j.appender.MAIN_LOG=org.apache.log4j.RollingFileAppender
log4j.appender.MAIN_LOG.layout=com.mycompany.util.log.Log4JSimpleLayout
log4j.appender.MAIN_LOG.DatePattern='.'yyyy-MM-dd
log4j.appender.MAIN_LOG.MaxFileSize=10MB
log4j.appender.MAIN_LOG.MaxBackupIndex=99
log4j.appender.MAIN_LOG.append=true
log4j.rootCategory=ALL, MAIN_LOG
An alternative to RollingFileAppender would also be a fine solution.
I believe I have just misconfigured it; does anyone have a working example of configuring RollingFileAppender?
This seems to work fine for me #mcherm. See below.
Are you sure that you are using the log4j.properties that you think you are? Try changing the .File to another path to see if log output goes to the new file. What version of log4j are you using? I'm running 1.2.15.
Hope this helps.
I created the following test program:
package com.j256.ormlite;
import org.apache.log4j.Logger;
public class Foo {
private static Logger logger = Logger.getLogger(Foo.class);
public static void main(String[] args) {
for (int x = 0; x < 10000000; x++) {
logger.error("goodness this shouldn't be happening to us right here!!!!");
}
}
}
My log4j.properties file holds:
log4j.appender.MAIN_LOG=org.apache.log4j.RollingFileAppender
log4j.appender.MAIN_LOG.File=${catalina.base}/logs/webtop.log
log4j.appender.MAIN_LOG.layout=com.j256.ormlite.Log4JSimpleLayout
log4j.appender.MAIN_LOG.MaxFileSize=10MB
log4j.appender.MAIN_LOG.MaxBackupIndex=5
log4j.appender.MAIN_LOG.append=true
log4j.rootCategory=ALL, MAIN_LOG
Notice that I removed the DatePattern which wasn't valid for my RollingFileAppender. My layout is:
package com.j256.ormlite;
import org.apache.log4j.spi.LoggingEvent;
public class Log4JSimpleLayout extends org.apache.log4j.Layout {
#Override
public String format(LoggingEvent event) {
return "log message = " + event.getMessage().toString() + "\n";
}
#Override
public boolean ignoresThrowable() {
return true;
}
public void activateOptions() {
}
}
Running with -Dcatalina.base=/tmp/ I get files in /tmp/logs/ which go up to index #5 and are 10mb in size. If I tune the MaxFileSize or the MaxBackupIndex, it adjusts appropriately.
Your issue might be with the fact that you are specifying a DatePattern.
The DatePattern is meant to be used with the DailyRollingFileAppender to specify the date that the log file should roll.
I don't believe it can be used in conjunction with the MaxFileSize and MaxBackupIndex attributes.
Log4j lets you roll files based on file size or date but not both.
When we need log files to be rolled on a daily basis, we should be using DailyRollingFileAppender instead of RollingFileAppender.
You do not need to specify the MaxFileSize limit instead only DatePattern is enough for rolling files based on frequency.
I have tried the below configuration in log4j.properties file for rolling log files every minute.
log4j.appender.infoAppender=org.apache.log4j.DailyRollingFileAppender
log4j.appender.infoAppender.Threshold=INFO
log4j.appender.infoAppender.DatePattern='.' yyyy-MM-dd HH-mm
log4j.appender.infoAppender.File=C:/logs/info.log
Start by setting the -Dlog4j.debug JVM parameter. That prints out a few useful lines of debug information showing which config file it's found and is using, etc. That should give you some clues to what's going wrong.
See http://logging.apache.org/log4j/1.2/manual.html

Resources