잉여장비목록 화면 추가(최효준s)
This commit is contained in:
19
OwinProject/Class1.cs
Normal file
19
OwinProject/Class1.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using Microsoft.Owin.Hosting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OwinProject
|
||||
{
|
||||
public static class OwinServer
|
||||
{
|
||||
public static void Run()
|
||||
{
|
||||
// Start OWIN host
|
||||
WebApp.Start<OWIN.Startup>(url: "http://127.0.0.1:9000");
|
||||
Console.WriteLine("start webapp");
|
||||
}
|
||||
}
|
||||
}
|
||||
76
OwinProject/OWIN/Startup.cs
Normal file
76
OwinProject/OWIN/Startup.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using Microsoft.Owin;
|
||||
using Owin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Routing;
|
||||
|
||||
namespace OwinProject.OWIN
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public void Configuration(IAppBuilder appBuilder)
|
||||
{
|
||||
// Configure Web API for Self-Host
|
||||
HttpConfiguration config = new HttpConfiguration();
|
||||
config.MapHttpAttributeRoutes();
|
||||
|
||||
//메인파일 처리 방법
|
||||
IHttpRoute defaultRoute =
|
||||
config.Routes.CreateRoute("{controller}/{action}/{id}",
|
||||
new { controller = "home", action = "index", id = RouteParameter.Optional },
|
||||
null);
|
||||
|
||||
//기타파일들 처리 방법
|
||||
IHttpRoute cssRoute =
|
||||
config.Routes.CreateRoute("{path}/{subdir}/{resource}.{ext}",
|
||||
new { controller = "resource", action = "file", id = RouteParameter.Optional },
|
||||
null);
|
||||
|
||||
IHttpRoute mifRoute =
|
||||
config.Routes.CreateRoute("{path}/{resource}.{ext}",
|
||||
new { controller = "resource", action = "file", id = RouteParameter.Optional },
|
||||
null);
|
||||
|
||||
IHttpRoute icoRoute =
|
||||
config.Routes.CreateRoute("{resource}.{ext}",
|
||||
new { controller = "resource", action = "file", id = RouteParameter.Optional },
|
||||
null);
|
||||
|
||||
config.Routes.Add("mifRoute", mifRoute);
|
||||
config.Routes.Add("icoRoute", icoRoute);
|
||||
config.Routes.Add("cssRoute", cssRoute);
|
||||
config.Routes.Add("defaultRoute", defaultRoute);
|
||||
appBuilder.UseWebApi(config);
|
||||
|
||||
|
||||
//appBuilder.UseFileServer(new FileServerOptions
|
||||
//{
|
||||
// RequestPath = new PathString(string.Empty),
|
||||
// FileSystem = new PhysicalFileSystem("./MySubFolder"),
|
||||
// EnableDirectoryBrowsing = true,
|
||||
//});
|
||||
|
||||
//appBuilder.UseStageMarker(PipelineStage.MapHandler);
|
||||
|
||||
|
||||
//config.Routes.MapHttpRoute(
|
||||
// name: "ignore",
|
||||
// routeTemplate: @".*\.(css|js|gif|jpg)(/.*)?",
|
||||
// defaults: new
|
||||
// {
|
||||
// controller = "file",
|
||||
// action = "readtext",
|
||||
// id = RouteParameter.Optional
|
||||
// }
|
||||
// );
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
101
OwinProject/OWIN/StartupSSE.cs
Normal file
101
OwinProject/OWIN/StartupSSE.cs
Normal file
@@ -0,0 +1,101 @@
|
||||
using Microsoft.Owin;
|
||||
using Owin;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace OwinProject.OWIN
|
||||
{
|
||||
public class StartupSSE
|
||||
{
|
||||
|
||||
|
||||
public void Configuration(IAppBuilder app)
|
||||
{
|
||||
var api = new Api();
|
||||
app.Run(context => api.Invoke(context));
|
||||
}
|
||||
|
||||
public class Subscriber
|
||||
{
|
||||
private StreamWriter _writer;
|
||||
private TaskCompletionSource<bool> _tcs;
|
||||
public Subscriber(Stream body, TaskCompletionSource<bool> tcs)
|
||||
{
|
||||
this._writer = new StreamWriter(body);
|
||||
this._tcs = tcs;
|
||||
}
|
||||
|
||||
public async void WriteAsync(string message)
|
||||
{
|
||||
try
|
||||
{
|
||||
_writer.Write(message);
|
||||
_writer.Flush();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (e.HResult == -2146232800) // non-existent connection
|
||||
_tcs.SetResult(true);
|
||||
else
|
||||
_tcs.SetException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Api
|
||||
{
|
||||
System.Timers.Timer _timer = new System.Timers.Timer(500);
|
||||
List<Subscriber> _subscribers = new List<Subscriber>();
|
||||
public Api()
|
||||
{
|
||||
_timer.Elapsed += _timer_Elapsed;
|
||||
}
|
||||
|
||||
void _timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
UpdateSubscribers();
|
||||
}
|
||||
|
||||
public void UpdateSubscribers()
|
||||
{
|
||||
Console.WriteLine("updating {0} subscribers", _subscribers.Count);
|
||||
var subscribersCopy = _subscribers.ToList<Subscriber>();
|
||||
var msg = String.Format("Hello async at {0}\n", DateTime.Now);
|
||||
subscribersCopy.ForEach(w => w.WriteAsync(msg));
|
||||
_timer.Start();
|
||||
}
|
||||
|
||||
|
||||
public Task Invoke(IOwinContext context)
|
||||
{
|
||||
SetEventHeaders(context);
|
||||
System.IO.Stream responseStream = context.Environment["owin.ResponseBody"] as Stream;
|
||||
var tcs = new TaskCompletionSource<bool>();
|
||||
var s = CreateSubscriber(responseStream, tcs);
|
||||
tcs.Task.ContinueWith(_ => _subscribers.Remove(s));
|
||||
Console.WriteLine("Add subscriber. Now have {0}", _subscribers.Count);
|
||||
s.WriteAsync("Registered\n");
|
||||
_timer.Start();
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
private Subscriber CreateSubscriber(System.IO.Stream responseStream, TaskCompletionSource<bool> tcs)
|
||||
{
|
||||
var s = new Subscriber(responseStream, tcs);
|
||||
_subscribers.Add(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
private static void SetEventHeaders(IOwinContext context)
|
||||
{
|
||||
context.Response.ContentType = "text/eventstream";
|
||||
context.Response.Headers["Transfer-Encoding"] = "chunked";
|
||||
context.Response.Headers["cache-control"] = "no-cache";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
78
OwinProject/OwinProject.csproj
Normal file
78
OwinProject/OwinProject.csproj
Normal file
@@ -0,0 +1,78 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{0C3DC465-73BB-4086-BED4-5EAA100F082A}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>OwinProject</RootNamespace>
|
||||
<AssemblyName>OwinProject</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Owin, Version=4.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.4.1.1\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Host.HttpListener, Version=4.1.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.Host.HttpListener.4.1.1\lib\net45\Microsoft.Owin.Host.HttpListener.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Owin.Hosting, Version=2.0.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.Owin.Hosting.2.0.2\lib\net45\Microsoft.Owin.Hosting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.5.2.7\lib\net45\System.Net.Http.Formatting.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.5.2.7\lib\net45\System.Web.Http.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.Owin, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Owin.5.2.7\lib\net45\System.Web.Http.Owin.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="OWIN\Startup.cs" />
|
||||
<Compile Include="OWIN\StartupSSE.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="app.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
6
OwinProject/OwinProject.csproj.user
Normal file
6
OwinProject/OwinProject.csproj.user
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<ProjectView>ProjectFiles</ProjectView>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
36
OwinProject/Properties/AssemblyInfo.cs
Normal file
36
OwinProject/Properties/AssemblyInfo.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
|
||||
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
|
||||
// 이러한 특성 값을 변경하세요.
|
||||
[assembly: AssemblyTitle("OwinProject")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("OwinProject")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
|
||||
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
|
||||
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
|
||||
[assembly: Guid("0c3dc465-73bb-4086-bed4-5eaa100f082a")]
|
||||
|
||||
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
|
||||
//
|
||||
// 주 버전
|
||||
// 부 버전
|
||||
// 빌드 번호
|
||||
// 수정 버전
|
||||
//
|
||||
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
|
||||
// 기본값으로 할 수 있습니다.
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
15
OwinProject/app.config
Normal file
15
OwinProject/app.config
Normal file
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-12.0.0.0" newVersion="12.0.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
12
OwinProject/packages.config
Normal file
12
OwinProject/packages.config
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.7" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.7" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.7" targetFramework="net452" />
|
||||
<package id="Microsoft.AspNet.WebApi.OwinSelfHost" version="5.2.7" targetFramework="net452" />
|
||||
<package id="Microsoft.Owin" version="4.1.1" targetFramework="net452" />
|
||||
<package id="Microsoft.Owin.Host.HttpListener" version="4.1.1" targetFramework="net452" />
|
||||
<package id="Microsoft.Owin.Hosting" version="2.0.2" targetFramework="net452" />
|
||||
<package id="Newtonsoft.Json" version="12.0.3" targetFramework="net452" />
|
||||
<package id="Owin" version="1.0" targetFramework="net452" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user