diff --git a/Project/AdoNetEFMain.Context.cs b/Project/AdoNetEFMain.Context.cs new file mode 100644 index 0000000..acce4f9 --- /dev/null +++ b/Project/AdoNetEFMain.Context.cs @@ -0,0 +1,33 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace Project +{ + using System; + using System.Data.Entity; + using System.Data.Entity.Infrastructure; + + public partial class EEEntitiesMain : DbContext + { + public EEEntitiesMain() + : base("name=EEEntitiesMain") + { + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + throw new UnintentionalCodeFirstException(); + } + + public virtual DbSet EETGW_GroupUser { get; set; } + public virtual DbSet UserGroup { get; set; } + public virtual DbSet Users { get; set; } + public virtual DbSet vGroupUser { get; set; } + } +} diff --git a/Project/AdoNetEFMain.Context.tt b/Project/AdoNetEFMain.Context.tt new file mode 100644 index 0000000..95915a5 --- /dev/null +++ b/Project/AdoNetEFMain.Context.tt @@ -0,0 +1,636 @@ +<#@ template language="C#" debug="false" hostspecific="true"#> +<#@ include file="EF6.Utility.CS.ttinclude"#><#@ + output extension=".cs"#><# + +const string inputFile = @"AdoNetEFMain.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().FirstOrDefault(); +if (container == null) +{ + return string.Empty; +} +#> +//------------------------------------------------------------------------------ +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> +// +//------------------------------------------------------------------------------ + +<# + +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()) +{ + // 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()) + { +#> + <#=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 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(); + } + + 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 types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(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 GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } + + public IEnumerable GetAllGlobalItems(IEnumerable 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 GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable 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)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 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 arg, string name) where T : class +{ + if (arg == null) + { + throw new ArgumentNullException(name); + } +} +#> \ No newline at end of file diff --git a/Project/AdoNetEFMain.Designer.cs b/Project/AdoNetEFMain.Designer.cs new file mode 100644 index 0000000..fa76703 --- /dev/null +++ b/Project/AdoNetEFMain.Designer.cs @@ -0,0 +1,10 @@ +// 모델 'D:\Source\##### 완료아이템\(014) GroupWare\Source\Project\AdoNetEFMain.edmx'에 대해 T4 코드 생성이 사용됩니다. +// 레거시 코드 생성을 사용하려면 '코드 생성 전략' 디자이너 속성의 값을 +// 'Legacy ObjectContext'로 변경하십시오. 이 속성은 모델이 디자이너에서 열릴 때 +// 속성 창에서 사용할 수 있습니다. + +// 컨텍스트 및 엔터티 클래스가 생성되지 않은 경우 빈 모델을 만들었기 때문일 수도 있지만 +// 사용할 Entity Framework 버전을 선택하지 않았기 때문일 수도 있습니다. 모델에 맞는 컨텍스트 클래스 및 +// 엔터티 클래스를 생성하려면 디자이너에서 모델을 열고 디자이너 화면에서 마우스 오른쪽 단추를 클릭한 +// 다음 '데이터베이스에서 모델 업데이트...', '모델에서 데이터베이스 생성...' 또는 '코드 생성 항목 추가...'를 +// 선택하십시오. \ No newline at end of file diff --git a/Project/AdoNetEFMain.cs b/Project/AdoNetEFMain.cs new file mode 100644 index 0000000..7a9ab12 --- /dev/null +++ b/Project/AdoNetEFMain.cs @@ -0,0 +1,9 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + diff --git a/Project/AdoNetEFMain.edmx b/Project/AdoNetEFMain.edmx new file mode 100644 index 0000000..b984f31 --- /dev/null +++ b/Project/AdoNetEFMain.edmx @@ -0,0 +1,294 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Project/AdoNetEFMain.edmx.diagram b/Project/AdoNetEFMain.edmx.diagram new file mode 100644 index 0000000..a829ade --- /dev/null +++ b/Project/AdoNetEFMain.edmx.diagram @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Project/AdoNetEFMain.tt b/Project/AdoNetEFMain.tt new file mode 100644 index 0000000..00d1872 --- /dev/null +++ b/Project/AdoNetEFMain.tt @@ -0,0 +1,733 @@ +<#@ template language="C#" debug="false" hostspecific="true"#> +<#@ include file="EF6.Utility.CS.ttinclude"#><#@ + output extension=".cs"#><# + +const string inputFile = @"AdoNetEFMain.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(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(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(); +#> +//------------------------------------------------------------------------------ +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> +// +//------------------------------------------------------------------------------ +<#=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 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(); + } + + 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 types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(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 GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } + + public IEnumerable GetAllGlobalItems(IEnumerable 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 GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable 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)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 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 arg, string name) where T : class +{ + if (arg == null) + { + throw new ArgumentNullException(name); + } +} +#> \ No newline at end of file diff --git a/Project/DataClasses1.dbml b/Project/DataClasses1.dbml deleted file mode 100644 index 4483b3e..0000000 --- a/Project/DataClasses1.dbml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - -
-
\ No newline at end of file diff --git a/Project/DataClasses1.dbml.layout b/Project/DataClasses1.dbml.layout deleted file mode 100644 index 7785523..0000000 --- a/Project/DataClasses1.dbml.layout +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Project/DataClasses1.designer.cs b/Project/DataClasses1.designer.cs deleted file mode 100644 index a749871..0000000 --- a/Project/DataClasses1.designer.cs +++ /dev/null @@ -1,1346 +0,0 @@ -#pragma warning disable 1591 -//------------------------------------------------------------------------------ -// -// 이 코드는 도구를 사용하여 생성되었습니다. -// 런타임 버전:4.0.30319.42000 -// -// 파일 내용을 변경하면 잘못된 동작이 발생할 수 있으며, 코드를 다시 생성하면 -// 이러한 변경 내용이 손실됩니다. -// -//------------------------------------------------------------------------------ - -namespace Project -{ - using System.Data.Linq; - using System.Data.Linq.Mapping; - using System.Data; - using System.Collections.Generic; - using System.Reflection; - using System.Linq; - using System.Linq.Expressions; - using System.ComponentModel; - using System; - - - [global::System.Data.Linq.Mapping.DatabaseAttribute(Name="EE")] - public partial class DataClasses1DataContext : System.Data.Linq.DataContext - { - - private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource(); - - #region 확장성 메서드 정의 - partial void OnCreated(); - partial void InsertUserGroup(UserGroup instance); - partial void UpdateUserGroup(UserGroup instance); - partial void DeleteUserGroup(UserGroup instance); - partial void InsertUsers(Users instance); - partial void UpdateUsers(Users instance); - partial void DeleteUsers(Users instance); - partial void InsertEETGW_GroupUser(EETGW_GroupUser instance); - partial void UpdateEETGW_GroupUser(EETGW_GroupUser instance); - partial void DeleteEETGW_GroupUser(EETGW_GroupUser instance); - #endregion - - public DataClasses1DataContext() : - base(global::Project.Properties.Settings.Default.gwcs, mappingSource) - { - OnCreated(); - } - - public DataClasses1DataContext(string connection) : - base(connection, mappingSource) - { - OnCreated(); - } - - public DataClasses1DataContext(System.Data.IDbConnection connection) : - base(connection, mappingSource) - { - OnCreated(); - } - - public DataClasses1DataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) - { - OnCreated(); - } - - public DataClasses1DataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) : - base(connection, mappingSource) - { - OnCreated(); - } - - public System.Data.Linq.Table UserGroup - { - get - { - return this.GetTable(); - } - } - - public System.Data.Linq.Table vGroupUser - { - get - { - return this.GetTable(); - } - } - - public System.Data.Linq.Table Users - { - get - { - return this.GetTable(); - } - } - - public System.Data.Linq.Table EETGW_GroupUser - { - get - { - return this.GetTable(); - } - } - } - - [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.UserGroup")] - public partial class UserGroup : INotifyPropertyChanging, INotifyPropertyChanged - { - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private string _dept; - - private string _gcode; - - private string _path_kj; - - private System.Nullable _advpurchase; - - private System.Nullable _permission; - - #region 확장성 메서드 정의 - partial void OnLoaded(); - partial void OnValidate(System.Data.Linq.ChangeAction action); - partial void OnCreated(); - partial void OndeptChanging(string value); - partial void OndeptChanged(); - partial void OngcodeChanging(string value); - partial void OngcodeChanged(); - partial void Onpath_kjChanging(string value); - partial void Onpath_kjChanged(); - partial void OnadvpurchaseChanging(System.Nullable value); - partial void OnadvpurchaseChanged(); - partial void OnpermissionChanging(System.Nullable value); - partial void OnpermissionChanged(); - #endregion - - public UserGroup() - { - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_dept", DbType="VarChar(100) NOT NULL", CanBeNull=false, IsPrimaryKey=true)] - public string dept - { - get - { - return this._dept; - } - set - { - if ((this._dept != value)) - { - this.OndeptChanging(value); - this.SendPropertyChanging(); - this._dept = value; - this.SendPropertyChanged("dept"); - this.OndeptChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_gcode", DbType="VarChar(10)")] - public string gcode - { - get - { - return this._gcode; - } - set - { - if ((this._gcode != value)) - { - this.OngcodeChanging(value); - this.SendPropertyChanging(); - this._gcode = value; - this.SendPropertyChanged("gcode"); - this.OngcodeChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_path_kj", DbType="NVarChar(100)")] - public string path_kj - { - get - { - return this._path_kj; - } - set - { - if ((this._path_kj != value)) - { - this.Onpath_kjChanging(value); - this.SendPropertyChanging(); - this._path_kj = value; - this.SendPropertyChanged("path_kj"); - this.Onpath_kjChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_advpurchase", DbType="Bit")] - public System.Nullable advpurchase - { - get - { - return this._advpurchase; - } - set - { - if ((this._advpurchase != value)) - { - this.OnadvpurchaseChanging(value); - this.SendPropertyChanging(); - this._advpurchase = value; - this.SendPropertyChanged("advpurchase"); - this.OnadvpurchaseChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_permission", DbType="Int")] - public System.Nullable permission - { - get - { - return this._permission; - } - set - { - if ((this._permission != value)) - { - this.OnpermissionChanging(value); - this.SendPropertyChanging(); - this._permission = value; - this.SendPropertyChanged("permission"); - this.OnpermissionChanged(); - } - } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) - { - this.PropertyChanging(this, emptyChangingEventArgs); - } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - } - - [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.vGroupUser")] - public partial class vGroupUser - { - - private string _gcode; - - private System.Nullable _level; - - private string _name; - - private string _nameE; - - private string _dept; - - private string _grade; - - private string _email; - - private string _tel; - - private string _indate; - - private string _outdate; - - private string _hp; - - private string _place; - - private string _ads_employNo; - - private string _ads_title; - - private string _ads_created; - - private string _memo; - - private string _processs; - - private string _id; - - public vGroupUser() - { - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_gcode", DbType="VarChar(10) NOT NULL", CanBeNull=false)] - public string gcode - { - get - { - return this._gcode; - } - set - { - if ((this._gcode != value)) - { - this._gcode = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Name="[level]", Storage="_level", DbType="SmallInt")] - public System.Nullable level - { - get - { - return this._level; - } - set - { - if ((this._level != value)) - { - this._level = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_name", DbType="NVarChar(100)")] - public string name - { - get - { - return this._name; - } - set - { - if ((this._name != value)) - { - this._name = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_nameE", DbType="NVarChar(100)")] - public string nameE - { - get - { - return this._nameE; - } - set - { - if ((this._nameE != value)) - { - this._nameE = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_dept", DbType="VarChar(100)")] - public string dept - { - get - { - return this._dept; - } - set - { - if ((this._dept != value)) - { - this._dept = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_grade", DbType="VarChar(10)")] - public string grade - { - get - { - return this._grade; - } - set - { - if ((this._grade != value)) - { - this._grade = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_email", DbType="VarChar(100)")] - public string email - { - get - { - return this._email; - } - set - { - if ((this._email != value)) - { - this._email = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_tel", DbType="VarChar(20)")] - public string tel - { - get - { - return this._tel; - } - set - { - if ((this._tel != value)) - { - this._tel = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_indate", DbType="VarChar(20)")] - public string indate - { - get - { - return this._indate; - } - set - { - if ((this._indate != value)) - { - this._indate = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_outdate", DbType="VarChar(20)")] - public string outdate - { - get - { - return this._outdate; - } - set - { - if ((this._outdate != value)) - { - this._outdate = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_hp", DbType="VarChar(20)")] - public string hp - { - get - { - return this._hp; - } - set - { - if ((this._hp != value)) - { - this._hp = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_place", DbType="VarChar(100)")] - public string place - { - get - { - return this._place; - } - set - { - if ((this._place != value)) - { - this._place = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ads_employNo", DbType="VarChar(50)")] - public string ads_employNo - { - get - { - return this._ads_employNo; - } - set - { - if ((this._ads_employNo != value)) - { - this._ads_employNo = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ads_title", DbType="NVarChar(100)")] - public string ads_title - { - get - { - return this._ads_title; - } - set - { - if ((this._ads_title != value)) - { - this._ads_title = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ads_created", DbType="VarChar(50)")] - public string ads_created - { - get - { - return this._ads_created; - } - set - { - if ((this._ads_created != value)) - { - this._ads_created = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_memo", DbType="NVarChar(255)")] - public string memo - { - get - { - return this._memo; - } - set - { - if ((this._memo != value)) - { - this._memo = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_processs", DbType="NVarChar(100)")] - public string processs - { - get - { - return this._processs; - } - set - { - if ((this._processs != value)) - { - this._processs = value; - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_id", DbType="VarChar(20)")] - public string id - { - get - { - return this._id; - } - set - { - if ((this._id != value)) - { - this._id = value; - } - } - } - } - - [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.Users")] - public partial class Users : INotifyPropertyChanging, INotifyPropertyChanged - { - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private string _id; - - private string _gcode; - - private string _password; - - private string _nameE; - - private string _name; - - private string _dept; - - private string _grade; - - private string _email; - - private System.Nullable _level; - - private string _indate; - - private string _outdate; - - private string _tel; - - private string _hp; - - private string _place; - - private string _ads_employNo; - - private string _ads_title; - - private string _ads_created; - - private string _memo; - - private string _wuid; - - private System.DateTime _wdate; - - private string _processs; - - #region 확장성 메서드 정의 - partial void OnLoaded(); - partial void OnValidate(System.Data.Linq.ChangeAction action); - partial void OnCreated(); - partial void OnidChanging(string value); - partial void OnidChanged(); - partial void OngcodeChanging(string value); - partial void OngcodeChanged(); - partial void OnpasswordChanging(string value); - partial void OnpasswordChanged(); - partial void OnnameEChanging(string value); - partial void OnnameEChanged(); - partial void OnnameChanging(string value); - partial void OnnameChanged(); - partial void OndeptChanging(string value); - partial void OndeptChanged(); - partial void OngradeChanging(string value); - partial void OngradeChanged(); - partial void OnemailChanging(string value); - partial void OnemailChanged(); - partial void OnlevelChanging(System.Nullable value); - partial void OnlevelChanged(); - partial void OnindateChanging(string value); - partial void OnindateChanged(); - partial void OnoutdateChanging(string value); - partial void OnoutdateChanged(); - partial void OntelChanging(string value); - partial void OntelChanged(); - partial void OnhpChanging(string value); - partial void OnhpChanged(); - partial void OnplaceChanging(string value); - partial void OnplaceChanged(); - partial void Onads_employNoChanging(string value); - partial void Onads_employNoChanged(); - partial void Onads_titleChanging(string value); - partial void Onads_titleChanged(); - partial void Onads_createdChanging(string value); - partial void Onads_createdChanged(); - partial void OnmemoChanging(string value); - partial void OnmemoChanged(); - partial void OnwuidChanging(string value); - partial void OnwuidChanged(); - partial void OnwdateChanging(System.DateTime value); - partial void OnwdateChanged(); - partial void OnprocesssChanging(string value); - partial void OnprocesssChanged(); - #endregion - - public Users() - { - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_id", DbType="VarChar(20) NOT NULL", CanBeNull=false, IsPrimaryKey=true)] - public string id - { - get - { - return this._id; - } - set - { - if ((this._id != value)) - { - this.OnidChanging(value); - this.SendPropertyChanging(); - this._id = value; - this.SendPropertyChanged("id"); - this.OnidChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_gcode", DbType="VarChar(10)")] - public string gcode - { - get - { - return this._gcode; - } - set - { - if ((this._gcode != value)) - { - this.OngcodeChanging(value); - this.SendPropertyChanging(); - this._gcode = value; - this.SendPropertyChanged("gcode"); - this.OngcodeChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_password", DbType="VarChar(50)")] - public string password - { - get - { - return this._password; - } - set - { - if ((this._password != value)) - { - this.OnpasswordChanging(value); - this.SendPropertyChanging(); - this._password = value; - this.SendPropertyChanged("password"); - this.OnpasswordChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_nameE", DbType="NVarChar(100)")] - public string nameE - { - get - { - return this._nameE; - } - set - { - if ((this._nameE != value)) - { - this.OnnameEChanging(value); - this.SendPropertyChanging(); - this._nameE = value; - this.SendPropertyChanged("nameE"); - this.OnnameEChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_name", DbType="NVarChar(100)")] - public string name - { - get - { - return this._name; - } - set - { - if ((this._name != value)) - { - this.OnnameChanging(value); - this.SendPropertyChanging(); - this._name = value; - this.SendPropertyChanged("name"); - this.OnnameChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_dept", DbType="VarChar(100)")] - public string dept - { - get - { - return this._dept; - } - set - { - if ((this._dept != value)) - { - this.OndeptChanging(value); - this.SendPropertyChanging(); - this._dept = value; - this.SendPropertyChanged("dept"); - this.OndeptChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_grade", DbType="VarChar(10)")] - public string grade - { - get - { - return this._grade; - } - set - { - if ((this._grade != value)) - { - this.OngradeChanging(value); - this.SendPropertyChanging(); - this._grade = value; - this.SendPropertyChanged("grade"); - this.OngradeChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_email", DbType="VarChar(100)")] - public string email - { - get - { - return this._email; - } - set - { - if ((this._email != value)) - { - this.OnemailChanging(value); - this.SendPropertyChanging(); - this._email = value; - this.SendPropertyChanged("email"); - this.OnemailChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Name="[level]", Storage="_level", DbType="SmallInt")] - public System.Nullable level - { - get - { - return this._level; - } - set - { - if ((this._level != value)) - { - this.OnlevelChanging(value); - this.SendPropertyChanging(); - this._level = value; - this.SendPropertyChanged("level"); - this.OnlevelChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_indate", DbType="VarChar(20)")] - public string indate - { - get - { - return this._indate; - } - set - { - if ((this._indate != value)) - { - this.OnindateChanging(value); - this.SendPropertyChanging(); - this._indate = value; - this.SendPropertyChanged("indate"); - this.OnindateChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_outdate", DbType="VarChar(20)")] - public string outdate - { - get - { - return this._outdate; - } - set - { - if ((this._outdate != value)) - { - this.OnoutdateChanging(value); - this.SendPropertyChanging(); - this._outdate = value; - this.SendPropertyChanged("outdate"); - this.OnoutdateChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_tel", DbType="VarChar(20)")] - public string tel - { - get - { - return this._tel; - } - set - { - if ((this._tel != value)) - { - this.OntelChanging(value); - this.SendPropertyChanging(); - this._tel = value; - this.SendPropertyChanged("tel"); - this.OntelChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_hp", DbType="VarChar(20)")] - public string hp - { - get - { - return this._hp; - } - set - { - if ((this._hp != value)) - { - this.OnhpChanging(value); - this.SendPropertyChanging(); - this._hp = value; - this.SendPropertyChanged("hp"); - this.OnhpChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_place", DbType="VarChar(100)")] - public string place - { - get - { - return this._place; - } - set - { - if ((this._place != value)) - { - this.OnplaceChanging(value); - this.SendPropertyChanging(); - this._place = value; - this.SendPropertyChanged("place"); - this.OnplaceChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ads_employNo", DbType="VarChar(50)")] - public string ads_employNo - { - get - { - return this._ads_employNo; - } - set - { - if ((this._ads_employNo != value)) - { - this.Onads_employNoChanging(value); - this.SendPropertyChanging(); - this._ads_employNo = value; - this.SendPropertyChanged("ads_employNo"); - this.Onads_employNoChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ads_title", DbType="NVarChar(100)")] - public string ads_title - { - get - { - return this._ads_title; - } - set - { - if ((this._ads_title != value)) - { - this.Onads_titleChanging(value); - this.SendPropertyChanging(); - this._ads_title = value; - this.SendPropertyChanged("ads_title"); - this.Onads_titleChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ads_created", DbType="VarChar(50)")] - public string ads_created - { - get - { - return this._ads_created; - } - set - { - if ((this._ads_created != value)) - { - this.Onads_createdChanging(value); - this.SendPropertyChanging(); - this._ads_created = value; - this.SendPropertyChanged("ads_created"); - this.Onads_createdChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_memo", DbType="NVarChar(255)")] - public string memo - { - get - { - return this._memo; - } - set - { - if ((this._memo != value)) - { - this.OnmemoChanging(value); - this.SendPropertyChanging(); - this._memo = value; - this.SendPropertyChanged("memo"); - this.OnmemoChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_wuid", DbType="VarChar(20) NOT NULL", CanBeNull=false)] - public string wuid - { - get - { - return this._wuid; - } - set - { - if ((this._wuid != value)) - { - this.OnwuidChanging(value); - this.SendPropertyChanging(); - this._wuid = value; - this.SendPropertyChanged("wuid"); - this.OnwuidChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_wdate", DbType="SmallDateTime NOT NULL")] - public System.DateTime wdate - { - get - { - return this._wdate; - } - set - { - if ((this._wdate != value)) - { - this.OnwdateChanging(value); - this.SendPropertyChanging(); - this._wdate = value; - this.SendPropertyChanged("wdate"); - this.OnwdateChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_processs", DbType="NVarChar(100)")] - public string processs - { - get - { - return this._processs; - } - set - { - if ((this._processs != value)) - { - this.OnprocesssChanging(value); - this.SendPropertyChanging(); - this._processs = value; - this.SendPropertyChanged("processs"); - this.OnprocesssChanged(); - } - } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) - { - this.PropertyChanging(this, emptyChangingEventArgs); - } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - } - - [global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.EETGW_GroupUser")] - public partial class EETGW_GroupUser : INotifyPropertyChanging, INotifyPropertyChanged - { - - private static PropertyChangingEventArgs emptyChangingEventArgs = new PropertyChangingEventArgs(String.Empty); - - private int _idx; - - private string _gcode; - - private string _uid; - - private System.Nullable _level; - - private string _Process; - - private string _wuid; - - private System.DateTime _wdate; - - #region 확장성 메서드 정의 - partial void OnLoaded(); - partial void OnValidate(System.Data.Linq.ChangeAction action); - partial void OnCreated(); - partial void OnidxChanging(int value); - partial void OnidxChanged(); - partial void OngcodeChanging(string value); - partial void OngcodeChanged(); - partial void OnuidChanging(string value); - partial void OnuidChanged(); - partial void OnlevelChanging(System.Nullable value); - partial void OnlevelChanged(); - partial void OnProcessChanging(string value); - partial void OnProcessChanged(); - partial void OnwuidChanging(string value); - partial void OnwuidChanged(); - partial void OnwdateChanging(System.DateTime value); - partial void OnwdateChanged(); - #endregion - - public EETGW_GroupUser() - { - OnCreated(); - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_idx", AutoSync=AutoSync.OnInsert, DbType="Int NOT NULL IDENTITY", IsPrimaryKey=true, IsDbGenerated=true)] - public int idx - { - get - { - return this._idx; - } - set - { - if ((this._idx != value)) - { - this.OnidxChanging(value); - this.SendPropertyChanging(); - this._idx = value; - this.SendPropertyChanged("idx"); - this.OnidxChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_gcode", DbType="VarChar(10) NOT NULL", CanBeNull=false)] - public string gcode - { - get - { - return this._gcode; - } - set - { - if ((this._gcode != value)) - { - this.OngcodeChanging(value); - this.SendPropertyChanging(); - this._gcode = value; - this.SendPropertyChanged("gcode"); - this.OngcodeChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_uid", DbType="VarChar(20) NOT NULL", CanBeNull=false)] - public string uid - { - get - { - return this._uid; - } - set - { - if ((this._uid != value)) - { - this.OnuidChanging(value); - this.SendPropertyChanging(); - this._uid = value; - this.SendPropertyChanged("uid"); - this.OnuidChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Name="[level]", Storage="_level", DbType="SmallInt")] - public System.Nullable level - { - get - { - return this._level; - } - set - { - if ((this._level != value)) - { - this.OnlevelChanging(value); - this.SendPropertyChanging(); - this._level = value; - this.SendPropertyChanged("level"); - this.OnlevelChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Process", DbType="VarChar(50)")] - public string Process - { - get - { - return this._Process; - } - set - { - if ((this._Process != value)) - { - this.OnProcessChanging(value); - this.SendPropertyChanging(); - this._Process = value; - this.SendPropertyChanged("Process"); - this.OnProcessChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_wuid", DbType="VarChar(20) NOT NULL", CanBeNull=false)] - public string wuid - { - get - { - return this._wuid; - } - set - { - if ((this._wuid != value)) - { - this.OnwuidChanging(value); - this.SendPropertyChanging(); - this._wuid = value; - this.SendPropertyChanged("wuid"); - this.OnwuidChanged(); - } - } - } - - [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_wdate", DbType="SmallDateTime NOT NULL")] - public System.DateTime wdate - { - get - { - return this._wdate; - } - set - { - if ((this._wdate != value)) - { - this.OnwdateChanging(value); - this.SendPropertyChanging(); - this._wdate = value; - this.SendPropertyChanged("wdate"); - this.OnwdateChanged(); - } - } - } - - public event PropertyChangingEventHandler PropertyChanging; - - public event PropertyChangedEventHandler PropertyChanged; - - protected virtual void SendPropertyChanging() - { - if ((this.PropertyChanging != null)) - { - this.PropertyChanging(this, emptyChangingEventArgs); - } - } - - protected virtual void SendPropertyChanged(String propertyName) - { - if ((this.PropertyChanged != null)) - { - this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); - } - } - } -} -#pragma warning restore 1591 diff --git a/Project/EETGW.csproj b/Project/EETGW.csproj index 6c8948f..ce091f3 100644 --- a/Project/EETGW.csproj +++ b/Project/EETGW.csproj @@ -124,6 +124,12 @@ False ..\DLL\ArSetting.Net4.dll + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.dll + + + ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll + @@ -134,12 +140,15 @@ + + + @@ -157,12 +166,22 @@ - - + True True - DataClasses1.dbml + AdoNetEFMain.Context.tt + + True + True + AdoNetEFMain.tt + + + True + True + AdoNetEFMain.edmx + + True True @@ -227,6 +246,9 @@ True DsPMPDatabase.xsd + + AdoNetEFMain.tt + Form @@ -252,6 +274,15 @@ + + AdoNetEFMain.tt + + + AdoNetEFMain.tt + + + AdoNetEFMain.tt + Form @@ -378,15 +409,14 @@ Resources.resx True + + EntityModelCodeGenerator + AdoNetEFMain.Designer.cs + + + AdoNetEFMain.edmx + - - MSLinqToSQLGenerator - DataClasses1.designer.cs - Designer - - - DataClasses1.dbml - DataSet1.xsd @@ -420,6 +450,7 @@ DsPMPDatabase.xsd + SettingsSingleFileGenerator @@ -435,6 +466,16 @@ + + TextTemplatingFileGenerator + AdoNetEFMain.edmx + AdoNetEFMain.Context.cs + + + TextTemplatingFileGenerator + AdoNetEFMain.edmx + AdoNetEFMain.cs + @@ -509,6 +550,7 @@ + \ No newline at end of file diff --git a/Project/EETGW_GroupUser.cs b/Project/EETGW_GroupUser.cs new file mode 100644 index 0000000..0b91489 --- /dev/null +++ b/Project/EETGW_GroupUser.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace Project +{ + using System; + using System.Collections.Generic; + + public partial class EETGW_GroupUser + { + public int idx { get; set; } + public string gcode { get; set; } + public string uid { get; set; } + public Nullable level { get; set; } + public string Process { get; set; } + public string wuid { get; set; } + public System.DateTime wdate { get; set; } + } +} diff --git a/Project/Properties/AssemblyInfo.cs b/Project/Properties/AssemblyInfo.cs index a5bd9e5..e3baec9 100644 --- a/Project/Properties/AssemblyInfo.cs +++ b/Project/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 // 지정되도록 할 수 있습니다. // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("20.10.27.1200")] -[assembly: AssemblyFileVersion("20.10.27.1200")] +[assembly: AssemblyVersion("20.10.29.1100")] +[assembly: AssemblyFileVersion("20.10.29.1100")] diff --git a/Project/Properties/Settings.Designer.cs b/Project/Properties/Settings.Designer.cs index 39a6c6a..8abd7e3 100644 --- a/Project/Properties/Settings.Designer.cs +++ b/Project/Properties/Settings.Designer.cs @@ -34,20 +34,6 @@ namespace Project.Properties { } } - [global::System.Configuration.UserScopedSettingAttribute()] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("using System; \r\nnamespace HelloWorld \r\n{ \r\n public static class HelloWorldCla" + - "ss \r\n { \r\n public static string test() \r\n { \r\n " + - " return {0};\r\n } \r\n } \r\n};")] - public string nilliila { - get { - return ((string)(this["nilliila"])); - } - set { - this["nilliila"] = value; - } - } - [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Configuration.SpecialSettingAttribute(global::System.Configuration.SpecialSetting.ConnectionString)] diff --git a/Project/Properties/Settings.settings b/Project/Properties/Settings.settings index 72eea44..980e2e6 100644 --- a/Project/Properties/Settings.settings +++ b/Project/Properties/Settings.settings @@ -10,19 +10,6 @@ </SerializableConnectionString> Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123! - - using System; -namespace HelloWorld -{ - public static class HelloWorldClass - { - public static string test() - { - return {0}; - } - } -}; - <?xml version="1.0" encoding="utf-16"?> <SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> diff --git a/Project/UserGroup.cs b/Project/UserGroup.cs new file mode 100644 index 0000000..5edb34f --- /dev/null +++ b/Project/UserGroup.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace Project +{ + using System; + using System.Collections.Generic; + + public partial class UserGroup + { + public string dept { get; set; } + public string gcode { get; set; } + public string path_kj { get; set; } + public Nullable advpurchase { get; set; } + public Nullable permission { get; set; } + } +} diff --git a/Project/Users.cs b/Project/Users.cs new file mode 100644 index 0000000..a0a7544 --- /dev/null +++ b/Project/Users.cs @@ -0,0 +1,39 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace Project +{ + using System; + using System.Collections.Generic; + + public partial class Users + { + public string id { get; set; } + public string gcode { get; set; } + public string password { get; set; } + public string nameE { get; set; } + public string name { get; set; } + public string dept { get; set; } + public string grade { get; set; } + public string email { get; set; } + public Nullable level { get; set; } + public string indate { get; set; } + public string outdate { get; set; } + public string tel { 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 wuid { get; set; } + public System.DateTime wdate { get; set; } + public string processs { get; set; } + } +} diff --git a/Project/_Common/fAddNewUser.cs b/Project/_Common/fAddNewUser.cs index 59edaa7..0218ee6 100644 --- a/Project/_Common/fAddNewUser.cs +++ b/Project/_Common/fAddNewUser.cs @@ -34,7 +34,7 @@ namespace Project._Common return; } - var db = new DataClasses1DataContext(); + var db = new EEEntitiesMain(); var dr_user = db.Users.Where(t => t.id == id).FirstOrDefault(); if (dr_user == null) { @@ -71,7 +71,7 @@ namespace Project._Common private void button2_Click(object sender, EventArgs e) { this.Validate(); - var db = new DataClasses1DataContext(); + var db = new EEEntitiesMain(); //해당 그룹에 데이터를 추가한다. var drDept = db.UserGroup.Where(t => t.dept == tbDept.Text).FirstOrDefault(); @@ -98,11 +98,12 @@ namespace Project._Common drGuser.uid = this.tbId.Text.Trim(); drGuser.Process = this.tbProcess.Text.Trim(); - db.EETGW_GroupUser.InsertOnSubmit(drGuser); + //db.EETGW_GroupUser.InsertOnSubmit(drGuser); + db.EETGW_GroupUser.Add(drGuser); } //사용자 목록에 없다면 추가한다 - var drUser = db.Users.Where(t => t.id == tbId.Text.Trim()).FirstOrDefault(); + var drUser = db.Users.SingleOrDefault(t => t.id == tbId.Text.Trim()); if(drUser == null) { drUser = new Users(); @@ -122,7 +123,7 @@ namespace Project._Common drUser.outdate = tbDateO.Text; drUser.memo = tbMemo.Text; drUser.processs = tbProcess.Text; - db.Users.InsertOnSubmit(drUser); + db.Users.Add(drUser); } else @@ -136,9 +137,9 @@ namespace Project._Common drUser.indate = tbDateIn.Text; drUser.outdate = tbDateO.Text; drUser.memo = tbMemo.Text; - drUser.processs = tbProcess.Text; + drUser.processs = tbProcess.Text; } - db.SubmitChanges(); + db.SaveChanges(); this.DialogResult = DialogResult.OK; } diff --git a/Project/_Common/fUserList.cs b/Project/_Common/fUserList.cs index 50aa8a5..db9f16d 100644 --- a/Project/_Common/fUserList.cs +++ b/Project/_Common/fUserList.cs @@ -63,7 +63,7 @@ namespace Project._Common } //부서목록 업데이트 - var db = new DataClasses1DataContext(); + var db = new EEEntitiesMain(); var GrpList = db.UserGroup.Where(t => t.gcode != null && t.permission != null && t.gcode != "" && t.permission > 0); //var tagrp = new dsMSSQLTableAdapters.UserGroupTableAdapter(); @@ -176,7 +176,7 @@ namespace Project._Common if (tbProcess.Text.Trim() == "") tbProcess.Text = "%"; this.dsMSSQL.Users.Clear(); - var db = new DataClasses1DataContext(); + var db = new EEEntitiesMain(); if (tbProcess.Text.Trim() != "" && tbProcess.Text.Trim() != "%") this.bs.DataSource = db.vGroupUser.Where(t => t.dept == this.cmbdept.Text && t.processs.Contains(tbProcess.Text.Trim())); else diff --git a/Project/app.config b/Project/app.config index 16715eb..e2f4c29 100644 --- a/Project/app.config +++ b/Project/app.config @@ -1,43 +1,22 @@ - - - - -
- - - - - - - - - - using System; -namespace HelloWorld -{ - public static class HelloWorldClass - { - public static string test() - { - return {0}; - } - } -}; - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + diff --git a/Project/packages.config b/Project/packages.config new file mode 100644 index 0000000..775cabc --- /dev/null +++ b/Project/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/Project/vGroupUser.cs b/Project/vGroupUser.cs new file mode 100644 index 0000000..b66656d --- /dev/null +++ b/Project/vGroupUser.cs @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace Project +{ + using System; + using System.Collections.Generic; + + public partial class vGroupUser + { + public string gcode { get; set; } + public string dept { get; set; } + public Nullable 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; } + } +} diff --git a/ReportForUser.xlsx b/ReportForUser.xlsx new file mode 100644 index 0000000..7403dac Binary files /dev/null and b/ReportForUser.xlsx differ diff --git a/SubProject/FPJ0000/Common.cs b/SubProject/FPJ0000/Common.cs new file mode 100644 index 0000000..d74e7d5 --- /dev/null +++ b/SubProject/FPJ0000/Common.cs @@ -0,0 +1,28 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace FPJ0000 +{ + using System; + using System.Collections.Generic; + + public partial class Common + { + public int idx { get; set; } + public string gcode { get; set; } + public string grp { get; set; } + public string code { get; set; } + public string svalue { get; set; } + public Nullable ivalue { get; set; } + public Nullable fvalue { get; set; } + public string memo { get; set; } + public string wuid { get; set; } + public System.DateTime wdate { get; set; } + } +} diff --git a/SubProject/FPJ0000/FPJ0000.csproj b/SubProject/FPJ0000/FPJ0000.csproj index 4eb817c..5aa298a 100644 --- a/SubProject/FPJ0000/FPJ0000.csproj +++ b/SubProject/FPJ0000/FPJ0000.csproj @@ -38,6 +38,12 @@ ..\..\DLL\ArSetting.Net4.dll + + ..\..\packages\EntityFramework.6.2.0\lib\net40\EntityFramework.dll + + + ..\..\packages\EntityFramework.6.2.0\lib\net40\EntityFramework.SqlServer.dll + @@ -80,8 +86,11 @@ ..\..\packages\RichTextBoxEx.1.0.0\lib\RichTextBoxEx.dll + + + @@ -99,6 +108,9 @@ + + Model1.tt + True @@ -143,6 +155,9 @@ fMailList.cs + + Model1.tt + Form @@ -155,6 +170,27 @@ rJobChart.cs + + Form + + + rJobReportUser.cs + + + True + True + Model1.Context.tt + + + True + True + Model1.tt + + + True + True + Model1.edmx + Form @@ -297,6 +333,24 @@ fProjectPartImport.cs + + Model1.tt + + + Model1.tt + + + Model1.tt + + + Model1.tt + + + Model1.tt + + + Model1.tt + fHistAdd.cs @@ -313,6 +367,9 @@ rJobChart.cs + + rJobReportUser.cs + fNote.cs @@ -452,6 +509,13 @@ dsReport.xsd + + EntityModelCodeGenerator + Model1.Designer.cs + + + Model1.edmx + SettingsSingleFileGenerator @@ -482,6 +546,9 @@ + + PreserveNewest + @@ -496,6 +563,21 @@ + + + + + + TextTemplatingFileGenerator + Model1.Context.cs + Model1.edmx + + + TextTemplatingFileGenerator + Model1.edmx + Model1.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 119, 17 + + + 17, 17 + + + 17, 17 + + + 183, 17 + + + 245, 17 + + \ No newline at end of file diff --git a/SubProject/FPJ0000/Model1.Context.cs b/SubProject/FPJ0000/Model1.Context.cs new file mode 100644 index 0000000..909c139 --- /dev/null +++ b/SubProject/FPJ0000/Model1.Context.cs @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace FPJ0000 +{ + 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 Common { get; set; } + public virtual DbSet UserGroup { get; set; } + public virtual DbSet Users { get; set; } + public virtual DbSet vHoliday_uselist { get; set; } + public virtual DbSet vUserWorkTimeList { get; set; } + public virtual DbSet HolidayLIst { get; set; } + public virtual DbSet vJobReportForUser { get; set; } + public virtual DbSet vGroupUser { get; set; } + } +} diff --git a/SubProject/FPJ0000/Model1.Context.tt b/SubProject/FPJ0000/Model1.Context.tt new file mode 100644 index 0000000..ba33bb5 --- /dev/null +++ b/SubProject/FPJ0000/Model1.Context.tt @@ -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().FirstOrDefault(); +if (container == null) +{ + return string.Empty; +} +#> +//------------------------------------------------------------------------------ +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> +// +//------------------------------------------------------------------------------ + +<# + +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()) +{ + // 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()) + { +#> + <#=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 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(); + } + + 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 types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(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 GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } + + public IEnumerable GetAllGlobalItems(IEnumerable 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 GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable 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)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 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 arg, string name) where T : class +{ + if (arg == null) + { + throw new ArgumentNullException(name); + } +} +#> \ No newline at end of file diff --git a/SubProject/FPJ0000/Model1.Designer.cs b/SubProject/FPJ0000/Model1.Designer.cs new file mode 100644 index 0000000..5f0ff54 --- /dev/null +++ b/SubProject/FPJ0000/Model1.Designer.cs @@ -0,0 +1,10 @@ +// 모델 'D:\Source\##### 완료아이템\(014) GroupWare\Source\SubProject\FPJ0000\Model1.edmx'에 대해 T4 코드 생성이 사용됩니다. +// 레거시 코드 생성을 사용하려면 '코드 생성 전략' 디자이너 속성의 값을 +// 'Legacy ObjectContext'로 변경하십시오. 이 속성은 모델이 디자이너에서 열릴 때 +// 속성 창에서 사용할 수 있습니다. + +// 컨텍스트 및 엔터티 클래스가 생성되지 않은 경우 빈 모델을 만들었기 때문일 수도 있지만 +// 사용할 Entity Framework 버전을 선택하지 않았기 때문일 수도 있습니다. 모델에 맞는 컨텍스트 클래스 및 +// 엔터티 클래스를 생성하려면 디자이너에서 모델을 열고 디자이너 화면에서 마우스 오른쪽 단추를 클릭한 +// 다음 '데이터베이스에서 모델 업데이트...', '모델에서 데이터베이스 생성...' 또는 '코드 생성 항목 추가...'를 +// 선택하십시오. \ No newline at end of file diff --git a/SubProject/FPJ0000/Model1.cs b/SubProject/FPJ0000/Model1.cs new file mode 100644 index 0000000..7a9ab12 --- /dev/null +++ b/SubProject/FPJ0000/Model1.cs @@ -0,0 +1,9 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + diff --git a/SubProject/FPJ0000/Model1.edmx b/SubProject/FPJ0000/Model1.edmx new file mode 100644 index 0000000..46df710 --- /dev/null +++ b/SubProject/FPJ0000/Model1.edmx @@ -0,0 +1,525 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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] + + + SELECT + [vHoliday_uselist].[idx] AS [idx], + [vHoliday_uselist].[gcode] AS [gcode], + [vHoliday_uselist].[pdate] AS [pdate], + [vHoliday_uselist].[term] AS [term], + [vHoliday_uselist].[termdr] AS [termdr], + [vHoliday_uselist].[description] AS [description], + [vHoliday_uselist].[uid] AS [uid], + [vHoliday_uselist].[wuid] AS [wuid], + [vHoliday_uselist].[wdate] AS [wdate] + FROM [dbo].[vHoliday_uselist] AS [vHoliday_uselist] + + + 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] + FROM [dbo].[vJobReportForUser] AS [vJobReportForUser] + + + SELECT + [vUserWorkTimeList].[gcode] AS [gcode], + [vUserWorkTimeList].[yymm] AS [yymm], + [vUserWorkTimeList].[total] AS [total], + [vUserWorkTimeList].[uid] AS [uid], + [vUserWorkTimeList].[uname] AS [uname], + [vUserWorkTimeList].[hrs] AS [hrs], + [vUserWorkTimeList].[ot] AS [ot] + FROM [dbo].[vUserWorkTimeList] AS [vUserWorkTimeList] + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SubProject/FPJ0000/Model1.edmx.diagram b/SubProject/FPJ0000/Model1.edmx.diagram new file mode 100644 index 0000000..30e51ed --- /dev/null +++ b/SubProject/FPJ0000/Model1.edmx.diagram @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SubProject/FPJ0000/Model1.tt b/SubProject/FPJ0000/Model1.tt new file mode 100644 index 0000000..985966b --- /dev/null +++ b/SubProject/FPJ0000/Model1.tt @@ -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(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(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(); +#> +//------------------------------------------------------------------------------ +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine1")#> +// +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine2")#> +// <#=CodeGenerationTools.GetResourceString("Template_GeneratedCodeCommentLine3")#> +// +//------------------------------------------------------------------------------ +<#=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 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(); + } + + 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 types, string sourceFile) + { + ArgumentNotNull(types, "types"); + ArgumentNotNull(sourceFile, "sourceFile"); + + var hash = new HashSet(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 GetEnumItemsToGenerate(IEnumerable itemCollection) + { + return GetItemsToGenerate(itemCollection) + .Where(e => IsEnumType(e)); + } + + public IEnumerable GetItemsToGenerate(IEnumerable itemCollection) where T: EdmType + { + return itemCollection + .OfType() + .Where(i => !i.MetadataProperties.Any(p => p.Name == ExternalTypeNameAttributeName)) + .OrderBy(i => i.Name); + } + + public IEnumerable GetAllGlobalItems(IEnumerable 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 GetSimpleProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetSimpleProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetComplexProperties(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is ComplexType && p.DeclaringType == type); + } + + public IEnumerable GetPropertiesWithDefaultValues(EntityType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetPropertiesWithDefaultValues(ComplexType type) + { + return type.Properties.Where(p => p.TypeUsage.EdmType is SimpleType && p.DeclaringType == type && p.DefaultValue != null); + } + + public IEnumerable GetNavigationProperties(EntityType type) + { + return type.NavigationProperties.Where(np => np.DeclaringType == type); + } + + public IEnumerable 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)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 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 arg, string name) where T : class +{ + if (arg == null) + { + throw new ArgumentNullException(name); + } +} +#> \ No newline at end of file diff --git a/SubProject/FPJ0000/Project/fPartList.cs b/SubProject/FPJ0000/Project/fPartList.cs index 07c7a58..f0be4ba 100644 --- a/SubProject/FPJ0000/Project/fPartList.cs +++ b/SubProject/FPJ0000/Project/fPartList.cs @@ -26,6 +26,7 @@ namespace FPJ0000 int colidx_supplyidx = -1; int colidx_sid = -1; int colidx_manu = -1; + int colidx_unit = -1; public fPartList(int idx_) @@ -114,6 +115,7 @@ namespace FPJ0000 else if (colname == "itemsupply") colidx_supply = col.Index; else if (colname == "itemsid") colidx_sid = col.Index; else if (colname == "itemmanu") colidx_manu = col.Index; + else if (colname == "itemunit") colidx_unit = col.Index; } this.Show(); Application.DoEvents(); @@ -485,8 +487,10 @@ namespace FPJ0000 //fpSpread1.ActiveSheet.Cells[Rowidx, colidx_supplyidx].Value = f.itemSupplyidx; //fpSpread1.ActiveSheet.Cells[Rowidx, colidx_supply].Value = f.itemSupply; - //제조사추가 201022 + //제조사추가 201022 - 박성민 fpSpread1.ActiveSheet.Cells[Rowidx, colidx_manu].Value = f.itemManu.Replace(" ", "").Trim(); + //단위추가 201028 - 박성민 + fpSpread1.ActiveSheet.Cells[Rowidx, colidx_unit].Value = f.itemUnit.Replace(" ", "").Trim(); if (f.itemmodel != "") fpSpread1.ActiveSheet.Cells[Rowidx, colidx_model].Value = f.itemmodel; diff --git a/SubProject/FPJ0000/Project/fPartList.resx b/SubProject/FPJ0000/Project/fPartList.resx index 6398f9a..d546c5d 100644 --- a/SubProject/FPJ0000/Project/fPartList.resx +++ b/SubProject/FPJ0000/Project/fPartList.resx @@ -396,20 +396,20 @@ iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALvSURBVDhPhZJZTxNRGIZ7JT/BoBdekrhAFKNGLxQELGCC - GwJBZCuFgIAEajARawpGZDEgARI1BKLxQg24QAHLVtrSNrQKUhCQfUtYKtBlpu20vJ6ZVsCExC95ci7O - vE/me2d47AQ/kCdcLtXIIso0v0PEGoqcNEc5e2rpiFI1HfZUZTgnUlQejny3jwvtntDHSsWKiV4zGAxO - o8UGo3mHNRMLjZ9LJhR8nkNM2aiVnyn18kTdE16sWmHD6hkHtLMMtHMMNDMMVNN2yH/Z0DZigY0Bmkcp - FHycRfJzA/WPJETcRm1a7dDPO/FtniEng35OYkfvhA1fR6xE4IJ+yQntogNF0jkE3u96y4WjywOmbooj - t4Q115FcfQPV7Q0obCxHoNgXAQR+0VkES06hormCW8VMM1hetyI4vpfhBFGlgR+6hlrQMv4K1Zo8ThJf - FYa8N3HIaoiBoPYKkmqT0Dy4jBaDGV9+bGKD9BQiUdKcgF/J9zoiznZqxnrwekiCEnkmJ0moCSfhq0h7 - kQrFhIVbpXOcgoz0sG5xIKSwzy1gJ7S4l86pS4RuQoVa7T086chFdPlFJFRFQjdjhY4UyxasmHR3YiSC - YMkuwfmHYsfp/EOIq+RDP6lGUU86JNIcxDwLQoP8EwYWGOhIseppB/oIKyYHAh95BCdE3kJ/0UFk1cfi - Vk0oYisucZIcaRxEjankTYLA3uvnnOhnPzHBRIr0y1a5Bf6i/Qv+ogPkIW/453njWkkQMl4mQjEiQ5Es - H+nvEyGoiYKOCLTk39AQAe1wEYF8Z4UL2Up6aYPG4IKTo3dsEXfr0pBCgsLaGOTW39m+Y7HanUTQtCNg - bfPGHcH/sLArpO4SnMnptrYq9Ft7PbwXA0PDrmPxzWZPnBSZ1jE1u2k1dSu/u6ZWKUytUJjwsGp2cLDN - m2kndAMGF0VRGz63W4c9cR7vZFp7hp+greO4UGb0EzbR26S48f2LoIn2EbSuH01q7fRNlCbzeDzeH4+W - nwKzKldlAAAAAElFTkSuQmCC + YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALvSURBVDhPhZLrS1NhHMf3qv6EsF70UpBSyqioF6WpTQ3s + Zipm3uYcmtrQhUG2mEbmJTRRoUKUohcV2kWnNm/bnNtwauoyNe838LLUXc7Rnc1vzzlbzkDoBx+eF8/5 + fji/7zk8doIfKhOuFOsUESW63yFSHUVOmqOUPfV0RLGWDnumMZ6XqMt9It8f4EJ7J/RJt3rFTK8ZjUaH + yboFk8XDmpmFxs8lM/K+zCGmZNTGz5AfdEddE16oWWHD2hk79LMM9HMMdDMMNNPbUP7aQsuIFVsM0DhK + Ie/TLJJfGKl/JCHSFmrTto2+eQf65xlyMujlJNtQTWzh24iNCJzoW3JAv2hHgXwOgQ863nHh6NKAqVvS + yB1h1Q0kV95EZWsd8utLESj1RQCBX3AOwbLTKGss41ax0AyW120IjlcxnCCqOPBjx3ATmsZfo1KXw0ni + K8KQ8zYOmXUxEFRfRVJ1EhoHl9FktODr0CY2SE8hsm6aE/DL+Qd9pFkO3VgX3gzLUKTM4CQJVeEkfA2i + l6lQT1i5VdrHKShID+tWO0Lye1wCdkILVbS4JhGGCQ2q9ffxtC0b0aWXkFARCcOMDQZSLFuwetLViYkI + gmV7BBceSe1nco8irpyPvkktCrrSIJOLEfM8CHXKz/i+wMBAitVO29FDWDHbEfjYLTgp8RL6S44gszYW + t6tCEVt2mZOI5XGQ1KeSNwkCe98350Av+4kJZlKkX5bGJfCXHFrwlxwmD3nBP8cL14uCkP4qEeoRBQoU + uUj7kAhBVRQMRKAn/4aOCGi7kwiUnhUuZnXTSxs0BhccHKqxRdyrESGFBIXVMciuvbt7x2LbdhBBg0fA + 2uZNHsH/sLIrpO4RnBV32uQqw85+D+/HwJDReTy+0eKOkyJFbVOzmzZzp7rfObVKYWqFwoSbVYudg23e + QpMiB4adFEVteN9p/uGO83inRK3pfoKWthNChclP2EDvkuLC9y+CBtpb0Lx+LKm53TdRnszj8Xh/AIdo + nvbIfe02AAAAAElFTkSuQmCC diff --git a/SubProject/FPJ0000/Project/fSPMaster.Designer.cs b/SubProject/FPJ0000/Project/fSPMaster.Designer.cs index 3a5a511..289daa7 100644 --- a/SubProject/FPJ0000/Project/fSPMaster.Designer.cs +++ b/SubProject/FPJ0000/Project/fSPMaster.Designer.cs @@ -33,21 +33,21 @@ FarPoint.Win.Spread.FlatFocusIndicatorRenderer flatFocusIndicatorRenderer1 = new FarPoint.Win.Spread.FlatFocusIndicatorRenderer(); FarPoint.Win.Spread.FlatScrollBarRenderer flatScrollBarRenderer1 = new FarPoint.Win.Spread.FlatScrollBarRenderer(); FarPoint.Win.Spread.FlatScrollBarRenderer flatScrollBarRenderer2 = new FarPoint.Win.Spread.FlatScrollBarRenderer(); - FarPoint.Win.Spread.CellType.NumberCellType numberCellType1 = new FarPoint.Win.Spread.CellType.NumberCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType1 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType2 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.NumberCellType numberCellType2 = new FarPoint.Win.Spread.CellType.NumberCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType3 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType4 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType5 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType6 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType7 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType8 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType9 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType10 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType11 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType12 = new FarPoint.Win.Spread.CellType.TextCellType(); - FarPoint.Win.Spread.CellType.TextCellType textCellType13 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.NumberCellType numberCellType5 = new FarPoint.Win.Spread.CellType.NumberCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType27 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType28 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.NumberCellType numberCellType6 = new FarPoint.Win.Spread.CellType.NumberCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType29 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType30 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType31 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType32 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType33 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType34 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType35 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType36 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType37 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType38 = new FarPoint.Win.Spread.CellType.TextCellType(); + FarPoint.Win.Spread.CellType.TextCellType textCellType39 = new FarPoint.Win.Spread.CellType.TextCellType(); this.bn = new System.Windows.Forms.BindingNavigator(this.components); this.bs = new System.Windows.Forms.BindingSource(this.components); this.dsMSSQL = new FPJ0000.dsPRJ(); @@ -71,19 +71,20 @@ this.saveToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.loadToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.exportListToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.fpSpread1_Sheet1 = new FarPoint.Win.Spread.SheetView(); this.panel2 = new System.Windows.Forms.Panel(); this.tbFind = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.label3 = new System.Windows.Forms.Label(); - this.fpSpread1_Sheet1 = new FarPoint.Win.Spread.SheetView(); + this.chkZeroCount = new System.Windows.Forms.ToolStripButton(); ((System.ComponentModel.ISupportInitialize)(this.bn)).BeginInit(); this.bn.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.bs)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dsMSSQL)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).BeginInit(); this.cm1.SuspendLayout(); - this.panel2.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).BeginInit(); + this.panel2.SuspendLayout(); this.SuspendLayout(); // // bn @@ -103,7 +104,8 @@ this.bindingNavigatorMoveNextItem, this.bindingNavigatorMoveLastItem, this.bindingNavigatorSeparator2, - this.toolStripSeparator1}); + this.toolStripSeparator1, + this.chkZeroCount}); this.bn.Location = new System.Drawing.Point(0, 514); this.bn.MoveFirstItem = this.bindingNavigatorMoveFirstItem; this.bn.MoveLastItem = this.bindingNavigatorMoveLastItem; @@ -119,6 +121,7 @@ // this.bs.DataMember = "SPMaster"; this.bs.DataSource = this.dsMSSQL; + this.bs.Filter = "CurrentQty > 0"; this.bs.CurrentChanged += new System.EventHandler(this.bs_CurrentChanged); // // dsMSSQL @@ -205,6 +208,7 @@ // tam // this.tam.BackupDataSetBeforeUpdate = false; + this.tam.EETGW_NoteTableAdapter = null; this.tam.JobReportTableAdapter = null; this.tam.ProjectsHistoryTableAdapter = null; this.tam.ProjectsIOMapTableAdapter = null; @@ -298,6 +302,104 @@ this.exportListToolStripMenuItem.Text = "목록 내보내기"; this.exportListToolStripMenuItem.Click += new System.EventHandler(this.exportListToolStripMenuItem_Click); // + // fpSpread1_Sheet1 + // + this.fpSpread1_Sheet1.Reset(); + this.fpSpread1_Sheet1.SheetName = "Sheet1"; + // Formulas and custom names must be loaded with R1C1 reference style + this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1; + this.fpSpread1_Sheet1.ColumnCount = 15; + this.fpSpread1_Sheet1.ActiveColumnIndex = -1; + this.fpSpread1_Sheet1.ActiveRowIndex = -1; + this.fpSpread1_Sheet1.AutoGenerateColumns = false; + this.fpSpread1_Sheet1.ColumnFooter.DefaultStyle.BackColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.ColumnFooter.DefaultStyle.ForeColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.ColumnFooter.DefaultStyle.Parent = "ColumnFooterFlat"; + this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.BackColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.ForeColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.Parent = "CornerFooterFlat"; + this.fpSpread1_Sheet1.ColumnHeader.DefaultStyle.BackColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.ColumnHeader.DefaultStyle.ForeColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.ColumnHeader.DefaultStyle.Parent = "ColumnHeaderFlat"; + this.fpSpread1_Sheet1.ColumnHeader.Rows.Get(0).Height = 36F; + numberCellType5.DecimalPlaces = 0; + numberCellType5.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.Yes; + numberCellType5.MaximumValue = 2147483647D; + numberCellType5.MinimumValue = -2147483648D; + this.fpSpread1_Sheet1.Columns.Get(0).CellType = numberCellType5; + this.fpSpread1_Sheet1.Columns.Get(0).DataField = "ID"; + this.fpSpread1_Sheet1.Columns.Get(0).Visible = false; + this.fpSpread1_Sheet1.Columns.Get(0).Width = 77F; + this.fpSpread1_Sheet1.Columns.Get(1).CellType = textCellType27; + this.fpSpread1_Sheet1.Columns.Get(1).DataField = "CtrlNo"; + this.fpSpread1_Sheet1.Columns.Get(1).Visible = false; + this.fpSpread1_Sheet1.Columns.Get(1).Width = 151F; + this.fpSpread1_Sheet1.Columns.Get(2).CellType = textCellType28; + this.fpSpread1_Sheet1.Columns.Get(2).DataField = "SIDNo"; + this.fpSpread1_Sheet1.Columns.Get(2).Width = 98F; + this.fpSpread1_Sheet1.Columns.Get(3).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); + numberCellType6.MaximumValue = 999999999999999D; + numberCellType6.MinimumValue = -999999999999999D; + this.fpSpread1_Sheet1.Columns.Get(3).CellType = numberCellType6; + this.fpSpread1_Sheet1.Columns.Get(3).DataField = "CurrentQty"; + this.fpSpread1_Sheet1.Columns.Get(3).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center; + this.fpSpread1_Sheet1.Columns.Get(3).VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; + this.fpSpread1_Sheet1.Columns.Get(3).Width = 97F; + this.fpSpread1_Sheet1.Columns.Get(4).CellType = textCellType29; + this.fpSpread1_Sheet1.Columns.Get(4).DataField = "PartName"; + this.fpSpread1_Sheet1.Columns.Get(4).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center; + this.fpSpread1_Sheet1.Columns.Get(4).VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; + this.fpSpread1_Sheet1.Columns.Get(4).Width = 91F; + this.fpSpread1_Sheet1.Columns.Get(5).CellType = textCellType30; + this.fpSpread1_Sheet1.Columns.Get(5).DataField = "PartNo"; + this.fpSpread1_Sheet1.Columns.Get(5).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center; + this.fpSpread1_Sheet1.Columns.Get(5).VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; + this.fpSpread1_Sheet1.Columns.Get(6).CellType = textCellType31; + this.fpSpread1_Sheet1.Columns.Get(6).DataField = "Storage"; + this.fpSpread1_Sheet1.Columns.Get(6).Width = 91F; + this.fpSpread1_Sheet1.Columns.Get(7).CellType = textCellType32; + this.fpSpread1_Sheet1.Columns.Get(7).DataField = "Location"; + this.fpSpread1_Sheet1.Columns.Get(7).Width = 97F; + this.fpSpread1_Sheet1.Columns.Get(8).CellType = textCellType33; + this.fpSpread1_Sheet1.Columns.Get(8).DataField = "UseEqmt"; + this.fpSpread1_Sheet1.Columns.Get(8).Visible = false; + this.fpSpread1_Sheet1.Columns.Get(8).Width = 151F; + this.fpSpread1_Sheet1.Columns.Get(9).CellType = textCellType34; + this.fpSpread1_Sheet1.Columns.Get(9).DataField = "SupplierNo"; + this.fpSpread1_Sheet1.Columns.Get(9).Visible = false; + this.fpSpread1_Sheet1.Columns.Get(9).Width = 151F; + this.fpSpread1_Sheet1.Columns.Get(10).CellType = textCellType35; + this.fpSpread1_Sheet1.Columns.Get(10).DataField = "Division"; + this.fpSpread1_Sheet1.Columns.Get(10).Width = 126F; + this.fpSpread1_Sheet1.Columns.Get(11).CellType = textCellType36; + this.fpSpread1_Sheet1.Columns.Get(11).DataField = "PriceUnit"; + this.fpSpread1_Sheet1.Columns.Get(11).Width = 72F; + this.fpSpread1_Sheet1.Columns.Get(12).CellType = textCellType37; + this.fpSpread1_Sheet1.Columns.Get(12).DataField = "Memo"; + this.fpSpread1_Sheet1.Columns.Get(12).Width = 77F; + this.fpSpread1_Sheet1.Columns.Get(13).CellType = textCellType38; + this.fpSpread1_Sheet1.Columns.Get(13).DataField = "EnrDate"; + this.fpSpread1_Sheet1.Columns.Get(13).Width = 96F; + this.fpSpread1_Sheet1.Columns.Get(14).CellType = textCellType39; + this.fpSpread1_Sheet1.Columns.Get(14).DataField = "Enrollee"; + this.fpSpread1_Sheet1.Columns.Get(14).Width = 94F; + this.fpSpread1_Sheet1.DataAutoSizeColumns = false; + this.fpSpread1_Sheet1.DataSource = this.bs; + this.fpSpread1_Sheet1.FilterBar.DefaultStyle.BackColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.FilterBar.DefaultStyle.ForeColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.FilterBar.DefaultStyle.Parent = "FilterBarFlat"; + this.fpSpread1_Sheet1.FilterBarHeaderStyle.BackColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.FilterBarHeaderStyle.ForeColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.FilterBarHeaderStyle.Parent = "FilterBarHeaderFlat"; + this.fpSpread1_Sheet1.RowHeader.Columns.Default.Resizable = false; + this.fpSpread1_Sheet1.RowHeader.DefaultStyle.BackColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.RowHeader.DefaultStyle.ForeColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.RowHeader.DefaultStyle.Parent = "RowHeaderFlat"; + this.fpSpread1_Sheet1.SheetCornerStyle.BackColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.SheetCornerStyle.ForeColor = System.Drawing.Color.Empty; + this.fpSpread1_Sheet1.SheetCornerStyle.Parent = "CornerHeaderFlat"; + this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1; + // // panel2 // this.panel2.Controls.Add(this.tbFind); @@ -344,103 +446,15 @@ this.label3.Text = "검색"; this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // fpSpread1_Sheet1 + // chkZeroCount // - this.fpSpread1_Sheet1.Reset(); - this.fpSpread1_Sheet1.SheetName = "Sheet1"; - // Formulas and custom names must be loaded with R1C1 reference style - this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.R1C1; - this.fpSpread1_Sheet1.ColumnCount = 15; - this.fpSpread1_Sheet1.ActiveColumnIndex = -1; - this.fpSpread1_Sheet1.ActiveRowIndex = -1; - this.fpSpread1_Sheet1.AutoGenerateColumns = false; - this.fpSpread1_Sheet1.ColumnFooter.DefaultStyle.BackColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.ColumnFooter.DefaultStyle.ForeColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.ColumnFooter.DefaultStyle.Parent = "ColumnFooterFlat"; - this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.BackColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.ForeColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.ColumnFooterSheetCornerStyle.Parent = "CornerFooterFlat"; - this.fpSpread1_Sheet1.ColumnHeader.DefaultStyle.BackColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.ColumnHeader.DefaultStyle.ForeColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.ColumnHeader.DefaultStyle.Parent = "ColumnHeaderFlat"; - this.fpSpread1_Sheet1.ColumnHeader.Rows.Get(0).Height = 36F; - numberCellType1.DecimalPlaces = 0; - numberCellType1.LeadingZero = FarPoint.Win.Spread.CellType.LeadingZero.Yes; - numberCellType1.MaximumValue = 2147483647D; - numberCellType1.MinimumValue = -2147483648D; - this.fpSpread1_Sheet1.Columns.Get(0).CellType = numberCellType1; - this.fpSpread1_Sheet1.Columns.Get(0).DataField = "ID"; - this.fpSpread1_Sheet1.Columns.Get(0).Visible = false; - this.fpSpread1_Sheet1.Columns.Get(0).Width = 77F; - this.fpSpread1_Sheet1.Columns.Get(1).CellType = textCellType1; - this.fpSpread1_Sheet1.Columns.Get(1).DataField = "CtrlNo"; - this.fpSpread1_Sheet1.Columns.Get(1).Visible = false; - this.fpSpread1_Sheet1.Columns.Get(1).Width = 151F; - this.fpSpread1_Sheet1.Columns.Get(2).CellType = textCellType2; - this.fpSpread1_Sheet1.Columns.Get(2).DataField = "SIDNo"; - this.fpSpread1_Sheet1.Columns.Get(2).Width = 98F; - this.fpSpread1_Sheet1.Columns.Get(3).BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(255)))), ((int)(((byte)(192))))); - numberCellType2.MaximumValue = 999999999999999D; - numberCellType2.MinimumValue = -999999999999999D; - this.fpSpread1_Sheet1.Columns.Get(3).CellType = numberCellType2; - this.fpSpread1_Sheet1.Columns.Get(3).DataField = "CurrentQty"; - this.fpSpread1_Sheet1.Columns.Get(3).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center; - this.fpSpread1_Sheet1.Columns.Get(3).VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; - this.fpSpread1_Sheet1.Columns.Get(3).Width = 97F; - this.fpSpread1_Sheet1.Columns.Get(4).CellType = textCellType3; - this.fpSpread1_Sheet1.Columns.Get(4).DataField = "PartName"; - this.fpSpread1_Sheet1.Columns.Get(4).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center; - this.fpSpread1_Sheet1.Columns.Get(4).VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; - this.fpSpread1_Sheet1.Columns.Get(4).Width = 91F; - this.fpSpread1_Sheet1.Columns.Get(5).CellType = textCellType4; - this.fpSpread1_Sheet1.Columns.Get(5).DataField = "PartNo"; - this.fpSpread1_Sheet1.Columns.Get(5).HorizontalAlignment = FarPoint.Win.Spread.CellHorizontalAlignment.Center; - this.fpSpread1_Sheet1.Columns.Get(5).VerticalAlignment = FarPoint.Win.Spread.CellVerticalAlignment.Center; - this.fpSpread1_Sheet1.Columns.Get(6).CellType = textCellType5; - this.fpSpread1_Sheet1.Columns.Get(6).DataField = "Storage"; - this.fpSpread1_Sheet1.Columns.Get(6).Width = 91F; - this.fpSpread1_Sheet1.Columns.Get(7).CellType = textCellType6; - this.fpSpread1_Sheet1.Columns.Get(7).DataField = "Location"; - this.fpSpread1_Sheet1.Columns.Get(7).Width = 97F; - this.fpSpread1_Sheet1.Columns.Get(8).CellType = textCellType7; - this.fpSpread1_Sheet1.Columns.Get(8).DataField = "UseEqmt"; - this.fpSpread1_Sheet1.Columns.Get(8).Visible = false; - this.fpSpread1_Sheet1.Columns.Get(8).Width = 151F; - this.fpSpread1_Sheet1.Columns.Get(9).CellType = textCellType8; - this.fpSpread1_Sheet1.Columns.Get(9).DataField = "SupplierNo"; - this.fpSpread1_Sheet1.Columns.Get(9).Visible = false; - this.fpSpread1_Sheet1.Columns.Get(9).Width = 151F; - this.fpSpread1_Sheet1.Columns.Get(10).CellType = textCellType9; - this.fpSpread1_Sheet1.Columns.Get(10).DataField = "Division"; - this.fpSpread1_Sheet1.Columns.Get(10).Width = 126F; - this.fpSpread1_Sheet1.Columns.Get(11).CellType = textCellType10; - this.fpSpread1_Sheet1.Columns.Get(11).DataField = "PriceUnit"; - this.fpSpread1_Sheet1.Columns.Get(11).Width = 72F; - this.fpSpread1_Sheet1.Columns.Get(12).CellType = textCellType11; - this.fpSpread1_Sheet1.Columns.Get(12).DataField = "Memo"; - this.fpSpread1_Sheet1.Columns.Get(12).Width = 77F; - this.fpSpread1_Sheet1.Columns.Get(13).CellType = textCellType12; - this.fpSpread1_Sheet1.Columns.Get(13).DataField = "EnrDate"; - this.fpSpread1_Sheet1.Columns.Get(13).Width = 96F; - this.fpSpread1_Sheet1.Columns.Get(14).CellType = textCellType13; - this.fpSpread1_Sheet1.Columns.Get(14).DataField = "Enrollee"; - this.fpSpread1_Sheet1.Columns.Get(14).Width = 94F; - this.fpSpread1_Sheet1.DataAutoSizeColumns = false; - this.fpSpread1_Sheet1.DataSource = this.bs; - this.fpSpread1_Sheet1.FilterBar.DefaultStyle.BackColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.FilterBar.DefaultStyle.ForeColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.FilterBar.DefaultStyle.Parent = "FilterBarFlat"; - this.fpSpread1_Sheet1.FilterBarHeaderStyle.BackColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.FilterBarHeaderStyle.ForeColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.FilterBarHeaderStyle.Parent = "FilterBarHeaderFlat"; - this.fpSpread1_Sheet1.RowHeader.Columns.Default.Resizable = false; - this.fpSpread1_Sheet1.RowHeader.DefaultStyle.BackColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.RowHeader.DefaultStyle.ForeColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.RowHeader.DefaultStyle.Parent = "RowHeaderFlat"; - this.fpSpread1_Sheet1.SheetCornerStyle.BackColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.SheetCornerStyle.ForeColor = System.Drawing.Color.Empty; - this.fpSpread1_Sheet1.SheetCornerStyle.Parent = "CornerHeaderFlat"; - this.fpSpread1_Sheet1.ReferenceStyle = FarPoint.Win.Spread.Model.ReferenceStyle.A1; + this.chkZeroCount.CheckOnClick = true; + this.chkZeroCount.Image = global::FPJ0000.Properties.Resources.accept; + this.chkZeroCount.ImageTransparentColor = System.Drawing.Color.Magenta; + this.chkZeroCount.Name = "chkZeroCount"; + this.chkZeroCount.Size = new System.Drawing.Size(96, 22); + this.chkZeroCount.Text = "수량 \'0\' 포함"; + this.chkZeroCount.Click += new System.EventHandler(this.chkZeroCount_Click); // // fSPMaster // @@ -459,9 +473,9 @@ ((System.ComponentModel.ISupportInitialize)(this.dsMSSQL)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.fpSpread1)).EndInit(); this.cm1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).EndInit(); this.panel2.ResumeLayout(false); this.panel2.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.fpSpread1_Sheet1)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); @@ -503,5 +517,6 @@ private System.Windows.Forms.ToolStripMenuItem loadToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem exportListToolStripMenuItem; private FarPoint.Win.Spread.SheetView fpSpread1_Sheet1; + private System.Windows.Forms.ToolStripButton chkZeroCount; } } \ No newline at end of file diff --git a/SubProject/FPJ0000/Project/fSPMaster.cs b/SubProject/FPJ0000/Project/fSPMaster.cs index 85a6ca9..1c41d3b 100644 --- a/SubProject/FPJ0000/Project/fSPMaster.cs +++ b/SubProject/FPJ0000/Project/fSPMaster.cs @@ -164,5 +164,13 @@ namespace FPJ0000 { FPUtil.ColSizeLoad(ref this.fpSpread1, fn_fpcolsize); } + + private void chkZeroCount_Click(object sender, EventArgs e) + { + if (chkZeroCount.Checked) + this.bs.Filter = "CurrentQty > 0"; + else + this.bs.Filter = ""; + } } } diff --git a/SubProject/FPJ0000/Project/fSPMaster.resx b/SubProject/FPJ0000/Project/fSPMaster.resx index 7de9e51..3f8a27b 100644 --- a/SubProject/FPJ0000/Project/fSPMaster.resx +++ b/SubProject/FPJ0000/Project/fSPMaster.resx @@ -167,6 +167,9 @@ 8l/FYwIYQ4UGBWBgAAC+0b+zuQxOnAAAAABJRU5ErkJggg== + + 17, 17 + 186, 17 @@ -176,6 +179,9 @@ 387, 17 + + 462, 17 + R0lGODlhEAAQAIQfAJXG2JXa+ZLO5ChrlkCy4TZ1kiVvpCN0trvo9SN5xTd4lrfh7iR9zo3S+EGz7JDJ @@ -215,7 +221,4 @@ vmv/Akgg2IMBDgsSdJwcAEICDhoECjDAmQIFBQouXNiwQYPOgqgLBgQAOw== - - 462, 17 - \ No newline at end of file diff --git a/SubProject/FPJ0000/Properties/Settings.Designer.cs b/SubProject/FPJ0000/Properties/Settings.Designer.cs index 9d8de5a..66bf1ba 100644 --- a/SubProject/FPJ0000/Properties/Settings.Designer.cs +++ b/SubProject/FPJ0000/Properties/Settings.Designer.cs @@ -33,5 +33,16 @@ namespace FPJ0000.Properties { return ((string)(this["gwcs"])); } } + + [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 EEEntities { + get { + return ((string)(this["EEEntities"])); + } + } } } diff --git a/SubProject/FPJ0000/Properties/Settings.settings b/SubProject/FPJ0000/Properties/Settings.settings index 0f03c1a..1f20ad0 100644 --- a/SubProject/FPJ0000/Properties/Settings.settings +++ b/SubProject/FPJ0000/Properties/Settings.settings @@ -7,6 +7,14 @@ <SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ConnectionString>Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123!</ConnectionString> <ProviderName>System.Data.SqlClient</ProviderName> +</SerializableConnectionString> + Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123! + + + <?xml version="1.0" encoding="utf-16"?> +<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> + <ConnectionString>Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123!</ConnectionString> + <ProviderName>System.Data.SqlClient</ProviderName> </SerializableConnectionString> Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123! diff --git a/SubProject/FPJ0000/ReportForUser.xlsx b/SubProject/FPJ0000/ReportForUser.xlsx new file mode 100644 index 0000000..44d845f Binary files /dev/null and b/SubProject/FPJ0000/ReportForUser.xlsx differ diff --git a/SubProject/FPJ0000/UserGroup.cs b/SubProject/FPJ0000/UserGroup.cs new file mode 100644 index 0000000..611a290 --- /dev/null +++ b/SubProject/FPJ0000/UserGroup.cs @@ -0,0 +1,23 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace FPJ0000 +{ + using System; + using System.Collections.Generic; + + public partial class UserGroup + { + public string dept { get; set; } + public string gcode { get; set; } + public string path_kj { get; set; } + public Nullable advpurchase { get; set; } + public Nullable permission { get; set; } + } +} diff --git a/SubProject/FPJ0000/Users.cs b/SubProject/FPJ0000/Users.cs new file mode 100644 index 0000000..b1b844e --- /dev/null +++ b/SubProject/FPJ0000/Users.cs @@ -0,0 +1,39 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace FPJ0000 +{ + using System; + using System.Collections.Generic; + + public partial class Users + { + public string id { get; set; } + public string gcode { get; set; } + public string password { get; set; } + public string nameE { get; set; } + public string name { get; set; } + public string dept { get; set; } + public string grade { get; set; } + public string email { get; set; } + public Nullable level { get; set; } + public string indate { get; set; } + public string outdate { get; set; } + public string tel { 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 wuid { get; set; } + public System.DateTime wdate { get; set; } + public string processs { get; set; } + } +} diff --git a/SubProject/FPJ0000/app.config b/SubProject/FPJ0000/app.config index 8b514fb..c9ec2b2 100644 --- a/SubProject/FPJ0000/app.config +++ b/SubProject/FPJ0000/app.config @@ -1,9 +1,29 @@ - + - - - - - - - + +
+ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/SubProject/FPJ0000/packages.config b/SubProject/FPJ0000/packages.config index e894982..f425afa 100644 --- a/SubProject/FPJ0000/packages.config +++ b/SubProject/FPJ0000/packages.config @@ -1,5 +1,7 @@  + + diff --git a/SubProject/FPJ0000/vGroupUser.cs b/SubProject/FPJ0000/vGroupUser.cs new file mode 100644 index 0000000..9d186b5 --- /dev/null +++ b/SubProject/FPJ0000/vGroupUser.cs @@ -0,0 +1,36 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace FPJ0000 +{ + using System; + using System.Collections.Generic; + + public partial class vGroupUser + { + public string gcode { get; set; } + public string dept { get; set; } + public Nullable 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; } + } +} diff --git a/SubProject/FPJ0000/vHoliday_uselist.cs b/SubProject/FPJ0000/vHoliday_uselist.cs new file mode 100644 index 0000000..7674910 --- /dev/null +++ b/SubProject/FPJ0000/vHoliday_uselist.cs @@ -0,0 +1,27 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace FPJ0000 +{ + using System; + using System.Collections.Generic; + + public partial class vHoliday_uselist + { + public int idx { get; set; } + public string gcode { get; set; } + public string pdate { get; set; } + public Nullable term { get; set; } + public int termdr { get; set; } + public string description { get; set; } + public string uid { get; set; } + public string wuid { get; set; } + public System.DateTime wdate { get; set; } + } +} diff --git a/SubProject/FPJ0000/vJobReportForUser.cs b/SubProject/FPJ0000/vJobReportForUser.cs new file mode 100644 index 0000000..247e2ef --- /dev/null +++ b/SubProject/FPJ0000/vJobReportForUser.cs @@ -0,0 +1,29 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace FPJ0000 +{ + 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 hrs { get; set; } + public Nullable ot { get; set; } + public string userProcess { get; set; } + } +} diff --git a/SubProject/FPJ0000/vUserWorkTimeList.cs b/SubProject/FPJ0000/vUserWorkTimeList.cs new file mode 100644 index 0000000..7ac3c7b --- /dev/null +++ b/SubProject/FPJ0000/vUserWorkTimeList.cs @@ -0,0 +1,25 @@ +//------------------------------------------------------------------------------ +// +// 이 코드는 템플릿에서 생성되었습니다. +// +// 이 파일을 수동으로 변경하면 응용 프로그램에서 예기치 않은 동작이 발생할 수 있습니다. +// 이 파일을 수동으로 변경하면 코드가 다시 생성될 때 변경 내용을 덮어씁니다. +// +//------------------------------------------------------------------------------ + +namespace FPJ0000 +{ + using System; + using System.Collections.Generic; + + public partial class vUserWorkTimeList + { + public string gcode { get; set; } + public string yymm { get; set; } + public Nullable total { get; set; } + public string uid { get; set; } + public string uname { get; set; } + public Nullable hrs { get; set; } + public Nullable ot { get; set; } + } +}