Exemplo n.º 1
0
        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();
            //}
        }
Exemplo n.º 2
0
        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 "";
            //}
        }
Exemplo n.º 3
0
        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;
            }
        }
Exemplo n.º 4
0
        /// <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);
        }
Exemplo n.º 5
0
 public Extension(string value, DrwgProps props) : this()
 {
     Value = value; PropsRef = props;
 }
Exemplo n.º 6
0
 public Title(string value, DrwgProps props) : this()
 {
     Value = value; PropsRef = props;
 }
Exemplo n.º 7
0
 public Number(string value, DrwgProps props) : this()
 {
     Value = value; PropsRef = props;
 }
Exemplo n.º 8
0
 public FileNameFormat(string value, DrwgProps props) : this()
 {
     Value = value; PropsRef = props;
 }
Exemplo n.º 9
0
 public DrawingListCategory(string value, DrwgProps props) : this()
 {
     Value = value; PropsRef = props;
 }
Exemplo n.º 10
0
 public RevisionDate(string value, DrwgProps props) : this()
 {
     Value = value; PropsRef = props;
 }