54 lines
1.9 KiB
C#
54 lines
1.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using WCS.BLL.DbModels;
|
|
using WCS.DAL.Db;
|
|
using WCS.DAL.Db.AuthDb;
|
|
using WCS.DAL.DbModels;
|
|
|
|
namespace WCS.BLL.Manager
|
|
{
|
|
public static class DbInit
|
|
{
|
|
public static void InitDb()
|
|
{
|
|
Logs.Write("【初始化数据库】开始", LogsType.StartBoot);
|
|
DbHelp.db.DbMaintenance.CreateDatabase();
|
|
|
|
DbHelp.db.CodeFirst.InitTables(typeof(ModuleInfo), typeof(ShelfInfo), typeof(StoreInfo)
|
|
, typeof(InventoryDetail), typeof(OutOrder), typeof(OutOrderDetail), typeof(OutOrderMatDetail)
|
|
, typeof(ShelfTypeInfo), typeof(MatBaseInfo), typeof(MatInfo)
|
|
, typeof(StockTakingOrder), typeof(StockTakingOrderMatDetail), typeof(InOutRecord)
|
|
, typeof(DocumentSerialNumber)
|
|
);
|
|
|
|
DbHelp.dbLog.CodeFirst.InitTables(typeof(SystemApiLogRecord));
|
|
|
|
//初始化单据序列号数据
|
|
if (!DbHelp.db.Queryable<DocumentSerialNumber>().Any())
|
|
{
|
|
var outDocumentSerialNumber = new DocumentSerialNumber()
|
|
{
|
|
DocumentType = DocumentTypeEnum.出库单据,
|
|
UpdateDate = DateTime.Now,
|
|
CurrentSerialNumber = 0
|
|
};
|
|
|
|
var stockTakingDocumentSerialNumber = new DocumentSerialNumber()
|
|
{
|
|
DocumentType = DocumentTypeEnum.盘点单据,
|
|
UpdateDate = DateTime.Now,
|
|
CurrentSerialNumber = 0
|
|
};
|
|
|
|
DbHelp.db.Insertable(outDocumentSerialNumber).ExecuteCommand();
|
|
DbHelp.db.Insertable(stockTakingDocumentSerialNumber).ExecuteCommand();
|
|
}
|
|
|
|
Logs.Write("【初始化数据库】结束", LogsType.StartBoot);
|
|
}
|
|
}
|
|
}
|