Пример #1
0
        private ListDataRow readRow(IRow xlRow)
        {
            ListDataRow row = new ListDataRow();

            //            for (int i = 0; i < xlRow.LastCellNum; i++)
            foreach (ColumnDef colDef in _columnMaps)
            {
                if (colDef.ExcelColNum < 0)
                {
                    row.Add(colDef.Name, null);
                    continue;
                }
                ICell  cell  = xlRow.GetCell(colDef.ExcelColNum);
                string value = cell == null ? null : cell.ToString();
                if (colDef.Type.Equals("datetime", StringComparison.OrdinalIgnoreCase))
                {
                    DateTime d;
                    if (DateTime.TryParse(value, out d))
                    {
                        value = d.ToString();
                    }
                    else if (DateTime.TryParse(value, CultureInfo.CreateSpecificCulture("en-US"), DateTimeStyles.AssumeLocal, out d))
                    {
                        value = d.ToString();
                    }
                }
                if (colDef.Type.Equals("numeric", StringComparison.OrdinalIgnoreCase))
                {
                    double d = 0;
                    double.TryParse(value, out d);
                    value = "0";
                }

                row.Add(colDef.Name, value);
                if (colDef.IsPriKey)
                {
                    row.Add(XSqlBuilder.OLD_VERSION_PIX + colDef.Name, value);
                }
            }
            return(row);
        }
Пример #2
0
        public List <ListDataRow> getFiles(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                path = "\\";
            }
            string physicalPath = getPhysicalPath(path);

            List <ListDataRow> ret = new List <ListDataRow>();

            foreach (string file in Directory.GetFiles(physicalPath))
            {
                string fileName = Path.GetFileName(file);

                ListDataRow row = new ListDataRow();
                row.Add("name", fileName);
                row.Add("createTime", File.GetCreationTime(file).ToString());
                row.Add("lastAccess", File.GetLastAccessTime(file).ToString());
                row.Add("lastWrite", File.GetLastWriteTime(file).ToString());
                ret.Add(row);
            }
            return(ret);
        }
Пример #3
0
        public string post()
        {
            ListDataRow row = new ListDataRow();

            foreach (string fld in this.Request.Form.AllKeys)
            {
                row.Add(fld, Request.Form[fld]);
            }

            DataSource ds = getDataSourse();

            //  bool isNew = DataSource.isNewRow(row);
            //  ds.updateRow(row);

            DataSourceSchema dss = ds.getSchema();

            foreach (string fld in Request.Files.Keys)
            {
                HttpPostedFile file = Request.Files[fld];
                if (file != null && file.ContentLength > 0)
                {
                    string fileName = Path.GetFileName(file.FileName);
                    fileName = ds.getFieldFolder(fld) + fileName;
                    file.SaveAs(fileName);
                    string virPath = XSite.DataFileVirPath + fileName.Remove(0, XSite.DataFilePath.Length).Replace("\\", "/");
                    //row.Add(fld, virPath);
                    string fname = fld;
                    if (fname.StartsWith("file_"))
                    {
                        fname = fld.Remove(0, 5);
                    }
                    row[fname] = virPath;
                }
            }
            //  if (isNew)
            ds.updateRow(row);
            _row = row;

            return(draw(null));
        }
Пример #4
0
        public ListData drillTable(string table, string fk, List <string> parentMembers)
        {
            if (string.IsNullOrEmpty(table))
            {
                table = this.table.name;
            }
            if (string.IsNullOrEmpty(fk))
            {
                fk = this.primaryKey;
            }

            EasyUiGridData grid = new EasyUiGridData();
            StringBuilder  sql  = new StringBuilder();

            //纬度表
            sql.Append("Select ");
            sql.Append(this.primaryKey);
            sql.Append(" Into #t ");
            sql.Append(" From  ");
            sql.Append(this.table.name);
            int           memberPathCount;
            StringBuilder sbWhere = getDrillWhere(parentMembers, out memberPathCount);

            if (sbWhere.Length > 0)
            {
                sql.Append(" Where ");
                sql.Append(sbWhere);
            }
            sql.Append(" Group By ");
            sql.Append(primaryKey);
            sql.Append(";");

            //事实表
            sql.Append(" Select ");
            sql.Append(table);
            sql.Append(".* From ");
            sql.Append(table);
            sql.Append(",");
            sql.Append("#t");
            sql.Append(" Where ");
            sql.Append(table);
            sql.Append(".");
            sql.Append(fk);
            sql.Append("=#t.");
            sql.Append(primaryKey);


            ListData ret = new ListData();

            DatabaseAdmin dba = DatabaseAdmin.getInstance(this.table.connection);
            DataTable     tb  = dba.executeTable(sql.ToString());

            ret.total = tb.Rows.Count;
            ret.rows  = new List <ListDataRow>();
            foreach (DataRow dRow in tb.Rows)
            {
                ListDataRow row = new ListDataRow();
                foreach (DataColumn col in tb.Columns)
                {
                    row.Add(col.ColumnName, dRow[col].ToString());
                }
                ret.rows.Add(row);
            }
            return(ret);
        }