public FileStreamResult GetUasCsv()
        {
            string paramFileId = Request["fileId"] as string;

            Debug.WriteLine("* * *  ExportController GetUasCsv fileId: " + paramFileId);
            int fileId = 0;

            try
            {
                fileId = Convert.ToInt32(paramFileId);
            }
            catch (Exception exptn)
            {
                Debug.WriteLine("* * *  ExportController GetUasCsv Exception: " + exptn.Message);
            }
            Debug.WriteLine("* * *  ExportController GetUasCsv fileId: " + fileId.ToString());

            IUasSql uasSql    = new UasSql();
            string  tableName = uasSql.GetUasTableName(fileId);

            if (String.IsNullOrEmpty(tableName))
            {
                string errMsg = "Error: Invalid fileId: " + paramFileId;
                return(ProcessError(errMsg));
            }

            Debug.WriteLine("   Connection: " + uasSql.GetConnectionString());

            string sqlQuery = getUASQuery(tableName);

            return(CreateCsvStream(uasSql.GetConnectionString(), sqlQuery));
        }
        //private static void AddHiddenField(IFormsRepository formsRepo, def_FormResults formResult, string fieldName, string value)
        //{
        //    int itemId = formsRepo.GetItemByIdentifier(SIS_HIDDEN).itemId;

        //    def_ItemResults itemResult = formsRepo.GetItemResultByFormResItem(formResult.formResultId, itemId);

        //    def_ResponseVariables relatedFormResultRV = null;

        //    try
        //    {
        //        relatedFormResultRV = formsRepo.GetResponseVariablesByFormResultIdentifier(formResult.formResultId, fieldName);
        //    }
        //    catch (Exception ex)
        //    {
        //        Console.WriteLine(ex.Message);
        //    }

        //    def_ItemVariables itemVariableRelated = formsRepo.GetItemVariableByIdentifier(fieldName);


        //    if (itemVariableRelated != null)
        //    {

        //        if (relatedFormResultRV != null)
        //        {
        //            relatedFormResultRV.rspValue = value;

        //            formsRepo.ConvertValueToNativeType(itemVariableRelated, relatedFormResultRV);
        //        }
        //        else
        //        {
        //            relatedFormResultRV = new def_ResponseVariables();

        //            relatedFormResultRV.itemResultId = itemResult.itemResultId;

        //            relatedFormResultRV.itemVariableId = itemVariableRelated.itemVariableId;

        //            relatedFormResultRV.rspValue = value;

        //            formsRepo.ConvertValueToNativeType(itemVariableRelated, relatedFormResultRV);

        //            formsRepo.AddResponseVariableNoSave(relatedFormResultRV);

        //        }

        //    }

        //    formsRepo.Save();
        //}



        private static void CopyAssessmentData(IFormsRepository formsRepo, int oldFormResultId, def_FormResults copyFormResult)
        {
            try
            {
                IUasSql uasSql = new UasSql();

                using (DbConnection connection = new SqlConnection(uasSql.GetConnectionString()))
                {
                    connection.Open();

                    using (DbCommand command = connection.CreateCommand())
                    {
                        command.CommandText
                            = "SELECT IR.itemId, RV.itemVariableId, RV.rspValue from def_ItemResults IR JOIN def_FormResults FR on FR.formResultId = IR.formResultId JOIN def_ResponseVariables RV on RV.itemResultId = IR.itemResultId WHERE FR.formResultId = " + oldFormResultId + " ORDER BY itemId";
                        command.CommandType = CommandType.Text;
                        DataTable dt = new DataTable();
                        dt.Load(command.ExecuteReader());

                        if (dt != null)
                        {
                            SaveAssessmentFromDataTable(formsRepo, copyFormResult, dt);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("* * *  CreateFormResultJSON exception: " + ex.Message);
            }
        }