using OASystem.Domain.Entities;
using OASystem.Domain.Entities.Business;
using OASystem.Domain.Entities.Customer;
using OASystem.Domain.Entities.Financial;
using OASystem.Domain.Entities.Groups;
using OASystem.Domain.Entities.PersonnelModule;
using OASystem.Domain.Entities.Resource;
using OASystem.Domain.Entities.System;
using SqlSugar;

var db = new SqlSugarClient(new ConnectionConfig()
{
    ConnectionString = "server=132.232.92.186;uid=sa;pwd=Yjx@158291;database=OA2023DB;",
    DbType = SqlSugar.DbType.SqlServer,
    IsAutoCloseConnection = true,
    InitKeyType = InitKeyType.Attribute
});

#region Aop
//db.Aop.OnLogExecuting = (sql, pars) =>
//{
//    Console.WriteLine(sql + "" + Db.Utilities.SerializeObject
//        (pars.ToDictionary(it => it.ParameterName, it => it.Value)));
//    Console.WriteLine();
//}; 
#endregion

#region 对话框
Console.WriteLine("是否确定同步数据库表结构？(同名数据表将会被备份，生产环境慎用，回车确认)");
var str = Console.ReadKey();
if (str.Key == ConsoleKey.Enter)
{
    Console.WriteLine("同步中，请稍后...");
}
else
{
    Console.WriteLine("\r\n输入错误，已退出...");
    return;
}
#endregion

//同步数据表结构
db.DbMaintenance.CreateDatabase();
db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
{
    //typeof(Sys_PageFunctionPermission)
    //,typeof(Sys_SystemMenuAndFunction)
    //,typeof(Sys_SystemMenuPermission)
    //,typeof(Sys_JobPostAuthority)
    //,typeof(Sys_UserAuthority)
    //typeof(Crm_CustomerCert),
    //typeof(Crm_CustomerCompany),
    //typeof(Crm_CustomerFile),
    //typeof(Crm_DeleClient)
    //typeof(Crm_VisaCustomerCompany),
    //typeof(Crm_VisaCustomerFamily),
    //typeof(Crm_VisaCustomerSchool)
    //typeof(Grp_AirInquiry),
    //typeof(Grp_AirPrice),
    //typeof(Grp_CreditCardPayment),
    //typeof(Grp_DeleFile),
    //typeof(Grp_DelegationInfo),
    //typeof(Grp_DelegationJoinCustomer),
    //typeof(Grp_DeleMeetingNeeds),
    //typeof(Grp_HotelReservations),
    //typeof(Grp_VisaProgress),
    //typeof(Grp_DeleClientNeeds),
    //typeof(Res_AirCompany),
    //typeof(Res_AirTicketAgent),
    //typeof(Res_HotelData),
    //typeof(Res_ThreeCode)
    //typeof(Res_ScenicSpotInfo),
    //typeof(Res_CarGuides),
    //typeof(Res_CarInfo),
    //typeof(Res_GuidesInfo)
    //typeof(Res_CarData),
    //typeof(Res_LocalGuideData)
    //typeof(Grp_ScheduleInfo),
    //typeof(Grp_ScheduleDetailInfo),
    //typeof(Grp_SchedulePersonInfo)
    //typeof(Sys_Message),
    //typeof(Sys_MessageReadAuth)
    //typeof(Crm_DeleClient)
    //typeof(Crm_NewClientData)
    //typeof(Crm_ClientDataAndUser),
    //typeof(Crm_ClientDataAndBusiness),
    //typeof(Res_ItemDetailInfo),
    //typeof(Res_ItemVendor)
    //typeof(Res_ItemTypeInfo)
    //typeof(Bus_ConfItemInfo)
    //typeof(Bus_ConfItemListInfo)
    //typeof(Res_CountryFeeCost)
    //typeof(Res_MemoInfo),
    //typeof(Fin_DailyFeePayment),       // 财务 - 日付申请
    //typeof(Fin_DailyFeePaymentContent),// 财务 - 日付申请详细类
    //typeof(Grp_GroupsTaskAssignment),
    //typeof(Grp_AirTicketReservations),
    //typeof(Grp_GroupCostParameter),
    //typeof(Grp_TeamRate),              // 团组汇率
    //typeof(Fin_ForeignReceivables),    // 对外收款账单
    //typeof(Fin_ProceedsReceived),      // 已收款项
    //typeof(Fin_OtherPrice),            // 其他款项
    //typeof(Res_OfficialActivities)     //公务出访
    //typeof(Res_AskData),//请示数据库
    //typeof(Grp_DelegationEnData),
    //typeof(Grp_EnterExitCost),
    //typeof(Grp_DayAndCost), 
    //typeof(Grp_NationalTravelFee),
    //typeof(Air_TicketBlackCode),
    //typeof(Pm_WageSheet)       //人事模块 工资表单
    //typeof(Grp_VisaProgressCustomer),
    //typeof(Grp_VisaProgressCustomerPicture)
    //typeof(Grp_VisaInfo)
    typeof(Grp_CarTouristGuideGroundReservations),
    typeof(Grp_CarTouristGuideGroundReservationsContent)
});
Console.WriteLine("数据库结构同步完成!");
