Esempio n. 1
0
        public static List <LeaveApp> GetLeaveApps()
        {
            var          leaveApps = new List <LeaveApp>();
            Axapta       ax;
            AxaptaRecord axRecord;

            try
            {
                // Login to Microsoft Dynamics AX.
                ax = new Axapta();
                ax.Logon(null, null, null, null);

                // Create a query using the AxaptaRecord class
                using (axRecord = ax.CreateAxaptaRecord(TABLE_NAME))
                {
                    // Execute the query on the table.
                    axRecord.ExecuteStmt("select * from %1 ");

                    while (axRecord.Found)
                    {
                        var leaveApp = new LeaveApp()
                        {
                            ApplicationId        = axRecord.get_Field(APPLICATION_ID).ToString(),
                            CreatedDateTime      = (DateTime)axRecord.get_Field(CREATE_DATETIME),
                            LeaveApplicationType = axRecord.get_Field(LEAVE_APP_TYPE).ToString(),
                            DefaultLeaveCode     = axRecord.get_Field(LEAVE_CODE).ToString(),
                            EmplId              = axRecord.get_Field(EMPLOYEE_ID).ToString(),
                            RequestedBy         = (long)axRecord.get_Field(REQUESTED_BY),
                            ScheduledLeaveDate  = (DateTime)axRecord.get_Field(SCH_LEAVE_DATE),
                            ScheduledReturnDate = (DateTime)axRecord.get_Field(SCH_RETURN_DATE),
                            Days             = (int)axRecord.get_Field(DAYS),
                            ApprovalStatus   = axRecord.get_Field(APPROVAL_STATUS).ToString(),
                            ExitVisaType     = axRecord.get_Field(EXIT_VISA_TYPE).ToString(),
                            Comments         = axRecord.get_Field(COMMENTS).ToString(),
                            CommentsApproval = axRecord.get_Field(COMMENTS_APPROVAL).ToString()
                        };
                        leaveApps.Add(leaveApp);
                        axRecord.Next();
                    }
                    return(leaveApps);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error encountered: {0}", ex.Message);
                throw;
            }
        }
Esempio n. 2
0
        public static void Print(LeaveApp item)
        {
            var jSON = new JavaScriptSerializer().Serialize(item);

            Console.WriteLine(jSON);
        }