public string[] doGetRelationships(string sSession, string sModule, string sID, string sRelMod, string sRelModQuery, int iDeleted) { sModule = this.doConvertToProper(sModule); SugarCRM.get_relationships_result oSugarRelRes = oSugarCRM.get_relationships(sSession, sModule, sID, sRelMod, sRelModQuery, iDeleted); SugarCRM.error_value oSugarErr = oSugarRelRes.error; if (oSugarErr.number != "0") { string[] sErrResults = new string[] { "Error: " + oSugarErr.number + "\r\n" + oSugarErr.description }; return(sErrResults); } SugarCRM.id_mod[] oSugarIDMods = oSugarRelRes.ids; string[] sResults = new string[oSugarIDMods.Length]; int iCounter = 0; foreach (SugarCRM.id_mod oSugarIDMod in oSugarIDMods) { sResults[iCounter] = oSugarIDMod.id; iCounter++; } return(sResults); }
public string[] doGetAvailableModules(string sSession) { SugarCRM.module_list oSugarModList = oSugarCRM.get_available_modules(sSession); SugarCRM.error_value oSugarErrVal = oSugarModList.error; int iLength = 1; if (oSugarModList.modules.Length > 0) { iLength = oSugarModList.modules.Length; } string[] saResults = new string[iLength]; if (oSugarErrVal.number == "0") { int iTemp = 0; foreach (string sModule in oSugarModList.modules) { saResults[iTemp] = sModule; iTemp++; } } else { saResults[0] = oSugarErrVal.number; } return(saResults); }
public string[,] doGetEntryList(string sSession, string sModule, string sQuery, string sOrder, int iOffset, string[] sFields, int iLimit, int iDel) { sModule = this.doConvertToProper(sModule); string[,] sResults = null; try { SugarCRM.get_entry_list_result oSugarGetListRes = oSugarCRM.get_entry_list(sSession, sModule, sQuery, sOrder, iOffset, sFields, iLimit, iDel); SugarCRM.error_value oSugarErrVal = oSugarGetListRes.error; if (oSugarErrVal.number != "0") { string[,] saErrResults = new string[1, 1]; saErrResults[0, 0] = oSugarErrVal.number; saErrResults[0, 1] = oSugarErrVal.description; return(saErrResults); } SugarCRM.entry_value[] oSugarListVals = oSugarGetListRes.entry_list; int iRows = oSugarGetListRes.result_count; int iColumns = sFields.Length + 1; //Additional column added to accommodate ID value sResults = new string[iRows, iColumns]; //Iterate through each row to process results int iRecords = 0; foreach (SugarCRM.entry_value oSugarEntryVal in oSugarListVals) { int iCounter = 1; SugarCRM.name_value[] oSugarNV = oSugarEntryVal.name_value_list; //First column on each row is always the ID value sResults[iRecords, 0] = oSugarEntryVal.id; //Iterate through the rest of the columns before moving to next record foreach (SugarCRM.name_value oSugarVal in oSugarNV) { sResults[iRecords, iCounter] = oSugarVal.value; iCounter++; } iRecords++; } } catch (Exception ex) { sResults = new string[1, 1]; sResults[0, 0] = "0"; } return(sResults); }
public string doRelateNoteToModule(string sSession, string sNoteID, string sModule, string sModuleID) { SugarCRM.error_value oSugarError = oSugarCRM.relate_note_to_module(sSession, sNoteID, sModule, sModuleID); string sErrNum = oSugarError.number; string sErrDesc = oSugarError.description; string sResult = "Error: " + sErrNum + "\n"; sResult += sErrDesc; return(sResult); }
public string doLogout(string sSession) { SugarCRM.error_value oSugarErrVal = oSugarCRM.logout(sSession); //Check if error occurred string sResult = "Logout Successful!"; if (oSugarErrVal.number != "0") { sResult = "Logout Error: "; sResult += oSugarErrVal.number + "\n"; sResult += oSugarErrVal.description; } return(sResult); }
public string doRelateRecord(string sSession, string sParent, string sParentID, string sChild, string sChildID) { string sResults = string.Empty; sParent = this.doConvertToProper(sParent); sChild = this.doConvertToProper(sChild); SugarCRM.set_relationship_value oSugarSetRelVal = new SugarCRM.set_relationship_value(); oSugarSetRelVal.module1 = sParent; oSugarSetRelVal.module1_id = sParentID; oSugarSetRelVal.module2 = sChild; oSugarSetRelVal.module2_id = sChildID; SugarCRM.error_value oSugarErrVal = oSugarCRM.set_relationship(sSession, oSugarSetRelVal); //TODO: Error checking/handling sResults = oSugarErrVal.number + ":" + oSugarErrVal.description; return(sResults); }
public string doSetEntry(string sSession, string sModule, string[] saNames, string[] saValues) { int iNVLength = saNames.Length; int iCounter = 0; string sResults = string.Empty; sModule = this.doConvertToProper(sModule); //Convert array to Sugar NV pairing SugarCRM.name_value[] oSugarNVList = new SugarCRM.name_value[iNVLength]; while (iCounter < iNVLength) { oSugarNVList[iCounter] = new SugarCRM.name_value(); oSugarNVList[iCounter].name = saNames[iCounter]; oSugarNVList[iCounter].value = saValues[iCounter]; iCounter++; } SugarCRM.set_entry_result oSugarSetEntryRes = null; try { oSugarSetEntryRes = oSugarCRM.set_entry(sSession, sModule, oSugarNVList); } catch (Exception ex) { sResults = "doSetEntry Error: " + ex.Message; return(sResults); } SugarCRM.error_value oSugarErrVal = oSugarSetEntryRes.error; if (oSugarErrVal.number != "0") { sResults = "Error Creating Record: " + oSugarErrVal.number + "\r\n" + oSugarErrVal.description; } else { sResults = oSugarSetEntryRes.id; } return(sResults); }