FlowHeater Demo Video
 
FlowHeater - The Data Import / Export Specialist
 
Welcome, Guest
Username: Password: Remember me
See also the general examples available, which may answer your question: Hello World 1 / 2 / 3 , format numbers as character strings , simple If-Then-Else , complex If-Then-ElseIf , filtering and grouping data , consolidate grouped values
  • Page:
  • 1

TOPIC:

Parameters 1 month 3 days ago #3632

I'm using this .NET Script heater (Execute Per Row) and it seems to be working fine:
public object DoWork()
{
    if (InValues.Length == 0)
    throw new ArgumentException("min. 1 input parameters expected!");
    
    DateTime mydate = (DateTime)InValues[0].GetDateTime();    //order date
    bool prior2 = (bool)InValues[1].GetBool();                             //prior to 2pm
    int myday = (int)mydate.DayOfWeek;
    int ret = 1;
    int days = 1;

    switch (myday)
    {
        case 5: //friday add 3 days if after 2pm
            if (prior2 == false)
                ret = 3;
                break;
        case 6: //saturday add 2 days
            ret = 2;
            break;
    }
    //set flowheater parameter days to advance export date
      Parameter["days"].Value = ret;
    return null;
}
The problem is with the parameter $days$ in the number value field in the AddDays heater.
I get this error on the first row:

H: AddDays    The value [$days$] could not be converted into a number.

If I'm unable to use the parameter in the AddDays heater would I be able to calculate the date add in the .NET heater and return that value?
 

Please Log in or Create an account to join the conversation.

Parameters 1 month 3 days ago #3633

Usually “Each row Heaters” should be executed before common heaters are processed. But in case you using conditions ( IF-THEN-ELSE Heater ) or for example Set Parameter Heater and this chain triggers the AddDays Heater the FlowHeater Parameter DAYS isn´t right initialized. In this case you´re always using the calculated DAYS from the previous record!

If modified your script, see below. Now the .NET Script Heater returns the calculated date. Please have a look to the attached example.

File Attachment:

File Name: script-add...8-14.zip
File Size:8 KB


C# .NET AddDays script example
public object DoWork()
{
    if (InValues.Length == 0)
    throw new ArgumentException("min. 1 input parameters expected!");
    
    DateTime mydate = (DateTime)InValues[0].GetDateTime();    //order date
    bool prior2 = (bool)InValues[1].GetBool();                             //prior to 2pm
    int myday = (int)mydate.DayOfWeek;
    int ret = 1;
    int days = 1;

    switch (myday)
    {
        case 5: //friday add 3 days if after 2pm
            if (prior2 == false)
                ret = 3;
                break;
        case 6: //saturday add 2 days
            ret = 2;
            break;
    }

    return mydate.AddDays(ret);
}
Best wishes
Robert Stark

Did this answer your question? We would be grateful if you provide a brief comment as feedback. It may also help others who may have encountered a similar problem.
Attachments:

Please Log in or Create an account to join the conversation.

Last edit: by FlowHeater-Team.

Parameters 1 month 21 hours ago #3634

Thanks Robert,

The .NET Script got me where I needed to be.

JD

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.156 seconds

other Languages

de

FlowHeater Home

de en

Imprint/Contact

Privacy Statement

Copyright © 2009-2021 by FlowHeater GmbH.
All rights reserved.

Follow us on

twitter  facebook

YouTube

 de en