public DataTable GetMyDefectsData() { string soqlQuery = "Select Description__c, " + " Escalation_ID__c, Name, OwnerId, " + " Priority__c, " + " Escalation_Status__c, Summary__c, Support_Product__c " + "from Problem_Management_Escalation__c where Support_Product__c in ('OneSite Affordable', 'OneSite Tax Credits', 'OneSite Leasing and Rents Rural Housing') " + "and OwnerId ='00537000002yoU5AAI' order by Name desc"; try { sforce.QueryResult qr = SalesForcePartner.binding.query( soqlQuery); if (qr.size > 0) { DataTable dt = CreateDataTable(ParseFieldList(soqlQuery), qr); return(dt); } else { return(null); } } catch (Exception ex) { return(null); //throw ex; } }
private DataTable GetHighPriorityDefectsSOQL() { try { string soqlQuery = "Select Description__c, " + " Escalation_ID__c, Name, OwnerId, " + " Priority__c, " + " Escalation_Status__c, Summary__c, Support_Product__c " + "from Problem_Management_Escalation__c where Priority__c ='P2 - High' and Support_Product__c in ('OneSite Affordable', 'OneSite Tax Credits', 'OneSite Leasing and Rents Rural Housing') " + " order by Name desc"; //this.btnMore.Visible = false; //PartnerSample.binding.QueryOptionsValue = new sforce.QueryOptions(); //PartnerSample.binding.QueryOptionsValue.batchSize = Convert.ToInt16(Application.UserAppDataRegistry.GetValue("batchSize", "500")); //PartnerSample.binding.QueryOptionsValue.batchSizeSpecified = true; sforce.QueryResult qr = SalesForcePartner.binding.query( soqlQuery); if (qr.size > 0) { DataTable dt = CreateDataTable(ParseFieldList(soqlQuery), qr); return(dt); } else { return(null); //System.Windows.Forms.MessageBox.Show("No records matched query.", "Patner Sample", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } } catch (Exception ex) { return(null); //System.Windows.Forms.MessageBox.Show("Query failed: " + ex.Message, "Partner Sample", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } }
private DataTable GetOverallNewDefectsSOQL() { try { string soqlQuery = "Select Description__c, " + " Escalation_ID__c, Name, OwnerId, " + " Priority__c, " + " Escalation_Status__c, Summary__c, Support_Product__c " + "from Problem_Management_Escalation__c where Escalation_Status__c='New' and Support_Product__c in ('OneSite Affordable', 'OneSite Tax Credits', 'OneSite Leasing and Rents Rural Housing') " + " order by Name desc"; sforce.QueryResult qr = SalesForcePartner.binding.query( soqlQuery); if (qr.size > 0) { DataTable dt = CreateDataTable(ParseFieldList(soqlQuery), qr); return(dt); } else { return(null); //System.Windows.Forms.MessageBox.Show("No records matched query.", "Patner Sample", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } } catch (Exception ex) { return(null); //System.Windows.Forms.MessageBox.Show("Query failed: " + ex.Message, "Partner Sample", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information); } }
private DataTable CreateDataTable(ArrayList fieldList, sforce.QueryResult qr) { DataTable dt = new DataTable(); for (int i = 0; i < fieldList.Count; i++) { dt.Columns.Add(fieldList[i].ToString()); } for (int i = 0; i < qr.records.Length; i++) { DataRow dr = dt.NewRow(); sforce.sObject record = qr.records[i]; if (dr.Table.Columns.Contains("ID")) { dr["Id"] = record.Id; } for (int j = 0; j < record.Any.Length; j++) { System.Xml.XmlElement xEl = (System.Xml.XmlElement)record.Any[j]; dr[xEl.LocalName] = xEl.InnerText; } dt.Rows.Add(dr); } return(dt); }
public static void LoadDataTable(sforce.QueryResult qr, System.Data.DataTable dt) { sforce.sObject[] records = qr.records; for (int i = 0; i < records.Length; i++) { System.Data.DataRow dr = dt.NewRow(); if (records[i].Id != null) { dr["Id"] = records[i].Id; } System.Xml.XmlElement[] fields = records[i].Any; for (int j = 0; j < fields.Length; j++) { if (!fields[j].LocalName.Equals("type")) { if (fields[j].InnerText.Length > 0) { dr[fields[j].LocalName] = fields[j].InnerText; } else if (!dr.Table.Columns[fields[j].LocalName].AllowDBNull) { if (dr.Table.Columns[fields[j].LocalName].DataType.Equals(typeof(System.DateTime))) { dr[fields[j].LocalName] = System.DateTime.Now; } else if (dr.Table.Columns[fields[j].LocalName].DataType.Equals(typeof(System.Double))) { dr[fields[j].LocalName] = 0.0; } else if (dr.Table.Columns[fields[j].LocalName].DataType.Equals(typeof(System.Int32))) { dr[fields[j].LocalName] = 0; } else { dr[fields[j].LocalName] = "(missing)"; } } } } dt.Rows.Add(dr); } }
private DataTable GetSearchedDataSOQL(string search) { //Cursor = Cursors.WaitCursor; try { string soqlQuery = "Select Description__c, " + " Escalation_ID__c, Name, OwnerId, " + " Priority__c, Problem_Mgmt_Action_Pending_Date__c, Related_PME__c, " + " Escalation_Status__c, Summary__c, Support_Product__c " + "from Problem_Management_Escalation__c where Support_Product__c in ('OneSite Affordable', 'OneSite Tax Credits', 'OneSite Leasing and Rents Rural Housing') " + "order by Name desc"; sforce.QueryResult qr = SalesForcePartner.binding.query( soqlQuery); if (qr.size > 0) { String[] words = search .Split(s_Separators, StringSplitOptions.RemoveEmptyEntries) .Where(word => !s_StopWords.Contains(word)) .ToArray(); // Combine back: "I go school" String result = String.Join(" ", words); DataTable dt = CreateDataTable(ParseFieldList(soqlQuery), qr); //string[] words = search.Split(' '); string[] sentences = Regex.Split(search, @"(?<=[.!?])\s+(?=\p{Lt})"); DataTable dtResult = new DataTable(); DataTable dtDescriptionQuery = new DataTable(); if (dt == null) { return(null); } DataTable dtSummaryQuery = new DataTable(); if (dt.Select("Summary__c LIKE '%" + search + "%'").Count() > 0) { dtSummaryQuery = dt.Select("Summary__c LIKE '%" + search + "%'").CopyToDataTable(); } DataTable dtOutput = new DataTable(); for (int i = 0; i <= words.Length - 1; i++) { if (dt.Select("Description__c LIKE '%" + words[i] + "%'") != null) { dt = dt.Select("Description__c LIKE '%" + words[i] + "%'").CopyToDataTable(); if (dt.Rows.Count < 20) { dtDescriptionQuery.Merge(dt); break; } } } DataTable dtResultsData = new DataTable(); if (dtSummaryQuery.Rows.Count >= 1) { dtResult.Merge(dtSummaryQuery); } if (dtDescriptionQuery.Rows.Count >= 1) { dtResult.Merge(dtDescriptionQuery); } if (dtResult.Rows.Count > 1) { dtResult.DefaultView.Sort = "Name desc"; dtResultsData = dtResult.DefaultView.ToTable(); } return(dtResultsData); } else { return(null); } } catch (Exception ex) { return(null); } }