Best way log BusinessOperation executions

StatusIDPriorityType
Closed37447MajorQuestion
ProfileReply
gabossoloClient

Hello -- Could you please help me on the best way log BusinessOperation executions.

Thank you!

Replies

UserDescriptionPosted On
MariyaVoytovichAgent

Hello gabossolo!

If you use Managed Business Operation, you can use Managed Operations logging.

For example:

[BusinessOperation(typeof(ChangeFreightContext))]
[DisplayName(@"Default implementation")]
[Description("Performs change of freight costs by a predetermined amount in%.")]
public class ChangeFreightContextDefaultImpl : OperationServiceBase
{
public override void Execute(IBusinessOperation businessOperation)
{
var bo = (ChangeFreightContext)businessOperation;
bo.Process.Name = bo.Name;var rate = (decimal)(bo.Percent / 100);if (bo.Orders == null || !bo.Orders.Any())
return;

using (var objectSpace = BusinessOperationManager.Instance.Application.CreateObjectSpace())
{
bo.Process.TotalStep = bo.Orders.Count;
var step = 0;
foreach (var rawOrder in bo.Orders)
{
var order = objectSpace.GetObject(rawOrder); // Order in the current ObjectSpace
if (order == null)
continue; // The Order is absent in the DB
var oldFreight = order.Freight;
order.Freight = order.Freight + (order.Freight * rate);
var msg = string.Format(Resources.Order, order.Number, oldFreight, order.Freight);
bo.Process.NextStep(msg, step);
bo.ProcessedOrdersLog.Add(msg);
step++;
}
objectSpace.CommitChanges();
}
}
}

Information for the log is transmitted using :

bo.Process.NextStep(msg, step);

To view the log, you need to click on the "Show log" button on the detailed view.

Feel free to contact us if you need further assistance or have additional questions.

Regards,
Mariya
On behalf of Xafari Client Services Team

× This ticket is closed.

Write US