I have not seen anyone else on the web do this, and I spent a couple days trying to figure this out.
Given an out of box Sharepoint Approval workflow, I wanted to be able to update the Approval task programmatically, and have the status update to Approved or Rejected as appropriate.
Simple, right? Not so much. You can't update the task directly, and there is no documentation to speak of on the workflow.
I compared the extended properties of an approved & rejected task and found out that the internals of the workflow use the following symbols to represent the Approved and Rejected state:
Approved = "#"
Rejected = "@"
Makes perfect sense!!!! Good grief...
Anyway, here's what you really want: the code.
SPListItem task = pendingItem.Tasks[1]; // Modify this code to get the most recent task in case an item is edited
Hashtable data = new Hashtable();
data["Comments"] = "whoop de do";
data["PercentComplete"] = 1.0f;
data["Completed"] = "TRUE";
data["Status"] = "Completed";
// Use one or the other
data["TaskStatus"] = "@"; // Rejected
data["TaskStatus"] = "#"; // Approved
SPWorkflowTask.AlterTask(task, data, true);