public static IApplicationBuilder UseDatabaseMigration(this IApplicationBuilder app) { using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope()) { serviceScope.ServiceProvider.GetService <FootballAnalyzesDbContext>().Database.Migrate(); var userManager = serviceScope.ServiceProvider.GetService <UserManager <User> >(); var roleManager = serviceScope.ServiceProvider.GetService <RoleManager <IdentityRole> >(); var db = serviceScope.ServiceProvider.GetService <FootballAnalyzesDbContext>(); Task .Run(async() => { await AddAdminUser(userManager, roleManager); if (await db.FootballGames.CountAsync() == 0) { var updateDb = new StartUpdate(db); updateDb.SeedOldGames(); } }) .Wait(); } return(app); }
public ConfigInput() { try { if (!File.Exists(_configName)) { StartUpdate.SendStartMsg("输入配置文件加载失败"); } else { List <string[]> InputArrayList = Functions.CsvToStringArray(_configName, 0); for (int i = 1; i < InputArrayList.Count; i++) { if (InputArrayList[i][2] != "") { inputNamelist.Add(InputArrayList[i][1] + " -> " + InputArrayList[i][2]); inputBit.Add(i - 1); } } } StartUpdate.SendStartMsg("输入配置文件加载成功"); } catch (Exception ex) { StartUpdate.SendStartMsg("输入配置文件加载失败"); LogWriter.WriteException(ex); LogWriter.WriteLog(string.Format("错误:加载配置文件[{0}]失败!\n异常描述:{1}\n时间:{2}", _name, ex.Message, System.DateTime.Now.ToString("yyyyMMddhhmmss"))); } }
public FormMain() { try { InitializeComponent(); StartUpdate.SendStartMsg("应用程序启动 请稍等>>>"); ConfigSpace.ConfigHandle.Instance.Load(); InitializeControl(); //VisionProject.Instance.InitVisionProject(); StartUpdate.SendStartMsg("正在进入系统>>>"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { timer1.Interval = 200; timer1.Enabled = true; } HZZH.Logic.LogicMain.TaskMain.Init(); HzControl.Logic.TaskManager.Show(0); }
public string UpdateDb(DateTime nextGamesDate) { DateTime lastDateGame = this.FindOldestPossibleDateForUpdate(); DateTime endDate = DateTime.Now.AddDays(-2).Date; var updateDb = new StartUpdate(this.db); var gamesBeforeUpdate = this.db .FootballGames .Where(g => g.MatchDate.Date >= lastDateGame && g.MatchDate.Date <= endDate && g.FullTimeResult != null) .Count(); int newGamesBeforeUpdateCount = this.db.FootballGames.Where(g => g.MatchDate.Date == nextGamesDate).Count(); updateDb.MakeAnalyzesForNextGames(lastDateGame, endDate, nextGamesDate); var gamesAfterUpdate = this.db .FootballGames .Where(g => g.MatchDate.Date >= lastDateGame && g.MatchDate.Date <= endDate && g.FullTimeResult != null) .Count(); int updatedGamesCount = gamesAfterUpdate - gamesBeforeUpdate; int newGamesCount = this.db.FootballGames.Where(g => g.MatchDate.Date == nextGamesDate).Count(); return($"Updated old games : {updatedGamesCount}," + $"Add new games: {newGamesCount - newGamesBeforeUpdateCount}"); }
static void InitSysterm() { StartUpdate.SendStartMsg("读取配置文件"); Thread.Sleep(100); //StartUpdate.SendStartMsg("初始化相机"); //CameraMgr.Inst.GetHashCode(); StartUpdate.SendStartMsg("初始化几面窗口"); FrmMgr.Init(); Thread.Sleep(200); HZZH.Common.Config.AlarmLog.LoadLogData(AppDomain.CurrentDomain.BaseDirectory + "Logs\\", DateTime.Now.ToString("yyyy-MM-dd")); }
public ConfigAlarm() { try { if (!File.Exists(_configName)) { StartUpdate.SendStartMsg("报警配置文件加载失败"); } else { List <string[]> ErrorCodeArr = Functions.CsvToStringArray(_configName, 0); for (int i = 1; i <= 32; i++) { str_InputMsg[0, i - 1] = ErrorCodeArr[i + 1][2]; str_InputMsg[1, i - 1] = ErrorCodeArr[i + 1][5]; str_InputMsg[2, i - 1] = ErrorCodeArr[i + 1][8]; str_InputMsg[3, i - 1] = ErrorCodeArr[i + 1][11]; str_InputMsg[4, i - 1] = ErrorCodeArr[i + 1][14]; str_InputMsg[5, i - 1] = ErrorCodeArr[i + 1][17]; str_InputMsg[6, i - 1] = ErrorCodeArr[i + 1][20]; str_InputMsg[7, i - 1] = ErrorCodeArr[i + 1][23]; str_InputMsg[8, i - 1] = ErrorCodeArr[i + 1][26]; str_InputMsg[9, i - 1] = ErrorCodeArr[i + 1][29]; str_InputMsg[10, i - 1] = ErrorCodeArr[i + 1][32]; str_InputMsg[11, i - 1] = ErrorCodeArr[i + 1][35]; str_InputMsg[12, i - 1] = ErrorCodeArr[i + 1][38]; str_InputMsg[13, i - 1] = ErrorCodeArr[i + 1][41]; str_InputMsg[14, i - 1] = ErrorCodeArr[i + 1][44]; str_InputMsg[15, i - 1] = ErrorCodeArr[i + 1][47]; str_InputMsg[16, i - 1] = ErrorCodeArr[i + 1][50]; str_InputMsg[17, i - 1] = ErrorCodeArr[i + 1][53]; str_InputMsg[18, i - 1] = ErrorCodeArr[i + 1][56]; str_InputMsg[19, i - 1] = ErrorCodeArr[i + 1][59]; } } StartUpdate.SendStartMsg("报警配置文件加载成功"); } catch (Exception ex) { StartUpdate.SendStartMsg("报警配置文件加载失败"); LogWriter.WriteException(ex); LogWriter.WriteLog(string.Format("错误:加载配置文件[{0}]失败!\n异常描述:{1}\n时间:{2}", _name, ex.Message, System.DateTime.Now.ToString("yyyyMMddhhmmss"))); } }
public string UpdateOldGames(DateTime startDate, DateTime endDate) { var updateDb = new StartUpdate(this.db); var gamesBeforeUpdate = this.db .FootballGames .Where(g => g.MatchDate.Date >= startDate && g.MatchDate.Date <= endDate && g.FullTimeResult != null) .Count(); updateDb.UpdateOldGames(startDate, endDate); var gamesAfterUpdate = this.db .FootballGames .Where(g => g.MatchDate.Date >= startDate && g.MatchDate.Date <= endDate && g.FullTimeResult != null) .Count(); int updatedGamesCount = gamesAfterUpdate - gamesBeforeUpdate; return($"Updated old games : {updatedGamesCount}"); }
public FormMain() { try { InitializeComponent(); StartUpdate.SendStartMsg("应用程序启动 请稍等>>>"); ConfigSpace.ConfigHandle.Instance.Load(); InitializeControl(); StartUpdate.SendStartMsg("正在进入系统>>>"); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } finally { timer1.Interval = 200; timer1.Enabled = true; } }
public void InitializeControl() { StartUpdate.SendStartMsg("初始化控件"); frmLog = new FormLog(); userInfo = new UserInfo(); frm_Stick = new Frm_Runing(); frm_Stick.TopLevel = false; //将子窗体设置成非最高层,非顶级控件 frm_Stick.FormBorderStyle = FormBorderStyle.None; //去掉窗体边框 frm_Stick.Size = this.panel1.Size; frm_Stick.Parent = this.panel1; //指定子窗体显示的容器 frm_Stick.Dock = DockStyle.Fill; frm_Stick.Show(); frm_Stick.Activate(); StartUpdate.SendStartMsg("控件初始化完成"); frm_Stick.data.DataBanding(); frm_Stick.clean.databanding(); frm_Stick.frm_Machine.Binding(); StartUpdate.SendStartMsg("数据绑定完成"); }
public void InitializeControl() { StartUpdate.SendStartMsg("初始化控件"); frmLog = new FormLog(); userInfo = new UserInfo(); //frm_Stick = null; Frm_Machine = new Frm_MotorParam(); //frm_Stick.TopLevel = false; //将子窗体设置成非最高层,非顶级控件 //frm_Stick.FormBorderStyle = FormBorderStyle.None;//去掉窗体边框 //frm_Stick.Size = this.panel1.Size; //frm_Stick.Parent = this.panel1;//指定子窗体显示的容器 //frm_Stick.Dock = DockStyle.Fill; //frm_Stick.Show(); //frm_Stick.Activate(); skinTabControl1.ItemSize = new Size(0, 1); skinTabControl1.Appearance = TabAppearance.FlatButtons; skinTabControl1.SizeMode = TabSizeMode.Fixed; skinTabControl1.SelectedTab = 主页Tag; StartUpdate.SendStartMsg("控件初始化完成"); }
private void LoadEquipmentConfig() { AppSqliteConfigure.mDataSource = _configName; AppSqliteConfigure.Connected(); try { //********************* 创建系统配置表(包含:平台配置参数,通讯配置参数,高级设置参数) SysDataManage = new AppSqliteConfigure("SystemTb"); SysDataManage.CreatTable_DB(sqlSystemData, sqlSystemDataTyp); List <string> allData = new List <string>(); SysDataManage.ReadallDataFromSqliteTable_1("SystemTypes", ref allData); bool _needCreate = false; allData.Distinct(); if (!allData.Contains("ConfigUser") && !allData.Contains("ConfigAxis") && !allData.Contains("ConfigSystem")) { _needCreate = true; } else { if (!allData.Contains("ConfigUser")) { SysDataManage.InsertOneDataOfSqliteTable_1(new string[] { "ConfigUser", "", "", "", "" }); } if (!allData.Contains("ConfigAxis")) { SysDataManage.InsertOneDataOfSqliteTable_1(new string[] { "ConfigAxis", "", "", "", "" }); } if (!allData.Contains("ConfigSystem")) { SysDataManage.InsertOneDataOfSqliteTable_1(new string[] { "ConfigSystem", "", "", "", "" }); } } if (_needCreate) { //****************** 首次默认插入3行数据 ---- 第一位为配置类型名,第二位为详细配置参数 SysDataManage.InsertOneDataOfSqliteTable_1(new string[] { "ConfigUser", "", "", "", "" }); SysDataManage.InsertOneDataOfSqliteTable_1(new string[] { "ConfigAxis", "", "", "", "" }); SysDataManage.InsertOneDataOfSqliteTable_1(new string[] { "ConfigSystem", "", "", "", "" }); //****************** 对象序列化成JSON UserDefine = new ConfigUser(); string UserJson = JsonHelper.SerializeObject(UserDefine); AxisDefine = new ConfigAxis(); string AxisJson = JsonHelper.SerializeObject(AxisDefine); SystemDefine = new ConfigSystem(); string SystemJson = JsonHelper.SerializeObject(SystemDefine); //****************** 更新数据库 SysDataManage.UpdateOneDataOfSqliteTable_1("SystemTypes", "ConfigUser", "Data1", UserJson); SysDataManage.UpdateOneDataOfSqliteTable_1("SystemTypes", "ConfigAxis", "Data1", AxisJson); SysDataManage.UpdateOneDataOfSqliteTable_1("SystemTypes", "ConfigSystem", "Data1", SystemJson); _needCreate = false; } //********************** 检查数据库信息 List <string> platMsg = new List <string>(); SysDataManage.ReadallDataFromSqliteTable_1("SystemTypes", ref platMsg); foreach (string item in platMsg) { string DesCriptionMsg = ""; SysDataManage.ReadOneDataFromSqliteTable_1("SystemTypes", item, "Data1", ref DesCriptionMsg); if (DesCriptionMsg != "") { if (item == "ConfigSystem") { SystemDefine = JsonHelper.DeserializeJsonToObject <ConfigSystem>(DesCriptionMsg); StartUpdate.SendStartMsg("系统配置加载成功"); } else if (item == "ConfigUser") { UserDefine = JsonHelper.DeserializeJsonToObject <ConfigUser>(DesCriptionMsg); StartUpdate.SendStartMsg("用户配置加载成功"); } else if (item == "ConfigAxis") { AxisDefine = JsonHelper.DeserializeJsonToObject <ConfigAxis>(DesCriptionMsg); StartUpdate.SendStartMsg("轴配置加载成功"); } } else { StartUpdate.SendStartMsg(item + "配置加载失败"); LogWriter.WriteLog(string.Format("错误:加载配置文件失败!\n异常描述:{0}\n时间:{1}", item, System.DateTime.Now.ToString("yyyyMMddhhmmss"))); } } } catch (Exception ex) { StartUpdate.SendStartMsg("设备配置加载错误"); LogWriter.WriteLog(string.Format("错误:设备配置加载错误!\n异常描述:{0}\n时间:{1}", ex.ToString(), System.DateTime.Now.ToString("yyyyMMddhhmmss"))); } }
protected void OnStartUpdate( EventArgs args) { StartUpdate?.Invoke(this, args); }
protected async Task definedStateSolver() { parameters = new ParametersOfSolver(numberQueens, initialTemperature, initialstabilizer, coolingFactor, stabilizingFactor, freezingTemperature); await StartUpdate.InvokeAsync(parameters); }