This commit is contained in:
chi
2020-12-11 17:53:47 +09:00
parent 0f44fbe9f8
commit bd41902254
60 changed files with 12425 additions and 2853 deletions

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="JobReportMailService.Properties.Settings.CS" connectionString="Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123!" providerName="System.Data.SqlClient" />
<add name="EEEntities" connectionString="metadata=res://*/Model1.csdl|res://*/Model1.ssdl|res://*/Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=10.131.15.18;initial catalog=EE;persist security info=True;user id=eeuser;password=Amkor123!;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>

View File

@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace JobReportMailService
{
public class CSetting : arUtil.Setting
{
public string connstr { get; set; }
public override void AfterLoad()
{
//throw new NotImplementedException();
if (connstr == "")
connstr = "Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123!";
}
public override void AfterSave()
{
//throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,24 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 템플릿에서 생성되었습니다.
//
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JobReportMailService
{
using System;
using System.Collections.Generic;
public partial class HolidayLIst
{
public int idx { get; set; }
public string pdate { get; set; }
public Nullable<bool> free { get; set; }
public string memo { get; set; }
public string wuid { get; set; }
public System.DateTime wdate { get; set; }
}
}

View File

@@ -0,0 +1,38 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 템플릿에서 생성되었습니다.
//
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JobReportMailService
{
using System;
using System.Collections.Generic;
public partial class JobReport
{
public int idx { get; set; }
public string gcode { get; set; }
public string pdate { get; set; }
public Nullable<int> pidx { get; set; }
public string projectName { get; set; }
public string uid { get; set; }
public string requestpart { get; set; }
public string package { get; set; }
public string status { get; set; }
public string type { get; set; }
public string process { get; set; }
public string description { get; set; }
public string remark { get; set; }
public Nullable<double> hrs { get; set; }
public Nullable<double> ot { get; set; }
public Nullable<bool> import { get; set; }
public string wuid { get; set; }
public System.DateTime wdate { get; set; }
public string description2 { get; set; }
public string tag { get; set; }
}
}

View File

@@ -0,0 +1,133 @@
<?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>{DBE5BD4A-09D3-4437-AD6C-81FE270C6458}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>JobReportMailService</RootNamespace>
<AssemblyName>JobReportMailService</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="ArSetting.Net4">
<HintPath>..\DLL\ArSetting.Net4.dll</HintPath>
</Reference>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Security" />
<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="CSetting.cs" />
<Compile Include="HolidayLIst.cs">
<DependentUpon>Model1.tt</DependentUpon>
</Compile>
<Compile Include="JobReport.cs">
<DependentUpon>Model1.tt</DependentUpon>
</Compile>
<Compile Include="MailData.cs">
<DependentUpon>Model1.tt</DependentUpon>
</Compile>
<Compile Include="MailForm.cs">
<DependentUpon>Model1.tt</DependentUpon>
</Compile>
<Compile Include="Model1.Context.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Model1.Context.tt</DependentUpon>
</Compile>
<Compile Include="Model1.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Model1.tt</DependentUpon>
</Compile>
<Compile Include="Model1.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Model1.edmx</DependentUpon>
</Compile>
<Compile Include="ProgramWeek.cs" />
<Compile Include="ProgramDay.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="ReportUserData.cs" />
<Compile Include="vGroupUser.cs">
<DependentUpon>Model1.tt</DependentUpon>
</Compile>
<Compile Include="vJobReportForUser.cs">
<DependentUpon>Model1.tt</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<EntityDeploy Include="Model1.edmx">
<Generator>EntityModelCodeGenerator</Generator>
<LastGenOutput>Model1.Designer.cs</LastGenOutput>
</EntityDeploy>
<None Include="Model1.edmx.diagram">
<DependentUpon>Model1.edmx</DependentUpon>
</None>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Model1.Context.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>Model1.Context.cs</LastGenOutput>
<DependentUpon>Model1.edmx</DependentUpon>
</Content>
<Content Include="Model1.tt">
<Generator>TextTemplatingFileGenerator</Generator>
<DependentUpon>Model1.edmx</DependentUpon>
<LastGenOutput>Model1.cs</LastGenOutput>
</Content>
</ItemGroup>
<ItemGroup>
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 템플릿에서 생성되었습니다.
//
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JobReportMailService
{
using System;
using System.Collections.Generic;
public partial class MailData
{
public int idx { get; set; }
public Nullable<int> project { get; set; }
public string gcode { get; set; }
public string cate { get; set; }
public string pdate { get; set; }
public string subject { get; set; }
public string fromlist { get; set; }
public string tolist { get; set; }
public string bcc { get; set; }
public string cc { get; set; }
public string body { get; set; }
public Nullable<bool> SendOK { get; set; }
public string SendMsg { get; set; }
public Nullable<int> aidx { get; set; }
public string atime { get; set; }
public string wuid { get; set; }
public System.DateTime wdate { get; set; }
}
}

View File

@@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 템플릿에서 생성되었습니다.
//
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JobReportMailService
{
using System;
using System.Collections.Generic;
public partial class MailForm
{
public int idx { get; set; }
public string gcode { get; set; }
public string cate { get; set; }
public string title { get; set; }
public string tolist { get; set; }
public string bcc { get; set; }
public string cc { get; set; }
public string subject { get; set; }
public string tail { get; set; }
public string body { get; set; }
public Nullable<bool> selfTo { get; set; }
public Nullable<bool> selfCC { get; set; }
public Nullable<bool> selfBCC { get; set; }
public string wuid { get; set; }
public System.DateTime wdate { get; set; }
public string exceptmail { get; set; }
public string exceptmailcc { get; set; }
}
}

View File

@@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 템플릿에서 생성되었습니다.
//
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JobReportMailService
{
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
public partial class EEEntities : DbContext
{
public EEEntities()
: base("name=EEEntities")
{
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
public virtual DbSet<JobReport> JobReport { get; set; }
public virtual DbSet<MailData> MailData { get; set; }
public virtual DbSet<vGroupUser> vGroupUser { get; set; }
public virtual DbSet<vJobReportForUser> vJobReportForUser { get; set; }
public virtual DbSet<HolidayLIst> HolidayLIst { get; set; }
public virtual DbSet<MailForm> MailForm { get; set; }
}
}

View File

@@ -0,0 +1,636 @@
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
output extension=".cs"#><#
const string inputFile = @"Model1.edmx";
var textTransform = DynamicTextTransformation.Create(this);
var code = new CodeGenerationTools(this);
var ef = new MetadataTools(this);
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
var loader = new EdmMetadataLoader(textTransform.Host, textTransform.Errors);
var itemCollection = loader.CreateEdmItemCollection(inputFile);
var modelNamespace = loader.GetModelNamespace(inputFile);
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
var container = itemCollection.OfType<EntityContainer>().FirstOrDefault();
if (container == null)
{
return string.Empty;
}
#>
//------------------------------------------------------------------------------
// <auto-generated>
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
//
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
// </auto-generated>
//------------------------------------------------------------------------------
<#
var codeNamespace = code.VsNamespaceSuggestion();
if (!String.IsNullOrEmpty(codeNamespace))
{
#>
namespace <#=code.EscapeNamespace(codeNamespace)#>
{
<#
PushIndent(" ");
}
#>
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
<#
if (container.FunctionImports.Any())
{
#>
using System.Data.Entity.Core.Objects;
using System.Linq;
<#
}
#>
<#=Accessibility.ForType(container)#> partial class <#=code.Escape(container)#> : DbContext
{
public <#=code.Escape(container)#>()
: base("name=<#=container.Name#>")
{
<#
if (!loader.IsLazyLoadingEnabled(container))
{
#>
this.Configuration.LazyLoadingEnabled = false;
<#
}
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
{
// Note: the DbSet members are defined below such that the getter and
// setter always have the same accessibility as the DbSet definition
if (Accessibility.ForReadOnlyProperty(entitySet) != "public")
{
#>
<#=codeStringGenerator.DbSetInitializer(entitySet)#>
<#
}
}
#>
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
throw new UnintentionalCodeFirstException();
}
<#
foreach (var entitySet in container.BaseEntitySets.OfType<EntitySet>())
{
#>
<#=codeStringGenerator.DbSet(entitySet)#>
<#
}
foreach (var edmFunction in container.FunctionImports)
{
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: false);
}
#>
}
<#
if (!String.IsNullOrEmpty(codeNamespace))
{
PopIndent();
#>
}
<#
}
#>
<#+
private void WriteFunctionImport(TypeMapper typeMapper, CodeStringGenerator codeStringGenerator, EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
{
if (typeMapper.IsComposable(edmFunction))
{
#>
[DbFunction("<#=edmFunction.NamespaceName#>", "<#=edmFunction.Name#>")]
<#=codeStringGenerator.ComposableFunctionMethod(edmFunction, modelNamespace)#>
{
<#+
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
#>
<#=codeStringGenerator.ComposableCreateQuery(edmFunction, modelNamespace)#>
}
<#+
}
else
{
#>
<#=codeStringGenerator.FunctionMethod(edmFunction, modelNamespace, includeMergeOption)#>
{
<#+
codeStringGenerator.WriteFunctionParameters(edmFunction, WriteFunctionParameter);
#>
<#=codeStringGenerator.ExecuteFunction(edmFunction, modelNamespace, includeMergeOption)#>
}
<#+
if (typeMapper.GenerateMergeOptionFunction(edmFunction, includeMergeOption))
{
WriteFunctionImport(typeMapper, codeStringGenerator, edmFunction, modelNamespace, includeMergeOption: true);
}
}
}
public void WriteFunctionParameter(string name, string isNotNull, string notNullInit, string nullInit)
{
#>
var <#=name#> = <#=isNotNull#> ?
<#=notNullInit#> :
<#=nullInit#>;
<#+
}
public const string TemplateId = "CSharp_DbContext_Context_EF6";
public class CodeStringGenerator
{
private readonly CodeGenerationTools _code;
private readonly TypeMapper _typeMapper;
private readonly MetadataTools _ef;
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
{
ArgumentNotNull(code, "code");
ArgumentNotNull(typeMapper, "typeMapper");
ArgumentNotNull(ef, "ef");
_code = code;
_typeMapper = typeMapper;
_ef = ef;
}
public string Property(EdmProperty edmProperty)
{
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1} {2} {{ {3}get; {4}set; }}",
Accessibility.ForProperty(edmProperty),
_typeMapper.GetTypeName(edmProperty.TypeUsage),
_code.Escape(edmProperty),
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
}
public string NavigationProperty(NavigationProperty navProp)
{
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1} {2} {{ {3}get; {4}set; }}",
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
_code.Escape(navProp),
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
}
public string AccessibilityAndVirtual(string accessibility)
{
return accessibility + (accessibility != "private" ? " virtual" : "");
}
public string EntityClassOpening(EntityType entity)
{
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1}partial class {2}{3}",
Accessibility.ForType(entity),
_code.SpaceAfter(_code.AbstractOption(entity)),
_code.Escape(entity),
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
}
public string EnumOpening(SimpleType enumType)
{
return string.Format(
CultureInfo.InvariantCulture,
"{0} enum {1} : {2}",
Accessibility.ForType(enumType),
_code.Escape(enumType),
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
}
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
{
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
{
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
}
}
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
{
var parameters = _typeMapper.GetParameters(edmFunction);
return string.Format(
CultureInfo.InvariantCulture,
"{0} IQueryable<{1}> {2}({3})",
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
_code.Escape(edmFunction),
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
}
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
{
var parameters = _typeMapper.GetParameters(edmFunction);
return string.Format(
CultureInfo.InvariantCulture,
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
edmFunction.NamespaceName,
edmFunction.Name,
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
}
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
{
var parameters = _typeMapper.GetParameters(edmFunction);
var returnType = _typeMapper.GetReturnType(edmFunction);
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
if (includeMergeOption)
{
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
}
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1} {2}({3})",
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
_code.Escape(edmFunction),
paramList);
}
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
{
var parameters = _typeMapper.GetParameters(edmFunction);
var returnType = _typeMapper.GetReturnType(edmFunction);
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
if (includeMergeOption)
{
callParams = ", mergeOption" + callParams;
}
return string.Format(
CultureInfo.InvariantCulture,
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
edmFunction.Name,
callParams);
}
public string DbSet(EntitySet entitySet)
{
return string.Format(
CultureInfo.InvariantCulture,
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
Accessibility.ForReadOnlyProperty(entitySet),
_typeMapper.GetTypeName(entitySet.ElementType),
_code.Escape(entitySet));
}
public string DbSetInitializer(EntitySet entitySet)
{
return string.Format(
CultureInfo.InvariantCulture,
"{0} = Set<{1}>();",
_code.Escape(entitySet),
_typeMapper.GetTypeName(entitySet.ElementType));
}
public string UsingDirectives(bool inHeader, bool includeCollections = true)
{
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
? string.Format(
CultureInfo.InvariantCulture,
"{0}using System;{1}" +
"{2}",
inHeader ? Environment.NewLine : "",
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
inHeader ? "" : Environment.NewLine)
: "";
}
}
public class TypeMapper
{
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
private readonly System.Collections.IList _errors;
private readonly CodeGenerationTools _code;
private readonly MetadataTools _ef;
public static string FixNamespaces(string typeName)
{
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
}
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
{
ArgumentNotNull(code, "code");
ArgumentNotNull(ef, "ef");
ArgumentNotNull(errors, "errors");
_code = code;
_ef = ef;
_errors = errors;
}
public string GetTypeName(TypeUsage typeUsage)
{
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
}
public string GetTypeName(EdmType edmType)
{
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
}
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
{
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
}
public string GetTypeName(EdmType edmType, string modelNamespace)
{
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
}
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
{
if (edmType == null)
{
return null;
}
var collectionType = edmType as CollectionType;
if (collectionType != null)
{
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
}
var typeName = _code.Escape(edmType.MetadataProperties
.Where(p => p.Name == ExternalTypeNameAttributeName)
.Select(p => (string)p.Value)
.FirstOrDefault())
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
_code.Escape(edmType));
if (edmType is StructuralType)
{
return typeName;
}
if (edmType is SimpleType)
{
var clrType = UnderlyingClrType(edmType);
if (!IsEnumType(edmType))
{
typeName = _code.Escape(clrType);
}
typeName = FixNamespaces(typeName);
return clrType.IsValueType && isNullable == true ?
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
typeName;
}
throw new ArgumentException("edmType");
}
public Type UnderlyingClrType(EdmType edmType)
{
ArgumentNotNull(edmType, "edmType");
var primitiveType = edmType as PrimitiveType;
if (primitiveType != null)
{
return primitiveType.ClrEquivalentType;
}
if (IsEnumType(edmType))
{
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
}
return typeof(object);
}
public object GetEnumMemberValue(MetadataItem enumMember)
{
ArgumentNotNull(enumMember, "enumMember");
var valueProperty = enumMember.GetType().GetProperty("Value");
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
}
public string GetEnumMemberName(MetadataItem enumMember)
{
ArgumentNotNull(enumMember, "enumMember");
var nameProperty = enumMember.GetType().GetProperty("Name");
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
}
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
{
ArgumentNotNull(enumType, "enumType");
var membersProperty = enumType.GetType().GetProperty("Members");
return membersProperty != null
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
: Enumerable.Empty<MetadataItem>();
}
public bool EnumIsFlags(EdmType enumType)
{
ArgumentNotNull(enumType, "enumType");
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
}
public bool IsEnumType(GlobalItem edmType)
{
ArgumentNotNull(edmType, "edmType");
return edmType.GetType().Name == "EnumType";
}
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
{
ArgumentNotNull(enumType, "enumType");
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
}
public string CreateLiteral(object value)
{
if (value == null || value.GetType() != typeof(TimeSpan))
{
return _code.CreateLiteral(value);
}
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
}
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
{
ArgumentNotNull(types, "types");
ArgumentNotNull(sourceFile, "sourceFile");
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
if (types.Any(item => !hash.Add(item)))
{
_errors.Add(
new CompilerError(sourceFile, -1, -1, "6023",
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
return false;
}
return true;
}
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
{
return GetItemsToGenerate<SimpleType>(itemCollection)
.Where(e => IsEnumType(e));
}
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
{
return itemCollection
.OfType<T>()
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
.OrderBy(i => i.Name);
}
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
{
return itemCollection
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
.Select(g => GetGlobalItemName(g));
}
public string GetGlobalItemName(GlobalItem item)
{
if (item is EdmType)
{
return ((EdmType)item).Name;
}
else
{
return ((EntityContainer)item).Name;
}
}
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
}
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
}
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
}
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
}
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
}
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
}
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
{
return type.NavigationProperties.Where(np => np.DeclaringType == type);
}
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
{
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
}
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
{
ArgumentNotNull(edmFunction, "edmFunction");
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
return returnParamsProperty == null
? edmFunction.ReturnParameter
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
}
public bool IsComposable(EdmFunction edmFunction)
{
ArgumentNotNull(edmFunction, "edmFunction");
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
}
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
{
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
}
public TypeUsage GetReturnType(EdmFunction edmFunction)
{
var returnParam = GetReturnParameter(edmFunction);
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
}
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
{
var returnType = GetReturnType(edmFunction);
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
}
}
public static void ArgumentNotNull<T>(T arg, string name) where T : class
{
if (arg == null)
{
throw new ArgumentNullException(name);
}
}
#>

10
JobReportMailService/Model1.Designer.cs generated Normal file
View File

@@ -0,0 +1,10 @@
// 모델 'D:\Source\##### 완료아이템\(014) GroupWare\Source\JobReportMailService\Model1.edmx'에 대해 T4 코드 생성이 사용됩니다.
// 레거시 코드 생성을 사용하려면 '코드 생성 전략' 디자이너 속성의 값을
// 'Legacy ObjectContext'로 변경하십시오. 이 속성은 모델이 디자이너에서 열릴 때
// 속성 창에서 사용할 수 있습니다.
// 컨텍스트 및 엔터티 클래스가 생성되지 않은 경우 빈 모델을 만들었기 때문일 수도 있지만
// 사용할 Entity Framework 버전을 선택하지 않았기 때문일 수도 있습니다. 모델에 맞는 컨텍스트 클래스 및
// 엔터티 클래스를 생성하려면 디자이너에서 모델을 열고 디자이너 화면에서 마우스 오른쪽 단추를 클릭한
// 다음 '데이터베이스에서 모델 업데이트...', '모델에서 데이터베이스 생성...' 또는 '코드 생성 항목 추가...'를
// 선택하십시오.

View File

@@ -0,0 +1,9 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 템플릿에서 생성되었습니다.
//
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
// </auto-generated>
//------------------------------------------------------------------------------

View File

@@ -0,0 +1,469 @@
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Runtime content -->
<edmx:Runtime>
<!-- SSDL content -->
<edmx:StorageModels>
<Schema Namespace="EEModel.Store" Provider="System.Data.SqlClient" ProviderManifestToken="2008" Alias="Self" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm/ssdl">
<EntityType Name="HolidayLIst">
<Key>
<PropertyRef Name="idx" />
</Key>
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="pdate" Type="varchar" MaxLength="10" />
<Property Name="free" Type="bit" />
<Property Name="memo" Type="nvarchar" MaxLength="255" />
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
</EntityType>
<EntityType Name="JobReport">
<Key>
<PropertyRef Name="idx" />
</Key>
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
<Property Name="pdate" Type="varchar" MaxLength="10" />
<Property Name="pidx" Type="int" />
<Property Name="projectName" Type="nvarchar" MaxLength="255" />
<Property Name="uid" Type="varchar" MaxLength="20" />
<Property Name="requestpart" Type="varchar" MaxLength="50" />
<Property Name="package" Type="varchar" MaxLength="50" />
<Property Name="status" Type="varchar" MaxLength="20" />
<Property Name="type" Type="varchar" MaxLength="50" />
<Property Name="process" Type="varchar" MaxLength="50" />
<Property Name="description" Type="nvarchar(max)" />
<Property Name="remark" Type="nvarchar" MaxLength="255" />
<Property Name="hrs" Type="float" />
<Property Name="ot" Type="float" />
<Property Name="import" Type="bit" />
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
<Property Name="description2" Type="nvarchar(max)" />
<Property Name="tag" Type="varchar" MaxLength="255" />
</EntityType>
<EntityType Name="MailData">
<Key>
<PropertyRef Name="idx" />
</Key>
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="project" Type="int" />
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
<Property Name="cate" Type="varchar" MaxLength="20" />
<Property Name="pdate" Type="varchar" MaxLength="10" />
<Property Name="subject" Type="varchar(max)" />
<Property Name="fromlist" Type="varchar(max)" />
<Property Name="tolist" Type="varchar(max)" />
<Property Name="bcc" Type="varchar(max)" />
<Property Name="cc" Type="varchar(max)" />
<Property Name="body" Type="varchar(max)" />
<Property Name="SendOK" Type="bit" />
<Property Name="SendMsg" Type="varchar" MaxLength="255" />
<Property Name="aidx" Type="int" />
<Property Name="atime" Type="varchar" MaxLength="20" />
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
</EntityType>
<EntityType Name="MailForm">
<Key>
<PropertyRef Name="idx" />
</Key>
<Property Name="idx" Type="int" StoreGeneratedPattern="Identity" Nullable="false" />
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
<Property Name="cate" Type="varchar" MaxLength="2" />
<Property Name="title" Type="varchar" MaxLength="100" />
<Property Name="tolist" Type="varchar(max)" />
<Property Name="bcc" Type="varchar(max)" />
<Property Name="cc" Type="varchar(max)" />
<Property Name="subject" Type="varchar(max)" />
<Property Name="tail" Type="varchar(max)" />
<Property Name="body" Type="varchar(max)" />
<Property Name="selfTo" Type="bit" />
<Property Name="selfCC" Type="bit" />
<Property Name="selfBCC" Type="bit" />
<Property Name="wuid" Type="varchar" MaxLength="20" Nullable="false" />
<Property Name="wdate" Type="smalldatetime" Nullable="false" />
<Property Name="exceptmail" Type="varchar(max)" />
<Property Name="exceptmailcc" Type="varchar(max)" />
</EntityType>
<!--생성 중 오류 발생:
경고 6002: 테이블/뷰 'EE.dbo.vGroupUser'에 기본 키가 정의되지 않았습니다. 키가 유추되었고 읽기 전용 테이블/뷰로 정의되었습니다.-->
<EntityType Name="vGroupUser">
<Key>
<PropertyRef Name="gcode" />
</Key>
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
<Property Name="dept" Type="varchar" MaxLength="100" />
<Property Name="level" Type="smallint" />
<Property Name="name" Type="nvarchar" MaxLength="100" />
<Property Name="nameE" Type="nvarchar" MaxLength="100" />
<Property Name="grade" Type="varchar" MaxLength="10" />
<Property Name="email" Type="varchar" MaxLength="100" />
<Property Name="tel" Type="varchar" MaxLength="20" />
<Property Name="indate" Type="varchar" MaxLength="20" />
<Property Name="outdate" Type="varchar" MaxLength="20" />
<Property Name="hp" Type="varchar" MaxLength="20" />
<Property Name="place" Type="varchar" MaxLength="100" />
<Property Name="ads_employNo" Type="varchar" MaxLength="50" />
<Property Name="ads_title" Type="nvarchar" MaxLength="100" />
<Property Name="ads_created" Type="varchar" MaxLength="50" />
<Property Name="memo" Type="nvarchar" MaxLength="255" />
<Property Name="processs" Type="varchar" MaxLength="50" />
<Property Name="id" Type="varchar" MaxLength="20" />
</EntityType>
<!--생성 중 오류 발생:
경고 6002: 테이블/뷰 'EE.dbo.vJobReportForUser'에 기본 키가 정의되지 않았습니다. 키가 유추되었고 읽기 전용 테이블/뷰로 정의되었습니다.-->
<EntityType Name="vJobReportForUser">
<Key>
<PropertyRef Name="idx" />
<PropertyRef Name="gcode" />
</Key>
<Property Name="idx" Type="int" Nullable="false" />
<Property Name="pdate" Type="varchar" MaxLength="10" />
<Property Name="gcode" Type="varchar" MaxLength="10" Nullable="false" />
<Property Name="id" Type="varchar" MaxLength="20" />
<Property Name="name" Type="nvarchar" MaxLength="100" />
<Property Name="process" Type="varchar" MaxLength="50" />
<Property Name="type" Type="varchar" MaxLength="50" />
<Property Name="svalue" Type="varchar" MaxLength="255" />
<Property Name="hrs" Type="float" />
<Property Name="ot" Type="float" />
<Property Name="userProcess" Type="nvarchar" MaxLength="100" />
<Property Name="requestpart" Type="varchar" MaxLength="50" />
<Property Name="package" Type="varchar" MaxLength="50" />
</EntityType>
<EntityContainer Name="EEModelStoreContainer">
<EntitySet Name="HolidayLIst" EntityType="Self.HolidayLIst" Schema="dbo" store:Type="Tables" />
<EntitySet Name="JobReport" EntityType="Self.JobReport" Schema="dbo" store:Type="Tables" />
<EntitySet Name="MailData" EntityType="Self.MailData" Schema="dbo" store:Type="Tables" />
<EntitySet Name="MailForm" EntityType="Self.MailForm" Schema="dbo" store:Type="Tables" />
<EntitySet Name="vGroupUser" EntityType="Self.vGroupUser" store:Type="Views" store:Schema="dbo">
<DefiningQuery>SELECT
[vGroupUser].[gcode] AS [gcode],
[vGroupUser].[dept] AS [dept],
[vGroupUser].[level] AS [level],
[vGroupUser].[name] AS [name],
[vGroupUser].[nameE] AS [nameE],
[vGroupUser].[grade] AS [grade],
[vGroupUser].[email] AS [email],
[vGroupUser].[tel] AS [tel],
[vGroupUser].[indate] AS [indate],
[vGroupUser].[outdate] AS [outdate],
[vGroupUser].[hp] AS [hp],
[vGroupUser].[place] AS [place],
[vGroupUser].[ads_employNo] AS [ads_employNo],
[vGroupUser].[ads_title] AS [ads_title],
[vGroupUser].[ads_created] AS [ads_created],
[vGroupUser].[memo] AS [memo],
[vGroupUser].[processs] AS [processs],
[vGroupUser].[id] AS [id]
FROM [dbo].[vGroupUser] AS [vGroupUser]</DefiningQuery>
</EntitySet>
<EntitySet Name="vJobReportForUser" EntityType="Self.vJobReportForUser" store:Type="Views" store:Schema="dbo">
<DefiningQuery>SELECT
[vJobReportForUser].[idx] AS [idx],
[vJobReportForUser].[pdate] AS [pdate],
[vJobReportForUser].[gcode] AS [gcode],
[vJobReportForUser].[id] AS [id],
[vJobReportForUser].[name] AS [name],
[vJobReportForUser].[process] AS [process],
[vJobReportForUser].[type] AS [type],
[vJobReportForUser].[svalue] AS [svalue],
[vJobReportForUser].[hrs] AS [hrs],
[vJobReportForUser].[ot] AS [ot],
[vJobReportForUser].[userProcess] AS [userProcess],
[vJobReportForUser].[requestpart] AS [requestpart],
[vJobReportForUser].[package] AS [package]
FROM [dbo].[vJobReportForUser] AS [vJobReportForUser]</DefiningQuery>
</EntitySet>
</EntityContainer>
</Schema></edmx:StorageModels>
<!-- CSDL content -->
<edmx:ConceptualModels>
<Schema Namespace="EEModel" Alias="Self" annotation:UseStrongSpatialTypes="false" xmlns:annotation="http://schemas.microsoft.com/ado/2009/02/edm/annotation" xmlns:customannotation="http://schemas.microsoft.com/ado/2013/11/edm/customannotation" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">
<EntityType Name="JobReport">
<Key>
<PropertyRef Name="idx" />
</Key>
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" Nullable="false" />
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="pidx" Type="Int32" />
<Property Name="projectName" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
<Property Name="uid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="requestpart" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="package" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="status" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="type" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="process" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="description" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="remark" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
<Property Name="hrs" Type="Double" />
<Property Name="ot" Type="Double" />
<Property Name="import" Type="Boolean" />
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
<Property Name="description2" Type="String" MaxLength="Max" FixedLength="false" Unicode="true" />
<Property Name="tag" Type="String" MaxLength="255" FixedLength="false" Unicode="false" />
</EntityType>
<EntityType Name="MailData">
<Key>
<PropertyRef Name="idx" />
</Key>
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="project" Type="Int32" />
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" Nullable="false" />
<Property Name="cate" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="subject" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="fromlist" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="tolist" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="bcc" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="cc" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="body" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="SendOK" Type="Boolean" />
<Property Name="SendMsg" Type="String" MaxLength="255" FixedLength="false" Unicode="false" />
<Property Name="aidx" Type="Int32" />
<Property Name="atime" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="wuid" Type="String" MaxLength="20" FixedLength="false" Unicode="false" Nullable="false" />
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
</EntityType>
<EntityType Name="vGroupUser">
<Key>
<PropertyRef Name="gcode" />
</Key>
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" Nullable="false" />
<Property Name="dept" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
<Property Name="level" Type="Int16" />
<Property Name="name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
<Property Name="nameE" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
<Property Name="grade" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="email" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
<Property Name="tel" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="indate" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="outdate" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="hp" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="place" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
<Property Name="ads_employNo" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="ads_title" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
<Property Name="ads_created" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
<Property Name="processs" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="id" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
</EntityType>
<EntityType Name="vJobReportForUser">
<Key>
<PropertyRef Name="idx" />
<PropertyRef Name="gcode" />
</Key>
<Property Name="idx" Type="Int32" Nullable="false" />
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="gcode" Type="String" MaxLength="10" FixedLength="false" Unicode="false" Nullable="false" />
<Property Name="id" Type="String" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="name" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
<Property Name="process" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="type" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="svalue" Type="String" MaxLength="255" FixedLength="false" Unicode="false" />
<Property Name="hrs" Type="Double" />
<Property Name="ot" Type="Double" />
<Property Name="userProcess" Type="String" MaxLength="100" FixedLength="false" Unicode="true" />
<Property Name="requestpart" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
<Property Name="package" Type="String" MaxLength="50" FixedLength="false" Unicode="false" />
</EntityType>
<EntityContainer Name="EEEntities" annotation:LazyLoadingEnabled="true">
<EntitySet Name="JobReport" EntityType="Self.JobReport" />
<EntitySet Name="MailData" EntityType="Self.MailData" />
<EntitySet Name="vGroupUser" EntityType="Self.vGroupUser" />
<EntitySet Name="vJobReportForUser" EntityType="Self.vJobReportForUser" />
<EntitySet Name="HolidayLIst" EntityType="EEModel.HolidayLIst" />
<EntitySet Name="MailForm" EntityType="EEModel.MailForm" />
</EntityContainer>
<EntityType Name="HolidayLIst">
<Key>
<PropertyRef Name="idx" />
</Key>
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="pdate" Type="String" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="free" Type="Boolean" />
<Property Name="memo" Type="String" MaxLength="255" FixedLength="false" Unicode="true" />
<Property Name="wuid" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
</EntityType>
<EntityType Name="MailForm">
<Key>
<PropertyRef Name="idx" />
</Key>
<Property Name="idx" Type="Int32" Nullable="false" annotation:StoreGeneratedPattern="Identity" />
<Property Name="gcode" Type="String" Nullable="false" MaxLength="10" FixedLength="false" Unicode="false" />
<Property Name="cate" Type="String" MaxLength="2" FixedLength="false" Unicode="false" />
<Property Name="title" Type="String" MaxLength="100" FixedLength="false" Unicode="false" />
<Property Name="tolist" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="bcc" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="cc" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="subject" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="tail" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="body" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="selfTo" Type="Boolean" />
<Property Name="selfCC" Type="Boolean" />
<Property Name="selfBCC" Type="Boolean" />
<Property Name="wuid" Type="String" Nullable="false" MaxLength="20" FixedLength="false" Unicode="false" />
<Property Name="wdate" Type="DateTime" Nullable="false" Precision="0" />
<Property Name="exceptmail" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
<Property Name="exceptmailcc" Type="String" MaxLength="Max" FixedLength="false" Unicode="false" />
</EntityType>
</Schema>
</edmx:ConceptualModels>
<!-- C-S mapping content -->
<edmx:Mappings>
<Mapping Space="C-S" xmlns="http://schemas.microsoft.com/ado/2009/11/mapping/cs">
<EntityContainerMapping StorageEntityContainer="EEModelStoreContainer" CdmEntityContainer="EEEntities">
<EntitySetMapping Name="JobReport">
<EntityTypeMapping TypeName="EEModel.JobReport">
<MappingFragment StoreEntitySet="JobReport">
<ScalarProperty Name="idx" ColumnName="idx" />
<ScalarProperty Name="gcode" ColumnName="gcode" />
<ScalarProperty Name="pdate" ColumnName="pdate" />
<ScalarProperty Name="pidx" ColumnName="pidx" />
<ScalarProperty Name="projectName" ColumnName="projectName" />
<ScalarProperty Name="uid" ColumnName="uid" />
<ScalarProperty Name="requestpart" ColumnName="requestpart" />
<ScalarProperty Name="package" ColumnName="package" />
<ScalarProperty Name="status" ColumnName="status" />
<ScalarProperty Name="type" ColumnName="type" />
<ScalarProperty Name="process" ColumnName="process" />
<ScalarProperty Name="description" ColumnName="description" />
<ScalarProperty Name="remark" ColumnName="remark" />
<ScalarProperty Name="hrs" ColumnName="hrs" />
<ScalarProperty Name="ot" ColumnName="ot" />
<ScalarProperty Name="import" ColumnName="import" />
<ScalarProperty Name="wuid" ColumnName="wuid" />
<ScalarProperty Name="wdate" ColumnName="wdate" />
<ScalarProperty Name="description2" ColumnName="description2" />
<ScalarProperty Name="tag" ColumnName="tag" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="MailData">
<EntityTypeMapping TypeName="EEModel.MailData">
<MappingFragment StoreEntitySet="MailData">
<ScalarProperty Name="idx" ColumnName="idx" />
<ScalarProperty Name="project" ColumnName="project" />
<ScalarProperty Name="gcode" ColumnName="gcode" />
<ScalarProperty Name="cate" ColumnName="cate" />
<ScalarProperty Name="pdate" ColumnName="pdate" />
<ScalarProperty Name="subject" ColumnName="subject" />
<ScalarProperty Name="fromlist" ColumnName="fromlist" />
<ScalarProperty Name="tolist" ColumnName="tolist" />
<ScalarProperty Name="bcc" ColumnName="bcc" />
<ScalarProperty Name="cc" ColumnName="cc" />
<ScalarProperty Name="body" ColumnName="body" />
<ScalarProperty Name="SendOK" ColumnName="SendOK" />
<ScalarProperty Name="SendMsg" ColumnName="SendMsg" />
<ScalarProperty Name="aidx" ColumnName="aidx" />
<ScalarProperty Name="atime" ColumnName="atime" />
<ScalarProperty Name="wuid" ColumnName="wuid" />
<ScalarProperty Name="wdate" ColumnName="wdate" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="vGroupUser">
<EntityTypeMapping TypeName="EEModel.vGroupUser">
<MappingFragment StoreEntitySet="vGroupUser">
<ScalarProperty Name="gcode" ColumnName="gcode" />
<ScalarProperty Name="dept" ColumnName="dept" />
<ScalarProperty Name="level" ColumnName="level" />
<ScalarProperty Name="name" ColumnName="name" />
<ScalarProperty Name="nameE" ColumnName="nameE" />
<ScalarProperty Name="grade" ColumnName="grade" />
<ScalarProperty Name="email" ColumnName="email" />
<ScalarProperty Name="tel" ColumnName="tel" />
<ScalarProperty Name="indate" ColumnName="indate" />
<ScalarProperty Name="outdate" ColumnName="outdate" />
<ScalarProperty Name="hp" ColumnName="hp" />
<ScalarProperty Name="place" ColumnName="place" />
<ScalarProperty Name="ads_employNo" ColumnName="ads_employNo" />
<ScalarProperty Name="ads_title" ColumnName="ads_title" />
<ScalarProperty Name="ads_created" ColumnName="ads_created" />
<ScalarProperty Name="memo" ColumnName="memo" />
<ScalarProperty Name="processs" ColumnName="processs" />
<ScalarProperty Name="id" ColumnName="id" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="vJobReportForUser">
<EntityTypeMapping TypeName="EEModel.vJobReportForUser">
<MappingFragment StoreEntitySet="vJobReportForUser">
<ScalarProperty Name="idx" ColumnName="idx" />
<ScalarProperty Name="pdate" ColumnName="pdate" />
<ScalarProperty Name="gcode" ColumnName="gcode" />
<ScalarProperty Name="id" ColumnName="id" />
<ScalarProperty Name="name" ColumnName="name" />
<ScalarProperty Name="process" ColumnName="process" />
<ScalarProperty Name="type" ColumnName="type" />
<ScalarProperty Name="svalue" ColumnName="svalue" />
<ScalarProperty Name="hrs" ColumnName="hrs" />
<ScalarProperty Name="ot" ColumnName="ot" />
<ScalarProperty Name="userProcess" ColumnName="userProcess" />
<ScalarProperty Name="requestpart" ColumnName="requestpart" />
<ScalarProperty Name="package" ColumnName="package" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="HolidayLIst">
<EntityTypeMapping TypeName="EEModel.HolidayLIst">
<MappingFragment StoreEntitySet="HolidayLIst">
<ScalarProperty Name="wdate" ColumnName="wdate" />
<ScalarProperty Name="wuid" ColumnName="wuid" />
<ScalarProperty Name="memo" ColumnName="memo" />
<ScalarProperty Name="free" ColumnName="free" />
<ScalarProperty Name="pdate" ColumnName="pdate" />
<ScalarProperty Name="idx" ColumnName="idx" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
<EntitySetMapping Name="MailForm">
<EntityTypeMapping TypeName="EEModel.MailForm">
<MappingFragment StoreEntitySet="MailForm">
<ScalarProperty Name="exceptmailcc" ColumnName="exceptmailcc" />
<ScalarProperty Name="exceptmail" ColumnName="exceptmail" />
<ScalarProperty Name="wdate" ColumnName="wdate" />
<ScalarProperty Name="wuid" ColumnName="wuid" />
<ScalarProperty Name="selfBCC" ColumnName="selfBCC" />
<ScalarProperty Name="selfCC" ColumnName="selfCC" />
<ScalarProperty Name="selfTo" ColumnName="selfTo" />
<ScalarProperty Name="body" ColumnName="body" />
<ScalarProperty Name="tail" ColumnName="tail" />
<ScalarProperty Name="subject" ColumnName="subject" />
<ScalarProperty Name="cc" ColumnName="cc" />
<ScalarProperty Name="bcc" ColumnName="bcc" />
<ScalarProperty Name="tolist" ColumnName="tolist" />
<ScalarProperty Name="title" ColumnName="title" />
<ScalarProperty Name="cate" ColumnName="cate" />
<ScalarProperty Name="gcode" ColumnName="gcode" />
<ScalarProperty Name="idx" ColumnName="idx" />
</MappingFragment>
</EntityTypeMapping>
</EntitySetMapping>
</EntityContainerMapping>
</Mapping>
</edmx:Mappings>
</edmx:Runtime>
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<Connection>
<DesignerInfoPropertySet>
<DesignerProperty Name="MetadataArtifactProcessing" Value="EmbedInOutputAssembly" />
</DesignerInfoPropertySet>
</Connection>
<Options>
<DesignerInfoPropertySet>
<DesignerProperty Name="ValidateOnBuild" Value="true" />
<DesignerProperty Name="EnablePluralization" Value="false" />
<DesignerProperty Name="IncludeForeignKeysInModel" Value="true" />
<DesignerProperty Name="UseLegacyProvider" Value="false" />
<DesignerProperty Name="CodeGenerationStrategy" Value="없음" />
</DesignerInfoPropertySet>
</Options>
<!-- Diagram content (shape and connector positions) -->
<Diagrams></Diagrams>
</Designer>
</edmx:Edmx>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- EF Designer content (DO NOT EDIT MANUALLY BELOW HERE) -->
<edmx:Designer xmlns="http://schemas.microsoft.com/ado/2009/11/edmx">
<!-- Diagram content (shape and connector positions) -->
<edmx:Diagrams>
<Diagram DiagramId="c8b8f2389aab4dbe8db51886b86fe9b4" Name="Diagram1">
<EntityTypeShape EntityType="EEModel.JobReport" Width="1.5" PointX="0.75" PointY="0.75" IsExpanded="true" />
<EntityTypeShape EntityType="EEModel.MailData" Width="1.5" PointX="2.75" PointY="0.75" IsExpanded="true" />
<EntityTypeShape EntityType="EEModel.vGroupUser" Width="1.5" PointX="4.75" PointY="5.75" IsExpanded="true" />
<EntityTypeShape EntityType="EEModel.vJobReportForUser" Width="1.5" PointX="6.75" PointY="0.75" IsExpanded="true" />
<EntityTypeShape EntityType="EEModel.HolidayLIst" Width="1.5" PointX="0.75" PointY="6.75" />
<EntityTypeShape EntityType="EEModel.MailForm" Width="1.5" PointX="7.375" PointY="5.75" />
</Diagram>
</edmx:Diagrams>
</edmx:Designer>
</edmx:Edmx>

View File

@@ -0,0 +1,733 @@
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF6.Utility.CS.ttinclude"#><#@
output extension=".cs"#><#
const string inputFile = @"Model1.edmx";
var textTransform = DynamicTextTransformation.Create(this);
var code = new CodeGenerationTools(this);
var ef = new MetadataTools(this);
var typeMapper = new TypeMapper(code, ef, textTransform.Errors);
var fileManager = EntityFrameworkTemplateFileManager.Create(this);
var itemCollection = new EdmMetadataLoader(textTransform.Host, textTransform.Errors).CreateEdmItemCollection(inputFile);
var codeStringGenerator = new CodeStringGenerator(code, typeMapper, ef);
if (!typeMapper.VerifyCaseInsensitiveTypeUniqueness(typeMapper.GetAllGlobalItems(itemCollection), inputFile))
{
return string.Empty;
}
WriteHeader(codeStringGenerator, fileManager);
foreach (var entity in typeMapper.GetItemsToGenerate<EntityType>(itemCollection))
{
fileManager.StartNewFile(entity.Name + ".cs");
BeginNamespace(code);
#>
<#=codeStringGenerator.UsingDirectives(inHeader: false)#>
<#=codeStringGenerator.EntityClassOpening(entity)#>
{
<#
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(entity);
var collectionNavigationProperties = typeMapper.GetCollectionNavigationProperties(entity);
var complexProperties = typeMapper.GetComplexProperties(entity);
if (propertiesWithDefaultValues.Any() || collectionNavigationProperties.Any() || complexProperties.Any())
{
#>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public <#=code.Escape(entity)#>()
{
<#
foreach (var edmProperty in propertiesWithDefaultValues)
{
#>
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
<#
}
foreach (var navigationProperty in collectionNavigationProperties)
{
#>
this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
<#
}
foreach (var complexProperty in complexProperties)
{
#>
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
<#
}
#>
}
<#
}
var simpleProperties = typeMapper.GetSimpleProperties(entity);
if (simpleProperties.Any())
{
foreach (var edmProperty in simpleProperties)
{
#>
<#=codeStringGenerator.Property(edmProperty)#>
<#
}
}
if (complexProperties.Any())
{
#>
<#
foreach(var complexProperty in complexProperties)
{
#>
<#=codeStringGenerator.Property(complexProperty)#>
<#
}
}
var navigationProperties = typeMapper.GetNavigationProperties(entity);
if (navigationProperties.Any())
{
#>
<#
foreach (var navigationProperty in navigationProperties)
{
if (navigationProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many)
{
#>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
<#
}
#>
<#=codeStringGenerator.NavigationProperty(navigationProperty)#>
<#
}
}
#>
}
<#
EndNamespace(code);
}
foreach (var complex in typeMapper.GetItemsToGenerate<ComplexType>(itemCollection))
{
fileManager.StartNewFile(complex.Name + ".cs");
BeginNamespace(code);
#>
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
<#=Accessibility.ForType(complex)#> partial class <#=code.Escape(complex)#>
{
<#
var complexProperties = typeMapper.GetComplexProperties(complex);
var propertiesWithDefaultValues = typeMapper.GetPropertiesWithDefaultValues(complex);
if (propertiesWithDefaultValues.Any() || complexProperties.Any())
{
#>
public <#=code.Escape(complex)#>()
{
<#
foreach (var edmProperty in propertiesWithDefaultValues)
{
#>
this.<#=code.Escape(edmProperty)#> = <#=typeMapper.CreateLiteral(edmProperty.DefaultValue)#>;
<#
}
foreach (var complexProperty in complexProperties)
{
#>
this.<#=code.Escape(complexProperty)#> = new <#=typeMapper.GetTypeName(complexProperty.TypeUsage)#>();
<#
}
#>
}
<#
}
var simpleProperties = typeMapper.GetSimpleProperties(complex);
if (simpleProperties.Any())
{
foreach(var edmProperty in simpleProperties)
{
#>
<#=codeStringGenerator.Property(edmProperty)#>
<#
}
}
if (complexProperties.Any())
{
#>
<#
foreach(var edmProperty in complexProperties)
{
#>
<#=codeStringGenerator.Property(edmProperty)#>
<#
}
}
#>
}
<#
EndNamespace(code);
}
foreach (var enumType in typeMapper.GetEnumItemsToGenerate(itemCollection))
{
fileManager.StartNewFile(enumType.Name + ".cs");
BeginNamespace(code);
#>
<#=codeStringGenerator.UsingDirectives(inHeader: false, includeCollections: false)#>
<#
if (typeMapper.EnumIsFlags(enumType))
{
#>
[Flags]
<#
}
#>
<#=codeStringGenerator.EnumOpening(enumType)#>
{
<#
var foundOne = false;
foreach (MetadataItem member in typeMapper.GetEnumMembers(enumType))
{
foundOne = true;
#>
<#=code.Escape(typeMapper.GetEnumMemberName(member))#> = <#=typeMapper.GetEnumMemberValue(member)#>,
<#
}
if (foundOne)
{
this.GenerationEnvironment.Remove(this.GenerationEnvironment.Length - 3, 1);
}
#>
}
<#
EndNamespace(code);
}
fileManager.Process();
#>
<#+
public void WriteHeader(CodeStringGenerator codeStringGenerator, EntityFrameworkTemplateFileManager fileManager)
{
fileManager.StartHeader();
#>
//------------------------------------------------------------------------------
// <auto-generated>
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#>
//
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#>
// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#>
// </auto-generated>
//------------------------------------------------------------------------------
<#=codeStringGenerator.UsingDirectives(inHeader: true)#>
<#+
fileManager.EndBlock();
}
public void BeginNamespace(CodeGenerationTools code)
{
var codeNamespace = code.VsNamespaceSuggestion();
if (!String.IsNullOrEmpty(codeNamespace))
{
#>
namespace <#=code.EscapeNamespace(codeNamespace)#>
{
<#+
PushIndent(" ");
}
}
public void EndNamespace(CodeGenerationTools code)
{
if (!String.IsNullOrEmpty(code.VsNamespaceSuggestion()))
{
PopIndent();
#>
}
<#+
}
}
public const string TemplateId = "CSharp_DbContext_Types_EF6";
public class CodeStringGenerator
{
private readonly CodeGenerationTools _code;
private readonly TypeMapper _typeMapper;
private readonly MetadataTools _ef;
public CodeStringGenerator(CodeGenerationTools code, TypeMapper typeMapper, MetadataTools ef)
{
ArgumentNotNull(code, "code");
ArgumentNotNull(typeMapper, "typeMapper");
ArgumentNotNull(ef, "ef");
_code = code;
_typeMapper = typeMapper;
_ef = ef;
}
public string Property(EdmProperty edmProperty)
{
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1} {2} {{ {3}get; {4}set; }}",
Accessibility.ForProperty(edmProperty),
_typeMapper.GetTypeName(edmProperty.TypeUsage),
_code.Escape(edmProperty),
_code.SpaceAfter(Accessibility.ForGetter(edmProperty)),
_code.SpaceAfter(Accessibility.ForSetter(edmProperty)));
}
public string NavigationProperty(NavigationProperty navProp)
{
var endType = _typeMapper.GetTypeName(navProp.ToEndMember.GetEntityType());
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1} {2} {{ {3}get; {4}set; }}",
AccessibilityAndVirtual(Accessibility.ForNavigationProperty(navProp)),
navProp.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many ? ("ICollection<" + endType + ">") : endType,
_code.Escape(navProp),
_code.SpaceAfter(Accessibility.ForGetter(navProp)),
_code.SpaceAfter(Accessibility.ForSetter(navProp)));
}
public string AccessibilityAndVirtual(string accessibility)
{
return accessibility + (accessibility != "private" ? " virtual" : "");
}
public string EntityClassOpening(EntityType entity)
{
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1}partial class {2}{3}",
Accessibility.ForType(entity),
_code.SpaceAfter(_code.AbstractOption(entity)),
_code.Escape(entity),
_code.StringBefore(" : ", _typeMapper.GetTypeName(entity.BaseType)));
}
public string EnumOpening(SimpleType enumType)
{
return string.Format(
CultureInfo.InvariantCulture,
"{0} enum {1} : {2}",
Accessibility.ForType(enumType),
_code.Escape(enumType),
_code.Escape(_typeMapper.UnderlyingClrType(enumType)));
}
public void WriteFunctionParameters(EdmFunction edmFunction, Action<string, string, string, string> writeParameter)
{
var parameters = FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
foreach (var parameter in parameters.Where(p => p.NeedsLocalVariable))
{
var isNotNull = parameter.IsNullableOfT ? parameter.FunctionParameterName + ".HasValue" : parameter.FunctionParameterName + " != null";
var notNullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", " + parameter.FunctionParameterName + ")";
var nullInit = "new ObjectParameter(\"" + parameter.EsqlParameterName + "\", typeof(" + TypeMapper.FixNamespaces(parameter.RawClrTypeName) + "))";
writeParameter(parameter.LocalVariableName, isNotNull, notNullInit, nullInit);
}
}
public string ComposableFunctionMethod(EdmFunction edmFunction, string modelNamespace)
{
var parameters = _typeMapper.GetParameters(edmFunction);
return string.Format(
CultureInfo.InvariantCulture,
"{0} IQueryable<{1}> {2}({3})",
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
_code.Escape(edmFunction),
string.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray()));
}
public string ComposableCreateQuery(EdmFunction edmFunction, string modelNamespace)
{
var parameters = _typeMapper.GetParameters(edmFunction);
return string.Format(
CultureInfo.InvariantCulture,
"return ((IObjectContextAdapter)this).ObjectContext.CreateQuery<{0}>(\"[{1}].[{2}]({3})\"{4});",
_typeMapper.GetTypeName(_typeMapper.GetReturnType(edmFunction), modelNamespace),
edmFunction.NamespaceName,
edmFunction.Name,
string.Join(", ", parameters.Select(p => "@" + p.EsqlParameterName).ToArray()),
_code.StringBefore(", ", string.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray())));
}
public string FunctionMethod(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
{
var parameters = _typeMapper.GetParameters(edmFunction);
var returnType = _typeMapper.GetReturnType(edmFunction);
var paramList = String.Join(", ", parameters.Select(p => TypeMapper.FixNamespaces(p.FunctionParameterType) + " " + p.FunctionParameterName).ToArray());
if (includeMergeOption)
{
paramList = _code.StringAfter(paramList, ", ") + "MergeOption mergeOption";
}
return string.Format(
CultureInfo.InvariantCulture,
"{0} {1} {2}({3})",
AccessibilityAndVirtual(Accessibility.ForMethod(edmFunction)),
returnType == null ? "int" : "ObjectResult<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
_code.Escape(edmFunction),
paramList);
}
public string ExecuteFunction(EdmFunction edmFunction, string modelNamespace, bool includeMergeOption)
{
var parameters = _typeMapper.GetParameters(edmFunction);
var returnType = _typeMapper.GetReturnType(edmFunction);
var callParams = _code.StringBefore(", ", String.Join(", ", parameters.Select(p => p.ExecuteParameterName).ToArray()));
if (includeMergeOption)
{
callParams = ", mergeOption" + callParams;
}
return string.Format(
CultureInfo.InvariantCulture,
"return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction{0}(\"{1}\"{2});",
returnType == null ? "" : "<" + _typeMapper.GetTypeName(returnType, modelNamespace) + ">",
edmFunction.Name,
callParams);
}
public string DbSet(EntitySet entitySet)
{
return string.Format(
CultureInfo.InvariantCulture,
"{0} virtual DbSet<{1}> {2} {{ get; set; }}",
Accessibility.ForReadOnlyProperty(entitySet),
_typeMapper.GetTypeName(entitySet.ElementType),
_code.Escape(entitySet));
}
public string UsingDirectives(bool inHeader, bool includeCollections = true)
{
return inHeader == string.IsNullOrEmpty(_code.VsNamespaceSuggestion())
? string.Format(
CultureInfo.InvariantCulture,
"{0}using System;{1}" +
"{2}",
inHeader ? Environment.NewLine : "",
includeCollections ? (Environment.NewLine + "using System.Collections.Generic;") : "",
inHeader ? "" : Environment.NewLine)
: "";
}
}
public class TypeMapper
{
private const string ExternalTypeNameAttributeName = @"http://schemas.microsoft.com/ado/2006/04/codegeneration:ExternalTypeName";
private readonly System.Collections.IList _errors;
private readonly CodeGenerationTools _code;
private readonly MetadataTools _ef;
public TypeMapper(CodeGenerationTools code, MetadataTools ef, System.Collections.IList errors)
{
ArgumentNotNull(code, "code");
ArgumentNotNull(ef, "ef");
ArgumentNotNull(errors, "errors");
_code = code;
_ef = ef;
_errors = errors;
}
public static string FixNamespaces(string typeName)
{
return typeName.Replace("System.Data.Spatial.", "System.Data.Entity.Spatial.");
}
public string GetTypeName(TypeUsage typeUsage)
{
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace: null);
}
public string GetTypeName(EdmType edmType)
{
return GetTypeName(edmType, isNullable: null, modelNamespace: null);
}
public string GetTypeName(TypeUsage typeUsage, string modelNamespace)
{
return typeUsage == null ? null : GetTypeName(typeUsage.EdmType, _ef.IsNullable(typeUsage), modelNamespace);
}
public string GetTypeName(EdmType edmType, string modelNamespace)
{
return GetTypeName(edmType, isNullable: null, modelNamespace: modelNamespace);
}
public string GetTypeName(EdmType edmType, bool? isNullable, string modelNamespace)
{
if (edmType == null)
{
return null;
}
var collectionType = edmType as CollectionType;
if (collectionType != null)
{
return String.Format(CultureInfo.InvariantCulture, "ICollection<{0}>", GetTypeName(collectionType.TypeUsage, modelNamespace));
}
var typeName = _code.Escape(edmType.MetadataProperties
.Where(p => p.Name == ExternalTypeNameAttributeName)
.Select(p => (string)p.Value)
.FirstOrDefault())
?? (modelNamespace != null && edmType.NamespaceName != modelNamespace ?
_code.CreateFullName(_code.EscapeNamespace(edmType.NamespaceName), _code.Escape(edmType)) :
_code.Escape(edmType));
if (edmType is StructuralType)
{
return typeName;
}
if (edmType is SimpleType)
{
var clrType = UnderlyingClrType(edmType);
if (!IsEnumType(edmType))
{
typeName = _code.Escape(clrType);
}
typeName = FixNamespaces(typeName);
return clrType.IsValueType && isNullable == true ?
String.Format(CultureInfo.InvariantCulture, "Nullable<{0}>", typeName) :
typeName;
}
throw new ArgumentException("edmType");
}
public Type UnderlyingClrType(EdmType edmType)
{
ArgumentNotNull(edmType, "edmType");
var primitiveType = edmType as PrimitiveType;
if (primitiveType != null)
{
return primitiveType.ClrEquivalentType;
}
if (IsEnumType(edmType))
{
return GetEnumUnderlyingType(edmType).ClrEquivalentType;
}
return typeof(object);
}
public object GetEnumMemberValue(MetadataItem enumMember)
{
ArgumentNotNull(enumMember, "enumMember");
var valueProperty = enumMember.GetType().GetProperty("Value");
return valueProperty == null ? null : valueProperty.GetValue(enumMember, null);
}
public string GetEnumMemberName(MetadataItem enumMember)
{
ArgumentNotNull(enumMember, "enumMember");
var nameProperty = enumMember.GetType().GetProperty("Name");
return nameProperty == null ? null : (string)nameProperty.GetValue(enumMember, null);
}
public System.Collections.IEnumerable GetEnumMembers(EdmType enumType)
{
ArgumentNotNull(enumType, "enumType");
var membersProperty = enumType.GetType().GetProperty("Members");
return membersProperty != null
? (System.Collections.IEnumerable)membersProperty.GetValue(enumType, null)
: Enumerable.Empty<MetadataItem>();
}
public bool EnumIsFlags(EdmType enumType)
{
ArgumentNotNull(enumType, "enumType");
var isFlagsProperty = enumType.GetType().GetProperty("IsFlags");
return isFlagsProperty != null && (bool)isFlagsProperty.GetValue(enumType, null);
}
public bool IsEnumType(GlobalItem edmType)
{
ArgumentNotNull(edmType, "edmType");
return edmType.GetType().Name == "EnumType";
}
public PrimitiveType GetEnumUnderlyingType(EdmType enumType)
{
ArgumentNotNull(enumType, "enumType");
return (PrimitiveType)enumType.GetType().GetProperty("UnderlyingType").GetValue(enumType, null);
}
public string CreateLiteral(object value)
{
if (value == null || value.GetType() != typeof(TimeSpan))
{
return _code.CreateLiteral(value);
}
return string.Format(CultureInfo.InvariantCulture, "new TimeSpan({0})", ((TimeSpan)value).Ticks);
}
public bool VerifyCaseInsensitiveTypeUniqueness(IEnumerable<string> types, string sourceFile)
{
ArgumentNotNull(types, "types");
ArgumentNotNull(sourceFile, "sourceFile");
var hash = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase);
if (types.Any(item => !hash.Add(item)))
{
_errors.Add(
new CompilerError(sourceFile, -1, -1, "6023",
String.Format(CultureInfo.CurrentCulture, CodeGenerationTools.GetResourceString("Template_CaseInsensitiveTypeConflict"))));
return false;
}
return true;
}
public IEnumerable<SimpleType> GetEnumItemsToGenerate(IEnumerable<GlobalItem> itemCollection)
{
return GetItemsToGenerate<SimpleType>(itemCollection)
.Where(e => IsEnumType(e));
}
public IEnumerable<T> GetItemsToGenerate<T>(IEnumerable<GlobalItem> itemCollection) where T: EdmType
{
return itemCollection
.OfType<T>()
.Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName))
.OrderBy(i => i.Name);
}
public IEnumerable<string> GetAllGlobalItems(IEnumerable<GlobalItem> itemCollection)
{
return itemCollection
.Where(i => i is EntityType || i is ComplexType || i is EntityContainer || IsEnumType(i))
.Select(g => GetGlobalItemName(g));
}
public string GetGlobalItemName(GlobalItem item)
{
if (item is EdmType)
{
return ((EdmType)item).Name;
}
else
{
return ((EntityContainer)item).Name;
}
}
public IEnumerable<EdmProperty> GetSimpleProperties(EntityType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
}
public IEnumerable<EdmProperty> GetSimpleProperties(ComplexType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type);
}
public IEnumerable<EdmProperty> GetComplexProperties(EntityType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
}
public IEnumerable<EdmProperty> GetComplexProperties(ComplexType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type);
}
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(EntityType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
}
public IEnumerable<EdmProperty> GetPropertiesWithDefaultValues(ComplexType type)
{
return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null);
}
public IEnumerable<NavigationProperty> GetNavigationProperties(EntityType type)
{
return type.NavigationProperties.Where(np => np.DeclaringType == type);
}
public IEnumerable<NavigationProperty> GetCollectionNavigationProperties(EntityType type)
{
return type.NavigationProperties.Where(np => np.DeclaringType == type && np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many);
}
public FunctionParameter GetReturnParameter(EdmFunction edmFunction)
{
ArgumentNotNull(edmFunction, "edmFunction");
var returnParamsProperty = edmFunction.GetType().GetProperty("ReturnParameters");
return returnParamsProperty == null
? edmFunction.ReturnParameter
: ((IEnumerable<FunctionParameter>)returnParamsProperty.GetValue(edmFunction, null)).FirstOrDefault();
}
public bool IsComposable(EdmFunction edmFunction)
{
ArgumentNotNull(edmFunction, "edmFunction");
var isComposableProperty = edmFunction.GetType().GetProperty("IsComposableAttribute");
return isComposableProperty != null && (bool)isComposableProperty.GetValue(edmFunction, null);
}
public IEnumerable<FunctionImportParameter> GetParameters(EdmFunction edmFunction)
{
return FunctionImportParameter.Create(edmFunction.Parameters, _code, _ef);
}
public TypeUsage GetReturnType(EdmFunction edmFunction)
{
var returnParam = GetReturnParameter(edmFunction);
return returnParam == null ? null : _ef.GetElementType(returnParam.TypeUsage);
}
public bool GenerateMergeOptionFunction(EdmFunction edmFunction, bool includeMergeOption)
{
var returnType = GetReturnType(edmFunction);
return !includeMergeOption && returnType != null && returnType.EdmType.BuiltInTypeKind == BuiltInTypeKind.EntityType;
}
}
public static void ArgumentNotNull<T>(T arg, string name) where T : class
{
if (arg == null)
{
throw new ArgumentNullException(name);
}
}
#>

View File

@@ -0,0 +1,100 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JobReportMailService
{
partial class Program
{
static CSetting setting = new CSetting();
static DateTime ChkAutoDate = DateTime.Now.AddDays(-1);
static string vGcode = "EET1P";
static bool cn = false;
static DateTime LastUpdateTime = DateTime.Now.AddHours(-1);
static DateTime ConsoleTime = DateTime.Now.AddDays(-1);
static void Main(string[] args)
{
setting = new CSetting();
setting.Load();
if (setting.Xml.Exist() == false)
{
Console.WriteLine("new setting file make");
setting.Save();
}
while (true)
{
//등록된 날짜를 확인하여, 해당 일자가 일반 평일 이라면 8시간 체크해서 메일을 보낸다.
//등록된 날짜가 토,일은 제외한다.
var ts = DateTime.Now - LastUpdateTime;
if (ts.TotalMinutes <= 15)
{
//15분 미만이면 동작하지 않는다
if ((DateTime.Now - ConsoleTime).TotalHours >= 1.0)
{
Console.WriteLine("15분 미만이라 동작하지 않습니다");
ConsoleTime = DateTime.Now;
}
}
else if (DateTime.Now.DayOfWeek == DayOfWeek.Saturday || DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
{
//토,일요일에는 동작하지 않는다
if ((DateTime.Now - ConsoleTime).TotalHours >= 1.0)
{
Console.WriteLine("토/일에는 동작하지 않습니다");
ConsoleTime = DateTime.Now;
}
}
else if (DateTime.Now.Hour < 9)
{
if ((DateTime.Now - ConsoleTime).TotalHours >= 1.0)
{
Console.WriteLine("9시 이전에는 동작하지 않습니다");
ConsoleTime = DateTime.Now;
}
}
else
{
LastUpdateTime = DateTime.Now;
try
{
WorkDay();
}
catch (Exception ex)
{
}
try
{
WorkWeek();
}
catch (Exception ex)
{
}
}
System.Threading.Thread.Sleep(60000); //1분단위로 체크한다
}
}
static string MailSort(string addr, string except)
{
if (string.IsNullOrEmpty(except)) return addr;
var alist = addr.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
var elist = except.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
foreach (var item in elist)
alist.Remove(item);
if (alist.Count < 1) return string.Empty;
return string.Join(";", alist);
}
}
}

View File

@@ -0,0 +1,191 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JobReportMailService
{
partial class Program
{
static void WorkDay()
{
Console.WriteLine("업무일지 미 작성자 추출 작업을 시작 합니다");
var db = new EEEntities();
//메일양식이 지정되어있는지 체크
var MailJD = db.MailForm.Where(t => t.gcode == vGcode & t.cate == "JD").FirstOrDefault();
//var MailJW = db.MailForm.Where(t => t.gcode == vGcode & t.cate == "JW").FirstOrDefault();
if (MailJD == null)
{
//토,일요일에는 동작하지 않는다
Console.WriteLine("업무일지 미작성 메일 양식이 입력되지 않았습니다");
return;
}
//기준일자는 오늘부터 -15일이다
var sd = DateTime.Now.AddDays(-15);
var ed = DateTime.Now;
var str_sd = sd.ToShortDateString();
var str_ed = ed.ToShortDateString();
var str_dt = DateTime.Now.ToShortDateString();
//대상 사용자 목록을 추출한다
db = new EEEntities();
var users = db.vJobReportForUser.Where(t => t.gcode == vGcode).GroupBy(t => t.id);
Dictionary<string, string> uids = new Dictionary<string, string>();
foreach (var user in users)
{
//해당 사용자의 오늘 날짜로 등록된 자동 데이터가 있다면 대상에 넣지 않는다
var userinfo = user.FirstOrDefault();
//퇴사자 확인
db = new EEEntities();
var userdata = db.vGroupUser.Where(t => t.id == userinfo.id).FirstOrDefault();
if (userdata != null && string.IsNullOrEmpty(userdata.outdate) == false) continue;
db = new EEEntities();
var Exists = db.MailData.Where(t => t.gcode == vGcode && t.wuid == userinfo.id && t.pdate == str_dt && t.cate == "JD").Any();
if (Exists == false) uids.Add(userinfo.id, userinfo.name); //자동생성된 자료가 없는 경우에만 처리한다
}
Console.WriteLine($"{uids.Count} 명의 전체 사용자가 확인 되었습니다");
//먼저 날짜목록을 가져온다
db = new EEEntities();
var lstDate = db.JobReport
.Where(t => t.gcode == vGcode && t.pdate.CompareTo(str_sd) >= 0 && t.pdate.CompareTo(str_ed) < 0)
.OrderBy(t => t.pdate)
.GroupBy(t => t.pdate).ToList();
//날짜대로 루프를 돈다
List<DateTime> days = new List<DateTime>();
foreach (var dateitem in lstDate)
{
var jobdata = dateitem.FirstOrDefault();
var dt = DateTime.Parse(jobdata.pdate);
if (dt.DayOfWeek == DayOfWeek.Sunday || dt.DayOfWeek == DayOfWeek.Saturday) continue;
//이 날짜가 휴일인지 체크한다.
db = new EEEntities();
var Holyinfo = db.HolidayLIst.Where(t => t.pdate == jobdata.package).FirstOrDefault();
if (Holyinfo != null && Holyinfo.free != null && (bool)(Holyinfo.free)) continue;
//이날짜에는 8시간을 근무 해야 한다
days.Add(DateTime.Parse(jobdata.pdate));
}
Console.WriteLine($"{days.Count} 건의 일자가 확인 되었습니다(기간:{str_sd}~{str_ed}");
//사용자 목록과 날짜 목록을 모두 수집했다
List<ReportUserData> totWarnList = new List<ReportUserData>();
foreach (var uid in uids)
{
//이사용자의 날짜별 근무시간을 확인한다.
db = new EEEntities();
var UserDatas = db.vJobReportForUser.Where(t => t.gcode == vGcode && t.id == uid.Key && t.pdate.CompareTo(str_sd) >= 0 && t.pdate.CompareTo(str_ed) < 0).ToList();
Dictionary<DateTime, double?> WarnList = new Dictionary<DateTime, double?>();
foreach (var dt in days.OrderBy(t => t))
{
var dtstr = dt.ToShortDateString();
var userdata = UserDatas.Where(t => t.pdate == dtstr); //해당날짜의 데이터를 확인한다.
var hrs = 0.0;
if (userdata.Any()) hrs = (double)userdata.Sum(t => t.hrs);
//자료를 입력하지 않았거나, 입력시간이 8시간 미만이면 경고한다
if (hrs < 8.0)
{
WarnList.Add(dt, hrs);
totWarnList.Add(new ReportUserData { date = dt, hrs = hrs, uid = uid.Key, uname = uid.Value }); //전체알림시에 사용하는 목록
}
}
if (WarnList.Count > 0)
{
Console.WriteLine($"{uid.Value}({uid.Key}) 의 경고 일수는 {WarnList.Count} 건 입니다");
db = new EEEntities();
var userinfo = db.vGroupUser.Where(t => t.id == uid.Key).FirstOrDefault();
if (userinfo == null)
{
Console.WriteLine($"{uid.Value}({uid.Key}) 의 사용자 정보를 확인 할 수 없습니다");
}
else if (string.IsNullOrEmpty(userinfo.email))
{
Console.WriteLine($"{uid.Value}({uid.Key}) 의 메일 정보가 존재하지 않습니다");
}
else
{
//일별경고(월요일제외)
if (DateTime.Now.DayOfWeek != DayOfWeek.Monday && MailJD != null)
{
var mail_subject = MailJD.subject.Replace("{담당자}", userinfo.name).Replace("{사번}", userinfo.id);
var mail_to = MailJD.tolist.Replace("{담당자}", userinfo.email);
var mail_cc = string.Empty; //
if (MailJD.cc != null) mail_cc = MailJD.cc.Replace("{담당자}", userinfo.email);
var mail_bcc = string.Empty;
if (MailJD.bcc != null) mail_bcc = MailJD.bcc.Replace("{담당자}", userinfo.email);
var mail_body = MailJD.body.Replace("{담당자}", userinfo.name);
mail_body = mail_body.Replace("{사번}", userinfo.id);
//메일본문을 생성해서 진행해야함
var mail_content = "<p>일자별 정보</p>";
mail_content += $"<br/>조회기간 : {str_sd}~{str_ed}";
mail_content += "<br/><table border='1' cellspacing='1' cellpadding='1'><tr><td>날짜</td><td>요일</td><td>시간</td></tr>";
foreach (var warnitem in WarnList)
{
mail_content += $"<tr><td>{warnitem.Key.ToShortDateString()}</td><td>{warnitem.Key.DayOfWeek.ToString()}</td><td>{warnitem.Value.ToString()}</td></tr>";
}
mail_content += "</table>";
//메일데이터를 생성한다.
mail_to = "chikyun.kim@amkor.co.kr";
mail_bcc = string.Empty;
mail_cc = string.Empty;
mail_to = MailSort(mail_to, MailJD.exceptmail);
if (string.IsNullOrEmpty(mail_to) == false)
{
db = new EEEntities();
db.MailData.Add(new MailData
{
gcode = vGcode,
cate = "JD",
subject = mail_subject,
fromlist = userinfo.email,
tolist = MailSort(mail_to, MailJD.exceptmail),
bcc = mail_bcc,
cc = MailSort(mail_cc, MailJD.exceptmailcc),
pdate = DateTime.Now.ToShortDateString(),
body = mail_body.Replace("{내용}", mail_content),
wuid = userinfo.id,
wdate = DateTime.Now,
});
db.SaveChanges();
Console.WriteLine($"{userinfo.name}({userinfo.email}) 메일 전송 완료(day)");
System.Threading.Thread.Sleep(10000);
}
else
{
Console.WriteLine("받는사람이 소거되어 메일을 생성하지 않습니다");
}
}
}
System.Threading.Thread.Sleep(3000);
}
else
{
Console.WriteLine($"{uid.Value}({uid.Key}) 미 작성 일자가 없습니다");
}
}
}
}
}

View File

@@ -0,0 +1,214 @@
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JobReportMailService
{
partial class Program
{
static void WorkWeek()
{
if (DateTime.Now.DayOfWeek != DayOfWeek.Monday)
{
Console.WriteLine("주간 업무일지 보고는 월요일에만 작동 합니다");
//return;
}
Console.WriteLine("업무일지 미 작성자(주간) 추출 작업을 시작 합니다");
var db = new EEEntities();
//메일양식이 지정되어있는지 체크
var MailJW = db.MailForm.Where(t => t.gcode == vGcode & t.cate == "JW").FirstOrDefault();
if (MailJW == null)
{
//토,일요일에는 동작하지 않는다
Console.WriteLine("업무일지 미작성(주간) 메일 양식이 입력되지 않았습니다");
return;
}
//기준일자는 오늘부터 -15일이다
var sd = DateTime.Now.AddDays(-15);
var ed = DateTime.Now;
var str_sd = sd.ToShortDateString();
var str_ed = ed.ToShortDateString();
var str_dt = DateTime.Now.ToShortDateString();
//오늘날짜로 주간 데이터가 등록되어있느지 확인한다.
db = new EEEntities();
var Existweek = db.MailData.Where(t => t.gcode == vGcode && t.cate == "JW" && t.wuid == "395552" && t.pdate == str_dt).Any();
if (Existweek)
{
Console.WriteLine($"주간일자({str_dt}) 보고 메일이 이미 등록되어 있습니다");
return;
}
//대상 사용자 목록을 추출한다
db = new EEEntities();
var users = db.vJobReportForUser.Where(t => t.gcode == vGcode).GroupBy(t => t.id);
Dictionary<string, string> uids = new Dictionary<string, string>();
foreach (var user in users)
{
//해당 사용자의 오늘 날짜로 등록된 자동 데이터가 있다면 대상에 넣지 않는다
var userinfo = user.FirstOrDefault();
//퇴사자 확인
db = new EEEntities();
var userdata = db.vGroupUser.Where(t => t.id == userinfo.id).FirstOrDefault();
if (userdata != null && string.IsNullOrEmpty(userdata.outdate) == false) continue;
//모두대상으로 처리한다
uids.Add(userinfo.id, userinfo.name);
}
Console.WriteLine($"{uids.Count} 명의 전체 사용자가 확인 되었습니다");
//먼저 날짜목록을 가져온다
db = new EEEntities();
var lstDate = db.JobReport
.Where(t => t.gcode == vGcode && t.pdate.CompareTo(str_sd) >= 0 && t.pdate.CompareTo(str_ed) < 0)
.OrderBy(t => t.pdate)
.GroupBy(t => t.pdate).ToList();
//날짜대로 루프를 돈다
List<DateTime> days = new List<DateTime>();
foreach (var dateitem in lstDate)
{
var jobdata = dateitem.FirstOrDefault();
var dt = DateTime.Parse(jobdata.pdate);
if (dt.DayOfWeek == DayOfWeek.Sunday || dt.DayOfWeek == DayOfWeek.Saturday) continue;
//이 날짜가 휴일인지 체크한다.
db = new EEEntities();
var Holyinfo = db.HolidayLIst.Where(t => t.pdate == jobdata.package).FirstOrDefault();
if (Holyinfo != null && Holyinfo.free != null && (bool)(Holyinfo.free)) continue;
//이날짜에는 8시간을 근무 해야 한다
days.Add(DateTime.Parse(jobdata.pdate));
}
Console.WriteLine($"{days.Count} 건의 일자가 확인 되었습니다(기간:{str_sd}~{str_ed}");
//사용자 목록과 날짜 목록을 모두 수집했다
List<ReportUserData> totWarnList = new List<ReportUserData>();
foreach (var uid in uids)
{
//이사용자의 날짜별 근무시간을 확인한다.
db = new EEEntities();
var UserDatas = db.vJobReportForUser.Where(t => t.gcode == vGcode && t.id == uid.Key && t.pdate.CompareTo(str_sd) >= 0 && t.pdate.CompareTo(str_ed) < 0).ToList();
Dictionary<DateTime, double?> WarnList = new Dictionary<DateTime, double?>();
foreach (var dt in days.OrderBy(t => t))
{
var dtstr = dt.ToShortDateString();
var userdata = UserDatas.Where(t => t.pdate == dtstr); //해당날짜의 데이터를 확인한다.
var hrs = 0.0;
if (userdata.Any()) hrs = (double)userdata.Sum(t => t.hrs);
//자료를 입력하지 않았거나, 입력시간이 8시간 미만이면 경고한다
if (hrs < 8.0)
{
//WarnList.Add(dt, hrs);
totWarnList.Add(new ReportUserData { date = dt, hrs = hrs, uid = uid.Key, uname = uid.Value }); //전체알림시에 사용하는 목록
}
}
}
if (totWarnList.Count > 0)
{
Console.WriteLine($"주간 경고 데이터는 {totWarnList.Count} 건 입니다");
//오늘잘짜로 등록된 자료가 있으면 처리하지 안흔다.
//해당 사용자의 오늘 날짜로 등록된 자동 데이터가 있다면 대상에 넣지 않는다
db = new EEEntities();
var Exists = db.MailData.Where(t => t.gcode == vGcode && t.wuid == "395552" && t.pdate == str_dt && t.cate.StartsWith("JW")).Any();
if (Exists == false)
{
var mail_subject = MailJW.subject;
var mail_to = MailJW.tolist;//.Replace("{담당자}", userinfo.email);
var pmail_cc = new List<string>(); //
if (MailJW.cc != null) pmail_cc = MailJW.cc.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();//.Replace("{담당자}", userinfo.email);
var mail_bcc = string.Empty;
if (MailJW.bcc != null) mail_bcc = MailJW.bcc;//.Replace("{담당자}", userinfo.email);
var mail_body = MailJW.body;//.Replace("{담당자}", userinfo.name);
//메일본문을 생성해서 진행해야함
var vmail_body = "<p>담당자별 정보</p>";
vmail_body += "<br/>조회기간 : " + sd.ToShortDateString() + "~" + ed.ToShortDateString();
//참고데이터를 추가한다
var usergrplist = totWarnList.OrderBy(t=>t.uname).GroupBy(t => t.uid).ToList();
foreach (var item in usergrplist)
{
var fitem = item.FirstOrDefault();
db = new EEEntities();
var userinfo = db.vGroupUser.Where(t => t.id == fitem.uid).FirstOrDefault();
var username = string.Empty;
if (userinfo != null)
{
if (string.IsNullOrEmpty(userinfo.email) == false)
{
if(pmail_cc.Contains(userinfo.email)==false)
pmail_cc.Add(userinfo.email);
}
username = userinfo.name;
}
}
vmail_body += "<br/><table border='1' cellspacing='1' cellpadding='1'><tr><td>담당자</td><td>일자별시간</td></tr>";
var mail_cc = string.Join(";", pmail_cc); //모든 대상을 세미콜론으로 붙인다.
foreach (var warnitem in usergrplist)
{
var item = warnitem.FirstOrDefault();
vmail_body += $"<tr><td>{item.uname}({item.uid})</td><td>";
foreach (var ii in warnitem.OrderBy(t => t.date))
{
vmail_body += $" {ii.date.ToString("MM/dd")}({ii.hrs}h)";
}
vmail_body += "</td></tr>";
}
vmail_body += "</table>";
//메일데이터를 생성한다.
mail_bcc = string.Empty;
mail_cc = string.Empty;
mail_to = "chikyun.kim@amkor.co.kr";
db = new EEEntities();
mail_to = MailSort(mail_to, MailJW.exceptmail);
if (string.IsNullOrEmpty(mail_to) == false)
{
db.MailData.Add(new MailData
{
gcode = vGcode,
cate = "JW",
subject = mail_subject,
fromlist = "EETGW@amkor.co.kr",
tolist = MailSort(mail_to, MailJW.exceptmail),
bcc = mail_bcc,
cc = MailSort(mail_cc, MailJW.exceptmailcc),
pdate = DateTime.Now.ToShortDateString(),
body = mail_body.Replace("{내용}", vmail_body),
wuid = "395552",
wdate = DateTime.Now,
});
db.SaveChanges();
Console.WriteLine("주간 알림데이터가 등록되었습니다");
}
else
{
Console.WriteLine("받는사람이 소거되어 메일을 생성하지 않습니다");
}
}
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해
// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면
// 이러한 특성 값을 변경하세요.
[assembly: AssemblyTitle("JobReportMailService")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JobReportMailService")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에
// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면
// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요.
[assembly: ComVisible(false)]
// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다.
[assembly: Guid("dbe5bd4a-09d3-4437-ad6c-81fe270c6458")]
// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다.
//
// 주 버전
// 부 버전
// 빌드 번호
// 수정 버전
//
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
// 기본값으로 할 수 있습니다.
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,37 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 도구를 사용하여 생성되었습니다.
// 런타임 버전:4.0.30319.42000
//
// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면
// 이러한 변경 내용이 손실됩니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JobReportMailService.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)]
[global::System.Configuration.DefaultSettingValueAttribute("Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=ee" +
"user;Password=Amkor123!")]
public string CS {
get {
return ((string)(this["CS"]));
}
}
}
}

View File

@@ -0,0 +1,14 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="JobReportMailService.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="CS" Type="(Connection string)" Scope="Application">
<DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;ConnectionString&gt;Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123!&lt;/ConnectionString&gt;
&lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</DesignTimeValue>
<Value Profile="(Default)">Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123!</Value>
</Setting>
</Settings>
</SettingsFile>

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace JobReportMailService
{
public class ReportUserData
{
public DateTime date { get; set; }
public string uid { get; set; }
public string uname { get; set; }
public double hrs { get; set; }
}
}

View File

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net45" />
<package id="EntityFramework.ko" version="6.2.0" targetFramework="net45" />
</packages>

View File

@@ -0,0 +1,36 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 템플릿에서 생성되었습니다.
//
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JobReportMailService
{
using System;
using System.Collections.Generic;
public partial class vGroupUser
{
public string gcode { get; set; }
public string dept { get; set; }
public Nullable<short> level { get; set; }
public string name { get; set; }
public string nameE { get; set; }
public string grade { get; set; }
public string email { get; set; }
public string tel { get; set; }
public string indate { get; set; }
public string outdate { get; set; }
public string hp { get; set; }
public string place { get; set; }
public string ads_employNo { get; set; }
public string ads_title { get; set; }
public string ads_created { get; set; }
public string memo { get; set; }
public string processs { get; set; }
public string id { get; set; }
}
}

View File

@@ -0,0 +1,31 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 이 코드는 템플릿에서 생성되었습니다.
//
// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다.
// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다.
// </auto-generated>
//------------------------------------------------------------------------------
namespace JobReportMailService
{
using System;
using System.Collections.Generic;
public partial class vJobReportForUser
{
public int idx { get; set; }
public string pdate { get; set; }
public string gcode { get; set; }
public string id { get; set; }
public string name { get; set; }
public string process { get; set; }
public string type { get; set; }
public string svalue { get; set; }
public Nullable<double> hrs { get; set; }
public Nullable<double> ot { get; set; }
public string userProcess { get; set; }
public string requestpart { get; set; }
public string package { get; set; }
}
}