protected IList <T> GetListEntryStatictisc( String Qulification, Nullable <UInt32> TargetFieldId, ARStatictisc ARStat, PropertyFilterDelegate2 filter ) { ModelMeteData <T> metaData = new ModelMeteData <T>(); metaData.FormName = _metaProvider.GetFormNameFromModelType(); var props = _metaProvider.GetPropertyInfoes( BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Instance, filter ); metaData.Properties = new List <PropertyAndField <T> >(); foreach (var p in props) { if ((p.AccessLevel & ModelBinderAccessLevel.OnlyBind) == ModelBinderAccessLevel.OnlyBind) { metaData.Properties.Add(p); } } return(GetListEntryStatictisc(ARStat, Qulification, TargetFieldId, metaData)); }
public List <ARGroupByStatictisc> GetEntryListStatictisc( String SchemaName, String Qulification, ARStatictisc ARStat, Nullable <UInt32> TargetFieldId, List <UInt32> GroupbyFieldIdList ) { CheckSessionNull(); if (ARStat != ARStatictisc.STAT_OP_COUNT && TargetFieldId == null) { throw new ArgumentNullException("TargetFieldId can not be null while ARStat is not COUNT"); } return(SessionInstance.GetListEntryStatictisc(SchemaName, Qulification, ARStat, TargetFieldId, GroupbyFieldIdList == null ? null : GroupbyFieldIdList.ToArray() )); }
/// <summary> /// GetListEntryStatictisc function /// the return value is the model list, but have the two situation: /// 1.GroupbyFieldIdList is null or count is 0 /// the return list must have one entry,no field will be bind into the entry , the result is stored in base class(ARBaseForm)'s Statictis /// 2. /// the return list may have more than one entry, group by field will be bind to each entry, and the result is stored in base class(ARBaseForm)'s Statictis /// note : the result is object , but mostly the actual type is double,don't forget to Convert /// </summary> /// <param name="SchemaName"></param> /// <param name="Qulification"></param> /// <param name="ARStat"></param> /// <param name="TargetFieldId"></param> /// <param name="Properties"></param> /// <returns></returns> public IList <T> GetListEntryStatictisc( String Qulification, Nullable <UInt32> TargetFieldId, IEnumerable <string> Properties, ARStatictisc ARStat ) { List <string> valid = new List <string>(Properties); return(GetListEntryStatictisc(Qulification, TargetFieldId, ARStat, delegate(PropertyInfo pi) { if (pi == null) { throw new ArgumentNullException("pi"); } return valid.Contains(pi.Name); } )); }
public List<ARGroupByStatictisc> GetEntryListStatictisc( String SchemaName, String Qulification, ARStatictisc ARStat, Nullable<UInt32> TargetFieldId, List<UInt32> GroupbyFieldIdList ) { CheckSessionNull(); if(ARStat != ARStatictisc.STAT_OP_COUNT && TargetFieldId == null) throw new ArgumentNullException("TargetFieldId can not be null while ARStat is not COUNT"); return SessionInstance.GetListEntryStatictisc(SchemaName, Qulification, ARStat, TargetFieldId, GroupbyFieldIdList == null ? null : GroupbyFieldIdList.ToArray() ); }
//formname //Properties // FieldId // DataType // Setter null|not null public IList <T> GetListEntryStatictisc( ARStatictisc ARStat, String Qulification, Nullable <UInt32> TargetFieldId, ModelMeteData <T> MetaData ) { //tagetfiledid must not null if ARStat is not count if (TargetFieldId == null && ARStat != ARStatictisc.STAT_OP_COUNT) { throw new InvalidOperationException("TargetFieldId must not null if ARStat is not COUNT"); } List <ARGroupByStatictisc> raw_entries = null; List <T> models = new List <T>(); Dictionary <uint, PropertyAndField <T> > mapps = new Dictionary <uint, PropertyAndField <T> >(); if (MetaData.Properties == null || MetaData.Properties.Count == 0) { raw_entries = loginContext.ServerInstance.GetEntryListStatictisc(MetaData.FormName, Qulification, ARStat, TargetFieldId, null); T model = Activator.CreateInstance <T>(); if (!(model is ARBaseForm)) { throw new InvalidCastException("T must be inherit from ARBaseForm so that Statictisc operation can be cast."); } model.Statictisc = raw_entries[0].Statictisc; models.Add(model); return(models); } List <uint> fil = new List <uint>(); foreach (var prop in MetaData.Properties) { fil.Add(prop.DatabaseId); mapps.Add(prop.DatabaseId, prop); } raw_entries = loginContext.ServerInstance.GetEntryListStatictisc(MetaData.FormName, Qulification, ARStat, TargetFieldId, fil); if (raw_entries == null) { return(null); } foreach (var raw in raw_entries) { T model = Activator.CreateInstance <T>(); var enumer1 = mapps.GetEnumerator(); var enumer2 = raw.GroupByValues.GetEnumerator(); while (enumer1.MoveNext() && enumer2.MoveNext()) { enumer1.Current.Value.SetValueC(model, enumer2.Current); model.Statictisc = raw.Statictisc; } models.Add(model); } return(models); }
/// <summary> /// GetListEntryStatictisc function /// the return value is the model list, but have the two situation: /// 1.GroupbyFieldIdList is null or count is 0 /// the return list must have one entry,no field will be bind into the entry , the result is stored in base class(ARBaseForm)'s Statictis /// 2. /// the return list may have more than one entry, group by field will be bind to each entry, and the result is stored in base class(ARBaseForm)'s Statictis /// note : the result is object , but mostly the actual type is double,don't forget to Convert /// </summary> /// <param name="SchemaName"></param> /// <param name="Qulification"></param> /// <param name="ARStat"></param> /// <param name="TargetFieldId"></param> /// <param name="GroupbyFieldIdList"></param> /// <returns></returns> public IList <T> GetListEntryStatictisc( String Qulification, ARStatictisc ARStat, Nullable <UInt32> TargetFieldId, List <UInt32> GroupbyFieldIdList ) { string formName = _metaProvider.GetFormNameFromModelType(); ModelMeteData <T> metaData = new ModelMeteData <T>(); if (GroupbyFieldIdList != null) { var properties = _metaProvider.GetPropertyInfoes(BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.Instance, null); List <PropertyAndField <T> > props = new List <PropertyAndField <T> >(); foreach (var p in properties) { if (GroupbyFieldIdList.Find(delegate(UInt32 arfv) { return(arfv == p.DatabaseId); }) != 0) { props.Add(p); } } metaData.Properties = props; } metaData.FormName = formName; return(GetListEntryStatictisc(ARStat, Qulification, TargetFieldId, metaData)); ////tagetfiledid must not null if ARStat is not count //if (TargetFieldId == null && ARStat != ARStatictisc.STAT_OP_COUNT) // throw new InvalidOperationException("TargetFieldId must not null if ARStat is not COUNT"); //string formName = _metaProvider.GetFormNameFromModelType(); //List<ARGroupByStatictisc> result = loginContext.ServerInstance.GetEntryListStatictisc( // formName, // Qulification, // ARStat, // TargetFieldId, // GroupbyFieldIdList); //List<T> models = new List<T>(); ////if GroupbyFieldIdList is null, the result must only one row ////tagetfiledid can be ignore //if (GroupbyFieldIdList == null || GroupbyFieldIdList.Count == 0) //{ // T model = Activator.CreateInstance<T>(); // if (!(model is ARBaseForm)) // throw new InvalidCastException("T must be inherit from ARBaseForm so that Statictisc operation can be cast."); // (model as ARBaseForm).Statictisc = result[0].Statictisc; // models.Add(model); //} ////else GroupbyFieldIdList is not null,the result may have rows more than 1 ////and targetfieldid can be ignore //else //{ // //store the arid and artype map // Dictionary<uint, ARType> idmaptype = new Dictionary<uint, ARType>(); // foreach (ARGroupByStatictisc g in result) // { // T model = Activator.CreateInstance<T>(); // List<ARFieldValue> fv = new List<ARFieldValue>(); // for (int i = 0; i < g.GroupByValues.Count; i++) // { // if (!idmaptype.ContainsKey(GroupbyFieldIdList[i])) // idmaptype.Add(GroupbyFieldIdList[i], _metaProvider.GetARTypeFromFieldId(typeof(T),GroupbyFieldIdList[i])); // fv.Add(new ARFieldValue(GroupbyFieldIdList[i], g.GroupByValues[i], (ARDataType)idmaptype[GroupbyFieldIdList[i]])); // } // //bind model property from groupvalues // model = binder.Bind(fv); // //add statictisc result to the ARBaseForm // if (!(model is ARBaseForm)) // throw new InvalidCastException("T must be inherit from ARBaseForm so that Statictisc operation can be cast."); // (model as ARBaseForm).Statictisc = g.Statictisc; // models.Add(model); // } //} //return models; }