public get_entry_list_result GetContacts(string SessionId, sugarsoapPortTypeClient SugarSoap, string Query, string OrderBy, int Offset, int MaxResults, bool GetDeleted) { string[] fields = new string[] { "phone_work" }; //Get a list of entries get_entry_list_result contactsList = this.sugarClient.get_entry_list(this.sessionId, "Contacts", Query, OrderBy, Offset, fields, MaxResults, Convert.ToInt32(GetDeleted)); return(contactsList); }
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); }
public List <SugarEntry> GetEntryList(string module, string query, string order, int offset, string[] fields, int limit, int del) { module = ConvertToProper(module); get_entry_list_result result = _sugarsoap.get_entry_list(_session, module, query, order, offset, fields, limit, del); VerifySugarResult.Verify(result.error); var entryList = new List <SugarEntry>(); entry_value[] valueList1 = result.entry_list; foreach (entry_value value1 in valueList1) { name_value[] valueList2 = value1.name_value_list; var entry = new SugarEntry(module); foreach (name_value value2 in valueList2) { entry.Add(value2.name, value2.value); } entryList.Add(entry); } return(entryList); }
public get_entry_list_result get_entry_list(string session, string module_name, string query, string order_by, int offset, string[] select_fields, int max_results, int deleted) { Guid gUSER_ID = GetSessionUserID(session); Guid gTIMEZONE = Sql.ToGuid(HttpContext.Current.Cache.Get("soap.user.timezone." + gUSER_ID.ToString())); TimeZone T10n = TimeZone.CreateTimeZone(gTIMEZONE); if ( offset < 0 ) throw(new Exception("offset must be a non-negative number")); if ( max_results <= 0 ) throw(new Exception("max_results must be a postive number")); string sTABLE_NAME = VerifyModuleName(module_name); query = query.ToUpper(); order_by = order_by.ToUpper(); query = query .Replace(sTABLE_NAME + ".", String.Empty); order_by = order_by.Replace(sTABLE_NAME + ".", String.Empty); int nACLACCESS = Security.GetUserAccess(module_name, "list"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } get_entry_list_result results = new get_entry_list_result(); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; sSQL = "select *" + ControlChars.CrLf + " from " + sTABLE_NAME + ControlChars.CrLf + " where DELETED = @DELETED" + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { if ( !Sql.IsEmptyString(query) ) { // 02/16/2006 Paul. As much as I dislike the idea of allowing a query string, // I don't have the time to parse this. // 03/08/2006 Paul. Prepend the AND clause. sSQL += " and " + query + ControlChars.CrLf; } cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@DELETED", Math.Min(deleted, 1)); if ( nACLACCESS == ACL_ACCESS.OWNER ) { // 09/01/2006 Paul. Notes do not have an ASSIGNED_USER_ID. if ( sTABLE_NAME != "NOTES" ) Sql.AppendParameter(cmd, gUSER_ID, "ASSIGNED_USER_ID"); } try { CultureInfo ciEnglish = CultureInfo.CreateSpecificCulture("en-US"); using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; using ( DataTable dt = new DataTable() ) { da.Fill(dt); if ( dt.Rows.Count > 0 ) { // 02/16/2006 Paul. Don't sort in the database as it provides a hacker another attempt at SQL-Injection. // Bad sort values will just throw an exception here. DataView dv = new DataView(dt); dv.Sort = order_by; results.result_count = Math.Min(dt.Rows.Count - offset, max_results); results.next_offset = offset + results.result_count; // 02/20/2006 Paul. First initialize the array. results.field_list = new field [select_fields.Length]; results.entry_list = new entry_value[results.result_count]; for ( int i=0; i < select_fields.Length; i++ ) { string sColumnName = select_fields[i]; DataColumn col = dt.Columns[sColumnName]; // 02/20/2006 Paul. Then initialize each element in the array. // 02/16/2006 Paul. We don't have a mapping for the labels, so just return the column name. // varchar, bool, datetime, int, text, blob results.field_list[i] = new field(sColumnName.ToLower(), col.DataType.ToString(), sColumnName, 0); } // 02/16/2006 Paul. SugarCRM 3.5.1 returns all fields even though only a few were requested. We will do the same. int j = 0; foreach ( DataRowView row in dv ) { if ( j >= offset && j < offset + results.result_count ) { int nItem = j - offset; // 02/20/2006 Paul. Then initialize each element in the array. results.entry_list[nItem] = new entry_value(); results.entry_list[nItem].id = Sql.ToGuid(row["ID"]).ToString(); results.entry_list[nItem].module_name = module_name; // 02/20/2006 Paul. First initialize the array. results.entry_list[nItem].name_value_list = new name_value[dt.Columns.Count]; int nColumn = 0; foreach ( DataColumn col in dt.Columns ) { // 02/20/2006 Paul. Then initialize each element in the array. // 08/17/2006 Paul. We need to convert all dates to UniversalTime. if ( Information.IsDate(row[col.ColumnName]) ) { // 08/17/2006 Paul. The time on the server and the time in the database are both considered ServerTime. DateTime dtServerTime = Sql.ToDateTime(row[col.ColumnName]); // 08/17/2006 Paul. We need a special function to convert to UniversalTime because it might already be in UniversalTime, based on m_bGMTStorage flag. DateTime dtUniversalTime = T10n.ToUniversalTimeFromServerTime(dtServerTime); results.entry_list[nItem].name_value_list[nColumn] = new name_value(col.ColumnName.ToLower(), dtUniversalTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat)); } else { results.entry_list[nItem].name_value_list[nColumn] = new name_value(col.ColumnName.ToLower(), Sql.ToString(row[col.ColumnName])); } nColumn++; } } j++; } } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); throw(new Exception("SOAP: Failed get_entry_list", ex)); } } } return results; }