Exemplo n.º 1
0
 private ConditionExpression GetCondition(Schema.Domain.Attribute attr, object keyword, string entityAlias = "")
 {
     //数字类型
     if (keyword.ToString().IsNumeric() && (attr.TypeIsInt() ||
                                            attr.TypeIsFloat() ||
                                            attr.TypeIsDecimal() ||
                                            attr.TypeIsMoney() ||
                                            attr.TypeIsSmallMoney() ||
                                            attr.TypeIsSmallInt()
                                            ))
     {
         return(new ConditionExpression(GetSearchName(attr, entityAlias), GetConditionOperator(attr), keyword));
     }
     //日期类型
     else if ((attr.TypeIsDateTime() ||
               attr.TypeIsSmallDateTime()
               ))
     {
         if (DateTime.TryParse(keyword.ToString(), out DateTime d))
         {
             return(new ConditionExpression(GetSearchName(attr, entityAlias), GetConditionOperator(attr), keyword));
         }
     }
     //guid类型
     else if (attr.TypeIsPrimaryKey() ||
              attr.TypeIsLookUp() ||
              attr.TypeIsOwner() ||
              attr.TypeIsCustomer())
     {
         if (keyword.ToString().IsGuid())
         {
             return(new ConditionExpression(attr.Name, GetConditionOperator(attr), keyword));
         }
         return(new ConditionExpression(GetSearchName(attr, entityAlias), ConditionOperator.Like, keyword));
     }
     //选项类型
     else if ((attr.TypeIsState() ||
               attr.TypeIsBit() ||
               attr.TypeIsPickList() || attr.TypeIsStatus()))
     {
         if (keyword.ToString().IsInteger())//如果是数值
         {
             return(new ConditionExpression(entityAlias.IsEmpty() ? attr.Name : entityAlias + "." + attr.Name, GetConditionOperator(attr), keyword));
         }
         else
         {
             //按名称查找选项值
             //...
             if (attr.TypeIsState() || attr.TypeIsBit())
             {
                 if (attr.PickLists.IsEmpty())
                 {
                     attr.PickLists = _stringMapFinder.Query(n => n.Where(f => f.AttributeId == attr.AttributeId));
                 }
                 var value = attr.PickLists.Find(n => n.Name.IsCaseInsensitiveEqual(keyword.ToString()));
                 if (null != value)
                 {
                     keyword = value.Value;
                 }
             }
             else if (attr.TypeIsPickList() || attr.TypeIsStatus())
             {
                 if (attr.OptionSet == null)
                 {
                     attr.OptionSet = new OptionSet();//_optionSetFinder.FindById(attr.OptionSetId.Value);
                 }
                 var value = attr.OptionSet.Items.Find(n => n.Name.IsCaseInsensitiveEqual(keyword.ToString()));
                 if (null != value)
                 {
                     keyword = value.Value;
                 }
             }
         }
         //if (keyword.ToString().IsInteger())
         //{
         //    return new ConditionExpression(attr.Name, ConditionOperator.Equal, keyword);
         //}
     }
     //字符串类型
     else if ((attr.TypeIsNvarchar() ||
               attr.TypeIsVarchar() ||
               attr.TypeIsChar()))
     {
         return(new ConditionExpression(GetSearchName(attr, entityAlias), GetConditionOperator(attr), keyword));
     }
     return(null);
 }
Exemplo n.º 2
0
        //private void ToExcel(QueryView.Domain.QueryView queryView, FilterExpression filter, OrderExpression order, string fileName, bool includePrimaryKey = false, bool includeIndex = false, string title = "")
        //{
        //}

        private void SetCellValue(ICell cell, object value, Schema.Domain.Attribute attr)
        {
            if (value != null)
            {
                if (attr != null && (attr.TypeIsMoney() || attr.TypeIsSmallMoney() || attr.TypeIsFloat() || attr.TypeIsDecimal() || attr.TypeIsInt() || attr.TypeIsSmallInt()))
                {
                    cell.SetCellValue(double.Parse((string)value));
                    cell.SetCellType(CellType.Numeric);
                }
                else
                {
                    cell.SetCellValue((string)value);
                }
            }
            else
            {
                cell.SetCellValue(string.Empty);
            }
        }