Beispiel #1
0
        /// <summary>
        ///   does first example already exist in the list specified by listType.
        /// </summary>
        /// <param name="firstExample">first example to compare</param>
        /// <param name="listType">type of list</param>
        /// <returns>is cop flag</returns>
        public bool IsCopLocation(
            string location,
            IJnyId jnyId,
            LocalListType listType)
        {
            switch (listType)
            {
            case LocalListType.allPurpose:
                this.LoadAllPurposeList(jnyId.Date.Year.ToString());
                foreach (FirstExampleType example in m_listLocation)
                {
                    if (location == example.Item &&
                        jnyId.Date == example.Date &&
                        jnyId.JnyNumber == example.Index)
                    {
                        return(true);
                    }
                }

                return(false);

            case LocalListType.complete:
                foreach (FirstExampleType example in m_completeListLocation)
                {
                    if (location == example.Item &&
                        jnyId.Date == example.Date &&
                        jnyId.JnyNumber == example.Index)
                    {
                        return(true);
                    }
                }

                return(false);

            case LocalListType.annual:
                foreach (FirstExampleType example in m_annualListLocation)
                {
                    if (location == example.Item &&
                        jnyId.Date == example.Date &&
                        jnyId.JnyNumber == example.Index)
                    {
                        return(true);
                    }
                }

                return(false);

            default:
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// Calculate the location state
 /// </summary>
 /// <param name="location">location to check</param>
 /// <param name="id">journey id</param>
 /// <param name="firstExamples">first example manager</param>
 /// <returns>current location state</returns>
 private ComponentState CalculateLocationState(
     string location,
     IJnyId id,
     FirstExampleManager firstExamples)
 {
     if (firstExamples.IsCopLocation(location, id, LocalListType.complete))
     {
         return(ComponentState.Cop);
     }
     else if (firstExamples.IsCopLocation(location, id, LocalListType.annual))
     {
         return(ComponentState.CopYear);
     }
     else
     {
         return(ComponentState.None);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Calculate the unit state
        /// </summary>
        /// <param name="unit">unit to check</param>
        /// <param name="id">journey id</param>
        /// <param name="firstExamples">first example manager</param>
        /// <param name="parent">
        /// Used where this journey is set against a specific unit. This is the id of that unit
        /// </param>
        /// <returns>current unit state</returns>
        private ComponentState CalculateUnitState(
            string unit,
            IJnyId id,
            FirstExampleManager firstExamples,
            string parent)
        {
            if (string.Compare(unit, parent) == 0)
            {
                return(ComponentState.CurrentUnit);
            }

            if (firstExamples.IsCopNumber(unit, id, LocalListType.complete))
            {
                return(ComponentState.Cop);
            }
            else if (firstExamples.IsCopNumber(unit, id, LocalListType.annual))
            {
                return(ComponentState.CopYear);
            }
            else
            {
                return(ComponentState.None);
            }
        }