public DbSchemaCol(string columnName, OdDbType dataType, TextSizeMySqlOracle textSize) { ColumnName = columnName; DataType = dataType; //Indexed=indexed; TextSize = textSize; }
public DbSchemaCol(string columnName,OdDbType dataType,TextSizeMySqlOracle textSize,bool intUseSmallInt) { ColumnName=columnName; DataType=dataType; //Indexed=indexed; TextSize=textSize; IntUseSmallInt=intUseSmallInt; }
public DbSchemaCol(string columnName, OdDbType dataType, TextSizeMySqlOracle textSize, bool intUseSmallInt) { ColumnName = columnName; DataType = dataType; //Indexed=indexed; TextSize = textSize; IntUseSmallInt = intUseSmallInt; }
public DbSchemaCol(string columnName,OdDbType dataType,TextSizeMySqlOracle textSize) { ColumnName=columnName; DataType=dataType; //Indexed=indexed; TextSize=textSize; }
/* /// <summary>Takes DbSchemaCol and makes a new instance of it. </summary> public DbSchemaCol(DbSchemaCol newCol) { ColumnName=newCol.ColumnName; DataType=newCol.DataType; //Indexed=newCol.Indexed; IntUseSmallInt=newCol.IntUseSmallInt; TextSize=newCol.TextSize; }*/ public DbSchemaCol(string columnName,OdDbType dataType) { ColumnName=columnName; DataType=dataType; //Indexed=false; }
///<summary>Writes any necessary queries to the end of the ConvertDatabase file. Usually zero or one. The convertDbFile could also be the one in the Mobile folder.</summary> ///<param name="logFileName">If this is blank, will display the results in a MessageBox, otherwise writes the results to the file.</param> public static void Write(string convertDbFile, Type typeClass, string dbName, bool isMobile, bool doRunQueries, bool doAppendToConvertDbFile, string logFileName = "") { StringBuilder strb; FieldInfo[] fields = typeClass.GetFields(); //We can't assume they are in the correct order. FieldInfo priKey = null; FieldInfo priKey1 = null; FieldInfo priKey2 = null; if (isMobile) { priKey1 = CrudGenHelper.GetPriKeyMobile1(fields, typeClass.Name); priKey2 = CrudGenHelper.GetPriKeyMobile2(fields, typeClass.Name); } else { priKey = CrudGenHelper.GetPriKey(fields, typeClass.Name); } string tablename = CrudGenHelper.GetTableName(typeClass); //in lowercase now. string priKeyParam = null; string priKeyParam1 = null; string priKeyParam2 = null; if (isMobile) { priKeyParam1 = priKey1.Name.Substring(0, 1).ToLower() + priKey1.Name.Substring(1); //lowercase initial letter. Example customerNum priKeyParam2 = priKey2.Name.Substring(0, 1).ToLower() + priKey2.Name.Substring(1); //lowercase initial letter. Example patNum } else { priKeyParam = priKey.Name.Substring(0, 1).ToLower() + priKey.Name.Substring(1); //lowercase initial letter. Example patNum } string obj = typeClass.Name.Substring(0, 1).ToLower() + typeClass.Name.Substring(1); //lowercase initial letter. Example feeSched or feeSchedm List <FieldInfo> fieldsExceptPri = null; if (isMobile) { fieldsExceptPri = CrudGenHelper.GetFieldsExceptPriKey(fields, priKey2); //for mobile, only excludes PK2 } else { fieldsExceptPri = CrudGenHelper.GetFieldsExceptPriKey(fields, priKey); } CrudSpecialColType specialType; string command = "SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '" + dbName + "' AND table_name = '" + tablename + "'"; if (DataCore.GetScalar(command) != "1") { if (!CrudGenHelper.IsMissingInGeneral(typeClass)) { strb = new StringBuilder(); strb.Append("This table was not found in the database:" + rn + tablename); if (doAppendToConvertDbFile) { strb.Append(rn + "Query will be found at the end of " + Path.GetFileName(convertDbFile)); } if (doRunQueries) { strb.Append(rn + "Table will be added to database."); } if (string.IsNullOrEmpty(logFileName)) { MessageBox.Show(strb.ToString()); } else { File.AppendAllText(logFileName, strb.ToString() + "\r\n"); } strb = new StringBuilder(); strb.Append(rn + rn + t4 + "/*"); List <DbSchemaCol> cols = null; if (isMobile) { cols = CrudQueries.GetListColumns(priKey1.Name, priKey2.Name, fieldsExceptPri, true); } else { cols = CrudQueries.GetListColumns(priKey.Name, null, fieldsExceptPri, false); } strb.Append("\r\n" + CrudSchemaRaw.AddTable(tablename, cols, 4, isMobile, doRunQueries)); strb.Append(rn + t4 + "*/"); if (doAppendToConvertDbFile) { File.AppendAllText(convertDbFile, strb.ToString()); } } } List <FieldInfo> newColumns = CrudGenHelper.GetNewFields(fields, typeClass, dbName); if (newColumns.Count > 0) { strb = new StringBuilder(); strb.Append("The following columns were not found in the database."); for (int f = 0; f < newColumns.Count; f++) { strb.Append(rn + tablename + "." + newColumns[f].Name); } if (doAppendToConvertDbFile) { strb.Append(rn + "Query will be found at the end of " + Path.GetFileName(convertDbFile)); } if (doRunQueries) { strb.Append(rn + "Column will be added to table."); } if (string.IsNullOrEmpty(logFileName)) { MessageBox.Show(strb.ToString()); //one message for all new columns in a table. } else { File.AppendAllText(logFileName, strb.ToString() + "\r\n"); } strb = new StringBuilder(); strb.Append(rn + rn + t4 + "/*"); for (int f = 0; f < newColumns.Count; f++) { specialType = CrudGenHelper.GetSpecialType(newColumns[f]); OdDbType odtype = GetOdDbTypeFromColType(newColumns[f].FieldType, specialType); TextSizeMySqlOracle textsize = TextSizeMySqlOracle.Small; if (specialType.HasFlag(CrudSpecialColType.TextIsClob)) { textsize = TextSizeMySqlOracle.Medium; } DbSchemaCol col = new DbSchemaCol(newColumns[f].Name, odtype, textsize); strb.Append(CrudSchemaRaw.AddColumnEnd(tablename, col, 4, doRunQueries, typeClass)); } strb.Append(rn + t4 + "*/"); if (doAppendToConvertDbFile) { File.AppendAllText(convertDbFile, strb.ToString()); } } }
/* * /// <summary>Takes DbSchemaCol and makes a new instance of it. </summary> * public DbSchemaCol(DbSchemaCol newCol) { * ColumnName=newCol.ColumnName; * DataType=newCol.DataType; * //Indexed=newCol.Indexed; * IntUseSmallInt=newCol.IntUseSmallInt; * TextSize=newCol.TextSize; * }*/ public DbSchemaCol(string columnName, OdDbType dataType) { ColumnName = columnName; DataType = dataType; //Indexed=false; }
///<summary>parameterName should not include the leading character such as @ or : . And DbHelper.ParamChar() should be used to determine the char in the query itself.</summary> public OdSqlParameter(string parameterName, OdDbType dbType, Object value) { this.parameterName = parameterName; this.dbType = dbType; this.value = value; }
///<summary>parameterName should not include the leading character such as @ or : . And DbHelper.ParamChar() should be used to determine the char in the query itself.</summary> public OdSqlParameter(string parameterName,OdDbType dbType,Object value) { this.parameterName=parameterName; this.dbType=dbType; this.value=value; }