Example #1
0
		private void MakeInsertSPFile(string folderPath, string yourName, string targetDomain, TableInfoTS tableInfo, bool checkDontOverwrite, bool checkAlter)
		{
			string annoText = string.Empty;
			string mainText = string.Empty;
			string spName = string.Empty;

			// SP 명 만듬
			spName = "BOYZBE_" + targetDomain + "_" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "_Insert";

			// SP text 만듬
			// 주석 텍스트
			annoText = MakeInsertAnnotationText(spName, yourName, tableInfo);
			// 메인 텍스트
			mainText = MakeInsertMainText(spName, tableInfo, checkAlter);

			if(checkDontOverwrite)
			{
				// 파일존재 여부 확인
				if(System.IO.File.Exists(folderPath + "\\" + spName + ".sql"))
				{
					System.IO.File.WriteAllText(folderPath + "\\" + spName + "_temp.sql", annoText + mainText, Encoding.UTF8);
				}
				else
				{
					// 파일 저장
					System.IO.File.WriteAllText(folderPath + "\\" + spName + ".sql", annoText + mainText, Encoding.UTF8);
				}
					
			}
			else
				System.IO.File.WriteAllText(folderPath + "\\" + spName + ".sql", annoText + mainText, Encoding.UTF8);
			
		}
Example #2
0
		/// <summary>
		/// Dac.cs 파일을 만든다
		/// </summary>
		/// <param name="folderPath"></param>
		/// <param name="targetDomain"></param>
		/// <param name="tableInfo"></param>
		/// <remarks>
		/// 2015-07-03 양승빈 최초작성
		/// </remarks>
		private void MakeDacFile(string folderPath, string yourName, string targetDomain, TableInfoTS tableInfo)
		{
			// 텍스트 만듬
			string usingText = string.Empty;
			string mainText = string.Empty;
			usingText = MakeDacUsingText();
			mainText = MakeDacNamespaceAndClassText(targetDomain, yourName, tableInfo);

			// 파일 저장
			System.IO.File.WriteAllText(folderPath + "\\" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "Dac.cs", usingText + mainText, Encoding.UTF8);
		}
		public string MakeMappingXML(TableInfoTS tableInfo)
		{
			string result = string.Empty;

			result += "<FieldMapping name=\"" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T\">" + Environment.NewLine;
			foreach (ColumnInfoTS column in tableInfo.ColumnInfos)
			{
				if (!string.IsNullOrEmpty(column.SQLDataType))
				{
					result += "\t<Item typeFieldName=\"" + new StrConverter().ChangeSnakeToCamel(column.ColumnName) + "\"\t\tdataColumnName=\"" + column.ColumnName + "\" />" + Environment.NewLine;
				}
			}

			result += "</FieldMapping>";

			return result;
		}
Example #4
0
		public bool MakeDBEntityFiles(string folderPath, string yourName, string targetDomain, TableInfoTS tableInfo, MainOptionsTS options)
		{
			bool result = false;

			try
			{
				MakeDBEntityFile(folderPath, yourName, targetDomain, tableInfo);

				result = true;
			}
			catch (Exception ee)
			{
				result = false;
			}

			return result;
		}
Example #5
0
		public bool MakeSPFiles(string folderPath, string yourName, string domain, TableInfoTS tableInfo, MainOptionsTS options)
		{
			bool result = false;

			try
			{
				MakeInsertSPFile(folderPath, yourName, domain, tableInfo, options.CheckDontOverwrite, options.CheckAlter);
				MakeSelectSPFile(folderPath, yourName, domain, tableInfo, options.CheckDontOverwrite, options.CheckAlter);

				result = true;
			}
			catch (Exception ee)
			{
				result = false;
			}

			return result;
		}
Example #6
0
		public string MakeAddFunctionHeaderParam(TableInfoTS tableInfo)
		{
			string result = string.Empty;

			foreach (ColumnInfoTS colInfo in tableInfo.ColumnInfos)
			{
				if (colInfo.isIdentity == false)
				{
					if (colInfo.ColumnName != "INS_DATE" && colInfo.ColumnName != "INS_OPRT" && colInfo.ColumnName != "UPD_DATE" && colInfo.ColumnName != "UPD_OPRT")
					{
						if (string.IsNullOrEmpty(result))
							result += GetCSharpType(colInfo.SQLDataType) + " " + ChangeSnakeToCamelFirstLower(colInfo.ColumnName);
						else
							result += ", " + GetCSharpType(colInfo.SQLDataType) + " " + ChangeSnakeToCamelFirstLower(colInfo.ColumnName);
					}
				}
			}
			return result;
		}
		public string MakeXsd(TableInfoTS tableInfo)
		{
			string result = string.Empty;

			result += "<xs:complexType name=\"" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T\">" + Environment.NewLine;
			result += "\t<xs:sequence/>" + Environment.NewLine;
			foreach (ColumnInfoTS column in tableInfo.ColumnInfos)
			{
				if (!string.IsNullOrEmpty(column.SQLDataType))
				{
					string xmlType = new StrConverter().GetXmlType(column.SQLDataType);
					result += "\t<xs:attribute name=\"" + new StrConverter().ChangeSnakeToCamel(column.ColumnName) + "\"\t\t\ttype=\"xs:" + xmlType + "\"/>" + Environment.NewLine;
				}				
			}

			result += "</xs:complexType>";

			return result;
		}
Example #8
0
		public string GetSelectSP(string yourName, string domain, TableInfoTS tableInfo, MainOptionsTS options)
		{
			string result = string.Empty;
			string annoText = string.Empty;
			string mainText = string.Empty;
			string spName = string.Empty;

			// SP 명 만듬
			spName = "BoyzBe_" + domain + "_" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "_Select";

			// SP text 만듬
			// 주석 텍스트
			annoText = MakeSelectAnnotationText(spName, yourName, tableInfo);
			// 메인 텍스트
			mainText = MakeSelectMainText(spName, tableInfo, options.CheckAlter);

			result = annoText + mainText;

			return result;
		}
Example #9
0
		private string MakeDBEntityNamespaceAndClassText(string targetDomain, string yourName, TableInfoTS tableInfo)
		{
			string result = string.Empty;

			result += "namespace BoyzBe." + targetDomain + Environment.NewLine;
			result += "{" + Environment.NewLine;
			result += "\t/// <summary>" + Environment.NewLine;
			result += "\t/// " + tableInfo.TableName + " DB Entity Class" + Environment.NewLine;
			result += "\t/// </summary>" + Environment.NewLine;
			result += "\t/// <remarks>" + Environment.NewLine;
			result += "\t/// " + DateTime.Now.ToShortDateString() + " " + yourName + " " + "최초 작성" + Environment.NewLine;
			result += "\t/// </remarks>" + Environment.NewLine;
			result += "\tpublic class " + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T" + Environment.NewLine;
			result += "\t{" + Environment.NewLine;

			result += new StrConverter().MakeDbEntityMembers(tableInfo);

			result += "\t}" + Environment.NewLine;
			result += "}" + Environment.NewLine;

			return result;
		}
Example #10
0
		/// <summary>
		/// Dac의 주 클래스 텍스트 만듬
		/// </summary>
		/// <param name="domain"></param>
		/// <param name="tableInfo"></param>
		/// <returns></returns>
		/// <remarks>
		/// 2015-07-03 양승빈 최초작성
		/// </remarks>
		private string MakeBehaviorNamespaceAndClassText(string domain, string yourName, TableInfoTS tableInfo)
		{
			string result = string.Empty;

			// 여기가 헤더라 생각
			result += "namespace BoyzBe." + domain + Environment.NewLine;
			result += "{" + Environment.NewLine;
			result += "\t/// <summary>" + Environment.NewLine;
			result += "\t/// " + tableInfo.TableName + " 테이블 Behavior Class" + Environment.NewLine;
			result += "\t/// </summary>" + Environment.NewLine;
			result += "\t/// <remarks>" + Environment.NewLine;
			result += "\t/// " + DateTime.Now.ToShortDateString() + " " + yourName + " " + "최초 작성" + Environment.NewLine;
			result += "\t/// </remarks>" + Environment.NewLine;
			result += "\tpublic class " + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "Behavior" + Environment.NewLine;
			result += "\t{" + Environment.NewLine;

			// 데이터 추가 부분 - 아이덴티티 제외 해야함
			result += "\t\t#region [C: 레코드 추가]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\tpublic void Insert(" + new StrConverter().MakeAddFunctionHeaderParam(tableInfo) + ")" + Environment.NewLine;
			result += "\t\t{" + Environment.NewLine;

			result += "\t\t\tDataAccessor.Execute(" + Environment.NewLine;
			result += "\t\t\t\t\"" + tableInfo.DBName + "_write\"," + Environment.NewLine;
			result += "\t\t\t\tCommandType.StoredProcedure," + Environment.NewLine;

			result += "\t\t\t\t\"dbo.BOYZBE_" + domain + "_" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "_Insert\"," + Environment.NewLine;

			result += new StrConverter().MakeInsertFunctionCallParam(tableInfo) + Environment.NewLine;
			result += "\t\t\t);" + Environment.NewLine;
			result += "\t\t}" + Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += Environment.NewLine;

			// 데이터 조회 부분 - 키로만 조회
			result += "\t\t#region [R: 레코드 조회]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\tpublic " + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T Select(" + new StrConverter().MakeGetFunctionHeaderParam(tableInfo) + ")" + Environment.NewLine;
			result += "\t\t{" + Environment.NewLine;
			result += "\t\t\treturn " + "DataAccessor.SelectSingleEntity<" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T>(" + Environment.NewLine;
			result += "\t\t\t\t\"" + tableInfo.DBName + "_read\"," + Environment.NewLine;
			
			result += "\t\t\t\tCommandType.StoredProcedure," + Environment.NewLine;
			result += "\t\t\t\t\"dbo.BOYZBE_" + domain + "_" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "_Select\"," + Environment.NewLine;
			result += new StrConverter().MakeSelectFunctionCallParam(tableInfo) + Environment.NewLine;
			result += "\t\t\t);" + Environment.NewLine;
			result += "\t\t}" + Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += Environment.NewLine;

			// 여기가 풋터라 생각
			result += "\t\t#region [U: 레코드 변경]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t#region [D: 레코드 삭제]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += "\t}" + Environment.NewLine;
			result += "}" + Environment.NewLine;

			return result;
		}
Example #11
0
		/// <summary>
		/// 해당 테이블 정보를 가져옴
		/// </summary>
		/// <param name="tableName"></param>
		/// <returns></returns>
		/// <remarks>
		/// 2015-07-03 양승빈 최초작성
		/// </remarks>
		public TableInfoTS GetTableInfo(string tableName)
		{
			TableInfoTS tableInfo = new TableInfoTS();
			List<string> keys = new List<string>();
			List<string> identity = new List<string>();

			try
			{
				// 컬럼명, 데이터 타입, 길이 조회
				scom = new SqlCommand();
				scom.Connection = conn;
				scom.CommandText = "SELECT COLUMN_NAME,DATA_TYPE, CHARACTER_MAXIMUM_LENGTH FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '" + tableName + "'";

				sdr = scom.ExecuteReader();
				while (sdr.Read())
				{
					ColumnInfoTS columnInfo = new ColumnInfoTS();
					columnInfo.ColumnName = sdr["COLUMN_NAME"].ToString();
					columnInfo.SQLDataType = sdr["DATA_TYPE"].ToString();
					columnInfo.DataLength = sdr["CHARACTER_MAXIMUM_LENGTH"].ToString();
					tableInfo.ColumnInfos.Add(columnInfo);
				}
				sdr.Close();

				// 프라이머리 키 조회
				scom = new SqlCommand();
				scom.Connection = conn;
				scom.CommandText = "SELECT KU.table_name as tablename,column_name as primarykeycolumn "
				+ "FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC "
				+ "INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KU "
				+ "ON TC.CONSTRAINT_TYPE = 'PRIMARY KEY'"
				+ "AND TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME "
				+ "AND KU.TABLE_NAME='" + tableName + "'"
				+ "ORDER BY KU.TABLE_NAME, KU.ORDINAL_POSITION";

				sdr = scom.ExecuteReader();
				while (sdr.Read())
				{
					keys.Add(sdr["primarykeycolumn"].ToString());
				}
				sdr.Close();

				foreach (ColumnInfoTS columInfo in tableInfo.ColumnInfos)
				{
					foreach (string keyName in keys)
					{
						if (columInfo.ColumnName == keyName)
						{
							columInfo.isKey = true;
						}
					}
				}

				// 아이덴티티 조회
				scom = new SqlCommand();
				scom.Connection = conn;
				scom.CommandText = "SELECT c.COLUMN_NAME "
				+ "FROM INFORMATION_SCHEMA.COLUMNS AS c "
				+ "JOIN INFORMATION_SCHEMA.TABLES AS t "
				+ "ON t.TABLE_NAME = c.TABLE_NAME "
				+ "WHERE COLUMNPROPERTY(OBJECT_ID(c.TABLE_NAME),c.COLUMN_NAME,'IsIdentity') = 1 "
				+ "AND t.TABLE_TYPE = 'Base Table' "
				+ "AND t.TABLE_NAME = '" + tableName + "' "
				+ "AND t.TABLE_NAME NOT LIKE 'dt%' "
				+ "AND t.TABLE_NAME NOT LIKE 'MS%' "
				+ "AND t.TABLE_NAME NOT LIKE 'syncobj_%'";

				sdr = scom.ExecuteReader();
				while (sdr.Read())
				{
					identity.Add(sdr["COLUMN_NAME"].ToString());
				}
				sdr.Close();

				foreach (ColumnInfoTS columInfo in tableInfo.ColumnInfos)
				{
					foreach (string id in identity)
					{
						if (columInfo.ColumnName == id)
						{
							columInfo.isIdentity = true;
						}
					}
				}

				// 컬럼 주석 가져옴
				foreach (ColumnInfoTS columInfo in tableInfo.ColumnInfos)
				{
					scom = new SqlCommand();
					scom.Connection = conn;
					scom.CommandText = "SELECT name FROM fn_listextendedproperty (null, 'schema', 'dbo', 'table', '" + tableName + "', 'column', '" + columInfo.ColumnName + "')";

					sdr = scom.ExecuteReader();
					while (sdr.Read())
					{
						columInfo.ColumnAnnotation = sdr["name"].ToString();
					}
					sdr.Close();
				}				

				// 결과 문장
				stateResult = "Success : Get Table Infomation" + "(" + DateTime.Now.ToString() + ")";
			}
			catch (Exception ee)
			{
				stateResult = "Fail : Get Table Infomation" + "(" + DateTime.Now.ToString() + ")";
			}
			tableInfo.DBName = curDatabaseName;
			tableInfo.TableName = tableName;

			return tableInfo;
		}
Example #12
0
		public string MakeGetFunctionCallParam(TableInfoTS tableInfo)
		{
			string result = string.Empty;

			foreach (ColumnInfoTS colInfo in tableInfo.ColumnInfos)
			{
				if (colInfo.isKey == true)
				{
					if (string.IsNullOrEmpty(result))
						result += ChangeSnakeToCamelFirstLower(colInfo.ColumnName);
					else
						result += ", " + ChangeSnakeToCamelFirstLower(colInfo.ColumnName);
				}
			}
			return result;
		}
Example #13
0
		private string MakeSelectMainText(string spName, TableInfoTS tableInfo, bool checkAlter)
		{
			string result = string.Empty;

			if(checkAlter)
				result += "ALTER PROCEDURE dbo." + spName + Environment.NewLine;
			else
				result += "CREATE PROCEDURE dbo." + spName + Environment.NewLine;			
			result += Environment.NewLine;
			foreach (ColumnInfoTS columnInfo in tableInfo.ColumnInfos)
			{
				if (columnInfo.isKey == false)
					continue;

				result += "\t@" + columnInfo.ColumnName + " " + columnInfo.SQLDataType;
				if (columnInfo.SQLDataType.ToLower() == "varchar" || columnInfo.SQLDataType.ToLower() == "char")
				{
					result += "(" + columnInfo.DataLength + ")";
				}
				result += ",";
				result += Environment.NewLine;
			}
			result = result.Substring(0, result.Length - 3);
			result += Environment.NewLine;
			result += "AS" + Environment.NewLine;
			result += "BEGIN" + Environment.NewLine;
			result += "\tSET NOCOUNT ON" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\tSELECT TOP 1 " + Environment.NewLine;
			foreach (ColumnInfoTS columnInfo in tableInfo.ColumnInfos)
			{
				result += "\t" + columnInfo.ColumnName + "," + Environment.NewLine;
			}
			result = result.Substring(0, result.Length - 3);
			result += Environment.NewLine;

			result += "\tFROM " + tableInfo.DBName + ".dbo." + tableInfo.TableName + " WITH (NOLOCK)" + Environment.NewLine;
			result += "\tWHERE ";
			foreach (ColumnInfoTS columnInfo in tableInfo.ColumnInfos)
			{
				if (columnInfo.isKey == true)
					result += columnInfo.ColumnName + "= @" + columnInfo.ColumnName + "AND";
			}
			result = result.Substring(0, result.Length - 3);
			result += Environment.NewLine;
			result += "END" + Environment.NewLine;

			return result;
		}
Example #14
0
		/// <summary>
		/// Dac의 주 클래스 텍스트 만듬
		/// </summary>
		/// <param name="domain"></param>
		/// <param name="tableInfo"></param>
		/// <returns></returns>
		/// <remarks>
		/// 2015-07-03 양승빈 최초작성
		/// </remarks>
		private string MakeDacNamespaceAndClassText(string domain, string yourName, TableInfoTS tableInfo)
		{
			string result = string.Empty;

			// 여기가 헤더라 생각
			result += "namespace IAC." + domain + Environment.NewLine;
			result += "{" + Environment.NewLine;
			result += "\t/// <summary>" + Environment.NewLine;
			result += "\t/// " + tableInfo.TableName + " 테이블 Dac Class" + Environment.NewLine;
			result += "\t/// </summary>" + Environment.NewLine;
			result += "\t/// <remarks>" + Environment.NewLine;
			result += "\t/// " + DateTime.Now.ToShortDateString() + " " + yourName + " " + "최초 작성" + Environment.NewLine;
			result += "\t/// </remarks>" + Environment.NewLine;
			result += "\tpublic class " + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "Dac : DacBase" + Environment.NewLine;
			result += "\t{" + Environment.NewLine;

			// 데이터 추가 부분 - 아이덴티티 제외 해야함
			result += "\t\t#region [C: 레코드 추가]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\tpublic void Insert(" + new StrConverter().MakeAddFunctionHeaderParam(tableInfo) + ")" + Environment.NewLine;
			result += "\t\t{" + Environment.NewLine;

			// maindb2ex만 일단 예외처리
			if(tableInfo.DBName != "maindb2ex")
				result += "\t\t\tnew DacHelper(_dbHelper, \"" + tableInfo.DBName + "_write\").Execute(" + Environment.NewLine;
			else
				result += "\t\t\tnew DacHelper(_dbHelper, \"maindb2_write\").Execute(" + Environment.NewLine;

			result += "\t\t\t\tCommandType.StoredProcedure," + Environment.NewLine;

			// maindb2ex만 일단 예외처리
			if (tableInfo.DBName != "maindb2ex")
				result += "\t\t\t\t\"dbo.UPIAC_" + domain + "_" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "_Insert\"," + Environment.NewLine;
			else
				result += "\t\t\t\t\"maindb2ex.dbo.UPIAC_" + domain + "_" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "_Insert\"," + Environment.NewLine;

			result += new StrConverter().MakeInsertFunctionCallParam(tableInfo) + Environment.NewLine;
			result += "\t\t\t);" + Environment.NewLine;
			result += "\t\t}" + Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += Environment.NewLine;

			// 데이터 조회 부분 - 키로만 조회
			result += "\t\t#region [R: 레코드 조회]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\tpublic " + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T Select(" + new StrConverter().MakeGetFunctionHeaderParam(tableInfo) + ")" + Environment.NewLine;
			result += "\t\t{" + Environment.NewLine;
			result += "\t\t\treturn (" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T)new DacHelper(_dbHelper, \"" + tableInfo.DBName + "_read\").SelectSingleEntity(" + Environment.NewLine;
			result += "\t\t\t\ttypeof(" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T)," + Environment.NewLine;
			result += "\t\t\t\tDataMappingCache.GetDataMappings(\"" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T\")," + Environment.NewLine;
			result += "\t\t\t\tCommandType.StoredProcedure," + Environment.NewLine;
			result += "\t\t\t\t\"dbo.UPIAC_" + domain + "_" + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "_Select\"," + Environment.NewLine;
			result += new StrConverter().MakeSelectFunctionCallParam(tableInfo) + Environment.NewLine;
			result += "\t\t\t);" + Environment.NewLine;
			result += "\t\t}" + Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += Environment.NewLine;

			// 여기가 풋터라 생각
			result += "\t\t#region [U: 레코드 변경]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t#region [D: 레코드 삭제]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += "\t}" + Environment.NewLine;
			result += "}" + Environment.NewLine;

			return result;
		}
Example #15
0
		public string MakeDbEntityMembers(TableInfoTS tableInfo)
		{
			string result = string.Empty;
			foreach (ColumnInfoTS colInfo in tableInfo.ColumnInfos)
			{
				result += "\t\tpublic " + GetCSharpType(colInfo.SQLDataType) + " " + colInfo.ColumnName + " { get; set; }" + Environment.NewLine;
				result += Environment.NewLine;
			}

			return result;
		}
Example #16
0
		public string MakeSelectFunctionCallParam(TableInfoTS tableInfo)
		{
			string result = string.Empty;

			foreach (ColumnInfoTS colInfo in tableInfo.ColumnInfos)
			{
				if (colInfo.isKey == true)
				{

					result += "\t\t\t\tnew AccessParameter(\"@" + colInfo.ColumnName + "\", ";
					result += ChangeSnakeToCamelFirstLower(colInfo.ColumnName) + ", SqlDbType.";
					result += ChangeSQLDataTypeToEnumSQLDBTypeString(colInfo.SQLDataType);
					if (colInfo.SQLDataType == "varchar" || colInfo.SQLDataType == "char")
						result += ", " + colInfo.DataLength;
					result += "),";
					result += Environment.NewLine;
				}
			}

			result = result.Substring(0, result.Length - 3);

			return result;
		}
Example #17
0
		public string MakeInsertFunctionCallParam(TableInfoTS tableInfo)
		{
			string result = string.Empty;

			foreach (ColumnInfoTS colInfo in tableInfo.ColumnInfos)
			{
				if (colInfo.isIdentity == false)
				{
					if (colInfo.ColumnName != "INS_DATE" && colInfo.ColumnName != "UPD_DATE" && colInfo.ColumnName != "UPD_OPRT")
					{
						result += "\t\t\t\tnew AccessParameter(\"@" + colInfo.ColumnName + "\", ";
						if (colInfo.ColumnName == "INS_OPRT")
							result += "System.Net.Dns.GetHostName()" + ", SqlDbType.";
						else
							result += ChangeSnakeToCamelFirstLower(colInfo.ColumnName) + ", SqlDbType.";
						result += ChangeSQLDataTypeToEnumSQLDBTypeString(colInfo.SQLDataType);
						if (colInfo.SQLDataType == "varchar" || colInfo.SQLDataType == "char")
							result += ", " + colInfo.DataLength;
						result += "),";
						result += Environment.NewLine;
					}
				}
			}

			result = result.Substring(0, result.Length - 3);

			return result;
		}
Example #18
0
		/// <summary>
		/// 클래스 주 내용 텍스트 만듬
		/// </summary>
		/// <param name="domain"></param>
		/// <param name="tableInfo"></param>
		/// <returns></returns>
		/// <remarks>
		/// 2015-07-03 양승빈 최초작성
		/// </remarks>
		private string MakeBizNamespaceAndClassText(string domain, string yourName, TableInfoTS tableInfo)
		{
			string result = string.Empty;

			// 여기가 헤더라 생각
			result += "namespace IAC." + domain + Environment.NewLine;
			result += "{" + Environment.NewLine;
			result += "\t/// <summary>" + Environment.NewLine;
			result += "\t/// " + tableInfo.TableName + " 테이블 Biz Class" + Environment.NewLine;
			result += "\t/// </summary>" + Environment.NewLine;
			result += "\t/// <remarks>" + Environment.NewLine;
			result += "\t/// " + DateTime.Now.ToShortDateString() + " " + yourName + " " + "최초 작성" + Environment.NewLine;
			result += "\t/// </remarks>" + Environment.NewLine;
			result += "\t[JustInTimeActivation, DxFramework.EnterpriseServices.Transaction(DxFramework.EnterpriseServices.TransactionOption.NotSupported)]" + Environment.NewLine;
			result += "\tpublic class " + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "Biz : BizBase" + Environment.NewLine;
			result += "\t{" + Environment.NewLine;

			// 데이터 추가 부분 - 아이덴티티 제외 해야함
			result += "\t\t#region [C: 레코드 추가]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t[AutoComplete, DxFramework.EnterpriseServices.Transaction(DxFramework.EnterpriseServices.TransactionOption.Supported)]" + Environment.NewLine;
			result += "\t\tpublic void Add(" + new StrConverter().MakeAddFunctionHeaderParam(tableInfo) + ")" + Environment.NewLine;
			result += "\t\t{" + Environment.NewLine;
			result += "\t\t\tnew " + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "Dac().Insert(" + new StrConverter().MakeAddFunctionCallParam(tableInfo) + ");" + Environment.NewLine;
			result += "\t\t}" + Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += Environment.NewLine;

			// 데이터 조회 부분 - 키로만 조회
			result += "\t\t#region [R: 레코드 조회]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t[AutoComplete, DxFramework.EnterpriseServices.Transaction(DxFramework.EnterpriseServices.TransactionOption.NotSupported)]" + Environment.NewLine;
			result += "\t\tpublic " + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "T Get(" + new StrConverter().MakeGetFunctionHeaderParam(tableInfo) + ")" + Environment.NewLine;
			result += "\t\t{" + Environment.NewLine;
			result += "\t\t\treturn new " + new StrConverter().ChangeSnakeToCamel(tableInfo.TableName) + "Dac().Select(" + new StrConverter().MakeGetFunctionCallParam(tableInfo) + ");" + Environment.NewLine;
			result += "\t\t}" + Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += Environment.NewLine;

			// 여기가 풋터라 생각
			result += "\t\t#region [U: 레코드 변경]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t#region [D: 레코드 삭제]" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\t\t#endregion" + Environment.NewLine;
			result += "\t}" + Environment.NewLine;
			result += "}" + Environment.NewLine;

			return result;
		}
Example #19
0
		private string MakeInsertMainText(string spName, TableInfoTS tableInfo, bool checkAlter)
		{
			string result = string.Empty;

			if(checkAlter)
				result += "ALTER PROCEDURE dbo." + spName + Environment.NewLine;
			else
				result += "CREATE PROCEDURE dbo." + spName + Environment.NewLine;
			result += Environment.NewLine;
			foreach (ColumnInfoTS columnInfo in tableInfo.ColumnInfos)
			{
				if (columnInfo.isIdentity == true)
					continue;
				if (columnInfo.ColumnName == "INS_DATE" || columnInfo.ColumnName == "UPD_DATE" || columnInfo.ColumnName == "UPD_OPRT")
					continue;

				result += "\t@" + columnInfo.ColumnName + " " + columnInfo.SQLDataType;
				if (columnInfo.SQLDataType.ToLower() == "varchar" || columnInfo.SQLDataType.ToLower() == "char")
				{
					result += "(" + columnInfo.DataLength + ")";
				}
				result += ",";
				result += Environment.NewLine;
			}
			result = result.Substring(0, result.Length - 3);

			result += Environment.NewLine;
			result += "AS" + Environment.NewLine;
			result += "BEGIN" + Environment.NewLine;
			result += "\tSET NOCOUNT ON" + Environment.NewLine;
			result += Environment.NewLine;
			result += "\tINSERT INTO " + tableInfo.DBName + ".dbo." + tableInfo.TableName + "(" + Environment.NewLine;
			foreach (ColumnInfoTS columnInfo in tableInfo.ColumnInfos)
			{
				if (columnInfo.isIdentity == true)
					continue;
				result += "\t\t" + columnInfo.ColumnName + "," + Environment.NewLine;
			}
			result = result.Substring(0, result.Length - 3);
			result += Environment.NewLine;
			result += "\t)" + Environment.NewLine;
			result += "\tVALUES(" + Environment.NewLine;

			foreach (ColumnInfoTS columnInfo in tableInfo.ColumnInfos)
			{
				if (columnInfo.isIdentity == true)
					continue;
				if (columnInfo.ColumnName == "INS_DATE")
				{
					result += "\t\tGETDATE()," + Environment.NewLine;
				}

				else if (columnInfo.ColumnName == "UPD_DATE")
				{
					result += "\t\tGETDATE()," + Environment.NewLine;
				}

				else if (columnInfo.ColumnName == "UPD_OPRT")
				{
					result += "\t\t@INS_OPRT," + Environment.NewLine;
				}
				else
					result += "\t\t@" + columnInfo.ColumnName + "," + Environment.NewLine;
			}
			result = result.Substring(0, result.Length - 3);
			result += Environment.NewLine;
			result += "\t)" + Environment.NewLine;
			result += "END" + Environment.NewLine;

			return result;
		}
Example #20
0
		private string MakeSelectAnnotationText(string spName, string yourName, TableInfoTS tableInfo)
		{
			string result = string.Empty;

			result += "/*******************************************************************************" + Environment.NewLine;
			result += "기본내용                                                                        " + Environment.NewLine;
			result += "********************************************************************************" + Environment.NewLine;
			result += "- SP 명 : " + spName + "                                 " + Environment.NewLine;
			result += "- 기 능 :                                                                       " + Environment.NewLine;
			result += "********************************************************************************" + Environment.NewLine;
			result += "참고내용                                                                        " + Environment.NewLine;
			result += "********************************************************************************" + Environment.NewLine;
			result += "- 파라미터설명 :                                                                " + Environment.NewLine;

			foreach (ColumnInfoTS columnInfo in tableInfo.ColumnInfos)
			{
				if (columnInfo.isKey == false)
					continue;

				result += "@" + columnInfo.ColumnName + ": " + columnInfo.ColumnAnnotation + Environment.NewLine;
			}

			result += "********************************************************************************" + Environment.NewLine;
			result += "변경내용                                                                        " + Environment.NewLine;
			result += "********************************************************************************" + Environment.NewLine;
			result += "- " + " " + DateTime.Now.ToShortDateString() + " " + yourName + " " + "최초 작성                                                   " + Environment.NewLine;
			result += "*******************************************************************************/" + Environment.NewLine;

			return result;
		}
Example #21
0
		private void Button_OneClickMake_Click(object sender, EventArgs e)
		{
			selectedDatabase = this.ListBox_DataBases.SelectedItem.ToString();
			yourName = this.TextBox_YourName.Text;

			TableInfoTS tableInfoTS = new TableInfoTS();

			bool bizDacMakeResult = false;
			bool spMakeResult = false;
			bool dbEntityMakeResult = false;

			string xsdString = string.Empty;
			string mappingString = string.Empty;

			// DB 접속
			db = new DataBaseManager(serverName, selectedDatabase);

			// 테이블 정보 조회
			tableInfoTS = db.GetTableInfo(selectedTable);

			// DB 접속 종료
			db.Close();

			// 조회 결과 텍스트 박스 출력
			MainRichBox_Add(db.StateResult);
			
			// XSD 만들기
			/*
			xsdString = new XsdMappingMaker().MakeXsd(tableInfoTS);
			this.RichTextBox_Xsd.Text = xsdString;
			if(!string.IsNullOrEmpty(xsdString))
				MainRichBox_Add("Success : Make Xsd Text" + "(" + DateTime.Now.ToString() + ")");
			else
				MainRichBox_Add("Fail : Make Xsd Text" + "(" + DateTime.Now.ToString() + ")");
			*/

			/*
			// Data Mapping 만들기                       
			mappingString = new XsdMappingMaker().MakeMappingXML(tableInfoTS);
			this.RichTextBox_Mapping.Text = mappingString;
			*/

			/*
			// BizDac 파일 만들기
			if (!string.IsNullOrEmpty(folderPathBizDacFiles))
			{
				bizDacMakeResult = new BizDacMaker().MakeBizDacFiles(folderPathBizDacFiles, yourName, domain, tableInfoTS, options);
				if (bizDacMakeResult)
					MainRichBox_Add("Success : Make Biz.cs , Dac.cs"+ "(" + DateTime.Now.ToString() + ")" );
				else
					MainRichBox_Add("Fail : Make Biz.cs , Dac.cs"+ "(" + DateTime.Now.ToString() + ")");
			}
			else
				MessageBox.Show("BizDac 파일을 저장할 폴더 주소를 입력 하세요");
			*/

			/*
			// SP 만들기
			if (!string.IsNullOrEmpty(folderPathSPFiles))
			{
				spMakeResult = new SPMaker().MakeSPFiles(folderPathSPFiles, yourName, domain, tableInfoTS, options);
				if (spMakeResult)
					MainRichBox_Add("Success : Make SQL File."+ "(" + DateTime.Now.ToString() + ")");
				else
					MainRichBox_Add("Fail : Make SQL File"+ "(" + DateTime.Now.ToString() + ")");
			}
			else
				MessageBox.Show("SP 파일을 저장할 폴더 주소를 입력 하세요");

			 * 
			*/

			// Behavior 만들기, DB Entity 만들기
			if (!string.IsNullOrEmpty(folderPathBizDacFiles))
			{
				spMakeResult = new BehaviorMaker().MakeBehaviorFiles(folderPathBizDacFiles, yourName, domain, tableInfoTS, options);
				dbEntityMakeResult = new DBEntityMaker().MakeDBEntityFiles(folderPathBizDacFiles, yourName, domain, tableInfoTS, options);
				if (spMakeResult)
					MainRichBox_Add("Success : Make Behavior, DBEntity File." + "(" + DateTime.Now.ToString() + ")");
				else
					MainRichBox_Add("Fail : Make Behavior, DBEntity File" + "(" + DateTime.Now.ToString() + ")");
			}
			else
				MessageBox.Show("Behavior, DBEntity 파일을 저장할 폴더 주소를 입력 하세요");

			// SP 반들기
			if (!string.IsNullOrEmpty(folderPathSPFiles))
			{
				spMakeResult = new SPMaker().MakeSPFiles(folderPathSPFiles, yourName, domain, tableInfoTS, options);
				if (spMakeResult)
					MainRichBox_Add("Success : Make SP File." + "(" + DateTime.Now.ToString() + ")");
				else
					MainRichBox_Add("Fail : Make SP File" + "(" + DateTime.Now.ToString() + ")");
			}
			else
				MessageBox.Show("SP 파일을 저장할 폴더 주소를 입력 하세요");
		}