255 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			255 lines
		
	
	
		
			7.7 KiB
		
	
	
	
		
			C#
		
	
	
	
|  | 
 | ||
|  | public bool isIgnored(ColumnSchema column){ | ||
|  |    bool rt = column.Name.ToString().ToUpper().Equals("ID")  | ||
|  |             || column.Name.ToString().ToUpper().Equals("DR") | ||
|  |             || column.Name.ToString().ToUpper().Equals("CREATE_TIME")   | ||
|  |             || column.Name.ToString().ToUpper().Equals("CREATETIME")   | ||
|  |             //|| column.Name.ToString().ToUpper().Equals("OPERATER")  | ||
|  |              || column.Name.ToString().ToUpper().Equals("LASTMODIFIED") ; | ||
|  |     return rt; | ||
|  | } | ||
|  | 
 | ||
|  | public string getTableName() | ||
|  | { | ||
|  | 	return this.SourceTable.Name.ToUpper() ; | ||
|  | } | ||
|  | public string getStringPeroperty(ColumnSchema column){ | ||
|  |      | ||
|  |     if(column.DataType.ToString() == "AnsiString"){ | ||
|  |         return "String"; | ||
|  |     } | ||
|  |      if(column.DataType.ToString() == "Date"){ | ||
|  |         return "DateTime"; | ||
|  |     } | ||
|  |     return column.DataType.ToString(); | ||
|  |      | ||
|  | } | ||
|  | public string getLogicClassName() | ||
|  | {  | ||
|  | 	string tablename = this.SourceTable.Name.Substring(2); | ||
|  |     string firstChar = tablename.Substring(0,1); | ||
|  |     string className = firstChar.ToUpper() + tablename.Substring(1); | ||
|  |     return "l"+ className ; | ||
|  | } | ||
|  | 
 | ||
|  | public string getObjClassName() | ||
|  | {  | ||
|  |     string tablename = this.SourceTable.Name.Substring(2); | ||
|  |     string firstChar = tablename.Substring(0,1); | ||
|  |     string className = firstChar.ToUpper() + tablename.Substring(1) ; | ||
|  |     return className + "_base"; | ||
|  | 	 //return  this.SourceTable.Name.Substring(2);  | ||
|  | } | ||
|  | public string getDbInstance() | ||
|  | {   | ||
|  |     string dbname = this.SourceDatabase.Name;  | ||
|  |     string firstdbChar = dbname.Length  >=9 ?  dbname.Substring(0,9) : dbname; | ||
|  |      | ||
|  |     if(firstdbChar.ToUpper().Contains("CUSTERP") ) | ||
|  |     { | ||
|  |         return "enumDbInstance.wms_erp"; //custErp_suzou2 | ||
|  |     }  | ||
|  |      | ||
|  |      if(firstdbChar.ToUpper().Contains("WMS") ) | ||
|  |     { | ||
|  |         return "enumDbInstance.wms"; | ||
|  |     } | ||
|  |     if(firstdbChar.ToUpper().Contains("PLAT") ) | ||
|  |     { | ||
|  |         return "enumDbInstance.platForm"; | ||
|  |     }  | ||
|  |      if(firstdbChar.ToUpper().Contains("EPICK") ) | ||
|  |     { | ||
|  |         return "enumDbInstance.wms"; | ||
|  |     }  | ||
|  |     return "enumDbInstance.platForm"; | ||
|  |      | ||
|  |      | ||
|  |     /* | ||
|  |     string tablename = this.SourceTable.Name; | ||
|  |     string firstChar = tablename.Substring(0,5); | ||
|  |    // string dbinstance = firstChar.ToUpper().Equals("T_WMS") ? "enumDbInstance.wms" : "enumDbInstance.platForm"; | ||
|  |     if(firstChar.ToUpper().Equals("T_WMS") ) | ||
|  |     { | ||
|  |         return "enumDbInstance.wms"; | ||
|  |     } | ||
|  |     if(firstChar.ToUpper().Equals("T_TMS") ) | ||
|  |     { | ||
|  |         return "enumDbInstance.tms"; | ||
|  |     } | ||
|  |      | ||
|  |      if(firstChar.ToUpper().Equals("T_ERP") ) | ||
|  |     { | ||
|  |         return "enumDbInstance.wms_erp"; | ||
|  |     } | ||
|  |      | ||
|  |     return "enumDbInstance.platForm"; | ||
|  |      | ||
|  |     */ | ||
|  |      | ||
|  |      | ||
|  | 	 //return  this.SourceTable.Name.Substring(2); | ||
|  | } | ||
|  | public string getColums4Insert(string prefix) | ||
|  | {  | ||
|  |     String colums =""; | ||
|  |        foreach (ColumnSchema column in this.SourceTable.Columns) {   | ||
|  |          //  if(!column.Name.ToUpper().Equals("ID") && !column.Name.ToUpper().Equals("DR")){   | ||
|  |             if(!isIgnored(column)){ | ||
|  |              colums+= prefix + column.Name.ToUpper()  + ","; | ||
|  |            } | ||
|  |        }           | ||
|  |                    | ||
|  | 	 return colums.Substring(0,colums.Length -1) ; | ||
|  | } | ||
|  | public string getColums4Enum() | ||
|  | {  | ||
|  |     String colums =""; | ||
|  |        foreach (ColumnSchema column in this.SourceTable.Columns) {   | ||
|  |          //  if(!column.Name.ToUpper().Equals("ID") && !column.Name.ToUpper().Equals("DR")){   | ||
|  |             if(!isIgnored(column)){ | ||
|  |              colums+= column.Name   + ","; | ||
|  |            } | ||
|  |        }           | ||
|  |                    | ||
|  | 	 return colums.Substring(0,colums.Length -1) ; | ||
|  | } | ||
|  | public string getColums4update() | ||
|  | {  | ||
|  |     String colums =""; | ||
|  |        foreach (ColumnSchema column in this.SourceTable.Columns) {  | ||
|  |             if(!isIgnored(column)){ | ||
|  |               colums+=  column.Name.ToUpper()  + " = @" +column.Name.ToUpper()  +"," ; | ||
|  |            }else if( column.Name.ToString().ToUpper().Equals("LASTMODIFIED") ){ | ||
|  |               colums+=  column.Name.ToUpper()  + " = getdate()"  +"," ; | ||
|  |            } | ||
|  |            | ||
|  |        }           | ||
|  |                    | ||
|  | 	 return colums.Substring(0,colums.Length -1) ; | ||
|  | } | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | public bool isIgnored4Property(ColumnSchema column){ | ||
|  |    bool rt = column.Name.ToString().ToUpper().Equals("ID")  | ||
|  |             || column.Name.ToString().ToUpper().Equals("DR")  | ||
|  |           //  || column.Name.ToString().ToUpper().Equals("OPERATER")  | ||
|  |             || column.Name.ToString().ToUpper().Equals("LASTMODIFIED") ; | ||
|  |     return rt; | ||
|  | } | ||
|  |   | ||
|  |   | ||
|  | public string getInternalDelcare(ColumnSchema column) | ||
|  | {  | ||
|  |     string declare =""; | ||
|  |     if  (column.DataType == DbType.Int32 ){ | ||
|  |           declare ="internal int _"+ column.Name +",_O"+ column.Name+";"; | ||
|  |     }else if (column.DataType == DbType.Boolean ){ | ||
|  |          declare ="internal bool _"+ column.Name +",_O"+ column.Name+";"; | ||
|  |     }else if (column.DataType == DbType.Decimal ){ | ||
|  |          declare ="internal decimal _"+ column.Name +",_O"+ column.Name +";"; | ||
|  |     }else {//if (column.DataType == DbType.String ){ | ||
|  |         declare ="internal string _"+ column.Name +" = String.Empty,"+"_O"+ column.Name +"= String.Empty;"; | ||
|  |     }   | ||
|  |     if (column.Name.ToUpper().Equals("ID")){ | ||
|  |         declare =""; | ||
|  |     } | ||
|  |     if(column.Name.ToString().ToUpper().Equals("OPERATER") ){ | ||
|  |            declare ="internal int _O"+ column.Name+";"; | ||
|  |     } | ||
|  |      | ||
|  |     if(isIgnored4Property(column)){ | ||
|  |         return ""; | ||
|  |     } | ||
|  |      | ||
|  |      | ||
|  |     return declare; | ||
|  | } | ||
|  | 
 | ||
|  | public string getType(ColumnSchema column) | ||
|  | {  | ||
|  |     string type ="string"; | ||
|  |     if  (column.DataType == DbType.Int32 ){ | ||
|  |           type =" int "; | ||
|  |     }else if (column.DataType == DbType.Boolean ){ | ||
|  |          type =" bool "; | ||
|  |     } else if (column.DataType == DbType.Decimal ){ | ||
|  |           type =" decimal "; | ||
|  |     } | ||
|  |     return type; | ||
|  | } | ||
|  | 
 | ||
|  | 
 | ||
|  | public string getWcfClassName() | ||
|  | {  | ||
|  |     string tablename = this.SourceTable.Name.Substring(2); | ||
|  |     string firstChar = tablename.Substring(0,1); | ||
|  |     string className = firstChar.ToUpper() + tablename.Substring(1) ; | ||
|  |     return "Wcf" + className ; | ||
|  | 	 //return  this.SourceTable.Name.Substring(2); | ||
|  | } | ||
|  | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | public bool isIgnoredProperty4wc(ColumnSchema column){ | ||
|  |    bool rt = // column.Name.ToString().ToUpper().Equals("ID")  | ||
|  |                 column.Name.ToString().ToUpper().Equals("DR")  | ||
|  |            // || column.Name.ToString().ToUpper().Equals("OPERATER")  | ||
|  |                 || column.Name.ToString().ToUpper().Equals("LASTMODIFIED") | ||
|  |                 || column.Name.ToString().ToUpper().Equals("CREATETIME") ;  | ||
|  |     return rt; | ||
|  | } | ||
|  | public string getInternalDelcare4wcf(ColumnSchema column) | ||
|  | {  | ||
|  |     string declare =""; | ||
|  |     if  (column.DataType == DbType.Int32 ){ | ||
|  |           declare ="internal int _"+ column.Name +";"; | ||
|  |     }else if (column.DataType == DbType.Boolean ){ | ||
|  |          declare ="internal bool _"+ column.Name +";"; | ||
|  |     }else if (column.DataType == DbType.Decimal ){ | ||
|  |          declare ="internal decimal _"+ column.Name +";"; | ||
|  |     }else {//if (column.DataType == DbType.String ){ | ||
|  |       //  declare ="internal string _"+ column.Name +" = String.Empty;"; | ||
|  |         declare ="internal string _"+ column.Name +";"; | ||
|  |     }   | ||
|  |     /* | ||
|  |     if (column.Name.ToUpper().Equals("ID")){ | ||
|  |         declare =""; | ||
|  |     } | ||
|  |     if(column.Name.ToString().ToUpper().Equals("OPERATER") ){ | ||
|  |           declare =""; | ||
|  |     } | ||
|  |      | ||
|  |     if(isIgnored4Property(column)){ | ||
|  |         return ""; | ||
|  |     } | ||
|  |     */ | ||
|  |      | ||
|  |     return declare; | ||
|  | } | ||
|  |   | ||
|  | 
 | ||
|  | public string getObjClassNameExt() | ||
|  | {  | ||
|  | 	string tablename = this.SourceTable.Name.Substring(2); | ||
|  |     string firstChar = tablename.Substring(0,1); | ||
|  |     string className = firstChar.ToUpper() + tablename.Substring(1); | ||
|  |     return className ; | ||
|  | } | ||
|  | 
 | ||
|  | public string getWcfSvcClassName() | ||
|  | {  | ||
|  |     string tablename = this.SourceTable.Name.Substring(2); | ||
|  |     string firstChar = tablename.Substring(0,1); | ||
|  |     string className = firstChar.ToUpper() + tablename.Substring(1) ; | ||
|  |     return   className + "Service" ; | ||
|  | 	 //return  this.SourceTable.Name.Substring(2); | ||
|  | } | ||
|  | public string getWcfSvcInterfaceName() | ||
|  | {   | ||
|  |     string tablename = this.SourceTable.Name.Substring(2); | ||
|  |     string firstChar = tablename.Substring(0,1); | ||
|  |     string className = firstChar.ToUpper() + tablename.Substring(1) ; | ||
|  |     return "I"+  className  ; | ||
|  | } |