示例#1
0
        /// <summary>
        /// Validate the criteria of a requested viewon and populate Errors in this instance with the problems found.
        /// </summary>
        public async Task ValidateCriteria(DatonDef datondef, ViewonKey viewonKey)
        {
            Errors = new List <string>();

            //built-in validation
            if (viewonKey.Criteria != null)
            {
                foreach (var cri in viewonKey.Criteria)
                {
                    var coldef = datondef.CriteriaDef.FindCol(cri.Name);
                    if (coldef == null)
                    {
                        Errors.Add("Unknown parameter: " + cri.Name);
                    }
                    else
                    {
                        ValidateCol(coldef, cri.PackedValue);
                    }
                }
            }

            //custom validation
            var tempViewon0 = Utils.Construct(datondef.Type);

            if (tempViewon0 is Viewon tempViewon)
            {
                await tempViewon.ValidateCriteria(User, viewonKey, message => Errors.Add(message));
            }
        }
示例#2
0
 /// <summary>
 /// Validate a viewon key; called on a temporary instance of the class, so the implementation should not expect any class members should be set.
 /// Implementations should call fail one or more times to register failures, passing user-readable messages
 /// </summary>
 public virtual Task ValidateCriteria(IUser user, ViewonKey key, Action <string> fail)
 {
     return(Task.CompletedTask);
 }
示例#3
0
        /// <summary>
        /// Get where clause for viewon main table
        /// </summary>
        protected virtual SqlSelectBuilder.Where MainTableWhereClause(TableDef tabledef, ViewonKey key)
        {
            var w = new SqlSelectBuilder.Where();

            foreach (var cri in key.Criteria)
            {
                var coldef = tabledef.FindCol(cri.Name);
                if (coldef != null)
                {
                    var crihelper = new ViewonCriterion(coldef, cri.PackedValue);
                    crihelper.ExportWhereClause(w, SqlFlavor);
                }
            }
            return(w);
        }