protected override void OnStartup(StartupEventArgs e) { // Setting log4net var logCollect = XmlConfigurator.Configure(new System.IO.FileInfo(AppDomain.CurrentDomain.BaseDirectory + @"Log4Config.xml")); var logger = LogManager.GetRepository(); foreach (var item in logger.GetAppenders()) { RollingFileAppender rolling = item as RollingFileAppender; if (null != rolling) { rolling.File = Path.Combine(MediConstants.ConfigPath, MediConstants.AppLog, "DriveLog.log"); rolling.ActivateOptions(); } } // end setting log4net // Log4Net 설정 호출 this.DispatcherUnhandledException += App_DispatcherUnhandledException; log.Debug("Start Logger"); // App 초기 설정 호출 MediCloudModel appModel = GetConfigSetting(); // TODO : appModel.AppSetting.IsStartUpApp을 확인해서 false가 아닌 경우 레지스트리를 확인해서 run에서 삭제되었는지 확인할 필요 // 메인 윈도 출력 MainWindow mainWin = new MainWindow(); mainWin.SetInitView(appModel); mainWin.ShowDialog(); base.OnStartup(e); }
public void SetInitView(MediCloudModel appModel) { // 인자로 app.cs에서 모델을 받아와서 초기값을 설정해준다 ViewModel = new MainViewModel(appModel); mainview.SetInitViewModel(ViewModel); System.Windows.Application.Current.MainWindow = this; }
public MainViewModel(MediCloudModel appModel) { Debug.Assert(appModel != null); this.AppModel = appModel; MenuModel = new MenuViewModel(this); ListViewModel = new MainListViewModel(this); StatusModel = new StatusViewModel(this); }
/// <summary> /// /// </summary> /// <returns></returns> private MediCloudModel GetConfigSetting() { // 설정파일 load해서 가져오기 // 파일이 없는 초기 상태면 기본값을 만들어서 넣고, // 파일이 있으면 해당 파일을 XML Deserialize 해서 가져온다 var logPath = Path.Combine(MediConstants.ConfigPath, MediConstants.AppLog); log.Debug("Log path : " + logPath); if (Directory.Exists(logPath) == false) { try { Directory.CreateDirectory(logPath); } catch (Exception ex) { log.Error(ex.Message); } } string configFullPath = Path.Combine(MediConstants.ConfigPath, MediConstants.ConfigFile); MediCloudModel optionModel = null; if (File.Exists(configFullPath) == true) { optionModel = MediSerialize <MediCloudModel> .DeserializeModel(configFullPath); } else { optionModel = new MediCloudModel(); #if DEBUG optionModel.AppSetting = new AppOption() { IsStartUpApp = true, RemainDis = DistanceTime.OneDay, }; #endif } return(optionModel); }
private void SaveAppModel() { log.Debug("Start Cloud Setting"); var AppOpt = ParentModel.AppModel.AppSetting; AppOpt.CompanyID = this.CompanyID; AppOpt.IsESCClose = this.IsEnableESC; AppOpt.IsInstantSend = this.IsRightNow; AppOpt.PCName = this.HospitalName; AppOpt.RemainDis = this.DisplayTime; AppOpt.IsStartUpApp = this.IsStartUp; var cloudInfo = ParentModel.AppModel.S3Info; cloudInfo.StorageName = CloudInfoModel.StorageName; cloudInfo.StoragePath = CloudInfoModel.StoragePath; cloudInfo.SecretKey = CloudInfoModel.SecretKey; cloudInfo.PrivateKey = CloudInfoModel.PrivateKey; MediCloudModel.SetConfigModel(ParentModel.AppModel); log.Debug("Complete Cloud Setting"); }