SIPSorcery.CRM.SugarCRM.SugarHelper.GetMeetings C# (CSharp) Method

GetMeetings() public method

public GetMeetings ( string SessionId, sugarsoapPortTypeClient SugarSoap, string Query, string OrderBy, int Offset, int MaxResults, bool GetDeleted ) : DataTable
SessionId string
SugarSoap sugarsoapPortTypeClient
Query string
OrderBy string
Offset int
MaxResults int
GetDeleted bool
return System.Data.DataTable
        public DataTable GetMeetings(string SessionId, sugarsoapPortTypeClient SugarSoap,
            string Query, string OrderBy, int Offset, int MaxResults, bool GetDeleted)
        {
            //Define the array
            string[] fields = new string[14];

            //Fill the array
            fields[0] = "id";
            fields[1] = "date_entered";
            fields[2] = "date_modified";
            fields[3] = "assigned_user";
            fields[4] = "modified_user";
            fields[5] = "created_by";
            fields[6] = "name";
            fields[7] = "location";
            fields[8] = "duration_hours";
            fields[9] = "duration_minutes";
            fields[10] = "date_start";
            fields[11] = "date_end";
            fields[12] = "status";
            fields[13] = "description";

            //Create a DataTable
            DataTable meetings = new DataTable("MEETINGS");

            //Define the Columns
            foreach (string field in fields)
            {
                meetings.Columns.Add(field);
            }

            //Get a list of entries
            get_entry_list_result entryList = this.sugarClient.get_entry_list(this.sessionId, "Meetings",
            Query, OrderBy, Offset, fields, MaxResults, Convert.ToInt32(GetDeleted));

            //Loop trough the entries
            foreach (entry_value entry in entryList.entry_list)
            {
                //Create a new DataRow
                DataRow meeting = meetings.NewRow();

                //Loop trough the columns
                foreach (name_value value in entry.name_value_list)
                {
                    meeting[value.name] = value.value;
                }

                //Add the DataRow to the DataTable
                meetings.Rows.Add(meeting);
            }

            return meetings;
        }

Usage Example

        public void GetMeetingsUnitTest()
        {
            //Create a new instance of the helper class
            SugarHelper helper = new SugarHelper();

            //Authenticate
            if (helper.Authenticate(m_username, m_password))
            {
                //Get the meetings
                DataTable meetings = helper.GetMeetings("", null, "", "", 0, 100, false);
                Console.WriteLine("Meetings count=" + meetings.Rows.Count + ".");
            }
        }