Beispiel #1
0
 /// <summary>
 /// 加载本次查询要返回的字段信息
 /// </summary>
 /// <param name="info"></param>
 internal override void LoadInfo(KeyWordInfomation info)
 {
     foreach (BQLParamHandle prm in parameters)
     {
         BQLValueItem.DoFillInfo(prm, info);
     }
 }
        ///// <summary>
        ///// 要插入的字段
        ///// </summary>
        //internal BQLParamHandle[] ParamHandles
        //{
        //    get
        //    {
        //        return paramHandles;
        //    }
        //}

        /// <summary>
        /// 值
        /// </summary>
        /// <param name="values">值</param>
        /// <returns></returns>
        public KeyWordInsertValueItem Values(params object[] values)
        {
            BQLValueItem[] vitems = new BQLValueItem[values.Length];
            for (int i = 0; i < values.Length; i++)
            {
                if (values[i] == null)
                {
                    vitems[i] = new BQLValueTypeItem(null);
                }
                else if (values[i] is BQLValueItem)
                {
                    vitems[i] = values[i] as BQLValueItem;
                }
                else if (values[i].GetType().IsEnum)
                {
                    vitems[i] = new BQLValueTypeItem((int)values[i]);
                }
                else
                {
                    vitems[i] = new BQLValueTypeItem(values[i]);
                }
            }
            KeyWordInsertValueItem valuesItem = new KeyWordInsertValueItem(vitems, this);

            return(valuesItem);
        }
 //private DbType convertType;
 public CsqConvertFunction(BQLValueItem value, DbType convertType, DelConvertFunction funHandle)
 {
     this.funHandle1   = funHandle;
     this.value        = value;
     this._valueDbType = convertType;
     //SetType(convertType);
 }
Beispiel #4
0
 /// <summary>
 /// 条件函数
 /// </summary>
 /// <param name="sourceHandle">发送源(字段)</param>
 /// <param name="query">查询</param>
 /// <param name="handle">关联处理函数</param>
 public BQLConditionItem(BQLParamHandle sourceHandle, BQLQuery query, DelConditionHandle handle)
 {
     this._sourceHandle = sourceHandle;
     this._handle       = handle;
     this._query        = query;
     this._valueDbType  = DbType.Boolean;
 }
Beispiel #5
0
 /// <summary>
 /// 条件函数
 /// </summary>
 /// <param name="sourceHandle">发送源(字段)</param>
 /// <param name="paramList">参数列表</param>
 /// <param name="handle">关联处理函数</param>
 public BQLConditionItem(BQLValueItem sourceHandle, IEnumerable paramList, DelConditionHandle handle)
 {
     this._sourceHandle = sourceHandle;
     this._handle       = handle;
     this._paramList    = paramList;
     this._valueDbType  = DbType.Boolean;
 }
Beispiel #6
0
 internal override void FillInfo(KeyWordInfomation info)
 {
     foreach (BQLValueItem item in values)
     {
         BQLValueItem.DoFillInfo(item, info);
     }
 }
 public CsqConvertFunction(BQLValueItem value, string format, DelConvertFunction2 funHandle)
 {
     this.funHandle2   = funHandle;
     this.value        = value;
     this._valueDbType = DbType.Object;
     this.format       = format;
 }
Beispiel #8
0
        /// <summary>
        /// 判断是否为空
        /// </summary>
        /// <param name="source">源值</param>
        /// <returns></returns>
        public static CsqCommonFunction Length(BQLValueItem source)
        {
            CsqCommonFunction handle = new CsqCommonFunction(new BQLValueItem[] { source }, DBCommonFunction.Len, DbType.Int32);

            //handle.ValueDataType = DefaultType.IntType;

            return(handle);
        }
Beispiel #9
0
 internal override void LoadInfo(KeyWordInfomation info)
 {
     //if (CommonMethods.IsNull(info.FromTable))
     //{
     //    info.FromTable = table;
     //}
     BQLValueItem.DoFillInfo(table, info);
 }
Beispiel #10
0
 internal override void LoadInfo(KeyWordInfomation info)
 {
     for (int i = 0; i < parameters.Length; i++)
     {
         BQLParamHandle prmHandle = parameters[i];
         BQLValueItem.DoFillInfo(prmHandle, info);
     }
 }
Beispiel #11
0
        /// <summary>
        /// 正切
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static CsqCommonFunction Tan(BQLValueItem value)
        {
            value.ValueDbType = DbType.Double;
            CsqCommonFunction handle = new CsqCommonFunction(new BQLValueItem[] { value }, DBMathFunction.DoTan, DbType.Double);

            //handle.ValueDataType = DefaultType.DoubleType;
            return(handle);
        }
Beispiel #12
0
        /// <summary>
        /// 反正弦函数
        /// </summary>
        /// <param name="value">弧度</param>
        /// <returns></returns>
        public static CsqCommonFunction Asin(BQLValueItem value)
        {
            value.ValueDbType = DbType.Double;
            CsqCommonFunction handle = new CsqCommonFunction(new BQLValueItem[] { value }, DBMathFunction.DoAsin, DbType.Double);

            //handle.ValueDbType = DbType.Double;
            return(handle);
        }
Beispiel #13
0
        /// <summary>
        /// 按位异或运算
        /// </summary>
        /// <param name="value1">数字1</param>
        /// <param name="value2">数字2</param>
        /// <returns></returns>
        public static CsqCommonFunction BitXOR(BQLValueItem value1, BQLValueItem value2)
        {
            value1.ValueDbType = DbType.Double;
            value2.ValueDbType = DbType.Double;
            CsqCommonFunction handle = new CsqCommonFunction(new BQLValueItem[] { value1, value2 }, DBMathFunction.BitXOR, DbType.Double);

            //handle.ValueDataType = DefaultType.DoubleType;
            return(handle);
        }
Beispiel #14
0
        /// <summary>
        /// 求任意数为底的幂
        /// </summary>
        /// <param name="value">数值</param>
        /// <param name="value2">几次方</param>
        /// <returns></returns>
        public static CsqCommonFunction Power(BQLValueItem value, BQLValueItem value2)
        {
            value.ValueDbType  = DbType.Double;
            value2.ValueDbType = DbType.Int32;
            CsqCommonFunction handle = new CsqCommonFunction(new BQLValueItem[] { value, value2 }, DBMathFunction.DoPower, DbType.Double);

            //handle.ValueDataType = DefaultType.DoubleType;
            return(handle);
        }
Beispiel #15
0
        /// <summary>
        /// 计算两个变量 x 和 y 的反正切值
        /// </summary>
        /// <param name="y">定点的 y 坐标</param>
        /// <param name="x">定点的 x 坐标</param>
        /// <returns></returns>
        public static CsqCommonFunction Atan2(BQLValueItem y, BQLValueItem x)
        {
            x.ValueDbType = DbType.Double;
            y.ValueDbType = DbType.Double;
            CsqCommonFunction handle = new CsqCommonFunction(new BQLValueItem[] { y, x }, DBMathFunction.DoAtan2, DbType.Double);

            //handle.ValueDataType = DefaultType.DoubleType;
            return(handle);
        }
 internal override void FillInfo(KeyWordInfomation info)
 {
     if (_values != null && _values.Length > 0)
     {
         foreach (BQLValueItem param in _values)
         {
             BQLValueItem.DoFillInfo(param, info);
         }
     }
 }
Beispiel #17
0
 internal override void LoadInfo(KeyWordInfomation info)
 {
     if (paramhandles != null && paramhandles.Count > 0) 
     {
         foreach (BQLParamHandle handle in paramhandles) 
         {
             BQLValueItem.DoFillInfo(handle, info);
         }
     }
     info.HasGroup = true;
 }
        public static DataSet Search(string[] searchs, PageContent objPage)
        {
            ScopeList lstScope = new ScopeList();

            lstScope.PageContent = objPage;
            double per = Math.Pow(2, searchs.Length);

            lstScope.ShowProperty.Add(Management.SampleInfo.SampleName.As("SampleName"));
            lstScope.ShowProperty.Add(Management.SampleInfo.SamplingTerrace.As("SamplingTerrace"));
            lstScope.ShowProperty.Add(Management.SampleInfo.SampleNumber.As("SampleNumber"));
            BQLValueItem perValue = BQLValueItem.ToValueItem(0);
            BQLCondition nameCon  = BQLCondition.FalseValue;

            foreach (string search in searchs)
            {
                nameCon  = nameCon | Management.SampleInfo.SampleName.Like(search);
                perValue = perValue + BQL.Case().When(BQL.ToParam("SampleName").IndexOf(search, 0) <= 0).Then(0).Else(1).End *per;
                per     /= 2;
            }
            lstScope.ShowProperty.Add(perValue.As("per1"));
            lstScope.Add(nameCon);
            lstScope.OrderBy.Add(perValue.As("").DESC);

            per      = Math.Pow(2, searchs.Length);
            perValue = BQLValueItem.ToValueItem(0);
            nameCon  = BQLCondition.FalseValue;
            foreach (string search in searchs)
            {
                nameCon  = nameCon | Management.SampleInfo.SamplingTerrace.Like(search);
                perValue = perValue + BQL.Case().When(BQL.ToParam("SamplingTerrace").IndexOf(search, 0) <= 0).Then(0).Else(1).End *per;
                per     /= 2;
            }
            lstScope.ShowProperty.Add(perValue.As("per2"));
            lstScope.Add(nameCon, ConnectType.OR);
            lstScope.OrderBy.Add(perValue.As("").DESC);

            per      = Math.Pow(2, searchs.Length);
            perValue = BQLValueItem.ToValueItem(0);
            nameCon  = BQLCondition.FalseValue;
            foreach (string search in searchs)
            {
                nameCon  = nameCon | Management.SampleInfo.SampleNumber.Like(search);
                perValue = perValue + BQL.Case().When(BQL.ToParam("SampleNumber").IndexOf(search, 0) <= 0).Then(0).Else(1).End *per;
                per     /= 2;
            }
            lstScope.ShowProperty.Add(perValue.As("per3"));
            lstScope.Add(nameCon, ConnectType.OR);
            lstScope.OrderBy.Add(perValue.As("").DESC);

            //lstScope.OrderBy.Add(BQL.ToParam("per1").DESC);
            //lstScope.OrderBy.Add(BQL.ToParam("per2").DESC);
            //lstScope.OrderBy.Add(BQL.ToParam("per3").DESC);
            return(GetContext().Select(lstScope));
        }
Beispiel #19
0
        /// <summary>
        /// 取模运算
        /// </summary>
        /// <param name="value">弧度</param>
        /// <returns></returns>
        public static BQLOperatorHandle MathMod(object value1, object value2)
        {
            BQLValueItem oValue1 = BQLValueItem.ToValueItem(value1);
            BQLValueItem oValue2 = BQLValueItem.ToValueItem(value2);

            BQLValueItem.UnityDbType(oValue1, oValue2);

            BQLOperatorHandle fHandle = new BQLOperatorHandle(FunctionManager.DoMod, new BQLValueItem[] { oValue1, oValue2 });

            //fHandle.PriorityLevel = 3;
            fHandle.PriorityLevel = OperatorPrecedenceUnit.GetPrecedence("%");
            return(fHandle);
        }
Beispiel #20
0
        //private static BQLAlias _alias = new BQLAlias();
        ///// <summary>
        ///// 别名函数
        ///// </summary>
        //protected static BQLAlias ALIAS
        //{
        //    get
        //    {
        //        return _alias;
        //    }
        //}
        #endregion

        #region 常用函数

        //ICommonFunction common = DbAdapterLoader.Common;
        /// <summary>
        /// 判断是否为空
        /// </summary>
        /// <param name="source">源值</param>
        /// <param name="nullValue">如果为空的话的输出值</param>
        /// <returns></returns>
        public static CsqCommonFunction IsNull(BQLValueItem source, BQLValueItem nullValue)
        {
            CsqCommonFunction handle = new CsqCommonFunction(new BQLValueItem[] { source, nullValue }, DBCommonFunction.IsNull, source.ValueDbType);

            if (!CommonMethods.IsNull(nullValue))
            {
                handle.ValueDbType = nullValue.ValueDbType;
            }
            else if (!CommonMethods.IsNull(source))
            {
                handle.ValueDbType = source.ValueDbType;
            }
            return(handle);
        }
Beispiel #21
0
 internal override void FillInfo(KeyWordInfomation info)
 {
     BQLValueItem.DoFillInfo(_sourceHandle, info);
     if (_paramList != null)
     {
         List <BQLValueItem> lst = new List <BQLValueItem>();
         foreach (object item in _paramList)
         {
             BQLValueItem value = BQLValueItem.ToValueItem(item);
             lst.Add(value);
             BQLValueItem.DoFillInfo(value, info);
         }
         _paramList = lst;
     }
 }
Beispiel #22
0
        ///// <summary>
        ///// 查询范围
        ///// </summary>
        ///// <param name="star">开始条数(从0开始)</param>
        ///// <param name="totalRecord">显示条数</param>
        ///// <returns></returns>
        //public KeyWordLimitItem Limit(uint star, uint totalRecord)
        //{
        //    KeyWordLimitItem item = new KeyWordLimitItem(star, totalRecord, this);
        //    return item;
        //}

        /// <summary>
        /// 加载表的别名信息
        /// </summary>
        /// <param name="info"></param>
        internal override void LoadInfo(KeyWordInfomation info)
        {
            foreach (BQLTableHandle tab in _tables)
            {
                if (CommonMethods.IsNull(info.FromTable))
                {
                    BQLEntityTableHandle etab = tab as BQLEntityTableHandle;
                    if (!CommonMethods.IsNull(etab))
                    {
                        info.FromTable = etab;
                    }
                }
                BQLValueItem.DoFillInfo(tab, info);
            }
        }
Beispiel #23
0
        public override string ToString()
        {
            BQLValueItem qvalue = value1 as BQLValueItem;

            if (!CommonMethods.IsNull(qvalue))
            {
                return(qvalue.DisplayValue(BQLValueItem.GetKeyInfo()));
            }
            else
            {
                string pName = propertyName;

                DbType dbType = DbType.AnsiString;
                if (value1 != null)
                {
                    dbType = DefaultType.ToDbType(value1.GetType());
                }
                return(DataAccessCommon.FormatScorp(this, null, pName, dbType, 0, null));
            }

            return(base.ToString());
        }
Beispiel #24
0
 internal override string DisplayValue(KeyWordInfomation info)
 {
     if (_handle != null)
     {
         if (_query != null)
         {
             KeyWordConver     conver = new KeyWordConver();
             KeyWordInfomation qInfo  = info.Clone() as KeyWordInfomation;
             return("(" + _handle(_sourceHandle.DisplayValue(info), new string[] { conver.ToConver(_query, qInfo).GetSql(false) }, info.DBInfo) + ")");
         }
         else if (_paramList != null)
         {
             List <string> lstPrm = new List <string>();
             foreach (object item in _paramList)
             {
                 lstPrm.Add(BQLValueItem.ToValueItem(item).DisplayValue(info));
             }
             return("(" + _handle(_sourceHandle.DisplayValue(info), lstPrm.ToArray(), info.DBInfo) + ")");
         }
     }
     return(null);
 }
        internal override void Tran(KeyWordInfomation info)
        {
            StringBuilder condition    = new StringBuilder();
            List <DbType> lstParamType = info.Condition.ParamTypes;

            for (int i = 0; i < valueHandles.Length; i++)
            {
                BQLValueItem vItem = valueHandles[i];
                if (lstParamType != null && lstParamType.Count > i)
                {
                    vItem.ValueDbType = lstParamType[i];
                }
                condition.Append(vItem.DisplayValue(info));
                condition.Append(',');
            }
            condition.Append(IdentityValueString(info));
            if (condition.Length > 0)
            {
                condition.Remove(condition.Length - 1, 1);
            }
            info.Condition.SqlValues.Append(condition.ToString());
            //return " values (" + condition.ToString()+")";
        }
Beispiel #26
0
 /// <summary>
 /// 添加一个set项
 /// </summary>
 /// <param name="parameter">字段</param>
 /// <param name="valueItem">值</param>
 /// <returns></returns>
 public KeyWordUpdateSetItem _(BQLParamHandle parameter, BQLValueItem valueItem)
 {
     lstItems.Add(parameter, valueItem);
     return(this);
 }
Beispiel #27
0
 /// <summary>
 /// Set关键字项
 /// </summary>
 /// <param name="parameter">要更新的字段</param>
 /// <param name="valueItem">值</param>
 /// <param name="previous">上一个</param>
 public KeyWordUpdateSetItem(BQLParamHandle parameter, BQLValueItem valueItem, BQLQuery previous)
     : base(previous)
 {
     lstItems = new UpdateSetParamItemList();
     lstItems.Add(parameter, valueItem);
 }
Beispiel #28
0
 /// <summary>
 /// Set关键字更新的项
 /// </summary>
 /// <param name="tables">表集合</param>
 /// <param name="previous">上一个关键字</param>
 internal UpdateSetParamItem(BQLParamHandle parameter, BQLValueItem valueItem)
 {
     this.parameter = parameter;
     this.valueItem = valueItem;
 }
Beispiel #29
0
        /// <summary>
        /// 添加一个set项
        /// </summary>
        /// <param name="parameter">字段</param>
        /// <param name="valueItem">值</param>
        /// <returns></returns>
        public KeyWordUpdateSetItem Set(BQLParamHandle parameter, BQLValueItem valueItem)
        {
            KeyWordUpdateSetItem item = new KeyWordUpdateSetItem(parameter, valueItem, this);

            return(item);
        }
 /// <summary>
 /// 添加一个更新项
 /// </summary>
 /// <param name="parameter">更新项的字段</param>
 /// <param name="valueItem">更新值</param>
 public void Add(BQLParamHandle parameter, BQLValueItem valueItem)
 {
     this.Add(new UpdateSetParamItem(parameter, valueItem));
 }