public static void DeleteDb(int type) { if (type == 0) { var db1 = new DbContext("LocationConnection"); var delResult1 = db1.Database.Delete(); var db2 = new DbContext("LocationHistoryConnection"); var delResult2 = db2.Database.Delete(); } else if (type == 1) { DirectoryInfo dirInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory + "\\Data\\"); FileInfo[] files = dirInfo.GetFiles("*.db"); foreach (var file in files) { file.Delete(); } } else { LocationDb Ldb = new LocationDb(); LocationHistoryDb Lhdb = new LocationHistoryDb(); // Ldb.Database.ExecuteSqlCommand("drop database location"); // Lhdb.Database.ExecuteSqlCommand("drop database locationhistory"); Ldb.Database.Delete(); Lhdb.Database.Delete(); } }
public void StartConnectEngine(EngineLogin login) { //Log.Info(LogTags.Engine,"StartConnectEngine:" + login.EngineIp); WriteLogLeft(GetLogText("StartConnectEngine:" + login.EngineIp)); LocationHistoryDb db = new LocationHistoryDb(); bool r1 = db.Database.Exists(); WriteLogLeft(GetLogText("数据库是否存在:" + r1)); if (r1 == false) { bool r2 = db.Database.CreateIfNotExists(); WriteLogLeft(GetLogText("数据库创建是否成功:" + r2)); } //int mockCount = int.Parse(TbMockTagPowerCount0.Text); if (engineDa == null) { //engineDa = new PositionEngineDA("192.168.10.155", "192.168.10.19");//todo:ip写到配置文件中 engineDa = new PositionEngineDA(login);//todo:ip写到配置文件中 engineDa.MockCount = MockCount; //engineDa.MessageReceived += EngineDa_MessageReceived; engineDa.MessageReceived += (msg) => { psCount++; string m = string.Format("{0}||{1}", psCount, msg); WriteLogLeft(GetLogText(m)); }; //engineDa.PositionRecived += EngineDa_PositionRecived; engineDa.PositionListRecived += EngineDa_PositionListRecived; } engineDa.Start(); if (IsWriteToDb) { InitTagPosition(MockCount); StartInsertPositionTimer(); } }
public Bll(bool autoDetectChangesEnabled, bool lazyLoadingEnabled, bool useProxy = true) { Db = new LocationDb(); Db.Configuration.AutoDetectChangesEnabled = autoDetectChangesEnabled; Db.Configuration.LazyLoadingEnabled = lazyLoadingEnabled; //关闭延迟加载 Db.Configuration.ProxyCreationEnabled = useProxy; DbHistory = new LocationHistoryDb(); DbHistory.Configuration.AutoDetectChangesEnabled = autoDetectChangesEnabled; DbHistory.Configuration.LazyLoadingEnabled = lazyLoadingEnabled; //关闭延迟加载 DbHistory.Configuration.ProxyCreationEnabled = useProxy; if (ShowLog) { Db.Database.Log = Log.Debug; } Archors = new ArchorBll(Db); Areas = new AreaBll(Db); Bounds = new BoundBll(Db); ConfigArgs = new ConfigArgBll(Db); Departments = new DepartmentBll(Db); DevAlarms = new DevAlarmBll(Db); DevInfos = new DevInfoBll(Db); Dev_DoorAccess = new Dev_DoorAccessBll(Db); Dev_CameraInfos = new Dev_CameraInfoBll(Db); DevInstantDatas = new DevInstantDataBll(Db); DevModels = new DevModelBll(Db); DevTypes = new DevTypeBll(Db); EntranceGuardCards = new EntranceGuardCardBll(Db); EntranceGuardCardToPersonnels = new EntranceGuardCardToPersonnelBll(Db); AreaAuthorizations = new AreaAuthorizationBll(Db); AreaAuthorizationRecords = new AreaAuthorizationRecordBll(Db); KKSCodes = new KKSCodeBll(Db); LocationAlarms = new LocationAlarmBll(Db); LocationCards = new LocationCardBll(Db); LocationCardPositions = new LocationCardPositionBll(Db); LocationCardToPersonnels = new LocationCardToPersonnelBll(Db); LocationCardToArea = new LocationCardToAreaBll(Db); MobileInspections = new MobileInspectionBll(Db); MobileInspectionContents = new MobileInspectionContentBll(Db); MobileInspectionDevs = new MobileInspectionDevBll(Db); MobileInspectionItems = new MobileInspectionItemBll(Db); NodeKKSs = new NodeKKSBll(Db); OperationItems = new OperationItemBll(Db); OperationTickets = new OperationTicketBll(Db); Personnels = new PersonnelBll(Db); PersonnelMobileInspections = new PersonnelMobileInspectionBll(Db); PersonnelMobileInspectionItems = new PersonnelMobileInspectionItemBll(Db); Points = new PointBll(Db); Posts = new PostBll(Db); Roles = new RoleBll(Db); SafetyMeasuress = new SafetyMeasuresBll(Db); WorkTickets = new WorkTicketBll(Db); OperationTicketSHs = new OperationTicketSHBll(Db); Pictures = new PictureBll(Db); ArchorSettings = new ArchorSettingBll(Db); CardRoles = new CardRoleBll(Db); DevMonitorNodes = new DevMonitorNodeBll(Db); InspectionTracks = new InspectionTrackBll(Db); PatrolPoints = new PatrolPointBll(Db); PatrolPointItems = new PatrolPointItemBll(Db); //Shapes = new ShapeBll(Db); //ShapePoints = new ShapePointBll(); HomePagePictures = new HomePagePictureBll(Db); Users = new UserBll(Db); CameraAlarmJsons = new CameraAlarmJsonBll(Db); PersonnelFirstInAreas = new PersonnelFirstInAreaBll(Db); DevAlarmHistorys = new DevAlarmHistoryBll(DbHistory); DevEntranceGuardCardActions = new DevEntranceGuardCardActionBll(DbHistory); DevInfoHistorys = new DevInfoHistoryBll(DbHistory); DevInstantDataHistorys = new DevInstantDataHistoryBll(DbHistory); EntranceGuardCardHistorys = new EntranceGuardCardHistoryBll(DbHistory); EntranceGuardCardToPersonnelHistorys = new EntranceGuardCardToPersonnelHistoryBll(DbHistory); LocationAlarmHistorys = new LocationAlarmHistoryBll(DbHistory); LocationCardHistorys = new LocationCardHistoryBll(DbHistory); LocationCardToPersonnelHistorys = new LocationCardToPersonnelHistoryBll(DbHistory); OperationItemHistorys = new OperationItemHistoryBll(DbHistory); OperationTicketHistorys = new OperationTicketHistoryBll(DbHistory); PersonnelHistorys = new PersonnelHistoryBll(DbHistory); PersonnelMobileInspectionHistorys = new PersonnelMobileInspectionHistoryBll(DbHistory); PersonnelMobileInspectionItemHistorys = new PersonnelMobileInspectionItemHistoryBll(DbHistory); Positions = new PositionBll(DbHistory); SafetyMeasuresHistorys = new SafetyMeasuresHistoryBll(DbHistory); U3DPositions = new U3DPositionBll(DbHistory); WorkTicketHistorys = new WorkTicketHistoryBll(DbHistory); InspectionTrackHistorys = new InspectionTrackHistoryBll(DbHistory); PatrolPointHistorys = new PatrolPointHistoryBll(DbHistory); PatrolPointItemHistorys = new PatrolPointItemHistoryBll(DbHistory); DevMonitorNodeHistorys = new DevMonitorNodeHistoryBll(DbHistory); DoorClicks = new DoorClickBll(DbHistory); OperationTicketHistorySHs = new OperationTicketHistorySHBll(DbHistory); WorkTicketHistorySHes = new WorkTicketHistorySHBll(DbHistory); PointHistories = new PointHistoryBll(DbHistory); bus_anchors = new bus_anchorBll(DbE); bus_tags = new bus_tagBll(DbE); bus_anchor_config = new bus_anchor_configBll(DbE); bus_anchor_switch_area = new bus_anchor_switch_areaBll(DbE); DoorClicks.ToList(); //LocationCards.ToList(); //DevEntranceGuardCardActions.ToList(); //bus_archors.ToList(); Z.EntityFramework.Extensions.LicenseManager.AddLicense("34;100-LLHSWWHA", "384799A60700037CBFC0EB5E03A62474"); }