This note describes wow to display product image after selecting the item in Ad-Hoc picking
There is a HookScript in the system that is triggered after selecting an item.
Item Configuration
I added a picture to the item in the Item master Data. I am going to load this filename and path from table ATC1inthescript.
Changing the Workflow script
Open the script of AdHocAfterItemToPickSelectedHookScript from Organizational Structure > Company object > Workflows tab, and replace the content of the script by the script below.
The Mobile Client application must be restarted.
I am using the IShowImageScreen in the script. This object will display the image.
TitleKey: set the title of the screen
MessageKey: adding text to the screen
ImagePath: defining the path of the picture
script:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Globalization;
using System.Reflection;
using System.Text;
using System.Transactions;
using Produmex.Foundation;
using Produmex.Foundation.Barcode;
using Produmex.Foundation.Data;
using Produmex.Foundation.Data.Sbo;
using Produmex.Foundation.Data.Sbo.BusinessObjects;
using Produmex.Foundation.Data.Sbo.BusinessObjects.Convertors;
using Produmex.Foundation.Data.Sbo.BusinessObjects.Definitions;
using Produmex.Foundation.Data.Sbo.BusinessObjects.Definitions.Tables;
using Produmex.Foundation.Data.Sbo.DataObjects;
using Produmex.Foundation.Data.Sbo.Providers;
using Produmex.Foundation.Data.Sbo.Utilities;
using Produmex.Foundation.Data.SqlClient;
using Produmex.Foundation.Diagnostics;
using Produmex.Foundation.GS1;
using Produmex.Foundation.Messages;
using Produmex.Foundation.SlimScreen;
using Produmex.Foundation.SlimScreen.Interfaces;
using Produmex.Foundation.SlimScreen.Interfaces.Definitions;
using Produmex.Foundation.SlimScreen.Interfaces.Definitions.DataObjects;
using Produmex.Foundation.SlimScreen.Interfaces.Definitions.KnownDataSets;
using Produmex.Foundation.SlimScreen.WinGui;
using Produmex.Foundation.Utilities;
using Produmex.Foundation.Workflows;
using Produmex.Foundation.Workflows.Parameters;
using Produmex.Foundation.Wwf.Sbo;
using Produmex.Foundation.Wwf.Sbo.DataObjects;
using Produmex.Foundation.Wwf.Sbo.LocalServices;
using Produmex.Sbo.Logex.Data.BusinessObjects;
using Produmex.Sbo.Logex.Data.BusinessObjects.Definitions;
using Produmex.Sbo.Logex.Data.BusinessObjects.Definitions.Tables;
using Produmex.Sbo.Logex.Data.DataObjects;
using Produmex.Sbo.Logex.Data.Devices;
using Produmex.Sbo.Logex.Data.Generators.BatchNumberGenerators;
using Produmex.Sbo.Logex.Data.Generators.PackingController;
using Produmex.Sbo.Logex.Data.Providers;
using Produmex.Sbo.Logex.Data.ViewObjects.Definitions.Views;
using Produmex.Foundation.Messages;
using Produmex.Foundation.SlimScreen;
using Produmex.Foundation.Wwf.Sbo.LocalServices;
namespace Produmex.Sbo.Logex.WorkflowScripts
{
public class WorkflowScript_AdHocAfterItemToPickSelectedHookScript : WorkflowInstanceScriptBase
{
private static readonly ILog s_log = LogProvider.GetLogger(MethodInfo.GetCurrentMethod().DeclaringType);
// Input parameters * do not change *
public ReadOnlyBinder<CultureInfo> DefaultCultureInfo;
public ReadOnlyBinder<PmxOseCompany> PmxOseCompany;
public ReadOnlyBinder<PmxItemInfo> ItemInfo;
public ReadOnlyBinder<int> PickListDocEntry;
public ReadOnlyBinder<string> PmxWhsCode;
public ReadOnlyBinder<DataRow> SelectedProductDataRow;
// Output parameters * do not change *
public ReadWriteBinder<bool> BackRequested;
// Sub-flows
// <none>
public WorkflowScript_AdHocAfterItemToPickSelectedHookScript(WorkflowInstanceBase parent, WorkflowInstanceFactory factory)
: base(parent, factory)
{
}
#region WorkflowInstanceScriptBase Members
protected override void Execute()
{
// Parameters in scope
Session session = GetScopeParameter("Session") as Session;
ISboProviderService sboProviderService = GetScopeParameter("<WwfService>ISboService") as ISboProviderService;
DataSet dsItemImage = null;
string query = BuildQuery.GetImagePath(ItemInfo.Get().ItemCode);
dsItemImage = sboProviderService.RunView(false, null, null, query);
if ( dsItemImage.Tables.Count > 0 )
{
Message msg = null;
session.ShowScreen(typeof(Produmex.Foundation.SlimScreen.Interfaces.IShowImageScreen),
this.DefaultCultureInfo, BuildParamCollection(
"TitleKey", "Picture of the product",
"MessageKey", ItemInfo.Get().ItemCode + " " + dsItemImage.Tables[0].Rows[0]["Attachment"].ToString(),
"ImagePath", dsItemImage.Tables[0].Rows[0]["Attachment"].ToString(),
"ShowButton", true
));
msg = WaitForMessage();
}
}
#endregion
#region BUILD QUERY
internal static class BuildQuery
{
public static string GetImagePath(string item)
{
return "select \"Attachment\" from OITM as A inner join ATC1 as B on A.\"AtcEntry\"=B.\"AbsEntry\" where A.\"ItemCode\" = '" + item + "'";
}
}
#endregion
}
}
Comments
0 comments
Please sign in to leave a comment.