Example #1
0
        public bool Import(string sUserID, string sTaskIDs, ref string sErr)
        {
            string sSQL = "";

            dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

            //we're doing this in a loop
            //why?  because each row may have different import requirements
            //(overwrite, new version, etc.)

            //Now we are adding different import types not necessarily tied to task/proc.
            //for now we're still just doing it all here until there's a good reason to split it out


            if (sTaskIDs.Length > 0)
            {
                sSQL = "select task_id, task_code, task_name, import_mode from import_task" +
                       " where user_id = '" + sUserID + "'" +
                       " and task_id in (" + sTaskIDs + ")";

                DataTable dt = new DataTable();
                if (!dc.sqlGetDataTable(ref dt, sSQL, ref sErr))
                {
                    throw new Exception(sErr);
                }

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        string sTaskID     = dr["task_id"].ToString();
                        string sNewTaskID  = dr["task_id"].ToString();
                        string sTaskCode   = dr["task_code"].ToString();
                        string sImportMode = dr["import_mode"].ToString();
                        string sOTID       = "";
                        int    iCount      = 0;

                        switch (sImportMode)
                        {
                        case "New":
                            //just jam in the new row, IF there are no GUID conflicts.

                            //~~~ NEW tasks get manipulated.
                            //* MIGHT have their ID changed if there's a collision
                            //* WILL have the original_task_id reset
                            //* WILL have the version reset to 1.000
                            //* WILL be loaded as 'Development' status
                            //* WILL be the default version

                            //check ID
                            oTrans.Command.CommandText = "select count(*) from task" +
                                                         " where task_id = '" + sTaskID + "'";
                            if (!oTrans.ExecGetSingleInteger(ref iCount, ref sErr))
                            {
                                throw new Exception("Unable to check for GUID conflicts.<br />" + sErr);
                            }

                            //if there's a GUID conflict then just generate a new guid for this task.
                            if (iCount > 0)
                            {
                                sNewTaskID = ui.NewGUID();
                            }

                            //check the steps to see if there are any GUID conflicts
                            //and repair them if necessary
                            if (!ReIDSteps(ref oTrans, sUserID, sTaskID, ref sErr))
                            {
                                throw new Exception("Unable to issue new Step GUIDs.<br />" + sErr);
                            }

                            //insert the manipulated TASK
                            oTrans.Command.CommandText = "insert into task" +
                                                         " (task_id, original_task_id, version," +
                                                         " task_name, task_code, task_desc, task_status," +
                                                         " use_connector_system, default_version," +
                                                         " concurrent_instances, queue_depth, parameter_xml, created_dt)" +
                                                         " select" +
                                                         " '" + sNewTaskID + "', '" + sNewTaskID + "', 1.000," +
                                                         " task_name, task_code, task_desc, 'Development'," +
                                                         " use_connector_system, 1," +
                                                         " concurrent_instances, queue_depth, parameter_xml, created_dt" +
                                                         " from import_task" +
                                                         " where user_id = '" + sUserID + "'" +
                                                         " and task_id = '" + sTaskID + "'";
                            if (!oTrans.ExecUpdate(ref sErr))
                            {
                                throw new Exception(sErr);
                            }

                            ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewTaskID, dr["task_code"].ToString() + " - " + dr["task_name"].ToString(), "New - Created via Import");

                            break;



                        case "New Version":
                            //if it's a new version, we need to make sure the "original_task_id"
                            //is correct in the target database.
                            //(no guarantee the original_id in the source db is correct.)

                            //just jam in the new row, IF there are no GUID conflicts.

                            //~~~ NEW VERSION tasks get manipulated.
                            //* MIGHT have their ID changed if there's a collision
                            //* MIGHT have the original_task_id reset (to match the target)
                            //* WILL have the version reset to the user selection
                            //* WILL be loaded as 'Development' status
                            //* WILL NOT be the default version

                            //check ID
                            oTrans.Command.CommandText = "select count(*) from task" +
                                                         " where task_id = '" + sTaskID + "'";
                            if (!oTrans.ExecGetSingleInteger(ref iCount, ref sErr))
                            {
                                throw new Exception("Unable to check for GUID conflicts.<br />" + sErr);
                            }

                            //if there's a GUID conflict then just generate a new guid for this task.
                            //and re-id the steps
                            if (iCount > 0)
                            {
                                sNewTaskID = ui.NewGUID();
                            }

                            //check the steps to see if there are any GUID conflicts
                            //and repair them if necessary
                            if (!ReIDSteps(ref oTrans, sUserID, sTaskID, ref sErr))
                            {
                                throw new Exception("Unable to issue new Step GUIDs.<br />" + sErr);
                            }


                            //NOW, we need to make sure this task is connected to it's family
                            //we do this by ensuring the original_task_id matches.

                            //BUT, we got here by assuming the task_code was the key.
                            //so... find the original_task_id for this task_code
                            oTrans.Command.CommandText = "select original_task_id" +
                                                         " from task where task_code = '" + sTaskCode + "' limit 1";
                            if (!oTrans.ExecGetSingleString(ref sOTID, ref sErr))
                            {
                                throw new Exception("Unable to get original task ID for [" + sTaskCode + "].<br />" + sErr);
                            }


                            //insert the manipulated TASK
                            oTrans.Command.CommandText = "insert into task" +
                                                         " (task_id, original_task_id, version," +
                                                         " task_name, task_code, task_desc, task_status," +
                                                         " use_connector_system, default_version," +
                                                         " concurrent_instances, queue_depth, parameter_xml, created_dt)" +
                                                         " select" +
                                                         " '" + sNewTaskID + "', '" + sOTID + "', version," +
                                                         " task_name, task_code, task_desc, 'Development'," +
                                                         " use_connector_system, 0," +
                                                         " concurrent_instances, queue_depth, parameter_xml, created_dt" +
                                                         " from import_task" +
                                                         " where user_id = '" + sUserID + "'" +
                                                         " and task_id = '" + sTaskID + "'";

                            if (!oTrans.ExecUpdate(ref sErr))
                            {
                                throw new Exception(sErr);
                            }

                            ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewTaskID, dr["task_code"].ToString() + " - " + dr["task_name"].ToString(), "New Version - Created via Import");
                            break;

                        /*
                         * Note: I stopped here because I'm not convinced that "Overwrite" is a safe or useful
                         * feature.
                         *
                         * So, we'll come back to it if needed.
                         *
                         * Be aware, this was pseudocode... it never worked, was just placeholder stuff and ideas.
                         */



                        //case "Overwrite":
                        //    //stomp it, but make sure to set the task_id/original_task_id
                        //    //to match in the target db.
                        //    //just because the code matches doesn't mean the ID's do.

                        //    //we can just UPDATE the task row

                        //    //DON'T FORGET to DELETE the existing steps and codeblocks


                        //    //we need to make sure the "original_task_id"
                        //    //is correct in the target database.
                        //    //(no guarantee the original_id in the source db is correct.)


                        //    //~~~ OVERWRITE tasks get manipulated.
                        //    //* MIGHT have their ID changed to match the code/version being imported
                        //    //* MIGHT have the original_task_id reset (to match the target)
                        //    //* WILL have the version reset to the user selection
                        //    //* WILL be loaded as 'Development' status
                        //    //* MIGHT be the default version (not gonna update that value)

                        //    //NOW, we need to make sure this task is connected to it's family
                        //    //we do this by ensuring the original_task_id matches.

                        //    //BUT, we got here by assuming the task_code was the key.
                        //    //so... find the task AND original_task_id for this task_code
                        //    oTrans.Command.CommandText = "select top 1 task_id" +
                        //        " from task where task_code = '" + sTaskCode + "'";
                        //    if (!oTrans.ExecGetSingleString(ref sNewTaskID, ref sErr))
                        //        throw new Exception("Unable to get task ID for [" + sTaskCode + "].<br />" + sErr);
                        //    oTrans.Command.CommandText = "select top 1 original_task_id" +
                        //        " from task where task_code = '" + sTaskCode + "'";
                        //    if (!oTrans.ExecGetSingleString(ref sOTID, ref sErr))
                        //        throw new Exception("Unable to get original task ID for [" + sTaskCode + "].<br />" + sErr);

                        //    //get a datareader on the import_task row
                        //    sSQL = "select task_desc, manual_or_digital, use_connector_system," +
                        //        " concurrent_instances, queue_depth, parameter_xml, created_dt" +
                        //        " from import_task" +
                        //        " where user_id = '" + sUserID + "'" +
                        //        " and task_id = '" + sTaskID + "'";
                        //    OdbcDataReader drTaskRow = null;
                        //    if (!dc.sqlGetDataReader(ref drTaskRow, sSQL, ref sErr)) return false;

                        //    if (drTaskRow.HasRows)
                        //    {
                        //        //insert the manipulated TASK
                        //        //THIS WAS NEVER TESTED
                        //        oTrans.Command.CommandText = "update task" +
                        //            " set task_desc = ''," +
                        //            " manual_or_digital = ''," +
                        //            " use_connector_system = ''," +
                        //            " concurrent_instances = ''," +
                        //            " queue_depth = ''," +
                        //            " parameter_xml = ''," +
                        //            " created_dt = ''" +
                        //            " select" +
                        //            " '" + sNewTaskID + "', '" + sOTID + "', version," +
                        //            " task_name, task_code, task_desc, 'Development', manual_or_digital," +
                        //            " use_connector_system, 0," +
                        //            " concurrent_instances, queue_depth, parameter_xml, created_dt" +
                        //            " from import_task" +
                        //            " where user_id = '" + sUserID + "'" +
                        //            " and task_id = '" + sTaskID + "'";

                        //        if (!oTrans.ExecUpdate(ref sErr))
                        //            throw new Exception(sErr);
                        //    }


                        //    ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewTaskID, dr["task_code"].ToString() + " - " + dr["task_name"].ToString(), "Overwritten by Import");

                        //    break;
                        default:
                            break;
                        }



                        //CODEBLOCKS AND STEPS can be done here... they are just inserted
                        // (because they were manipulated already if needed)


                        //CODEBLOCKS
                        oTrans.Command.CommandText = "insert into task_codeblock" +
                                                     " (task_id, codeblock_name)" +
                                                     " select" +
                                                     " '" + sNewTaskID + "', codeblock_name" +
                                                     " from import_task_codeblock" +
                                                     " where user_id = '" + sUserID + "'" +
                                                     " and task_id = '" + sTaskID + "'";
                        if (!oTrans.ExecUpdate(ref sErr))
                        {
                            throw new Exception(sErr);
                        }

                        //STEPS
                        oTrans.Command.CommandText = "insert into task_step" +
                                                     " (step_id, task_id, codeblock_name, step_order, commented," +
                                                     " locked, function_name, function_xml, step_desc, output_parse_type," +
                                                     " output_row_delimiter, output_column_delimiter, variable_xml)" +
                                                     " select" +
                                                     " step_id, '" + sNewTaskID + "', codeblock_name, step_order, commented," +
                                                     " locked, function_name, function_xml, step_desc, output_parse_type," +
                                                     " output_row_delimiter, output_column_delimiter, variable_xml" +
                                                     " from import_task_step" +
                                                     " where user_id = '" + sUserID + "'" +
                                                     " and task_id = '" + sTaskID + "'";
                        if (!oTrans.ExecUpdate(ref sErr))
                        {
                            throw new Exception(sErr);
                        }
                    }
                }
                else
                {
                    sErr = "No Task import items were found.";
                    oTrans.RollBack();
                    return(false);
                }


                //whack those rows from the import table.
                //why?  their disposition has now changed, and we don't wanna accidentally reload them.
                //or add confusion to the user.
                oTrans.Command.CommandText = "delete from import_task where user_id = '" + sUserID + "' and task_id in (" + sTaskIDs + ")";
                if (!oTrans.ExecUpdate(ref sErr))
                {
                    throw new Exception(sErr);
                }

                oTrans.Command.CommandText = "delete from import_task_codeblock where user_id = '" + sUserID + "' and task_id in (" + sTaskIDs + ")";
                if (!oTrans.ExecUpdate(ref sErr))
                {
                    throw new Exception(sErr);
                }

                oTrans.Command.CommandText = "delete from import_task_step where user_id = '" + sUserID + "' and task_id in (" + sTaskIDs + ")";
                if (!oTrans.ExecUpdate(ref sErr))
                {
                    throw new Exception(sErr);
                }
            }

            //all done with everything... close it out
            oTrans.Commit();

            return(true);
        }
        private string CopyTask(int iMode, string sSourceTaskID, string sNewTaskName, string sNewTaskCode)
        {
            //iMode 0=new task, 1=new major version, 2=new minor version
            dataAccess dc = new dataAccess();
            acUI.acUI ui = new acUI.acUI();

            string sErr = "";
            string sSQL = "";

            string sNewTaskID = ui.NewGUID();

            int iIsDefault = 0;
            string sTaskName = "";
            double dVersion = 1.000;
            double dMaxVer = 0.000;
            string sOTID = "";

            //do it all in a transaction
            dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

            //figure out the new name and selected version
            oTrans.Command.CommandText = "select task_name, version, original_task_id from task where task_id = '" + sSourceTaskID + "'";
            DataRow dr = null;
            if (!oTrans.ExecGetDataRow(ref dr, ref sErr))
                throw new Exception("Unable to find task for ID [" + sSourceTaskID + "]." + sErr);

            sTaskName = dr["task_name"].ToString();
            dVersion = Convert.ToDouble(dr["version"]);
            sOTID = dr["original_task_id"].ToString();

            //figure out the new version
            switch (iMode)
            {
                case 0:
                    sTaskName = sNewTaskName;
                    iIsDefault = 1;
                    dVersion = 1.000;
                    sOTID = sNewTaskID;

                    break;
                case 1:
                    //gotta get the highest version
                    sSQL = "select max(version) from task where task_id = '" + sOTID + "'";
                    dc.sqlGetSingleDouble(ref dMaxVer, sSQL, ref sErr);
                    if (sErr != "")
                    {
                        oTrans.RollBack();
                        throw new Exception(sErr);
                    }

                    dVersion = dMaxVer + 1;

                    break;
                case 2:
                    sSQL = "select max(version) from task where task_id = '" + sOTID + "'" +
                        " and cast(version as unsigned) = " + Convert.ToInt32(dVersion);
                    dc.sqlGetSingleDouble(ref dMaxVer, sSQL, ref sErr);
                    if (sErr != "")
                    {
                        oTrans.RollBack();
                        throw new Exception(sErr);
                    }

                    dVersion = dMaxVer + 0.001;

                    break;
                default: //a iMode is required
                    throw new Exception("A mode required for this copy operation." + sErr);
            }

            //if we are versioning, AND there are not yet any 'Approved' versions,
            //we set this new version to be the default
            //(that way it's the one that you get taken to when you pick it from a list)
            if (iMode > 0)
            {
                sSQL = "select case when count(*) = 0 then 1 else 0 end" +
                    " from task where original_task_id = '" + sOTID + "'" +
                    " and task_status = 'Approved'";
                dc.sqlGetSingleInteger(ref iIsDefault, sSQL, ref sErr);
                if (sErr != "")
                {
                    oTrans.RollBack();
                    throw new Exception(sErr);
                }
            }

            //start copying
            oTrans.Command.CommandText = "create temporary table _copy_task" +
                " select * from task where task_id = '" + sSourceTaskID + "'";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //update the task_id
            oTrans.Command.CommandText = "update _copy_task set" +
                " task_id = '" + sNewTaskID + "'," +
                " original_task_id = '" + sOTID + "'," +
                " version = '" + dVersion + "'," +
                " task_name = '" + sTaskName + "'," +
                " default_version = " + iIsDefault.ToString() + "," +
                " task_status = 'Development'," +
                " created_dt = now()";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //update the task_code if necessary
            if (iMode == 0)
            {
                oTrans.Command.CommandText = "update _copy_task set task_code = '" + sNewTaskCode + "'";
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);
            }

            //codeblocks
            oTrans.Command.CommandText = "create temporary table _copy_task_codeblock" +
                " select '" + sNewTaskID + "' as task_id, codeblock_name" +
                " from task_codeblock where task_id = '" + sSourceTaskID + "'";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //USING TEMPORARY TABLES... need a place to hold step ids while we manipulate them
            oTrans.Command.CommandText = "create temporary table _step_ids" +
                " select distinct step_id, uuid() as newstep_id" +
                " from task_step where task_id = '" + sSourceTaskID + "'";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //steps temp table
            oTrans.Command.CommandText = "create temporary table _copy_task_step" +
                " select step_id, '" + sNewTaskID + "' as task_id, codeblock_name, step_order, commented," +
                " locked, function_name, function_xml, step_desc, output_parse_type, output_row_delimiter," +
                " output_column_delimiter, variable_xml" +
                " from task_step where task_id = '" + sSourceTaskID + "'";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //update the step id
            oTrans.Command.CommandText = "update _copy_task_step a, _step_ids b" +
                " set a.step_id = b.newstep_id" +
                " where a.step_id = b.step_id";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //update steps with codeblocks that reference a step (embedded steps)
            oTrans.Command.CommandText = "update _copy_task_step a, _step_ids b" +
                " set a.codeblock_name = b.newstep_id" +
                " where b.step_id = a.codeblock_name";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //spin the steps and update any embedded step id's in the commands
            oTrans.Command.CommandText = "select step_id, newstep_id from _step_ids";
            DataTable dtStepIDs = new DataTable();
            if (!oTrans.ExecGetDataTable(ref dtStepIDs, ref sErr))
                throw new Exception("Unable to get step ids." + sErr);

            foreach (DataRow drStepIDs in dtStepIDs.Rows)
            {
                oTrans.Command.CommandText = "update _copy_task_step" +
                    " set function_xml = replace(lower(function_xml), '" + drStepIDs["step_id"].ToString().ToLower() + "', '" + drStepIDs["newstep_id"].ToString() + "')" +
                    " where function_name in ('if','loop','exists')";
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);
            }

            //finally, put the temp steps table in the real steps table
            oTrans.Command.CommandText = "insert into task select * from _copy_task";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            oTrans.Command.CommandText = "insert into task_codeblock select * from _copy_task_codeblock";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            oTrans.Command.CommandText = "insert into task_step select * from _copy_task_step";
            if (!oTrans.ExecUpdate(ref sErr))
                throw new Exception(sErr);

            //finally, if we versioned up and we set this one as the new default_version,
            //we need to unset the other row
            if (iMode > 0 && iIsDefault == 1)
            {
                oTrans.Command.CommandText = "update task" +
                    " set default_version = 0" +
                    " where original_task_id = '" + sOTID + "'" +
                    " and task_id <> '" + sNewTaskID + "'";
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);
            }

            oTrans.Commit();

            return sNewTaskID;
        }
Example #3
0
        public bool Import(string sUserID, string sTaskIDs, ref string sErr)
        {
            string sSQL = "";

            dataAccess.acTransaction oTrans = new dataAccess.acTransaction(ref sErr);

            //we're doing this in a loop
            //why?  because each row may have different import requirements
            //(overwrite, new version, etc.)

            //Now we are adding different import types not necessarily tied to task/proc.
            //for now we're still just doing it all here until there's a good reason to split it out

            if (sTaskIDs.Length > 0)
            {
                sSQL = "select task_id, task_code, task_name, import_mode from import_task" +
                    " where user_id = '" + sUserID + "'" +
                    " and task_id in (" + sTaskIDs + ")";

                DataTable dt = new DataTable();
                if (!dc.sqlGetDataTable(ref dt, sSQL, ref sErr))
                    throw new Exception(sErr);

                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        string sTaskID = dr["task_id"].ToString();
                        string sNewTaskID = dr["task_id"].ToString();
                        string sTaskCode = dr["task_code"].ToString();
                        string sImportMode = dr["import_mode"].ToString();
                        string sOTID = "";
                        int iCount = 0;

                        switch (sImportMode)
                        {
                            case "New":
                                //just jam in the new row, IF there are no GUID conflicts.

                                //~~~ NEW tasks get manipulated.
                                //* MIGHT have their ID changed if there's a collision
                                //* WILL have the original_task_id reset
                                //* WILL have the version reset to 1.000
                                //* WILL be loaded as 'Development' status
                                //* WILL be the default version

                                //check ID
                                oTrans.Command.CommandText = "select count(*) from task" +
                                    " where task_id = '" + sTaskID + "'";
                                if (!oTrans.ExecGetSingleInteger(ref iCount, ref sErr))
                                    throw new Exception("Unable to check for GUID conflicts.<br />" + sErr);

                                //if there's a GUID conflict then just generate a new guid for this task.
                                if (iCount > 0)
                                {
                                    sNewTaskID = ui.NewGUID();
                                }

                                //check the steps to see if there are any GUID conflicts
                                //and repair them if necessary
                                if (!ReIDSteps(ref oTrans, sUserID, sTaskID, ref sErr))
                                    throw new Exception("Unable to issue new Step GUIDs.<br />" + sErr);

                                //insert the manipulated TASK
                                oTrans.Command.CommandText = "insert into task" +
                                    " (task_id, original_task_id, version," +
                                    " task_name, task_code, task_desc, task_status," +
                                    " use_connector_system, default_version," +
                                    " concurrent_instances, queue_depth, parameter_xml, created_dt)" +
                                    " select" +
                                    " '" + sNewTaskID + "', '" + sNewTaskID + "', 1.000," +
                                    " task_name, task_code, task_desc, 'Development'," +
                                    " use_connector_system, 1," +
                                    " concurrent_instances, queue_depth, parameter_xml, created_dt" +
                                    " from import_task" +
                                    " where user_id = '" + sUserID + "'" +
                                    " and task_id = '" + sTaskID + "'";
                                if (!oTrans.ExecUpdate(ref sErr))
                                    throw new Exception(sErr);

                                ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewTaskID, dr["task_code"].ToString() + " - " + dr["task_name"].ToString(), "New - Created via Import");

                                break;

                            case "New Version":
                                //if it's a new version, we need to make sure the "original_task_id"
                                //is correct in the target database.
                                //(no guarantee the original_id in the source db is correct.)

                                //just jam in the new row, IF there are no GUID conflicts.

                                //~~~ NEW VERSION tasks get manipulated.
                                //* MIGHT have their ID changed if there's a collision
                                //* MIGHT have the original_task_id reset (to match the target)
                                //* WILL have the version reset to the user selection
                                //* WILL be loaded as 'Development' status
                                //* WILL NOT be the default version

                                //check ID
                                oTrans.Command.CommandText = "select count(*) from task" +
                                    " where task_id = '" + sTaskID + "'";
                                if (!oTrans.ExecGetSingleInteger(ref iCount, ref sErr))
                                    throw new Exception("Unable to check for GUID conflicts.<br />" + sErr);

                                //if there's a GUID conflict then just generate a new guid for this task.
                                //and re-id the steps
                                if (iCount > 0)
                                    sNewTaskID = ui.NewGUID();

                                //check the steps to see if there are any GUID conflicts
                                //and repair them if necessary
                                if (!ReIDSteps(ref oTrans, sUserID, sTaskID, ref sErr))
                                    throw new Exception("Unable to issue new Step GUIDs.<br />" + sErr);

                                //NOW, we need to make sure this task is connected to it's family
                                //we do this by ensuring the original_task_id matches.

                                //BUT, we got here by assuming the task_code was the key.
                                //so... find the original_task_id for this task_code
                                oTrans.Command.CommandText = "select original_task_id" +
                                    " from task where task_code = '" + sTaskCode + "' limit 1";
                                if (!oTrans.ExecGetSingleString(ref sOTID, ref sErr))
                                    throw new Exception("Unable to get original task ID for [" + sTaskCode + "].<br />" + sErr);

                                //insert the manipulated TASK
                                oTrans.Command.CommandText = "insert into task" +
                                    " (task_id, original_task_id, version," +
                                    " task_name, task_code, task_desc, task_status," +
                                    " use_connector_system, default_version," +
                                    " concurrent_instances, queue_depth, parameter_xml, created_dt)" +
                                    " select" +
                                    " '" + sNewTaskID + "', '" + sOTID + "', version," +
                                    " task_name, task_code, task_desc, 'Development'," +
                                    " use_connector_system, 0," +
                                    " concurrent_instances, queue_depth, parameter_xml, created_dt" +
                                    " from import_task" +
                                    " where user_id = '" + sUserID + "'" +
                                    " and task_id = '" + sTaskID + "'";

                                if (!oTrans.ExecUpdate(ref sErr))
                                    throw new Exception(sErr);

                                ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewTaskID, dr["task_code"].ToString() + " - " + dr["task_name"].ToString(), "New Version - Created via Import");
                                break;

                            /*
                             Note: I stopped here because I'm not convinced that "Overwrite" is a safe or useful
                             feature.

                             So, we'll come back to it if needed.

                             Be aware, this was pseudocode... it never worked, was just placeholder stuff and ideas.
                             */

                            //case "Overwrite":
                            //    //stomp it, but make sure to set the task_id/original_task_id
                            //    //to match in the target db.
                            //    //just because the code matches doesn't mean the ID's do.

                            //    //we can just UPDATE the task row

                            //    //DON'T FORGET to DELETE the existing steps and codeblocks

                            //    //we need to make sure the "original_task_id"
                            //    //is correct in the target database.
                            //    //(no guarantee the original_id in the source db is correct.)

                            //    //~~~ OVERWRITE tasks get manipulated.
                            //    //* MIGHT have their ID changed to match the code/version being imported
                            //    //* MIGHT have the original_task_id reset (to match the target)
                            //    //* WILL have the version reset to the user selection
                            //    //* WILL be loaded as 'Development' status
                            //    //* MIGHT be the default version (not gonna update that value)

                            //    //NOW, we need to make sure this task is connected to it's family
                            //    //we do this by ensuring the original_task_id matches.

                            //    //BUT, we got here by assuming the task_code was the key.
                            //    //so... find the task AND original_task_id for this task_code
                            //    oTrans.Command.CommandText = "select top 1 task_id" +
                            //        " from task where task_code = '" + sTaskCode + "'";
                            //    if (!oTrans.ExecGetSingleString(ref sNewTaskID, ref sErr))
                            //        throw new Exception("Unable to get task ID for [" + sTaskCode + "].<br />" + sErr);
                            //    oTrans.Command.CommandText = "select top 1 original_task_id" +
                            //        " from task where task_code = '" + sTaskCode + "'";
                            //    if (!oTrans.ExecGetSingleString(ref sOTID, ref sErr))
                            //        throw new Exception("Unable to get original task ID for [" + sTaskCode + "].<br />" + sErr);

                            //    //get a datareader on the import_task row
                            //    sSQL = "select task_desc, manual_or_digital, use_connector_system," +
                            //        " concurrent_instances, queue_depth, parameter_xml, created_dt" +
                            //        " from import_task" +
                            //        " where user_id = '" + sUserID + "'" +
                            //        " and task_id = '" + sTaskID + "'";
                            //    OdbcDataReader drTaskRow = null;
                            //    if (!dc.sqlGetDataReader(ref drTaskRow, sSQL, ref sErr)) return false;

                            //    if (drTaskRow.HasRows)
                            //    {
                            //        //insert the manipulated TASK
                            //        //THIS WAS NEVER TESTED
                            //        oTrans.Command.CommandText = "update task" +
                            //            " set task_desc = ''," +
                            //            " manual_or_digital = ''," +
                            //            " use_connector_system = ''," +
                            //            " concurrent_instances = ''," +
                            //            " queue_depth = ''," +
                            //            " parameter_xml = ''," +
                            //            " created_dt = ''" +
                            //            " select" +
                            //            " '" + sNewTaskID + "', '" + sOTID + "', version," +
                            //            " task_name, task_code, task_desc, 'Development', manual_or_digital," +
                            //            " use_connector_system, 0," +
                            //            " concurrent_instances, queue_depth, parameter_xml, created_dt" +
                            //            " from import_task" +
                            //            " where user_id = '" + sUserID + "'" +
                            //            " and task_id = '" + sTaskID + "'";

                            //        if (!oTrans.ExecUpdate(ref sErr))
                            //            throw new Exception(sErr);
                            //    }

                            //    ui.WriteObjectAddLog(Globals.acObjectTypes.Task, sNewTaskID, dr["task_code"].ToString() + " - " + dr["task_name"].ToString(), "Overwritten by Import");

                            //    break;
                            default:
                                break;
                        }

                        //CODEBLOCKS AND STEPS can be done here... they are just inserted
                        // (because they were manipulated already if needed)

                        //CODEBLOCKS
                        oTrans.Command.CommandText = "insert into task_codeblock" +
                            " (task_id, codeblock_name)" +
                            " select" +
                            " '" + sNewTaskID + "', codeblock_name" +
                            " from import_task_codeblock" +
                            " where user_id = '" + sUserID + "'" +
                            " and task_id = '" + sTaskID + "'";
                        if (!oTrans.ExecUpdate(ref sErr))
                            throw new Exception(sErr);

                        //STEPS
                        oTrans.Command.CommandText = "insert into task_step" +
                            " (step_id, task_id, codeblock_name, step_order, commented," +
                            " locked, function_name, function_xml, step_desc, output_parse_type," +
                            " output_row_delimiter, output_column_delimiter, variable_xml)" +
                            " select" +
                            " step_id, '" + sNewTaskID + "', codeblock_name, step_order, commented," +
                            " locked, function_name, function_xml, step_desc, output_parse_type," +
                            " output_row_delimiter, output_column_delimiter, variable_xml" +
                            " from import_task_step" +
                            " where user_id = '" + sUserID + "'" +
                            " and task_id = '" + sTaskID + "'";
                        if (!oTrans.ExecUpdate(ref sErr))
                            throw new Exception(sErr);

                    }
                }
                else
                {
                    sErr = "No Task import items were found.";
                    oTrans.RollBack();
                    return false;
                }

                //whack those rows from the import table.
                //why?  their disposition has now changed, and we don't wanna accidentally reload them.
                //or add confusion to the user.
                oTrans.Command.CommandText = "delete from import_task where user_id = '" + sUserID + "' and task_id in (" + sTaskIDs + ")";
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);

                oTrans.Command.CommandText = "delete from import_task_codeblock where user_id = '" + sUserID + "' and task_id in (" + sTaskIDs + ")";
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);

                oTrans.Command.CommandText = "delete from import_task_step where user_id = '" + sUserID + "' and task_id in (" + sTaskIDs + ")";
                if (!oTrans.ExecUpdate(ref sErr))
                    throw new Exception(sErr);
            }

            //all done with everything... close it out
            oTrans.Commit();

            return true;
        }