Esempio n. 1
0
        private static void AddInfoToDataSet(DataSet data, IUserInfo info, string source,
                                             bool isModule, Guid guid, string tkx, string sessionId)
        {
            DataTable           infoTable = DataSetUtil.CreateDataTable(INFO_TABLE_NAME, INFO_ARRAY);
            DataTableCollection tables    = data.Tables;

            if (!tables.Contains(infoTable.TableName))
            {
                DataRow row = infoTable.NewRow();
                DataSetUtil.SetRowValues(row, INFO_ARRAY, info.UserId, info.MainOrgId,
                                         source, isModule ? 1 : 0, 0, guid, tkx, sessionId);
                infoTable.Rows.Add(row);
                tables.Add(infoTable);
            }
        }
Esempio n. 2
0
        public static DataSet ExcelImport(string strFileName, Tk5ListMetaData metaInfos, ImportError importError)
        {
            DataSet   dataSet   = new DataSet();
            DataTable dataTable = DataSetUtil.CreateDataTable(metaInfos.Table.TableName, metaInfos.Table.TableList);

            dataTable.Columns.Add("OriginalRowNum", typeof(int));

            IWorkbook workbook;
            ISheet    sheet;

            ExcelUtil.ReadExcle(strFileName, metaInfos.Table.TableDesc, out workbook, out sheet);

            SheetImport(metaInfos, dataTable, sheet, importError);
            dataSet.Tables.Add(dataTable);
            return(dataSet);
        }
Esempio n. 3
0
        public ImportResultData(Tk5ListMetaData metaData)
        {
            Key           = Guid.NewGuid().ToString();
            ImportDataSet = new DataSet(ToolkitConst.TOOLKIT)
            {
                Locale = ObjectUtil.SysCulture
            };
            ImportTable = DataSetUtil.CreateDataTable(metaData.Table.TableName,
                                                      metaData.Table.TableList);
            ImportTable.Columns.Add(ROW_INDEX, typeof(string));
            ImportDataSet.Tables.Add(ImportTable);
            var tableList = (from item in metaData.Table.TableList select item.NickName).ToArray();

            ErrorTable = DataSetUtil.CreateDataTable(metaData.Table.TableName, tableList);
            ErrorTable.Columns.Add(ROW_INDEX, typeof(string));
            fErrors = new Dictionary <Tuple <int, string>, string>();
        }
Esempio n. 4
0
        private static void AddUrlToDataSet(DataSet data, Uri retUrl, Uri selfUrl, Uri encodeSelfUrl)
        {
            DataTable urlTable = DataSetUtil.CreateDataTable(URL_TABLE_NAME, URL_ARRAY);

            DataTableCollection tables = data.Tables;

            if (!tables.Contains(urlTable.TableName))
            {
                DataRow row       = urlTable.NewRow();
                string  returl    = GetUrlValue(retUrl);
                string  selfurl   = GetUrlValue(selfUrl);
                string  encodeUrl = GetUrlValue(encodeSelfUrl);
                DataSetUtil.SetRowValues(row, URL_ARRAY, returl, selfurl,
                                         HttpUtility.UrlEncode(returl, Encoding.UTF8),
                                         HttpUtility.UrlEncode(encodeUrl, Encoding.UTF8));
                urlTable.Rows.Add(row);
                tables.Add(urlTable);
            }
        }
Esempio n. 5
0
        public static DataSet ExcelImport(string strFileName, Tk5ListMetaData metaInfos, ResultHolder resultHolder)
        {
            DataSet      dataSet      = new DataSet();
            DataTable    dataTable    = DataSetUtil.CreateDataTable(metaInfos.Table.TableName, metaInfos.Table.TableList);
            string       sheetName    = metaInfos.Table.TableDesc;
            HSSFWorkbook hssfworkbook = null;
            XSSFWorkbook xssfworkbook = null;
            ISheet       sheet        = null;

            string fileExt = Path.GetExtension(strFileName);

            using (FileStream file = new FileStream(strFileName, FileMode.Open, FileAccess.Read))
            {
                if (fileExt == ".xls")
                {
                    hssfworkbook = new HSSFWorkbook(file);
                }
                else if (fileExt == ".xlsx")
                {
                    xssfworkbook = new XSSFWorkbook(file);
                }
            }

            if (hssfworkbook != null)
            {
                sheet = hssfworkbook.GetSheet(sheetName);
            }
            else if (xssfworkbook != null)
            {
                sheet = xssfworkbook.GetSheet(sheetName);
            }

            SheetImport(metaInfos, dataTable, sheet, resultHolder);
            dataSet.Tables.Add(dataTable);
            return(dataSet);
        }