internal Field GetFieldRef(DrwgProps props, FieldName fieldName) { string fn = fieldName.ToString(); return((Field)props.GetPropertyValue(fn)); //switch (fieldName) //{ // case FieldName.None: // return new Field.Empty(); // case FieldName.Number: // return props.Number; // case FieldName.Title: // return props.Title; // case FieldName.Revision: // return props.Revision; // case FieldName.Scale: // return props.Scale; // case FieldName.Date: // return props.Date; // case FieldName.RevisionDate: // return props.RevisionDate; // case FieldName.DrawingListCategory: // return props.DrawingListCategory; // case FieldName.FileNameFormat: // return props.FileNameFormat; // case FieldName.Selected: // throw new NotImplementedException(); // case FieldName.Extension: // return props.FileNameFormat; // default: // return new Field.Empty(); //} }
internal string GetValue(DrwgProps props, FieldName fieldName) { string fn = fieldName.ToString(); return((string)props.GetPropertyValue(fn)); //switch (fieldName) //{ // case FieldName.None: // return ""; //case FieldName.Number: // return props.Number.Value; //case FieldName.Title: // return props.Title.Value; //case FieldName.Revision: // return props.Revision.Value; //case FieldName.Scale: // return props.Scale.Value; //case FieldName.Date: // return props.Date.Value; //case FieldName.RevisionDate: // return props.RevisionDate.Value; //case FieldName.DrawingListCategory: // return props.DrawingListCategory.Value; //case FieldName.FileNameFormat: // return props.FileNameFormat.Value; //case FieldName.Selected: // throw new NotImplementedException(); //case FieldName.Extension: // return props.FileNameFormat.Value; //default: // return ""; //} }
internal void AddStateToGridView(Drwg drwg, DrwgProps props, DataTable data) { HashSet <DataRow> foundRows = GetRowsBySelectQuery(props, data, true); foreach (DataRow row in foundRows) { row["State"] = (int)drwg.State; } }
/// <summary> /// Retrieves datarows from supplied datatable based on values stored in props. Props are used to get the fields. /// </summary> /// <typeparam name="T">DataTable or DataSet.</typeparam> /// <param name="props">Data values -- must be populated!</param> /// <param name="Data">Data to search.</param> /// <param name="includeTitleFieldInSelectExpression">If searchin from file name data, exclude title, as the filenmae titles are not corresponding</param> /// <returns></returns> private HashSet <DataRow> GetRowsBySelectQuery <T>(DrwgProps props, T Data, bool includeTitleFieldInSelectExpression) { HashSet <DataRow> foundRows = new HashSet <DataRow>(); //Build expression to use Table.Select string number = props.Number.Value; string title = props.Title.Value.Replace("'", "''"); string rev = props.Revision.Value; List <string> exprlist = new List <string>(); exprlist.Add($"[{fs.Number.ColumnName}] = '{number}'"); if (includeTitleFieldInSelectExpression) { exprlist.Add($"[{fs.Title.ColumnName}] = '{title}'"); } if (!rev.IsNullOrEmpty()) { exprlist.Add($"[{fs.Revision.ColumnName}] = '{rev}'"); } string expr = string.Join(" AND ", exprlist); if (Data is DataSet dataSet) { foreach (DataTable table in dataSet.Tables) { DataRow[] result = table.Select(expr); HashSet <DataRow> newSet = new HashSet <DataRow>(result); foundRows.UnionWith(newSet); } } else if (Data is DataTable table) { DataRow[] result = table.Select(expr); HashSet <DataRow> newSet = new HashSet <DataRow>(result); foundRows.UnionWith(newSet); } return(foundRows); }
public Extension(string value, DrwgProps props) : this() { Value = value; PropsRef = props; }
public Title(string value, DrwgProps props) : this() { Value = value; PropsRef = props; }
public Number(string value, DrwgProps props) : this() { Value = value; PropsRef = props; }
public FileNameFormat(string value, DrwgProps props) : this() { Value = value; PropsRef = props; }
public DrawingListCategory(string value, DrwgProps props) : this() { Value = value; PropsRef = props; }
public RevisionDate(string value, DrwgProps props) : this() { Value = value; PropsRef = props; }