public void Init() { ConfManager.Init(); // ERP 读写分离配置 var readConnectionsOfErp = new List <string>(); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_1")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_2")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_3")); var writeConnectionOfErp = ConfManager.GetAppsetting("db_ERP_WriteConnection"); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_DB_NAME, writeConnectionOfErp, readConnectionsOfErp.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); }
/// <summary> /// 应用程序的主入口点。 /// </summary> static void Main() { ConfManager.Init(); // ERP 读写分离配置 var readConnectionsOfErp = new List <string>(); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_1")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_2")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_3")); var writeConnectionOfErp = ConfManager.GetAppsetting("db_ERP_WriteConnection"); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_DB_NAME, writeConnectionOfErp, readConnectionsOfErp.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); //var sh = new ServiceHost(typeof(Implement.Service)); //sh.Open(); var es = new Implement.Service(); var mm = es.GetFilialeIdGoodsIdAvgSettlePrice(DateTime.Now); Console.WriteLine("ERP服务已启动!"); Console.ReadLine(); }
/// <summary>初始化任务 /// </summary> private void Init() { ConfManager.Init(); //设置推送数据的连接字符串名称 Instance.Init.SetDataBaseConnectionString("System.Data.SqlClient", ConfManager.GetAppsetting("db_ERP_WriteConnection")); var readConnectionsOfErp = new List <string>(); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_1")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_2")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_3")); var writeConnectionOfErp = ConfManager.GetAppsetting("db_ERP_WriteConnection"); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_DB_NAME, writeConnectionOfErp, readConnectionsOfErp.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); // ERP 备份库读写分离配置 var readConnectionsOfErpHistory = new List <string>(); readConnectionsOfErpHistory.Add(ConfManager.GetAppsetting("db_ERP_HISTORY_ReadConnections_1")); readConnectionsOfErpHistory.Add(ConfManager.GetAppsetting("db_ERP_HISTORY_ReadConnections_2")); readConnectionsOfErpHistory.Add(ConfManager.GetAppsetting("db_ERP_HISTORY_ReadConnections_3")); var writeConnectionOfErpHistory = ConfManager.GetAppsetting("db_ERP_HISTORY_WriteConnection"); int maxYear = DateTime.Now.Year + 2;// 历史备份库年份,假定2年以后才会重启Web(事实可能吗?所以完全够了) for (var i = 2007; i <= maxYear; i++) { var readConnectionStringList = new List <string>(); for (var j = 0; j < readConnectionsOfErpHistory.Count; j++) { var readConnectionString = readConnectionsOfErpHistory[j]; if (string.IsNullOrEmpty(readConnectionString)) { continue; } var connectionlist = readConnectionString.Split(';').ToList(); var oldReadDbName = connectionlist.FirstOrDefault(c => c.IndexOf("database=", StringComparison.CurrentCultureIgnoreCase) > -1); var newReadDbName = oldReadDbName + i; readConnectionString = readConnectionString.Replace(oldReadDbName, newReadDbName); readConnectionStringList.Add(readConnectionString); } var writeConnectionString = writeConnectionOfErpHistory; var oldWriteDbName = writeConnectionString.Split(';').ToList().FirstOrDefault(c => c.IndexOf("database=", StringComparison.CurrentCultureIgnoreCase) > -1); var newWriteDbName = oldWriteDbName + i; writeConnectionString = writeConnectionString.Replace(oldWriteDbName, newWriteDbName); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_HISTORY_DB_NAME + i, writeConnectionString, readConnectionStringList.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); } // ERP Report 读写分离配置 var readConnectionsOfErpReport = new List <string>(); readConnectionsOfErpReport.Add(ConfManager.GetAppsetting("db_ERP_REPORT_ReadConnections_1")); readConnectionsOfErpReport.Add(ConfManager.GetAppsetting("db_ERP_REPORT_ReadConnections_2")); readConnectionsOfErpReport.Add(ConfManager.GetAppsetting("db_ERP_REPORT_ReadConnections_3")); var writeConnectionOfErpReport = ConfManager.GetAppsetting("db_ERP_REPORT_WriteConnection"); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_REPORT_DB_NAME, writeConnectionOfErpReport, readConnectionsOfErpReport.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); Dapper.Extension.TypeMapper.Initialize(typeof(Keede.Ecsoft.Model.GoodsOrderInfo).Assembly); //初始化AOP ConfigManager.Init(); //全局异常记录 TaskScheduler.UnobservedTaskException += (sender, exceptionArgs) => { Exception ex = exceptionArgs.Exception.InnerException ?? exceptionArgs.Exception; if (ex.InnerException != null) { ex = ex.InnerException; } LogAggregateException(ex, sender); exceptionArgs.SetObserved(); }; //记录添加出库任务器 AddTask(TaskKind.AddSellOut, AddStorageTaskManager.AddSellOutTask, 60); //往来帐生成任务 AddTask(TaskKind.BuildReckoning, ReckoningTaskManager.AddTask, 60); //完成订单第二步骤任务 AddTask(TaskKind.CompleteOrderWithSecond, CompleteOrderTask.Core.CompleteSecondTask.RunWaitConsignmentOrderTask, 60); //自动报备(采购) AddTask(TaskKind.AutoPurchasing, AutoPurchasing.Core.RunAutoPurchasingTask.RunAutoPurchasing, 60); //进货申报 AddTask(TaskKind.AutoStockDeclare, AutoStockDeclare.Core.StockDeclareTask.RunStockDeclare, 60); //商品结算价、库存及供应商销售额存档 AddTask(TaskKind.GoodsStockRecordAndSales, GoodsStockRecordTask.Core.GoodsStockRecordTaskManager.RunGoodsStockRecordTask, 60 * ConfigManager.ExcuteMinutes()); //每月商品毛利数据存档 AddTask(TaskKind.GoodsGrossProfit, GoodsStockRecordTask.Core.GoodsGrossProfitManager.RunGoodsGrossProfitTask, 1800); //每月公司毛利数据存档 AddTask(TaskKind.CompanyGrossProfit, GoodsStockRecordTask.Core.CompanyGrossProfitManager.RunCompanyGrossProfitTask, 1800); //供应商资质检索 AddTask(TaskKind.QualificationManager, GoodsStockRecordTask.Core.QualificationTaskManager.RunQualificationTask, 43200); //销量异步任务 AddTask(TaskKind.GoodsDaySalesStatisticsAsynTask, GoodsDaySalesStatisticsAsynTaskManager.RecordGoodsDaySalesStatistics, 60); //销售公司每天凌晨生成采购单及入库单任务(来自B2C的订单) SaleFilialeGenerateStockInAndPurchaseFormTaskConfig.Init(); AddTask(TaskKind.GenerateSaleFilialeStockInAndPurchaseFormTask, GenerateSaleFilialeStockInAndPurchaseFormTask.Generate, 3600); //销售订单关联的即时结算价 GenerateSaleOrderGoodsSettlementTaskConfig.Init(); AddTask(TaskKind.GenerateSaleOrderGoodsSettlement, GenerateSaleOrderGoodsSettlementTask.Generate, 3600); //商品即时结算价按月归档 ArchiveLastMonthGoodsSettlementTaskConfig.Init(); AddTask(TaskKind.ArchiveLastMonthGoodsSettlement, ArchiveLastMonthGoodsSettlementTask.Generate, 3600); }
protected void Application_Start(object sender, EventArgs e) { ConfManager.Init(); //设置推送数据的连接字符串名称 Instance.Init.SetDataBaseConnectionString("System.Data.SqlClient", ConfManager.GetAppsetting("db_ERP_WriteConnection")); //设置操作日志的异步本地数据库连接 OperationLog.Core.Init.InitSyncConnectionString(ConfManager.GetAppsetting("db_ERP_WriteConnection")); // ERP 读写分离配置 var readConnectionsOfErp = new List <string>(); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_1")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_2")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_3")); var writeConnectionOfErp = ConfManager.GetAppsetting("db_ERP_WriteConnection"); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_DB_NAME, writeConnectionOfErp, readConnectionsOfErp.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); // ERP 备份库读写分离配置 var readConnectionsOfErpHistory = new List <string>(); readConnectionsOfErpHistory.Add(ConfManager.GetAppsetting("db_ERP_HISTORY_ReadConnections_1")); readConnectionsOfErpHistory.Add(ConfManager.GetAppsetting("db_ERP_HISTORY_ReadConnections_2")); readConnectionsOfErpHistory.Add(ConfManager.GetAppsetting("db_ERP_HISTORY_ReadConnections_3")); var writeConnectionOfErpHistory = ConfManager.GetAppsetting("db_ERP_HISTORY_WriteConnection"); int maxYear = DateTime.Now.Year + 2;// 历史备份库年份,假定2年以后才会重启Web(事实可能吗?所以完全够了) for (var i = 2007; i <= maxYear; i++) { var readConnectionStringList = new List <string>(); for (var j = 0; j < readConnectionsOfErpHistory.Count; j++) { var readConnectionString = readConnectionsOfErpHistory[j]; if (string.IsNullOrEmpty(readConnectionString)) { continue; } var connectionlist = readConnectionString.Split(';').ToList(); var oldReadDbName = connectionlist.FirstOrDefault(c => c.IndexOf("database=", StringComparison.CurrentCultureIgnoreCase) > -1); var newReadDbName = oldReadDbName + i; readConnectionString = readConnectionString.Replace(oldReadDbName, newReadDbName); readConnectionStringList.Add(readConnectionString); } var writeConnectionString = writeConnectionOfErpHistory; var oldWriteDbName = writeConnectionString.Split(';').ToList().FirstOrDefault(c => c.IndexOf("database=", StringComparison.CurrentCultureIgnoreCase) > -1); var newWriteDbName = oldWriteDbName + i; writeConnectionString = writeConnectionString.Replace(oldWriteDbName, newWriteDbName); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_HISTORY_DB_NAME + i, writeConnectionString, readConnectionStringList.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); } // ERP Report 读写分离配置 var readConnectionsOfErpReport = new List <string>(); readConnectionsOfErpReport.Add(ConfManager.GetAppsetting("db_ERP_REPORT_ReadConnections_1")); readConnectionsOfErpReport.Add(ConfManager.GetAppsetting("db_ERP_REPORT_ReadConnections_2")); readConnectionsOfErpReport.Add(ConfManager.GetAppsetting("db_ERP_REPORT_ReadConnections_3")); var writeConnectionOfErpReport = ConfManager.GetAppsetting("db_ERP_REPORT_WriteConnection"); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_REPORT_DB_NAME, writeConnectionOfErpReport, readConnectionsOfErpReport.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); Dapper.Extension.TypeMapper.Initialize(typeof(Keede.Ecsoft.Model.GoodsOrderInfo).Assembly); SAL.LogCenter.LogService.LogInfo("网站启动", "应用程序异常信息", null); }
/// <summary> /// 应用程序的主入口点。 /// </summary> static void Main() { ConfManager.Init(); //设置推送数据的连接字符串名称 Instance.Init.SetDataBaseConnectionString("System.Data.SqlClient", ConfManager.GetAppsetting("db_ERP_WriteConnection")); // ERP 读写分离配置 var readConnectionsOfErp = new List <string>(); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_1")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_2")); readConnectionsOfErp.Add(ConfManager.GetAppsetting("db_ERP_ReadConnections_3")); var writeConnectionOfErp = ConfManager.GetAppsetting("db_ERP_WriteConnection"); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_DB_NAME, writeConnectionOfErp, readConnectionsOfErp.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); // ERP 备份库读写分离配置 var readConnectionsOfErpHistory = new List <string>(); readConnectionsOfErpHistory.Add(ConfManager.GetAppsetting("db_ERP_HISTORY_ReadConnections_1")); readConnectionsOfErpHistory.Add(ConfManager.GetAppsetting("db_ERP_HISTORY_ReadConnections_2")); readConnectionsOfErpHistory.Add(ConfManager.GetAppsetting("db_ERP_HISTORY_ReadConnections_3")); var writeConnectionOfErpHistory = ConfManager.GetAppsetting("db_ERP_HISTORY_WriteConnection"); int maxYear = DateTime.Now.Year + 2;// 历史备份库年份,假定2年以后才会重启Web(事实可能吗?所以完全够了) for (var i = 2007; i <= maxYear; i++) { var readConnectionStringList = new List <string>(); for (var j = 0; j < readConnectionsOfErpHistory.Count; j++) { var readConnectionString = readConnectionsOfErpHistory[j]; if (string.IsNullOrEmpty(readConnectionString)) { continue; } var connectionlist = readConnectionString.Split(';').ToList(); var oldReadDbName = connectionlist.FirstOrDefault(c => c.IndexOf("database=", StringComparison.CurrentCultureIgnoreCase) > -1); var newReadDbName = oldReadDbName + i; readConnectionString = readConnectionString.Replace(oldReadDbName, newReadDbName); readConnectionStringList.Add(readConnectionString); } var writeConnectionString = writeConnectionOfErpHistory; var oldWriteDbName = writeConnectionString.Split(';').ToList().FirstOrDefault(c => c.IndexOf("database=", StringComparison.CurrentCultureIgnoreCase) > -1); var newWriteDbName = oldWriteDbName + i; writeConnectionString = writeConnectionString.Replace(oldWriteDbName, newWriteDbName); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_HISTORY_DB_NAME + i, writeConnectionString, readConnectionStringList.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); } // ERP Report 读写分离配置 var readConnectionsOfErpReport = new List <string>(); readConnectionsOfErpReport.Add(ConfManager.GetAppsetting("db_ERP_REPORT_ReadConnections_1")); readConnectionsOfErpReport.Add(ConfManager.GetAppsetting("db_ERP_REPORT_ReadConnections_2")); readConnectionsOfErpReport.Add(ConfManager.GetAppsetting("db_ERP_REPORT_ReadConnections_3")); var writeConnectionOfErpReport = ConfManager.GetAppsetting("db_ERP_REPORT_WriteConnection"); Keede.DAL.RWSplitting.ConnectionContainer.AddDbConnections(GlobalConfig.ERP_REPORT_DB_NAME, writeConnectionOfErpReport, readConnectionsOfErpReport.Where(m => !string.IsNullOrEmpty(m)).ToArray(), Keede.DAL.RWSplitting.EnumStrategyType.Loop); Dapper.Extension.TypeMapper.Initialize(typeof(Keede.Ecsoft.Model.GoodsOrderInfo).Assembly); #if DEBUG ServiceHost sh = new ServiceHost(typeof(Implement.Service)); sh.Open(); ServiceHost hostForTest = new ServiceHost(typeof(Implement.TestForJMeter)); hostForTest.Open(); var form = new Form(); form.Text = "ERP服务"; Application.Run(form); #else var _servicesToRun = new ServiceBase[] { new Service() }; ServiceBase.Run(_servicesToRun); #endif }