Here is the relevant C# code we used to migrate from the CSV's into sugar.
AppendStringQuery argument 1 is the sugardb column name, the second argument is the column from CSV.
Code:
private void btnTaskCRM_Click(object sender, EventArgs e)
{
foreach (DataRow row in dttempMas.Rows)
{
ResetStringQuery();
string TaskID = row["ID"].ToString();
AppendStringQuery("id,", TaskID);
AppendStringQuery("name,", row["Subject"]);
AppendStringQuery("date_entered,", dateConvertforMysql(row["CreatedDate"].ToString()));
AppendStringQuery("date_modified,", dateConvertforMysql(row["LastModifiedDate"].ToString()));
AppendStringQuery("description,", row["Description"]);
AppendStringQuery("deleted,", row["IsDeleted"]);
AppendStringQuery("modified_user_id,", row["LastModifiedById"]);
AppendStringQuery("created_by,", row["CreatedById"]);
// TODO - Need to make sure task status picklist values exist already.
AppendStringQuery("status,", row["Status"]);
// TODO - Fix this value... probably should be date_start.
AppendStringQuery("date_start,", row["RecurrenceStartDateOnly"]);
// TODO - verify priority picklists exist.
AppendStringQuery("priority", row["Priority"]);
AppendStringQuery("assigned_user_id,", row["OwnerId"]);
AppendStringQuery("team_id",TEAM_ID);
AppendStringQuery("team_set_id",TEAM_SET_ID);
//AppendStringQuery("assigned_user_id,";
//AppendStringQuery("team_id,";
//AppendStringQuery("team_set_id,";
//AppendStringQuery("date_due_flag,";
//AppendStringQuery("date_due,";
//AppendStringQuery("date_start_flag,";
if (!row["WhoId"].ToString().Equals("000000000000000AAA"))
{
AppendStringQuery("contact_id", row["WhoId"]);
}
// TODO determine how Tasks are attached to just leads.
if (!String.IsNullOrEmpty(row["AccountId"].ToString()))
{
AppendStringQuery("parent_type", "Accounts");
AppendStringQuery("parent_id", row["AccountId"]);
}
Insertdata("tasks");
}
MessageBox.Show("Data Upload complete");
btnTask.Enabled = false;
btnTaskCRM.Enabled = false;
}
Bookmarks