private bool ReIDSteps(ref dataAccess.acTransaction oTrans, string sUserID, string sTaskID, ref string sErr) { //We join this to task_step on step_id, and only issue new GUID's //to the rows that are in conflict. //saves time, and if no steps are in conflict, the imported version is an exact match of the //exported one. //( and yes, I realize I did not join task_step on the task_id. // thats because the step_id is a guid AND the PK on the table. not necessary to check // it against task_id too.) oTrans.Command.CommandText = "select its.step_id" + " from import_task_step its" + " join task_step ts on its.step_id = ts.step_id" + " where its.user_id = '" + sUserID + "'" + " and its.task_id = '" + sTaskID + "'"; DataTable dtSteps = new DataTable(); if (!oTrans.ExecGetDataTable(ref dtSteps, ref sErr)) throw new Exception(sErr); if (dtSteps.Rows.Count > 0) { foreach (DataRow drSteps in dtSteps.Rows) { //update each row by: //*) getting a new guid //*) searching for references to the old ID and replacing them // specifically in function_xml //*) updating the row with the new guid string sOrigStepID = drSteps["step_id"].ToString(); string sNewStepID = ui.NewGUID(); //this will update any references in function_xml with // the new guid of this step oTrans.Command.CommandText = "update import_task_step" + " set function_xml = replace(function_xml, '" + sOrigStepID + "', '" + sNewStepID + "')" + " where ifnull(ExtractValue(function_xml, '(//*[. = ''" + sOrigStepID + "''])'), '') <> ''"; if (!oTrans.ExecUpdate(ref sErr)) throw new Exception(sErr); //then finally, we will update the actual step rows with the new id oTrans.Command.CommandText = "update import_task_step" + " set step_id = '" + sNewStepID + "'" + " where step_id = '" + sOrigStepID + "'"; if (!oTrans.ExecUpdate(ref sErr)) throw new Exception(sErr); } } return true; }