public void IsRequired() { AddConstraint(a => { return(a.All(s => TableField.IsNullOrSpace(s)) ? Name + " cannot all be empty" : null); }); }
internal static object HelperObject(TableField field, object item, object child) { if (field.Property.Name == "Quantity") { var childCollection = item.GetType().GetProperty(field.HelperContext).GetValue(item) as IEnumerable; int count = 0; foreach (object thing in childCollection) { if (thing == child) { count++; } } return(count); } else if (field.Property.Name == "Index") { var childCollection = item.GetType().GetProperty(field.HelperContext).GetValue(item) as IList; return(childCollection.Contains(child) ? childCollection.IndexOf(child) : 0); } else { throw new NotImplementedException(); } }
public override void RowPasted(UnicontaBaseEntity rec) { var Comp = api.CompanyEntity; var orderLine = rec as ProjectInvoiceProposalLineClient; if (orderLine == null) { return; } if (Comp._InvoiceUseQtyNow) { orderLine.QtyNow = orderLine._Qty; } if (orderLine._Item != null) { var selectedItem = (InvItem)items.Get(orderLine._Item); if (selectedItem != null) { PriceLookup?.SetPriceFromItem(orderLine, selectedItem); orderLine.SetItemValues(selectedItem, Comp._OrderLineStorage, true); TableField.SetUserFieldsFromRecord(selectedItem, orderLine); } else { orderLine._Item = null; } } }
public static void Run() { try { // ExStart:ConfigureGantChart // The path to the documents directory. string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName); Project project = new Project(dataDir + "Project5.mpp"); // Create a new project task Task task = project.RootTask.Children.Add("New Activity"); // Add custom text attribute to created task. ExtendedAttribute attr = new ExtendedAttribute(); attr.FieldId = ((int)ExtendedAttributeTask.Text1).ToString(); attr.Value = "Activity attribute"; task.ExtendedAttributes.Add(attr); // Customize table by adding text attribute field TableField attrField = new TableField(); attrField.Field = Field.TaskText1; attrField.Width = 20; attrField.Title = "Custom attribute"; attrField.AlignTitle = StringAlignment.Center; attrField.AlignData = StringAlignment.Center; Table table = project.Tables.ToList()[0]; table.TableFields.Insert(3, attrField); project.Save(dataDir + "ConfigureGantChart_out.mpp", SaveFileFormat.MPP); } catch (Exception ex) { Console.WriteLine(ex.Message + "\nThis example will only work if you apply a valid Aspose License. You can purchase full license or get 30 day temporary license from http:// Www.aspose.com/purchase/default.aspx."); } // ExEnd:ConfigureGantChart }
protected override string GetAttriDeclare(TableField info) { return(attriDeclareTemplet.Replace("#AttriName", info.filedName) .Replace("#Comment", info.isList ? (info.comment + " !" + info.fieldType.ToString().ToLower() + " List") : info.comment) .Replace("#AttriType", info.isList ? "string" : info.fieldType.ToString().ToLower())); }
public Dictionary <TableField, PropertyInfo> GetRelation(List <string> fields) { Type type = this.GetType(); Dictionary <TableField, PropertyInfo> Relation = new Dictionary <TableField, PropertyInfo>(); foreach (PropertyInfo propInfo in type.GetProperties()) { object[] objAttrs = propInfo.GetCustomAttributes(typeof(TableField), true); if (objAttrs.Length > 0) { TableField attr = objAttrs[0] as TableField; if (attr != null) { Relation.Add(attr, propInfo); } } } //Key:注解,VALUE:字段名称 Dictionary <TableField, PropertyInfo> newRelation = new Dictionary <TableField, PropertyInfo>(); foreach (var item in fields) { var Entity = (from c in Relation where c.Key.Name.ToLower().Equals(item.ToLower()) select c).FirstOrDefault(); if (Entity.Key != null) { newRelation.Add(Entity.Key, Entity.Value); } } return(newRelation); }
public override string TableField(TableField field, bool includeKey = true) { StringBuilder str = new StringBuilder(); str.AppendFormat("\"{0}\"", field.Name); str.Append(' '); str.Append(FieldType(field.Type)); str.Append(FieldLength(field)); if (includeKey && field.Key.HasFlag(KeyType.Primary)) { str.Append(" PRIMARY KEY"); } if (field.AutoIncrement) { str.Append(" AUTOINCREMENT"); } else if (field.NotNull) { str.Append(" NOT NULL"); } else { str.Append(" NULL"); } if (field.DefaultValue != null) { str.AppendFormat(" DEFAULT {0}", field.DefaultValue); } return(str.ToString()); }
private string GetType(TableField tableField) { switch (tableField.FieldType) { case "varchar": return(tableField.FieldType + "(" + tableField.FieldLength + ")"); case "nvarchar": return(tableField.FieldType + "(" + tableField.FieldLength + ")"); case "int": return(tableField.FieldType); case "datetime": return(tableField.FieldType); case "blob": return(tableField.FieldType); case "tinyint": return(tableField.FieldType); case "text": return(tableField.FieldType); default: return("varchar(50)"); } }
private static TableField[] getRecord(QueryResult res, long rowId) { int fields; TableField[] tfs = null; fields = res.Data[(int)rowId].Length; tfs = new TableField[fields]; for (int j = 0; j < fields; j++) { TableField tf = new TableField(); tf.setName(res.ColumnNames[j]); //tf.setDisplayName(res.ColumnDisplayNames[j]); tf.setUpdateable(false); //TODO Implement BLOB edit //is it a BLOB field turn edit off try { //tf.setValue(cursor.GetString(j)); tf.setValue(res.Data[(int)rowId][j]); } catch (Exception) { tf.setUpdateable(false); tf.setValue("BLOB"); } tfs[j] = tf; } return(tfs); }
public static IEnumerable <ParameterBase> ToParameters(this TableField field) { yield return(new SimpleParameter("ID", field.ID)); yield return(new SimpleParameter("Name", field.Name)); yield return(new SwitchParameter("Enabled", field.Enabled)); switch (field) { case CodeTableField c: yield return(new SimpleParameter("DataLength", c.DataLength)); break; case TextTableField t: yield return(new SimpleParameter("DataLength", t.DataLength)); break; } foreach (var parameter in field.AllProperties.Where(p => p.HasValue).SelectMany(p => p.ToParameters())) { yield return(parameter); } }
public override void Build(ParsedSql ret, List <string> tokens, ref int i) { TableField t = new TableField(); if (tokens[i] == "(") { t.Name = ParenBlockBuilder.ConsumeParenBlock(tokens, ref i); } else { t.Name = tokens[i++]; } var on = new On(); var join = new Join(); var where = new Where(); if (!join.Match(tokens[i], tokens, i) && !on.Match(tokens[i], tokens, i) && !where.Match(tokens[i], tokens, i)) { var token = tokens[i++]; if (token == "as") { token = tokens[i++]; } t.Alias = token; } ret.Select.Tables.Add(t); }
private void button1_Click(object sender, EventArgs e) { if (textBox2.Text.Length == 0) { MessageBox.Show("原始数据不能为空"); textBox2.Focus(); return; } foreach (TableField originData in _ComboBoxItemData.ExplainList) { if (originData.tableName == textBox2.Text) { MessageBox.Show("原始数据" + textBox2.Text + "已经存在"); textBox2.Focus(); return; } } TableField tf = new TableField(); tf.tableName = textBox2.Text; tf.fieldName = textBox1.Text; _ComboBoxItemData.ExplainList.Add(tf); string text = string.IsNullOrEmpty(textBox1.Text) ? (textBox2.Text) : (textBox2.Text + " -> " + textBox1.Text); listBox1.Items.Add(text); }
public static FieldFilterExpression AddFieldExpression(Filters Filters, IFilter Filter, TableField Field, string FieldTableAlias) { FieldFilterExpression FieldFilterExpression = Filter.CreateFieldFilterExpression(); FieldFilterExpression.Code = GenNewKeyValueFromCollection(Filters, "FieldFilterExpression"); FieldFilterExpression.Field = Field; FieldFilterExpression.TableAlias = FieldTableAlias; return FieldFilterExpression; }
public static GeneralColumn AddGeneralColumn(Columns Columns, TableField Field, bool IsEnabled, bool CanDisabled) { GeneralColumn Column = Columns.CreateGeneralColumn(); Column.Field = Field; Column.IsEnabled = IsEnabled; Column.CanDisable = CanDisabled; Columns.Add(Column); return Column; }
async void SetValuesFromMaster(Debtor debtor) { if (debtor == null) { return; } var loadedOrder = LoadedRow as DCOrder; if (loadedOrder?._DCAccount == debtor._Account) { return; } editrow.Account = debtor._Account; editrow.SetCurrency(debtor._Currency); editrow.Payment = debtor._Payment; editrow.PricesInclVat = debtor._PricesInclVat; editrow.EndDiscountPct = debtor._EndDiscountPct; editrow.PostingAccount = debtor._PostingAccount; editrow.LayoutGroup = debtor._LayoutGroup; editrow.Shipment = debtor._Shipment; editrow.Employee = debtor._Employee; editrow.DeliveryTerm = debtor._DeliveryTerm; if (!RecordLoadedFromTemplate || debtor._DeliveryAddress1 != null) { editrow.DeliveryName = debtor._DeliveryName; editrow.DeliveryAddress1 = debtor._DeliveryAddress1; editrow.DeliveryAddress2 = debtor._DeliveryAddress2; editrow.DeliveryAddress3 = debtor._DeliveryAddress3; editrow.DeliveryZipCode = debtor._DeliveryZipCode; editrow.DeliveryCity = debtor._DeliveryCity; if (debtor._DeliveryCountry != 0) { editrow.DeliveryCountry = debtor._DeliveryCountry; } else { editrow.DeliveryCountry = null; } } TableField.SetUserFieldsFromRecord(debtor, editrow); if (ProjectCache != null) { Projectlookupeditor.cacheFilter = new DebtorProjectFilter(ProjectCache, debtor._Account); Projectlookupeditor.InvalidCache(); } BindContact(debtor); if (installationCache != null) { leDeliveryAddress.cacheFilter = new AccountCacheFilter(installationCache, 1, debtor._Account); leDeliveryAddress.InvalidCache(); } await api.Read(debtor); editrow.RefreshBalance(); }
public FieldValue(TableField field) { if (field == null) { throw new ArgumentNullException(nameof(field)); } Type = field.FieldType; Length = field.Length; }
public void Section6() { var section6 = new DocumentSection("Recommended special education programs and services"); var tableField = new TableField(""); var specEdTable = new TableField("Special Education Program:"); specEdTable.Fields.Add(new TextField("")); tableField.Fields.Add(specEdTable); _doc.Sections.Add(section6); }
async void SetFieldFromDebtor(DebtorOrderClient editrow, Debtor debtor) { if (debtor == null) { return; } var loadedOrder = LoadedRow as DCOrder; editrow.SetMaster(debtor); if (this.Project == null) // no project master { editrow.PricesInclVat = debtor._PricesInclVat; } if (!RecordLoadedFromTemplate || debtor._DeliveryAddress1 != null) { editrow.DeliveryName = debtor._DeliveryName; editrow.DeliveryAddress1 = debtor._DeliveryAddress1; editrow.DeliveryAddress2 = debtor._DeliveryAddress2; editrow.DeliveryAddress3 = debtor._DeliveryAddress3; editrow.DeliveryCity = debtor._DeliveryCity; if (editrow.DeliveryZipCode != debtor._DeliveryZipCode) { lookupZipCode = false; editrow.DeliveryZipCode = debtor._DeliveryZipCode; } if (debtor._DeliveryCountry != 0) { editrow.DeliveryCountry = debtor._DeliveryCountry; } else { editrow.DeliveryCountry = null; } } if (ProjectCache != null) { Projectlookupeditor.cache = ProjectCache; } TableField.SetUserFieldsFromRecord(debtor, editrow); BindContact(debtor); if (installationCache != null) { leDeliveryAddress.cacheFilter = new AccountCacheFilter(installationCache, 1, debtor._Account); leDeliveryAddress.InvalidCache(); } layoutItems.DataContext = null; layoutItems.DataContext = editrow; await api.Read(debtor); editrow.RefreshBalance(); }
private void lstTables_SelectedIndexChanged(object sender, EventArgs e) { //string dbPath = Variables.NewFilePath; try { myDB = dbE.OpenDatabase(Variables.NewFilePath); } catch (Exception ex) { //MessageBox.Show("Error openning database! \n" + // "File path: " + dbPath + "\n" + ex, // "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); errorMsgDB(ex.ToString()); return; } //show tables fields if (lstTables.SelectedIndices.Count <= 0) { return; } int intselectedindex = lstTables.SelectedIndices[0]; if (intselectedindex < 0) { return; } string tblName = lstTables.Text; gridTblFld.Rows.Clear(); int i = 0; //show table info try { TableDef myTable = myDB.TableDefs[tblName]; foreach (Field fldExtItem in ((Fields)myTable.Fields)) { gridTblFld.Rows.Add(1); gridTblFld.Rows[i].Cells[0].Value = fldExtItem.Name.ToString(); gridTblFld.Rows[i].Cells[1].Value = TableField.decodeFldType(fldExtItem.Type); gridTblFld.Rows[i].Cells[2].Value = fldExtItem.Size.ToString(); i++; } } catch (Exception ex) { //MessageBox.Show("Error reading database! \n" + // "File path: " + Variables.NewFilePath + "\n" + ex, // "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); errorMsgDB(ex.ToString()); return; } }
public static void Run() { // ExStart:ReadTableDataFromProjectFile // The path to the documents directory. string dataDir = RunExamples.GetDataDir_ReadingData(); Project project = new Project(dataDir + "Project1.mpp"); Table task1 = project.Tables.ToList()[0]; Console.WriteLine("Table Fields Count" + task1.TableFields.Count); TableField tableField = task1.TableFields[0]; Console.WriteLine("Field width: " + tableField.Width); Console.WriteLine("Field Title: " + tableField.Title); Console.WriteLine("Field Title Alignment: " + tableField.AlignTitle.ToString()); Console.WriteLine("Field Align Data: " + tableField.AlignData.ToString()); tableField = task1.TableFields[1]; Console.WriteLine("Field width: " + tableField.Width); Console.WriteLine("Field Title: " + tableField.Title); Console.WriteLine("Field Title Alignment: " + tableField.AlignTitle.ToString()); Console.WriteLine("Field Align Data: " + tableField.AlignData.ToString()); tableField = task1.TableFields[2]; Console.WriteLine("Field width: " + tableField.Width); Console.WriteLine("Field Title: " + tableField.Title); Console.WriteLine("Field Title Alignment: " + tableField.AlignTitle.ToString()); Console.WriteLine("Field Align Data: " + tableField.AlignData.ToString()); tableField = task1.TableFields[3]; Console.WriteLine("Field width: " + tableField.Width); Console.WriteLine("Field Title: " + tableField.Title); Console.WriteLine("Field Title Alignment: " + tableField.AlignTitle.ToString()); Console.WriteLine("Field Align Data: " + tableField.AlignData.ToString()); tableField = task1.TableFields[4]; Console.WriteLine("Field width: " + tableField.Width); Console.WriteLine("Field Title: " + tableField.Title); Console.WriteLine("Field Title Alignment: " + tableField.AlignTitle.ToString()); Console.WriteLine("Field Align Data: " + tableField.AlignData.ToString()); tableField = task1.TableFields[5]; Console.WriteLine("Field width: " + tableField.Width); Console.WriteLine("Field Title: " + tableField.Title); Console.WriteLine("Field Title Alignment: " + tableField.AlignTitle.ToString()); Console.WriteLine("Field Align Data: " + tableField.AlignData.ToString()); tableField = task1.TableFields[6]; Console.WriteLine("Field width: " + tableField.Width); Console.WriteLine("Field Title: " + tableField.Title); Console.WriteLine("Field Title Alignment: " + tableField.AlignTitle.ToString()); Console.WriteLine("Field Align Data: " + tableField.AlignData.ToString()); tableField = task1.TableFields[7]; Console.WriteLine("Field width: " + tableField.Width); Console.WriteLine("Field Title: " + tableField.Title); Console.WriteLine("Field Title Alignment: " + tableField.AlignTitle.ToString()); Console.WriteLine("Field Align Data: " + tableField.AlignData.ToString()); // ExEnd:ReadTableDataFromProjectFile }
protected override void VisitTableField(TableField tree) { _TrySetResult(tree); if (_result != null) { return; } if (tree.index != null) { VisitAnySyntaxTree(tree.index); } VisitAnySyntaxTree(tree.value); }
private void leProdItem_SelectedIndexChanged(object sender, RoutedEventArgs e) { if (editrow.RowId == 0) { var item = leProdItem.SelectedItem as InvItem; if (item != null) { editrow.ProdQty = item._PurchaseQty; editrow.Warehouse = item._Warehouse; editrow.Location = item._Location; editrow.NotifyPropertyChanged("ProdQty"); TableField.SetUserFieldsFromRecord(item, editrow); } } }
private static string TypeName(this TableField field) { switch (field) { case BinaryTableField binaryTableField: return($"Binary{binaryTableField.DataLength}"); case CodeTableField codeTableField: return($"Code{codeTableField.DataLength}"); case GuidTableField guidTableField: return("GUID"); case TextTableField textTableField: return($"Text{textTableField.DataLength}"); default: return(field.Type.ToString()); } }
public JsonResult ModifyField(TableField tableField) { var field = _pDBaseContext.TableField.Where(p => p.FieldId == tableField.FieldId).FirstOrDefault(); field.FieldlKey = tableField.FieldlKey; field.FieldName = tableField.FieldName; field.FieldExplain = tableField.FieldExplain; field.FieldType = tableField.FieldType; field.FieldLength = tableField.FieldLength; field.FieldDefultValue = tableField.FieldDefultValue; field.FieldIsNull = tableField.FieldIsNull; field.FieldContentId = tableField.FieldContentId; _pDBaseContext.SaveChanges(); return(Json(new { success = 1, message = "OK" })); }
public object Any(TableField request) { var signature = this.Request.Headers.GetValues("Signature"); if (signature != null) { if (auth.AuthResult(signature[0].ToString(), this.Request.RawUrl)) { TableFieldResponse[] tfr = tableFieldLogic.ShowResponse(request); return(tfr); } } return(new AuthFaildResponse { strResult = "No Authentication." }); }
public void TestIsEqual_DateTime_NotEqual_TableField() { Field sourceField = new LiteralField("DateTime", "sourceField", "2016-02-28"); Field targetField = new TableField("DateTime", "targetField"); SimpleCondition condition = new IsEqual(sourceField, targetField); IDataSourceStore dsStore = new DataSourceStore(); IDataSource ds = new TableDataSource(new Dictionary <string, object>() { { "targetField", "2016-02-27" } }); bool isHold = condition.IsSimpleConditonHold(dsStore.AddDataSource(ds)); bool expected = false; Assert.AreEqual <bool>(expected, isHold); }
public JsonResult AddField(TableField filedModel) { if (filedModel.FieldlKey == "1") { filedModel.FieldIsNull = "0"; } string Name = User.FindFirstValue(ClaimTypes.Name); filedModel.FieldId = Guid.NewGuid().ToString("N"); filedModel.State = 1; filedModel.CreateTime = DateTime.Now; filedModel.Creater = Name; _pDBaseContext.TableField.Add(filedModel); _pDBaseContext.SaveChanges(); return(Json(new { success = 1, message = "OK" })); }
private void button1_Click(object sender, EventArgs e) { var tables = _repo.getTables(); var field = new TableField() { Name = textBox1.Text, FieldType = (FieldType)comboBox1.SelectedItem.Value, IsNullable = true, IsUnique = false }; tables.Where(x => x.Name == _tableName).FirstOrDefault().Fields.Add(field); _repo.UpdateDb(tables); _parentform.refreshView(); this.Close(); }
/** * read the field descriptions */ private void ReadFieldTypesAndSizes(BinaryReader inputStream) { try { Fields = new List <TableField>(); for (int i = 0; i < NumberOfFields; i++) { var pdxTableField = new TableField(); pdxTableField.ReadFieldTypeAndSize(inputStream); Fields.Add(pdxTableField); } } catch (Exception ex) { throw new Exception("Exception in readFields", ex); } }
public void Section4() { var section4 = new DocumentSection("Measurable annual goals"); var tableField = new TableField("Masurable annual goals"); var shortTermTable = new TableField("Short-Term intrucinal......"); tableField.Fields.Add(new TextField("Annual Goals")); tableField.Fields.Add(new TextField("Criteria")); tableField.Fields.Add(new TextField("Method")); tableField.Fields.Add(new TextField("Schedule")); shortTermTable.Fields.Add(new TextField("")); tableField.Fields.Add(shortTermTable); section4.Fields.Add(tableField); _doc.Sections.Add(section4); }
public override TableField TableField(ResultRow field) { TableField tableField = new TableField() { Name = field.GetString("COLUMN_NAME"), Type = ParseType(field.GetString("DATA_TYPE")), NotNull = !field.GetString("IS_NULLABLE").Equals("YES"), //Key = ParseKey(field.GetString("Key")), ??? DefaultValue = field["COLUMN_DEFAULT"], //Unsigned = field.GetString("Type").Split(' ').Contains("unsigned"), //Zerofill = field.GetString("Type").Split(' ').Contains("zerofill"), //AutoIncrement = field.GetString("Extra").Split(' ').Contains("auto_increment"), Length = field.GetInteger("CHARACTER_MAXIMUM_LENGTH", 0) }; return(tableField); }
private void CreateTextBox(FlowLayoutPanel flp, TableField field, Control valueBox) { TextBox tb = valueBox as TextBox; if (field.Type == "text") { tb.Multiline = true; tb.Width = tb.Width * 2; tb.Height = tb.Height * 2; } valueBox.Validating += (sender, e) => { if (field.Type == "int" || field.Type == "float") { const string pattern = @"^[0-9]*$"; string content = valueBox.Text; if (!(Regex.IsMatch(content, pattern))) { SystemSounds.Beep.Play(); MessageBox.Show("只能输入数字!"); e.Cancel = true; } } //else //{ // const string IllegalChars = "\"',.,。”‘;;\\、!!@#¥%……&*()(?)/|<>_+="; // string content = valueBox.Text; // if (IllegalChars.Any(c => content.Contains(c))) // { // SystemSounds.Beep.Play(); // MessageBox.Show("您输入的内容{"+ content + "}含有非法字符,如:\r\n" + IllegalChars); // e.Cancel = true; // } //} }; valueBox.KeyPress += (sender, e) => { if (System.Convert.ToInt32(e.KeyChar) == 13) { System.Windows.Forms.SendKeys.Send("{tab}"); e.Handled = true; } }; }
private static TableField CreateTableFieldFromFieldDataRow(Table table, IClassItemNamingConvention classItemTemplate, ITypeMapper typeTemplate, DataRow col, DataTable constraintsData, int indexInParentTable) { string fieldName = Convert.ToString(col["COLUMN_NAME"]); string nativeDbType = Convert.ToString(col["DATA_TYPE"]); int precision = (col["DATA_PRECISION"] != DBNull.Value) ? Convert.ToInt32(col["DATA_PRECISION"]) : 0; int scale = (col["DATA_SCALE"] != DBNull.Value) ? Convert.ToInt32(col["DATA_SCALE"]) : 0; bool isNullable = ("Y" == Convert.ToString(col["NULLABLE"])); int maxLength = (col["DATA_LENGTH"] != DBNull.Value) ? Convert.ToInt32(col["DATA_LENGTH"]) : 0; string dbDefaultValue = Convert.ToString(col["DATA_DEFAULT"]); bool isPrimaryKeyPart, isForeignKeyPart, isUniqueConstraintPart; SetConstraintPartFlags(fieldName, constraintsData, out isPrimaryKeyPart, out isForeignKeyPart, out isUniqueConstraintPart); TableField field = new TableField(table, fieldName, classItemTemplate, nativeDbType, typeTemplate, precision, scale, isNullable, indexInParentTable, /*autoIncrement*/ false, dbDefaultValue, maxLength, isPrimaryKeyPart, isForeignKeyPart, isUniqueConstraintPart, /*isAutoGenerated*/ false, /*sequenceName*/ null); //field.Ordinal = Convert.ToInt32(col["COLUMN_ID"]); return field; }
private static TableField CreateTableFieldFromFieldDataRow(Table table, IClassItemNamingConvention classItemTemplate, ITypeMapper typeTemplate, DataRow col, int indexInParentTable) { string columnName = col["COLUMN_NAME"].ToString(); string nativeDbType = col["DATA_TYPE"].ToString(); int precision = (col["NUMERIC_PRECISION"] != DBNull.Value) ? Convert.ToInt32(col["NUMERIC_PRECISION"]) : 0; int scale = (col["NUMERIC_SCALE"] != DBNull.Value) ? Convert.ToInt32(col["NUMERIC_SCALE"]) : 0; bool isNullable = (col["IS_NULLABLE"].ToString().ToLowerInvariant() == "yes"); int maxLength; bool isTextualOrBinary = (col["CHARACTER_MAXIMUM_LENGTH"] != DBNull.Value); if (isTextualOrBinary) { int maxCharsOrBytes = Convert.ToInt32(col["CHARACTER_MAXIMUM_LENGTH"]); maxLength = maxCharsOrBytes; } else { // Numeric types. maxLength = (col["ColumnLength"] != DBNull.Value) ? Convert.ToInt32(col["ColumnLength"]) : 0; } bool autoIncrement = (col["IsIdentity"] != DBNull.Value) && (Convert.ToInt32(col["IsIdentity"]) >= 1); string dbDefaultValue = col["COLUMN_DEFAULT"].ToString(); bool isPrimaryKeyPart = (Convert.ToInt32(col["IsPrimaryKey"]) == 1); // IsForeignKeyPart isn't working for some reason. It will be processed later when fetching relations. bool isForeignKeyPart = (Convert.ToInt32(col["IsForeignKey"]) == 1); bool isUniqueConstraintPart = (Convert.ToInt32(col["HasUniqueConstraint"]) == 1); // Auto-generated flag. Fields that are auto-generated may not be inserted or updated. bool isComputed = (Convert.ToInt32(col["IsComputed"]) == 1); bool isRowVersion = (nativeDbType == "timestamp") || (nativeDbType == "rowversion"); bool isAutoGenerated = (isComputed || isRowVersion); string sequenceName = (col["SequenceName"] != DBNull.Value) ? (string)col["SequenceName"] : null; TableField field = new TableField(table, columnName, classItemTemplate, nativeDbType, typeTemplate, precision, scale, isNullable, indexInParentTable, autoIncrement, dbDefaultValue, maxLength, isPrimaryKeyPart, isForeignKeyPart, isUniqueConstraintPart, isAutoGenerated, sequenceName); //int colSizeInBytes = Convert.ToInt32(row["ColumnLength"]); //table.Fields[i].Ordinal = Convert.ToInt32(row["ORDINAL_POSITION"]); return field; }
internal static ForeignKey GetFkContainingChildField(Table tbl, TableField fkPart) { foreach (ForeignKey fk in tbl.ForeignKeys) { foreach (string childFieldName in fk.ChildColumns) { if (childFieldName == fkPart.ColumnName) return fk; } } return null; }
private static TableField CreateTableFieldFromFieldDataRow(Table table, IClassItemNamingConvention classItemTemplate, ITypeMapper typeTemplate, DataRow col, int indexInParentTable) { string columnName = col["COLUMN_NAME"].ToString(); string nativeDbType = col["COLUMN_DATA_TYPE"].ToString(); int precision = (col["NUMERIC_PRECISION"] != DBNull.Value) ? Convert.ToInt32(col["NUMERIC_PRECISION"]) : 0; int scale = (col["NUMERIC_SCALE"] != DBNull.Value) ? Convert.ToInt32(col["NUMERIC_SCALE"]) : 0; bool isNullable = Convert.ToBoolean(col["IS_NULLABLE"]); int maxLength = Convert.ToInt32(col["COLUMN_SIZE"]); bool autoIncrement = false; string dbDefaultValue = col["COLUMN_DEFAULT"].ToString(); bool isPrimaryKeyPart = Convert.ToBoolean(col["IsPrimaryKey"]); bool isForeignKeyPart = Convert.ToBoolean(col["IsForeignKey"]); bool isUniqueConstraintPart = false; bool isAutoGenerated = false; string sequenceName = null; TableField field = new TableField(table, columnName, classItemTemplate, nativeDbType, typeTemplate, precision, scale, isNullable, indexInParentTable, autoIncrement, dbDefaultValue, maxLength, isPrimaryKeyPart, isForeignKeyPart, isUniqueConstraintPart, isAutoGenerated, sequenceName); return field; }
public object Any(TableField request) { var signature = this.Request.Headers.GetValues("Signature"); if (signature != null) { if (auth.AuthResult(signature[0].ToString(), this.Request.RawUrl)) { TableFieldResponse[] tfr = tableFieldLogic.ShowResponse(request); return tfr; } } return new AuthFaildResponse { strResult = "No Authentication." }; }