Beispiel #1
0
        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);
        }
Beispiel #2
0
 public lbItem(sforce.sObject item, string[] textFields)
 {
     //
     // TODO: Add constructor logic here
     //
     this.item       = item;
     this.textFields = textFields;
 }
Beispiel #3
0
 public static sforce.sObject[] RowsToObjects(System.Data.DataSet ds)
 {
     try
     {
         System.Collections.ArrayList flds    = new System.Collections.ArrayList();
         System.Xml.XmlDocument       xdoc    = new System.Xml.XmlDocument();
         sforce.sObject[]             records = new sforce.sObject[ds.Tables[0].Rows.Count];
         for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
         {
             sforce.sObject record = new sforce.sObject();
             record.type = ds.Tables[0].TableName;
             for (int j = 0; j < ds.Tables[0].Columns.Count; j++)
             {
                 if (!ds.Tables[0].Columns[j].ReadOnly)
                 {
                     if (ds.Tables[0].Rows[i][ds.Tables[0].Columns[j].ColumnName] != null && ds.Tables[0].Rows[i][ds.Tables[0].Columns[j].ColumnName] != DBNull.Value)
                     {
                         System.Xml.XmlElement xEl = xdoc.CreateElement(ds.Tables[0].Columns[j].ColumnName);
                         if (ds.Tables[0].Columns[j].DataType == typeof(System.DateTime))
                         {
                             xEl.InnerText = FormatISO861((DateTime)ds.Tables[0].Rows[i][ds.Tables[0].Columns[j].ColumnName]);
                         }
                         else
                         {
                             xEl.InnerText = ds.Tables[0].Rows[i][ds.Tables[0].Columns[j].ColumnName].ToString();
                         }
                         flds.Add(xEl);
                     }
                 }
                 else if (ds.Tables[0].Columns[j].ColumnName.Equals("Id"))
                 {
                     record.Id = ds.Tables[0].Rows[i][ds.Tables[0].Columns[j].ColumnName].ToString();
                 }
             }
             System.Xml.XmlElement[] xarray = new System.Xml.XmlElement[flds.Count];
             flds.CopyTo(xarray);
             record.Any = xarray;
             records[i] = record;
         }
         return(records);
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex.Message);
         return(null);
     }
 }