Example #1
0
        private static RevisionDataFields UpdateCodes(RevisionDataFields df)
        {
            df.OrderCode.TypeCode       = GetTypeSortCode(df.DeltaTitle);
            df.OrderCode.DisciplineCode = GetDisciplineSortCode(df.ShtNum);

            return(df);
        }
        // compare one row versus the filters
        public static bool Evaluate(RevisionDataFields items, RevisionFilters filters)
        {
            // scan through the list of filter tests to determine if
            // the provided information passes
            // return true if this item meets all of the criteria
            // return false if any part of this item does not meet the criteria

            if (filters == null || items == null)
            {
                throw new ArgumentNullException();
            }

            if (filters.Count == 0 || items.Count == 0)
            {
                return(false);
            }

            bool result = false;

            // compare the data item referenced in the filter to the filter criteria
            // the filters are in a outer (data enum) order
            // each data item field could have multiple criteria filters
            // inner loop is an 'or' loop - that is, if any of the inner
            // filters are true, the whole inner filter is true.  for conflicts
            // that is, filtering the same item in opposite ways (e.g. is true and is false)
            // a true will supersede a false
            //
            // the outer loop is the opposite
            // it is an 'and' loop - a single false and the data row fails

            foreach (KeyValuePair <DataItems.FilterEnum, RevisionFilters.Filters> kvpOuter in filters)
            {
                foreach (KeyValuePair <int, RevisionFilters.Criteria> kvpInner in kvpOuter.Value)
                {
                    if (kvpInner.Value.CompareOpr == RevisionFilters.ECompareOps.ANY)
                    {
                        result = true;
                    }
                    else
                    {
                        // evaluate the actual revision data versus the test criteria
                        result = Verify(items[kvpOuter.Key.DataIdx], kvpInner.Value);
                    }

                    if (result)
                    {
                        break;
                    }
                }

                if (!result)
                {
                    break;
                }
            }

            return(result);
        }
Example #3
0
        private static void CompareCodes(RevisionDataFields df)
        {
            string typeCode = GetTypeSortCode(df.DeltaTitle);
            string discCode = GetDisciplineSortCode(df.ShtNum);

            Console.WriteLine("adjusting sort codes");
            Console.WriteLine("sheet number| " + df.ShtNum);
            Console.WriteLine("alt id| " + df.OrderCode.AltId);
            Console.WriteLine("type code current| " + df.OrderCode.TypeCode
                              + "  calc'd| " + typeCode
                              + "  match?| " + (typeCode == df.OrderCode.TypeCode ? "yes" : "*** no ***"));
            Console.WriteLine("disc code current| " + df.OrderCode.DisciplineCode
                              + "  calc'd| " + discCode
                              + "  match?| " + (discCode == df.OrderCode.DisciplineCode ? "yes" : "*** no ***"));
            Console.Write(nl);
        }
//		public static bool SortSelected(params ISortable[] d)
//		{
//			if (_selected.Count == 0) return false;
//
//			foreach (RevisionDataFields rdf in _selected)
//			{
//				string key = GetKey(rdf, d);
//
//				rdf.SortKey = key;
//			}
//
//			_selected.Sort();
//
//			return true;
//		}

        public static string GetKey(RevisionDataFields items,
                                    RevOrderMgr om)
        {
            string key = null;

            int i = 0;

            foreach (DataItems.ISortable so in om.SortOrder.Iterate())
            {
                DataItems.DataEnum d = ((DataItems.DataEnum)so);

                key += RevisionFormat.FormatForKey(items[d.DataIdx], d.Display);

                if (++i != om.SortOrder.Count)
                {
                    key += "|";
                }
            }

            return(key);
        }
Example #5
0
        // has two purposes:
        // translate the data read to the correct format
        // basically nothing for most
        // put the data in the correct order
        // [i] = is the order from the above
        // [j] = the correct order in the array
        private static RevisionDataFields MakeRevDataItem(dynamic[] items)
        {
            RevisionDataFields df = new RevisionDataFields();

            df.Order = count++;

            for (int i = 0; i < items.Length; i++)
            {
                DataItems.DataEnum d = xlate[i];
                int j = d.DataIdx;

                switch (i)
                {
                // selected
                case 0:
                {
                    df[j] = bool.Parse(items[i]);
                    break;
                }

                // rev order code
                case 2:
                {
                    RevOrderCode rc = new RevOrderCode();
                    rc.AltId = items[i++];
                    REV_SUB_ALTID.Display.DataWidth = rc.AltId.Length;

                    rc.TypeCode = items[i++];
                    REV_SUB_TYPE_CODE.Display.DataWidth = rc.TypeCode.Length;

                    rc.DisciplineCode = items[i];
                    REV_SUB_DISCIPLINE_CODE.Display.DataWidth = rc.DisciplineCode.Length;

                    df[j] = rc;

                    items[i] = rc;

                    break;
                }

                // sequence
                case 1:
                // tag elem id
                case 13:
                // cloud elem id
                case 14:
                {
                    df[j] = Int32.Parse(items[i]);
                    break;
                }

                // visibility
                case 7:
                {
                    df[j] = Enum.Parse(typeof(RevisionVisibility), items[i]);
                    break;
                }

                // date
                case 10:
                {
                    df[j] = DateTime.Parse(items[i]);
                    break;
                }

                default:                        // all else - string
                {
                    df[j] = items[i];
                    break;
                }
                }

                d.Display.DataWidth = (items[i]?.ToString() ?? "").Length;
            }

            // "fix" the type code and the disc code
            df = UpdateCodes(df);

//			CompareCodes(df);

            return(df);
        }