Exemple #1
0
        public static String Pack(String cTABLE_ID, DataTable dtRows, String cRootDir, String cSYSID)
        {
            List <ExportObject> arKeys        = new List <ExportObject>();
            DataTable           dtFieldConfig = DbManager.QueryData("SELECT FIELD_NAME,ISKEY FROM S_ETL_FIELD WHERE TABLE_ID='" + cTABLE_ID + "'");

            for (int j = 0; (dtRows != null) && (j < dtRows.Rows.Count); j++)
            {
                ExportObject vo = new ExportObject();
                vo.TABLE_ID = cTABLE_ID;
                vo.SYS_ID   = cSYSID;
                String cKEY_ID = StringEx.getString(dtRows, 0, "ID").ToUpper();
                for (int k = 0; (dtFieldConfig != null) && (k < dtFieldConfig.Rows.Count); k++)
                {
                    String cFieldName  = StringEx.getString(dtFieldConfig, k, "FIELD_NAME").ToUpper();
                    String cFieldValue = StringEx.getString(dtRows, j, cFieldName);
                    vo.AddFieldValue(cFieldName, Base64.StrToBase64(cFieldValue));
                }
                String cFileID_List = StringEx.getString(dtRows, 0, "FILES_ID").ToUpper();
                if (cFileID_List.Length > 0)
                {
                    String[] File_List = cFileID_List.Split(',');
                    cFileID_List = "";
                    for (int i = 0; i < File_List.Length; i++)
                    {
                        if (cFileID_List == "")
                        {
                            cFileID_List = "'" + File_List[i] + "'";
                        }
                        else
                        {
                            cFileID_List = cFileID_List + "," + "'" + File_List[i] + "'";
                        }
                    }

                    DataTable dtFiles = DbManager.QueryData("SELECT ID,TEXT,URL FROM S_UPLOAD WHERE ID in (" + cFileID_List + ")");
                    for (int k = 0; (dtFiles != null) && (k < dtFiles.Rows.Count); k++)
                    {
                        String cID       = StringEx.getString(dtFiles, k, "ID").ToUpper();
                        String cText     = StringEx.getString(dtFiles, k, "TEXT").ToUpper();
                        String cUrl      = StringEx.getString(dtFiles, k, "URL").ToUpper();
                        String cFileName = cRootDir + cUrl.Replace("/", "\\");
                        if (File.Exists(cFileName))
                        {
                            vo.AddFileValue(cID, cText, cUrl, Base64.StrToBase64(cFileName));
                        }
                    }
                }
                arKeys.Add(vo);
            }
            return(JsonLib.ToJSON(arKeys));
        }