This is a migrated thread and some comments may be shown as answers.

User Function

2 Answers 63 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Mashran
Top achievements
Rank 1
Mashran asked on 09 Oct 2014, 03:31 AM
Hi, I have create a function

        public static double CallAge(string _status, string _sDate, string _eDate, string _last_update, string _report_datetime, string _total_holiday, string _total_hour)
        {
            if (_status == "6" || _status == "5" || _status == "4")
            {
                double Dys = 0, SatDys = 0, SunDys = 0;
                DateTime d1, d2, dateLastUpdate;
                TimeSpan timesp;
                d2 = Convert.ToDateTime(_eDate);
                d1 = Convert.ToDateTime(_report_datetime);
                dateLastUpdate = Convert.ToDateTime(_last_update);
                if (d2 < dateLastUpdate)
                {
                    timesp = (d2 - d1);
                    Dys = timesp.Seconds;
                    SatDys = findWeekCount(d1, d2, DayOfWeek.Saturday);
                    SunDys = findWeekCount(d1, d2, DayOfWeek.Sunday);
                    if (Dys > 0)
                    {
                        Dys = Dys - (checkHoliday(_total_holiday) + SatDys + SunDys) * 86400;
                        Dys = Dys - (timesp.Days - SatDys - SunDys - checkHoliday(_total_holiday) * Convert.ToDouble(_total_hour));
                        Math.Abs(Dys);
                        return Dys;
                    }
                    else
                    {
                        return 0;
                    }
                }
                else
                {
                    d2 = Convert.ToDateTime(_last_update);
                    d1 = Convert.ToDateTime(_report_datetime);
                    timesp = (d2 - d1);
                    Dys = timesp.Seconds;
                    SatDys = findWeekCount(d1, d2, DayOfWeek.Saturday);
                    SunDys = findWeekCount(d1, d2, DayOfWeek.Sunday);
                    if (Dys > 0)
                    {
                        Dys = ((checkHoliday(_total_holiday) + SatDys + SunDys) * 86400) - Dys;
                        Dys = Dys - ((timesp.Days - SatDys - SunDys - checkHoliday(_total_holiday) * Convert.ToDouble(_total_hour)));
                        Math.Abs(Dys);
                        return Dys;
                    }
                    else
                    {
                        return 0;
                    }
                }
            }
            else
            {
                return 0;
            }
        }


How to get field from store procedure?
I try like this on Expression Editor :

=TicketAge(Fields.STATUS,Parameters.sDate.Value,Parameters.eDate.Value,Fields.LAST_UPDATE,Fields.REPORT_DATETIME,Fields.TOTAL_HOLIDAY,Fields.TOTAL_HOUR)

But it display error : An error has occurred while processing TextBox 'textBox25': The expression contains undefined function call TicketAge().






2 Answers, 1 is accepted

Sort by
0
KS
Top achievements
Rank 1
answered on 13 Oct 2014, 08:24 AM
Hi,

Check this info - The expression contains undefined function call MyUserFunction() error. I believe it is the 3rd reason, and not all or some of the arguments are not of the expected type or are null.

-KS
0
Mashran
Top achievements
Rank 1
answered on 14 Oct 2014, 06:13 AM
Hi KS,

thanks for reply, and already solve my problem. The problem was came from datatype in database not match with datatype in user function.

public static double CallAge(string _status, string _sDate, string _eDate, string _last_update, string _report_datetime, string 

change to 

public static double CallAge(string _status, string _sDate, string _eDate, DateTime _last_update, DateTime _report_datetime, string 

Thanks a lot :)
Tags
General Discussions
Asked by
Mashran
Top achievements
Rank 1
Answers by
KS
Top achievements
Rank 1
Mashran
Top achievements
Rank 1
Share this question
or