Blog

Here I document some issues for searching of which I spent more then 15 minutes

  • How to override part of C# code in Automation Steps in Acumatica

    Hello everybody,

    today I want to share one interesting gotcha which took plenty of efforts from mine side in order to understand it.

    Recently I got an assignment to modify behaviour of Create Prepayment action at purchase orders. 

    If to look at CreatePreapyment implementation, it has following part of code:

    if (this.Document.Current == null)

      return;

    this.Save.Press();

    APInvoiceEntry instance = PXGraph.CreateInstance<APInvoiceEntry>();

    if (this.Document.Current.PrepaymentRefNbr == null)

    {

    if to put simply it checks if current purchase order already has a prepayment, and in case if it has, then give to a user error message. 

    Imagine, that you need to modify that behaviour for … more

  • How to override Create Prepayment in Acumatica without usage of custom delegate

    Hello everybody,

    today I want to share with you on how to override Action CreatePrepayment in Acumatica.

    General rule of overriding methods in Acumatica according to T300 manual is like this:

    Create delegate.

    Add [PXOverride] over your method which is named exactly as base method ( in our case CreatePrepayment )

    Add your implementation

    For example you can achieve it like this:

    //Create your delegate

    public delegate void CreatePrepaymentDelegate();

    [PXOverride]

    public void CreatePrepayment(CreatePrepaymentDelegate baseDel)

    {

        // your code of overriding

    }

    Way from manual T300 is perfectly workable, but  I propose you to use feature of .Net which is named Action, … more

  • Creating custom Autonumber which will be auto generated ID in Acumatica

    If you want to create custom Attribute for autonumbering field you need:

    Create Setup page for configuring autonumbering field or maybe you can use existing

    Create Attribute which you'll add to your entity

    Add attribute to field that you need increment 

    Create Setup page for configuration autonumbering field

    Setup.cs like this:

    [System.SerializableAttribute()]

        [PXPrimaryGraph(typeof(CurrencyMaint))]

        [PXCacheName("Your company Preferences")]

        public class Setup : PX.Data.IBqlTable

        {

            #region DocumentRefNbr

            public abstract class documentRefNbr : PX.Data.IBqlField

            {

            }

            protected string _DocumentRefNbr;

            [ … more

  • Entity Framework one to many relationship

    Hello everybody,

    today I want to make short post on how to confiugre one to many relationship in Entity Framework 6.

    Imagine following: One group can have multiple students. So one to many relationship. For this purpose you can use following convention configuration agreement:

    public class Student

    {

        public int StudentId { get; set; }

        public string StudentName { get; set; }

    }

    public class Group

    {

        public int GroupId { get; set; }

        public string GroupName { get; set; }

        public string Department { get; set; }

        public List<Student> Students { get; set; }

    }

    In presented example class group includes navigation property Students. 

    Another convention is … more

  • Complete description of arguments in jForex submitOrder

    Hello everybody,

    here I want to leave fragment of code related to submitOrder:

    public void onStart(IContext context) throws JFException {

    IEngine engine = context.getEngine();

    IHistory history = context.getHistory();

    Instrument instrument = Instrument.EURUSD;

    context.setSubscribedInstruments(java.util.Collections.singleton(instrument), true);

    ITick lastTick = history.getLastTick(instrument);

    double price = lastTick.getAsk() + instrument.getPipValue() * 5;

    double sl = lastTick.getAsk() - instrument.getPipValue() * 20;

    double tp = lastTick.getAsk() + instrument.getPipValue() * 10;

    long gtt = lastTick.getTime() + TimeUnit.SECONDS. … more

  • New class in Acumatica: PXImpersonationContext

    Hello everybody,

    here I want to document new scope in Acumatica: PXImpersonationContext. 

    As often is the case try to look at presented code:

    var thr = new Thread(

                                       () =>

                                       {

                                           try

                                           {

                                               using (new PXImpersonationContext(PX.Data.Update.PXInstanceHelper.ScopeUser)).

    .

    .

    }

                                foreach (var thread in threads)

                                {

                                    lock (thisLock)

                                    {

                                        thread.Start();

          … more

  • Manage serialization in .Net Core 2.0

    Hello everybody,

    today I want to write a short notice on how to manage uppercase/lowercase options for serialization in .Net Core.

    In mine practice I often had situation, when javascript or typescript code sends me some staff in lowercase class names, but in C# I'm used to Upper case class names. 

    Another option that you sometime can need is switching between xml and json serialization. How those options can be managed in .Net Core 2.0 ?

    For both of those options ( and even more ) you can use pipeline management of Startup class of ConfigureServices method.

    For example if you need to have xml serialization output you can use following code:

    public class Startup

        {

            // This  … more

  • Some notes on Jira usage

    Hello everybody,

    today I want to make a short recording of the following video: Introduction to Jira & Agile and Project management.

    Actually I just want to have short text version of Dan Chuparkoff's  advices.

    Task is something that is bigger then 30 minutes but smaller then 3 days to complete. It is practical don't have tasks that take more then one day to do.

    You can't wait in the middle of the task. If you are waiting in the middle of the task, then take another look, maybe you have series of tasks. 

    You can be in three modes: in progress, done, not started.

    Estimating is hard, but use estimates. And use story points, not the hours. 

    There are different kinds of story points.  … more

  • Ridge regression in C# with help of Math .Net Numerics

    Hello everybody,

    today I want to share a piece of code that took me almost few months of learning in order to implement it. It is Ridge regression. Below goes code that gives you weights for Ridge regression:

    public double[] RidgeRegression(double[][] xTrain, double[] yTrain, double lambda = 0.1)

    {

        var M = Matrix<double>.Build;

        var x = M.DenseOfRowArrays(xTrain);

        

        var ones = Vector<double>.Build.Dense(x.RowCount, 1);

        x = x.InsertColumn(0, ones);

        var y = Vector<double>.Build.DenseOfArray(yTrain);

        var xt = x.Transpose();

        var lambdaIdentity = lambda * M.DenseIdentity(x.ColumnCount);

        var sumDot = xt.Multiply(x) + lambdaIdentity;

        var  … more

  • Linear regression behavior with free weight

    Hello everybody,

    recently I've decided to implement some ML library in C#. But mine ultimate goal of that C# library was to make it use as much as possible TPL features of C#. 

    I'm aware about other ML libraries, but as often is said, if you wish to understand how some ML algorithm works, program it by yourself. I've decided to start with Linear regression.

    Here you can see how mine library utilizes processor:

    as you can see it uses 85% of mine 4-cores CPU, which is impossible with only one thread running.

    First step for me was to understand how that algorithm works. In order to understand it I've took course Machine Learning Specializationfrom University of Washington.

    I'll omit … more

General information

Greetings to everybody stopping at my blog. Purpose of this web site is to be google of my brain. Everything I found useful, or of possible beneficial for usage in future I've save here at this blog

Contact information

If you want to contact me more on any subject printed at this web stie, you can email me: zaletskiy(at)gmail.com

Job information

If to speak in general, I'm developer. For now I work as team lead in company GlobalLogic.