/// <summary>
 /// 提交
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     //建表
     DataTableEntity modelDT = new DataTableEntity { Name = txtName.Text };
     DataTableManage.Create(DB, modelDT);
     string[] arrName= Request.Form.GetValues("txtColumnName");
     string[] arrType=Request.Form.GetValues("ddlType");
     string[] arrLength=Request.Form.GetValues("txtLength");
     for (int i = 0; i < arrName.Length; i++)
     {
         if (!string.IsNullOrEmpty(arrName[i]))
         {
             DataColumnEntity modelDC = new DataColumnEntity
             {
                 Name = arrName[i],
                 Type = EColumnType.User,
                 DataType = WhqDatabase.Kernel.DataContent.ContentType.GetType(Convert.ToInt32(arrType[i])),
                 DataLength = Convert.ToInt32(arrLength[i])
             };
             //重复判断
             if (modelDT.UserColumns.Count(info => arrName[i] == info.Name) > 0)
             {
                 JScript.ShowMessage(this, "存在重名列");
                 DataTableManage.Delete(modelDT);
                 return;
             }
             DataColumnManage.Create(modelDT, modelDC);
         }
     }
     JScript.ResponseScript(this, "alert('建表成功!');location='DatabaseInfo.aspx?DatabaseID=" + DB.ID + "'");
 }
 /// <summary>
 /// 创建
 /// </summary>
 public static void Create(DataTableEntity modelDT, DataColumnEntity modelDC)
 {
     //赋值
     modelDC.ColumnPage = modelDT.ColumnPage;
     modelDC.Table = modelDT;
     //生成编号
     if (modelDC.Type == EColumnType.RowIndex)
     {
         modelDC.ID = 0;
     }
     else
     {
         modelDC.ID = modelDT.Columns.Max(info => info.ID) + 1;
     }
     //列信息编号
     modelDC.ContentPageID = DataFileManage.GetEmptyPageID(modelDT.DataFile);
     //写入列
     modelDC.ColumnPage.Columns.Add(modelDC);
     modelDC.ColumnPage.DataPage.Content = modelDC.ColumnPage.ToBytes();
     DataPageManage.Write(modelDC.ColumnPage.DataPage);
     //表用户列
     if (modelDC.Type == EColumnType.User)
     {
         modelDT.UserColumns.Add(modelDC);
     }
     //创建数据分页
     byte[] array = new byte[Config.PAGE_SIZE];
     array[0] = Convert.ToByte(EPageType.DataContent);
     DataPageManage.Write(new DataPageEntity { DataFile = modelDT.DataFile, ID = modelDC.ContentPageID, Content = array });
     //更新文件
     DataFileManage.Update(modelDT.DataFile);
 }
        public void ContentCreate()
        {
            WhqHelper.DatabaseInit();
            DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
            DataTableManage.Create(WhqHelper.modelD, modelDT);
            DataColumnEntity modelDC2 = new DataColumnEntity { Name = "ID", Type = EColumnType.User, DataType = EContentType.Int, DataLength = 4 };
            DataColumnEntity modelDC3 = new DataColumnEntity { Name = "Name", Type = EColumnType.User, DataType = EContentType.String, DataLength = 0x100 };
            DataColumnManage.Create(modelDT, modelDC2);
            DataColumnManage.Create(modelDT, modelDC3);
            //添加内容
            int RowIndex = DataContentManage.GetFirstEmpty(modelDT).GetRowIndex();
            DataContentManage.Create(modelDT.Columns[0], new DataContentEntity { Content = 1 }, RowIndex);
            DataContentManage.Create(modelDC2, new DataContentEntity { Content = 1 },RowIndex);
            DataContentManage.Create(modelDC3, new DataContentEntity { Content = "whq" }, RowIndex);

            RowIndex = DataContentManage.GetFirstEmpty(modelDT).GetRowIndex();
            DataContentManage.Create(modelDT.Columns[0], new DataContentEntity { Content = 1 }, RowIndex);
            DataContentManage.Create(modelDC2, new DataContentEntity { Content = 2 }, RowIndex);
            DataContentManage.Create(modelDC3, new DataContentEntity { Content = "zyp" }, RowIndex);

            RowIndex = DataContentManage.GetFirstEmpty(modelDT).GetRowIndex();
            DataContentManage.Create(modelDT.Columns[0], new DataContentEntity { Content = 1 }, RowIndex);
            DataContentManage.Create(modelDC2, new DataContentEntity { Content = 3 }, RowIndex);
            DataContentManage.Create(modelDC3, new DataContentEntity { Content = "xxx" }, RowIndex);

            Assert.AreEqual(DataContentManage.GetFirstEmpty(modelDT).GetRowIndex(), 3);
            WhqHelper.DatabaseClose();
        }
Exemple #4
0
 public void DataTableCreate()
 {
     WhqHelper.DatabaseInit();
     DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
     DataTableManage.Create(WhqHelper.modelD, modelDT);
     WhqHelper.DatabaseClose();
 }
 /// <summary>
 /// 新建库
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnNew_Click(object sender, EventArgs e)
 {
     string strName = txtName.Text;
     string strPath = txtPath.Text;
     if (string.IsNullOrEmpty(strName))
     {
         JScript.ShowMessage(this, "请填写名称");
         return;
     }
     if (string.IsNullOrEmpty(strPath))
     {
         strPath = Path.GetDirectoryName(DBMaster.DB.MasterFile.FilePath) + "\\" + strName + ".whqdata";
     }
     //判断是否重复
     DataTableEntity modelDT = new DataTableEntity { Name = "Database" };
     modelDT = DataTableManage.Read(DBMaster.DB, modelDT);
     if (Manage.ListDB.Where(info => info.Name == strName).Count() > 0)
     {
         JScript.ShowMessage(this, "数据库名已存在");
         return;
     }
     //创建数据库
     DatabaseEntity modelD = new DatabaseEntity
     {
         Name = strName,
         MasterFile = new DataFileEntity { FilePath = strPath }
     };
     DatabaseManage.Create(modelD);
     //添加到主库中
     Manage.DBAdd(modelD);
     JScript.ResponseScript(this, "alert('数据库创建成功!');window.top.menu.location=window.top.menu.location.href;");
 }
        public void ContentCreateSome()
        {
            WhqHelper.DatabaseInit();
            DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
            DataTableManage.Create(WhqHelper.modelD, modelDT);
            DataColumnEntity modelDC2 = new DataColumnEntity { Name = "ID", Type = EColumnType.User, DataType = EContentType.Int, DataLength = 4 };
            DataColumnEntity modelDC3 = new DataColumnEntity { Name = "Name", Type = EColumnType.User, DataType = EContentType.String, DataLength = 0x100 };
            DataColumnEntity modelDC4 = new DataColumnEntity { Name = "Content", Type = EColumnType.User, DataType = EContentType.String, DataLength = 0x100 };
            DataColumnManage.Create(modelDT, modelDC2);
            DataColumnManage.Create(modelDT, modelDC3);
            DataColumnManage.Create(modelDT, modelDC4);
            //添加内容
            int RowIndex = DataContentManage.GetFirstEmpty(modelDT).GetRowIndex();
            for (int i = 0; i < 50; i++)
            {
                DataContentManage.Create(modelDT.Columns[0], new DataContentEntity { Content = 1 }, RowIndex);
                DataContentManage.Create(modelDC2, new DataContentEntity { Content = i }, RowIndex);
                DataContentManage.Create(modelDC3, new DataContentEntity { Content = "whq" }, RowIndex);
                DataContentManage.Create(modelDC4, new DataContentEntity { Content = "whq is Good!" }, RowIndex);
                RowIndex++;
            }

            Assert.AreEqual(DataContentManage.Read(modelDT.Columns[0], info => true).Count(), 50);

            WhqHelper.DatabaseClose();
        }
Exemple #7
0
 /// <summary>
 /// 移除数据库
 /// </summary>
 /// <param name="modelDB"></param>
 public static void DBRemove(DatabaseEntity modelDB)
 {
     DataTableEntity modelDT = new DataTableEntity { Name = "Database" };
     modelDT = DataTableManage.Read(DBMaster.DB, modelDT);
     DataRowManage.Delete(modelDT, new DataWhereEntity[] { new DataWhereEntity { ColumnName = "ID", Predicate = info => Convert.ToInt32(info) == modelDB.ID } });
     ListDB.Remove(modelDB);
     modelDB.MasterFile.FileStream.Close();
 }
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="modelDT">表</param>
 /// <param name="where">条件</param>
 public static void Delete(DataTableEntity modelDT, DataWhereEntity[] where = null)
 {
     IEnumerable<int> listDC = ReadRowIndexList(modelDT, where);
     //删除行
     foreach (int RowIndex in listDC)
     {
         DataContentManage.Delete(DataContentManage.GetContent(modelDT.Columns[0], RowIndex));
     }
 }
Exemple #9
0
 /// <summary>
 /// 附加数据库
 /// </summary>
 /// <param name="modelDB"></param>
 public static void DBAdd(DatabaseEntity modelDB)
 {
     DataTableEntity modelDT = new DataTableEntity { Name = "Database" };
     modelDT = DataTableManage.Read(DBMaster.DB, modelDT);
     Manage.ListDB.Add(modelDB);
     List<DataRowEntity> listDR = DataRowManage.Read(modelDT, new string[] { "ID" });
     modelDB.ID = (listDR.Count == 0) ? 1 : listDR.Max(info => Convert.ToInt32(info.Contents[0])) + 1;
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = new string[] { "ID", "Name", "Path" }, Contents = new object[] { modelDB.ID, modelDB.Name, modelDB.MasterFile.FilePath } });
 }
Exemple #10
0
 public void DataColumnCreate()
 {
     WhqHelper.DatabaseInit();
     DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
     DataTableManage.Create(WhqHelper.modelD, modelDT);
     DataColumnEntity modelDC1 = new DataColumnEntity { Name = "ID", DataType = EContentType.Int, DataLength = 4 };
     DataColumnEntity modelDC2 = new DataColumnEntity { Name = "Column", DataType = EContentType.String, DataLength = 32 };
     DataColumnManage.Create(modelDT, modelDC1);
     DataColumnManage.Create(modelDT, modelDC2);
     WhqHelper.DatabaseClose();
 }
 /// <summary>
 /// 创建
 /// </summary>
 public static void Create(DataTableEntity modelDT, DataRowEntity modelDR)
 {
     int RowIndex = DataContentManage.GetFirstEmpty(modelDT).GetRowIndex();
     for (int i = 0; i < modelDR.Columns.Length; i++)
     {
         DataContentManage.Create(
             modelDT.Columns.Where(info => info.Name == modelDR.Columns[i]).First(),
             new DataContentEntity { Content = modelDR.Contents[i] },
             RowIndex);
     }
     DataContentManage.Create(modelDT.Columns[0], new DataContentEntity { Content = 1 }, RowIndex);
 }
 /// <summary>
 /// 页面初始化
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Page_Init(object sender, EventArgs e)
 {
     //Table赋值
     if (!string.IsNullOrEmpty(Request.QueryString["DatabaseID"]) && !string.IsNullOrEmpty(Request.QueryString["DataTableID"]))
     {
         Table = Manage.ListDB.First(info => info.ID == Convert.ToInt32(Request.QueryString["DatabaseID"])).Tables.First(info => info.ID == Convert.ToInt32(Request.QueryString["DataTableID"]));
     }
     //行号
     if (!string.IsNullOrEmpty(Request.QueryString["RowIndex"]))
     {
         RowIndex = Convert.ToInt32(Request.QueryString["RowIndex"]);
     }
 }
Exemple #13
0
        public void DataTableRead()
        {
            WhqHelper.DatabaseInit();
            DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
            DataTableManage.Create(WhqHelper.modelD, modelDT);
            WhqHelper.DatabaseClose();

            WhqHelper.DatabaseOpen();
            modelDT = new DataTableEntity { Name = "TestTable" };
            modelDT=DataTableManage.Read(WhqHelper.modelD, modelDT);
            Assert.IsNotNull(modelDT);
            WhqHelper.DatabaseClose();
        }
 /// <summary>
 /// 获取表中行索引列表
 /// </summary>
 /// <param name="modelDT"></param>
 public static List<int> GetRowIndexList(DataTableEntity modelDT)
 {
     List<int> listRowIndex = new List<int>();
     long ContentPageID = modelDT.Columns[0].ContentPageID;
     int PageIndex = 0;
     while (ContentPageID > 0)
     {
         ContentPageEntity modelCP = DataContentManage.ReadContentPage(new DataPageEntity { DataFile = modelDT.DataFile, ID = ContentPageID }, new ContentPageEntity { Column = modelDT.Columns[0], PageIndex = PageIndex });
         PageIndex++;
         ContentPageID = modelCP.NextPageID;
         listRowIndex.AddRange(modelCP.Contents.Select(info => info.RowIndex));
     }
     return listRowIndex;
 }
Exemple #15
0
        public void DataTableDelete()
        {
            WhqHelper.DatabaseInit();
            DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
            DataTableManage.Create(WhqHelper.modelD, modelDT);
            DataTableManage.Delete(modelDT);
            WhqHelper.DatabaseClose();

            WhqHelper.DatabaseOpen();
            modelDT = new DataTableEntity { Name = "TestTable" };
            modelDT = DataTableManage.Read(WhqHelper.modelD, modelDT);
            Assert.IsNull(modelDT);
            Assert.AreEqual(DataFileManage.GetEmptyPageID(WhqHelper.modelD.MasterFile), 3);
            WhqHelper.DatabaseClose();
        }
 /// <summary>
 /// 删除
 /// </summary>
 public static void Delete(DataTableEntity modelDT)
 {
     //逐个删除列
     for (int i = 0; i < modelDT.Columns.Count;i++ )
     {
         DataColumnManage.Delete(modelDT.Columns[i]);
     }
     //删除列空间
     DataPageManage.Clear(new DataPageEntity { DataFile = modelDT.DataFile, ID = modelDT.ColumnPageID });
     //移除表
     TablePageEntity modelTP = modelDT.TablePage;
     modelTP.Tables.Remove(modelDT);
     modelDT = null;
     modelTP.DataPage.Content = modelTP.ToBytes();
     DataPageManage.Write(modelTP.DataPage);
 }
 /// <summary>
 /// 从byte[]中读取
 /// </summary>
 /// <param name="arr"></param>
 public void FromBytes(byte[] arr)
 {
     NextPageID = BitConverter.ToInt64(arr, NEXTPAGEID_START);
     Tables = new List<DataTableEntity>();
     for (int i = 1; i < Config.PAGE_SIZE/DataTableEntity.DATA_SIZE; i++)
     {
         byte[] temp = new byte[DataTableEntity.DATA_SIZE];
         temp = ByteUtil.ReadBytes(arr, i * DataTableEntity.DATA_SIZE, DataTableEntity.DATA_SIZE);
         if (ByteUtil.IsNotZero(temp))
         {
             DataTableEntity modelDT = new DataTableEntity();
             modelDT.TablePage = this;
             modelDT.FromBytes(temp);
             Tables.Add(modelDT);
         }
     }
 }
Exemple #18
0
 public void DataRowCreateSome()
 {
     WhqHelper.DatabaseInit();
     DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
     DataTableManage.Create(WhqHelper.modelD, modelDT);
     DataColumnEntity modelDC1 = new DataColumnEntity { Name = "ID", Type = EColumnType.User, DataType = EContentType.Int, DataLength = 4 };
     DataColumnEntity modelDC2 = new DataColumnEntity { Name = "Name", Type = EColumnType.User, DataType = EContentType.String, DataLength = 0x100 };
     DataColumnEntity modelDC3 = new DataColumnEntity { Name = "Content", Type = EColumnType.User, DataType = EContentType.String, DataLength = 0x100 };
     DataColumnManage.Create(modelDT, modelDC1);
     DataColumnManage.Create(modelDT, modelDC2);
     DataColumnManage.Create(modelDT, modelDC3);
     string[] listColumn = new string[] { "ID", "Name", "Content" };
     for (int i = 0; i < 50; i++)
     {
         DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { i + 1, "name", (i + 1) + "Content" } });
     }
     Assert.AreEqual(DataRowManage.ReadCount(modelDT), 50);
     WhqHelper.DatabaseClose();
 }
 /// <summary>
 /// 获取列中第一个空位
 /// </summary>
 /// <param name="modelDC"></param>
 /// <returns></returns>
 public static ContentPoint GetFirstEmpty(DataTableEntity modelDT)
 {
     ContentPoint cpReturn = new ContentPoint { ContentIndex = -1 };
     DataColumnEntity modelDC = modelDT.Columns[0];
     ContentPageEntity modelCP = ReadContentPage(new DataPageEntity { DataFile = modelDT.DataFile, ID = modelDC.ContentPageID }, new ContentPageEntity { Column = modelDC, PageIndex = cpReturn.PageIndex });
     //遍历找空位
     for (int i = 0; i < modelDC.PageMaxCount; i++)
     {
         if (modelCP.Contents.Where(info => info.ContentIndex == i).Count() == 0)
         {
             cpReturn.ContentPageID = modelCP.PageID;
             cpReturn.PageIndex = 0;
             cpReturn.ContentIndex = i;
             break;
         }
     }
     //没有空位去下一页找
     while (cpReturn.ContentIndex == -1 && modelCP.NextPageID > 0)
     {
         cpReturn.PageIndex++;
         modelCP = ReadContentPage(new DataPageEntity { DataFile = modelDT.DataFile, ID = modelCP.NextPageID }, new ContentPageEntity { Column = modelDC, PageIndex = cpReturn.PageIndex });
         //遍历找空位
         for (int i = 0; i < modelDC.PageMaxCount; i++)
         {
             if (modelCP.Contents.Where(info => info.ContentIndex == i).Count() == 0)
             {
                 cpReturn.ContentPageID = modelCP.PageID;
                 cpReturn.ContentIndex = i;
                 break;
             }
         }
     }
     //没有空位创建新页
     if (cpReturn.ContentIndex == -1)
     {
         cpReturn.PageIndex++;
         cpReturn.ContentIndex = 0;
         modelCP = NewContentPage(modelDC, modelCP.PageID, cpReturn.PageIndex);
         cpReturn.ContentPageID = modelCP.PageID;
     }
     return cpReturn;
 }
Exemple #20
0
 /// <summary>
 /// 创建
 /// </summary>
 public static void Create()
 {
     DB = new DatabaseEntity
     {
         Name = Config.DBMasterName,
         MasterFile = new DataFileEntity { FilePath = Config.DBMasterPath }
     };
     DatabaseManage.Create(DB);
     //建表
     DataTableEntity modelDT = new DataTableEntity { Name = "Database" };
     DataTableManage.Create(DB, modelDT);
     DataColumnEntity modelDC1 = new DataColumnEntity { Name = "ID", Type = EColumnType.User, DataType = EContentType.Int, DataLength = 4 };
     DataColumnEntity modelDC2 = new DataColumnEntity { Name = "Name", Type = EColumnType.User, DataType = EContentType.String, DataLength = 0x100 };
     DataColumnEntity modelDC3 = new DataColumnEntity { Name = "Path", Type = EColumnType.User, DataType = EContentType.String, DataLength = 1024 };
     DataColumnManage.Create(modelDT, modelDC1);
     DataColumnManage.Create(modelDT, modelDC2);
     DataColumnManage.Create(modelDT, modelDC3);
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = new string[] { "ID", "Name", "Path" }, Contents = new object[] { DBMASTER_ID, DB.Name, DB.MasterFile.FilePath } });
     DatabaseManage.Close(DB);
 }
 /// <summary>
 /// 创建
 /// </summary>
 public static void Create(DatabaseEntity modelD,DataTableEntity modelDT)
 {
     modelDT.TablePage = modelD.MasterFile.TablePage;
     modelDT.ID = modelD.Tables.Count == 0 ? 1 : modelD.Tables.Max(info => info.ID) + 1;
     //列信息编号
     modelDT.ColumnPageID = DataFileManage.GetEmptyPageID(modelD.MasterFile);
     //写入表
     modelDT.TablePage.Tables.Add(modelDT);
     modelDT.TablePage.DataPage.Content = modelDT.TablePage.ToBytes();
     DataPageManage.Write(modelDT.TablePage.DataPage);
     //创建列分页
     ColumnPageEntity modelCP = new ColumnPageEntity { Columns = new List<DataColumnEntity>(),  Table = modelDT };
     DataPageEntity modelDP = new DataPageEntity { DataFile = modelD.MasterFile, ID = modelDT.ColumnPageID ,Content = modelCP.ToBytes()};
     DataPageManage.Write(modelDP);
     //赋值
     modelCP.DataPage = modelDP;
     modelDT.ColumnPage = modelCP;
     modelDT.UserColumns = new List<DataColumnEntity>();
     //创建系统列
     DataColumnEntity modelDC = new DataColumnEntity { Name = EColumnType.RowIndex.ToString(), Type = EColumnType.RowIndex, DataType = EContentType.Byte, DataLength = Config.ROWINDEX_LENGTH };
     DataColumnManage.Create(modelDT, modelDC);
 }
Exemple #22
0
 public void DataRowCreate()
 {
     WhqHelper.DatabaseInit();
     DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
     DataTableManage.Create(WhqHelper.modelD, modelDT);
     DataColumnEntity modelDC1 = new DataColumnEntity { Name = "ID", Type = EColumnType.User, DataType = EContentType.Int, DataLength = 4 };
     DataColumnEntity modelDC2 = new DataColumnEntity { Name = "Name", Type = EColumnType.User, DataType = EContentType.String, DataLength = 0x100 };
     DataColumnEntity modelDC3 = new DataColumnEntity { Name = "Content", Type = EColumnType.User, DataType = EContentType.String, DataLength = 0x100 };
     DataColumnManage.Create(modelDT, modelDC1);
     DataColumnManage.Create(modelDT, modelDC2);
     DataColumnManage.Create(modelDT, modelDC3);
     string[] listColumn = new string[] { "ID", "Name","Content" };
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 1, "whq", "Conten123t" } });
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 2, "zyp", "11111111b" } });
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 3, "z423yp", "Cosdfntent" } });
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 4, "sdf4", "Contsdfent" } });
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 5, "z423yp", "Co3entent" } });
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 6, "sdf4", "Con4213tent" } });
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 7, "z423yp", "Cosdafntent" } });
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 8, "zyp", "22222222a" } });
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 9, "z423yp", "Contentsdf" } });
     DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 10, "sdf4", "234Content" } });
     WhqHelper.DatabaseClose();
 }
Exemple #23
0
        public void DataColumnUpdateType()
        {
            WhqHelper.DatabaseInit();
            DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
            DataTableManage.Create(WhqHelper.modelD, modelDT);
            DataColumnEntity modelDC1 = new DataColumnEntity { Name = "ID", DataType = EContentType.Int, DataLength = 4 };
            DataColumnEntity modelDC2 = new DataColumnEntity { Name = "Column", DataType = EContentType.Int, DataLength = 4 };
            DataColumnManage.Create(modelDT, modelDC1);
            DataColumnManage.Create(modelDT, modelDC2);

            DataColumnManage.Update(modelDC2, new DataColumnEntity { Name = "TestColumn2", DataType = EContentType.String, DataLength = 32 });
            DataColumnManage.Read(modelDT, modelDC2);
            Assert.AreEqual(modelDC2.Name, "TestColumn2");
            Assert.AreEqual(modelDC2.DataType, EContentType.String);
            WhqHelper.DatabaseClose();
        }
 /// <summary>
 /// 修改
 /// </summary>
 public static void Update(DataTableEntity modelDT)
 {
     modelDT.TablePage.DataPage.Content = modelDT.TablePage.ToBytes();
     DataPageManage.Write(modelDT.TablePage.DataPage);
 }
 /// <summary>
 /// 读取
 /// </summary>
 public static DataTableEntity Read(DatabaseEntity modelD, DataTableEntity modelDT)
 {
     foreach(DataTableEntity modelTemp in modelD.Tables.Where(info=>info.Name==modelDT.Name))
     {
         return modelTemp;
     }
     return null;
 }
Exemple #26
0
        public void DataRowDelete()
        {
            DataRowCreate();
            WhqHelper.DatabaseOpen();
            DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
            modelDT = DataTableManage.Read(WhqHelper.modelD, modelDT);
            DataRowManage.Delete(modelDT, new DataWhereEntity[] { new DataWhereEntity { ColumnName = "Name", Predicate = info => info.ToString() == "zyp" } });

            List<DataRowEntity> listDR = DataRowManage.Read(modelDT, new string[] { "ID", "Name" } , new DataWhereEntity[] { new DataWhereEntity { ColumnName = "Name", Predicate = info => info.ToString() == "zyp" } });
            Assert.AreEqual(listDR.Count, 0);
            WhqHelper.DatabaseClose();
        }
Exemple #27
0
 public void DataRowUpdate()
 {
     DataRowCreate();
     WhqHelper.DatabaseOpen();
     DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
     modelDT = DataTableManage.Read(WhqHelper.modelD, modelDT);
     DataRowManage.Update(modelDT, new DataRowEntity { Columns = new string[] { "Name", "Content" }, Contents = new object[] { "hahahha", "ConHaHaHa" } }, new DataWhereEntity[] { new DataWhereEntity { ColumnName = "Name", Predicate = info => info.ToString() == "zyp" } });
     List<DataRowEntity> listDR = DataRowManage.Read(modelDT, new string[] { "ID", "Name", "Content" }, new DataWhereEntity[] { new DataWhereEntity { ColumnName = "Name", Predicate = info => info.ToString() == "zyp" } });
     Assert.AreEqual(listDR.Count, 0);
     listDR = DataRowManage.Read(modelDT, new string[] { "ID", "Name", "Content"  }, new DataWhereEntity[] { new DataWhereEntity { ColumnName = "Name", Predicate = info => info.ToString() == "hahahha" } });
     Assert.AreEqual(listDR[0].Contents[0], 2);
     Assert.AreEqual(listDR[0].Contents[1], "hahahha");
     Assert.AreEqual(listDR[0].Contents[2], "ConHaHaHa");
     WhqHelper.DatabaseClose();
 }
Exemple #28
0
 public void DataRowReadOrderLimit()
 {
     DataRowCreate();
     WhqHelper.DatabaseOpen();
     DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
     modelDT = DataTableManage.Read(WhqHelper.modelD, modelDT);
     List<DataRowEntity> listDR = DataRowManage.Read(modelDT, new string[] { "ID", "Name", "Content" },
         new DataWhereEntity[] { new DataWhereEntity { ColumnName = "ID", Predicate = info => Convert.ToInt32(info) > 2 } },
         new DataOrderEntity { Columns = new string[] { "ID" }, Comparison = (x, y) => Convert.ToInt32(x.Contents[0]) - Convert.ToInt32(y.Contents[0]) },
         new DataLimitEntity { Start = 1, Length = 4 });
     Assert.AreEqual(listDR.Count, 4);
     Assert.AreEqual(listDR[0].Contents[0], 4);
     WhqHelper.DatabaseClose();
 }
Exemple #29
0
 public void DataRowReadOrder()
 {
     DataRowCreate();
     WhqHelper.DatabaseOpen();
     DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
     modelDT = DataTableManage.Read(WhqHelper.modelD, modelDT);
     //Content倒序
     List<DataRowEntity> listDR = DataRowManage.Read(modelDT, new string[] { "ID", "Name", "Content" },
         new DataWhereEntity[] { new DataWhereEntity { ColumnName = "Name", Predicate = info => info.ToString() == "zyp" } },
         new DataOrderEntity { Columns = new string[] { "Content" }, Comparison = (x, y) => -string.Compare(x.Contents[0].ToString(), y.Contents[0].ToString()) });
     Assert.AreEqual(listDR[0].Contents[2], "22222222a");
     //Content正序
     listDR = DataRowManage.Read(modelDT, new string[] { "ID", "Name", "Content" },
         new DataWhereEntity[] { new DataWhereEntity { ColumnName = "Name", Predicate = info => info.ToString() == "zyp" } },
         new DataOrderEntity { Columns = new string[] { "Content" }, Comparison = (x, y) => string.Compare(x.Contents[0].ToString(), y.Contents[0].ToString()) });
     Assert.AreEqual(listDR[0].Contents[2], "11111111b");
     WhqHelper.DatabaseClose();
 }
Exemple #30
0
        public void DataColumnUpdateTypeWithData()
        {
            WhqHelper.DatabaseInit();
            DataTableEntity modelDT = new DataTableEntity { Name = "TestTable" };
            DataTableManage.Create(WhqHelper.modelD, modelDT);
            DataColumnEntity modelDC1 = new DataColumnEntity { Name = "ID", DataType = EContentType.Int, DataLength = 4 };
            DataColumnEntity modelDC2 = new DataColumnEntity { Name = "Column", DataType = EContentType.Int, DataLength = 4 };
            DataColumnManage.Create(modelDT, modelDC1);
            DataColumnManage.Create(modelDT, modelDC2);

            string[] listColumn = new string[] { "ID", "Column"};
            DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 1, 1 } });
            DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 2, 2 } });
            DataRowManage.Create(modelDT, new DataRowEntity { Columns = listColumn, Contents = new object[] { 3, 3 } });

            DataColumnManage.Update(modelDC2, new DataColumnEntity { Name = "TestColumn2", DataType = EContentType.String, DataLength = 32 });
            DataColumnManage.Read(modelDT, modelDC2);
            Assert.AreEqual(modelDC2.Name, "TestColumn2");
            Assert.AreEqual(modelDC2.DataType, EContentType.String);
            Assert.AreEqual(DataRowManage.ReadCount(modelDT), 3);
            WhqHelper.DatabaseClose();
        }