static void RunFileWatcherTB() { // Serviceサーバーを起動して、クライアントにWSDLなどを公開するためのコンソールプログラムです。 System.Threading.Thread.CurrentThread.Name = "Nadesico API"; application = new Application(); var buildAssemblyType = new BuildAssemblyParameter(); buildAssemblyType.Params["ApplicationDirectoryPath"] = @"\Nadesico_InvokeServiceConsole"; ApplicationContext.SetupApplicationContextImpl(ApplicationContextImpl.CreateInstance(application, buildAssemblyType)); ((ApplicationContextImpl)ApplicationContextImpl.GetInstance()).InitializeApplication(); var invoker = new FileWatcherTBInvoker(); invoker.Run(); bool isEnd = false; do { var command = Console.ReadLine(); switch (command) { case "d": invoker.OutputDump(); break; default: isEnd = true; break; } } while (!isEnd); }
static void RunContentTB1() { System.Threading.Thread.CurrentThread.Name = "Nadesico API"; application = new Application(); var buildAssemblyType = new BuildAssemblyParameter(); buildAssemblyType.Params["ApplicationDirectoryPath"] = @"\Nadesico_InvokeServiceConsole"; ApplicationContext.SetupApplicationContextImpl(ApplicationContextImpl.CreateInstance(application, buildAssemblyType)); ((ApplicationContextImpl)ApplicationContextImpl.GetInstance()).InitializeApplication(); using (var dbc = new AppDbContext()) { var content = new ContentImage(); content.IdentifyKey = "aaaa"; content.Title = "コンテントテストA"; content.ArchiveFlag = true; content.ReadableFlag = true; content.Starrating = 3; content.UnsetStarratingFlag = false; var repoContent = new ContentImageRepository(dbc); repoContent.Add(content); dbc.SaveChanges(); } Console.WriteLine("永続化が完了しました。"); }
static void Main(string[] args) { Console.WriteLine("サーバーシステム・プログラム:"); while (1 == 1) { Console.WriteLine("起動モードを選択してください"); Console.WriteLine(" 0: APIサーバ起動"); Console.Write("> "); string d = Console.ReadLine(); if (d == "0") { break; } } // Serviceサーバーを起動して、クライアントにWSDLなどを公開するためのコンソールプログラムです。 System.Threading.Thread.CurrentThread.Name = "Halcyon API"; application = new Application(); var buildAssemblyType = new BuildAssemblyParameter(); buildAssemblyType.Params["ApplicationDirectoryPath"] = @"\Mogami_InvokeServiceConsole"; ApplicationContext.SetupApplicationContextImpl(ApplicationContextImpl.CreateInstance(application, buildAssemblyType)); ((ApplicationContextImpl)ApplicationContextImpl.GetInstance()).InitializeApplication(); RunApiService(); }
static void RunCategoryTB1() { System.Threading.Thread.CurrentThread.Name = "Nadesico API"; application = new Application(); var buildAssemblyType = new BuildAssemblyParameter(); buildAssemblyType.Params["ApplicationDirectoryPath"] = @"\Nadesico_InvokeServiceConsole"; ApplicationContext.SetupApplicationContextImpl(ApplicationContextImpl.CreateInstance(application, buildAssemblyType)); ((ApplicationContextImpl)ApplicationContextImpl.GetInstance()).InitializeApplication(); long id_child; using (var dbc = new AppDbContext()) { var repoCategory = new CategoryRepository(dbc); var catRoot = repoCategory.Load(1L); var catNew = new Category { Name = "新しいカテゴリ", Memo = "新しいメモ", Comment = "コメント", CreateDate = DateTime.Now, LastUpDate = DateTime.Now, SortType = CategorySortType.MANUAL, }; repoCategory.Add(catNew); dbc.SaveChanges(); id_child = catNew.Id; catRoot.ChildCategories.Add(catNew); dbc.SaveChanges(); Console.WriteLine("ROOTカテゴリの子階層({0})に、新しいカテゴリを追加しました。", id_child); } // 保存した子階層カテゴリを参照 using (var dbc = new AppDbContext()) { var repoCategory = new CategoryRepository(dbc); var catRoot = repoCategory.Load(1L); Console.WriteLine("ROOTカテゴリの子階層カテゴリのID({0})を確認", catRoot.ChildCategories[0].Id); } // 子階層カテゴリから、親階層カテゴリ(ID=1)の参照 using (var dbc = new AppDbContext()) { var repoCategory = new CategoryRepository(dbc); var catChild = repoCategory.Load(id_child); Console.WriteLine("子階層カテゴリの親カテゴリ({0})を確認", catChild.ParentCategory.Id); } }
public void BeforeTest(ITest testDetails) { lock (this) { LOG.Info("UsingDatabaseAction::BeforeTest"); string personalDirectoryPath = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal); Console.WriteLine("Dir={0}", personalDirectoryPath); if (application == null) { application = new Application(); } var buildAssemblyType = new BuildAssemblyParameter(); buildAssemblyType.Params["ApplicationDirectoryPath"] = @"\Mogami.CT.xUnit"; ApplicationContext.SetupApplicationContextImpl(ApplicationContextImpl.CreateInstance(application, buildAssemblyType)); var task = Task.Factory.StartNew(() => { LOG.Info("アプリケーションの初期化を開始します。"); this.InitializeApplicationCompleteFlag = false; ((ApplicationContextImpl)ApplicationContextImpl.GetInstance()).RemoveUnitDbFile(); // DBファイルが削除できないこともある //((ApplicationContextImpl)ApplicationContextImpl.GetInstance()).InitializeApplicationProgressEvent += UsingDatabaseActionAttribute_InitializeApplicationProgressEvent; ((ApplicationContextImpl)ApplicationContextImpl.GetInstance()).InitializeApplication(); DeleteAllData("App"); DeleteAllData("Thumbnail"); ((ApplicationContextImpl)ApplicationContextImpl.GetInstance()).Initialize(InitializeParamType.DATABASE); LOG.Info("アプリケーションの初期化が終了しました。"); }); task.Wait(); LOG.Info("データベースの初期化を完了しました。"); if (ImportInitializeDataFlag) { ImportInitializeData(); if (!string.IsNullOrEmpty(ImportSqlFileName)) { ImportSqlFile(); } } } Console.WriteLine("BeforeTest"); }
static void RunServiceTB1() { // Serviceサーバーを起動して、クライアントにWSDLなどを公開するためのコンソールプログラムです。 System.Threading.Thread.CurrentThread.Name = "Nadesico API"; application = new Application(); var buildAssemblyType = new BuildAssemblyParameter(); buildAssemblyType.Params["ApplicationDirectoryPath"] = @"\Nadesico_InvokeServiceConsole"; ApplicationContext.SetupApplicationContextImpl(ApplicationContextImpl.CreateInstance(application, buildAssemblyType)); ((ApplicationContextImpl)ApplicationContextImpl.GetInstance()).InitializeApplication(); using (ServiceHost host = new ServiceHost(typeof(ApplicationInterfaceService))) { // ① エンドポイントの手動構成設定 (C/B/A を指定) // バインディングの構成設定を行いたい場合には、Binding インスタンスのプロパティを設定する var binder = new NetNamedPipeBinding(); binder.MaxBufferSize = 1073741824; binder.MaxBufferPoolSize = 1073741824; binder.MaxReceivedMessageSize = 1073741824; binder.ReaderQuotas.MaxArrayLength = 1073741824; host.AddServiceEndpoint(typeof(IApplicationInterfaceService), binder, "net.pipe://localhost/Nadesico.Server/Application"); // ② ビヘイビアの手動構成設定 // すでにいくつかのビヘイビアは既定で追加されているため、取り払ってから再設定する host.Description.Behaviors.Remove(typeof(ServiceDebugBehavior)); host.Description.Behaviors.Remove(typeof(ServiceMetadataBehavior)); host.Description.Behaviors.Add(new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true }); host.Description.Behaviors.Add(new ServiceMetadataBehavior { HttpGetEnabled = true, HttpGetUrl = new Uri("http://localhost:8001/Nadesico.Server/Application/mex") }); // ホストのオープン host.Open(); Console.WriteLine("WCF サービスを起動しました。"); Console.ReadLine(); host.Close(); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { InitializeContainer(app); var appConfig = new AppSettings(); Configuration.Bind("AppSettings", appConfig); container.Register <ErrorExceptionResolver>(); var assemblyParameter = new BuildAssemblyParameter(appConfig); var context = new ApplicationContextImpl(assemblyParameter); // アプリケーションコンテキスト context.SetDiContainer(container); container.RegisterInstance <IApplicationContext>(context); container.RegisterInstance <IBuildAssemblyParameter>(assemblyParameter); container.Register <ICategoryRepository, CategoryRepository>(); container.Register <IContentRepository, ContentRepository>(); container.Register <IEventLogRepository, EventLogRepository>(); container.Register <IFileMappingInfoRepository, FileMappingInfoRepository>(); container.Register <ILabelRepository, LabelRepository>(); container.Register <IWorkspaceRepository, WorkspaceRepository>(); container.Register <IAppAppMetaInfoRepository, AppAppMetaInfoRepository>(); container.Register <IThumbnailAppMetaInfoRepository, ThumbnailAppMetaInfoRepository>(); container.Register <IThumbnailRepository, ThumbnailRepository>(); container.Register <ApiResponseBuilder>(); container.Register <IAppDbContext, AppDbContext>(Lifestyle.Scoped); container.Register <IThumbnailDbContext, ThumbnailDbContext>(Lifestyle.Scoped); container.Register <IThumbnailBuilder, ThumbnailBuilder>(); container.Register <IFileUpdateRunner, FileUpdateRunner>(); var messagingManager = new MessagingManager(container); container.RegisterInstance <MessagingManager>(messagingManager); container.RegisterInstance <IMessagingManager>(messagingManager); var extentionManager = new ExtentionManager(container); //extentionManager.AddPlugin(typeof(FullBuildExtention)); // 開発中は常に拡張機能を読み込む //extentionManager.AddPlugin(typeof(WebScribeExtention)); // 開発中は常に拡張機能を読み込む container.RegisterInstance <ExtentionManager>(extentionManager); extentionManager.InitializePlugin(context.ExtentionDirectoryPath); extentionManager.CompletePlugin(); var vspFileUpdateWatchManager = new VspFileUpdateWatchManager(container); container.RegisterInstance <VspFileUpdateWatchManager>(vspFileUpdateWatchManager); container.Verify(); using (AsyncScopedLifestyle.BeginScope(container)) { var appCtx = (ApplicationContextImpl)container.GetInstance <IApplicationContext>(); appCtx.Initialize(); // デフォルトワークスペースが登録済みかチェックする var workspaceRepository = container.GetInstance <IWorkspaceRepository>(); var workspace = workspaceRepository.Load(1L); if (workspace == null) { if (appConfig.Workspace == null) { throw new ApplicationException("デフォルトワークスペースの設定が必要です。"); } // デフォルトワークスペースを新規登録する workspace = workspaceRepository.New(); workspace.Name = appConfig.Workspace.Name; if (appConfig.Workspace.RelativeApplicationDirectoryBasePath) { workspace.PhysicalPath = Path.Combine(appCtx.ApplicationDirectoryPath, appConfig.Workspace.PhysicalPath); workspace.VirtualPath = Path.Combine(appCtx.ApplicationDirectoryPath, appConfig.Workspace.VirtualPath); } else { workspace.PhysicalPath = appConfig.Workspace.PhysicalPath; workspace.VirtualPath = appConfig.Workspace.VirtualPath; } workspaceRepository.Save(); _logger.Info($"デフォルトワークスペースを作成しました。 Name:{workspace.Name}"); } } if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true }); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); using (AsyncScopedLifestyle.BeginScope(container)) { // カットポイント「INIT」を呼び出す extentionManager.Execute(ExtentionCutpointType.INIT); } using (AsyncScopedLifestyle.BeginScope(container)) { // カットポイント「START」を呼び出す extentionManager.Execute(ExtentionCutpointType.START, new CutpointStartParameter { WorkspaceId = 1L }); } // 監視開始 using (AsyncScopedLifestyle.BeginScope(container)) { var workspaceRepository = container.GetInstance <IWorkspaceRepository>(); var workspace = workspaceRepository.Load(1L); vspFileUpdateWatchManager.StartWatch(workspace); } app.Use((c, next) => container.GetInstance <ErrorExceptionResolver>().Invoke(c, next)); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapSpaFallbackRoute( name: "spa-fallback", defaults: new { controller = "Home", action = "Index" }); }); }