/// <summary> /// Convert a WebFactorField into an IFactorField instance. /// </summary> /// <param name="userContext"> /// Information about the user that makes this method call. /// </param> /// <param name="factorDataType">Factor data type that this factor field belongs to.</param> /// <param name="webFactorField">A WebFactorField instance.</param> /// <param name="factorFieldEnums">List of factor field enumerations.</param> /// <returns>An IFactorField instance.</returns> private IFactorField GetFactorField(IUserContext userContext, IFactorDataType factorDataType, WebFactorField webFactorField, FactorFieldEnumList factorFieldEnums) { Int32 factorFieldIndex; switch (webFactorField.DatabaseFieldName) { case "tal1": factorFieldIndex = 0; break; case "tal2": factorFieldIndex = 1; break; case "tal3": factorFieldIndex = 2; break; case "text1": factorFieldIndex = 3; break; case "text2": factorFieldIndex = 4; break; default: throw new ApplicationException("Unknown database field name = " + webFactorField.DatabaseFieldName); } IFactorField factorField = new FactorField { DataContext = GetDataContext(userContext), DatabaseFieldName = webFactorField.DatabaseFieldName, FactorDataType = factorDataType, Id = webFactorField.Id, Index = factorFieldIndex, Information = webFactorField.Information, IsMain = webFactorField.IsMain, IsSubstantial = webFactorField.IsSubstantial, Label = webFactorField.Label, Size = webFactorField.Size, Type = CoreData.FactorManager.GetFactorFieldType(userContext, webFactorField.TypeId), Unit = webFactorField.Unit }; if (webFactorField.IsEnumField) { factorField.Enum = factorFieldEnums.Get(webFactorField.EnumId); } return(factorField); }
/// <summary> /// Get factors with specified datatype. /// </summary> /// <param name="userContext"> /// Information about the user that makes this method call. /// </param> /// <param name="factorDataType">Factor datatype.</param> /// <returns>Factors with specified datatype.</returns> public virtual FactorList GetFactors(IUserContext userContext, IFactorDataType factorDataType) { FactorList allFactors, factors; // Check arguments. factorDataType.CheckNotNull("factorDataType"); allFactors = GetFactors(userContext); factors = new FactorList(); factors.AddRange(allFactors.FindAll(factor => factor.DataType.IsNotNull() && factor.DataType.Id == factorDataType.Id)); return(factors); }