Ejemplo n.º 1
0
        /// <summary>
        /// Evaluates a <see cref="ComplexCondition"/>
        /// </summary>
        /// <param name="condition">The <see cref="ComplexCondition"/> to evaluate</param>
        /// <returns></returns>
        private static bool EvaluateComplexCondition(ComplexCondition condition)
        {
            // evalute children
            var evaluationResults = new List <bool>();

            foreach (var child in condition.Children)
            {
                evaluationResults.Add(Evaluate(child));
            }

            // initial result is first child evaluation
            var result = evaluationResults.First();

            // continue with other child evaluations according to logic operators between them
            for (int i = 0; i < condition.LogicOperators.Count; i++)
            {
                switch (condition.LogicOperators[i])
                {
                case "AND": result &= evaluationResults[i + 1]; break;

                case "OR": result |= evaluationResults[i + 1]; break;

                case "XOR": result ^= evaluationResults[i + 1]; break;
                }
            }

            return(result);
        }
Ejemplo n.º 2
0
        private string CompileCondition(ComplexCondition condition)
        {
            List <string> parts = new List <string>();

            foreach (NotEmptyCondition innerCondition in condition.innerConditions)
            {
                parts.Add("(" + CompileCondition(innerCondition) + ")");
            }

            switch (condition.type)
            {
            case ConditionsJoinType.AND:
                return(string.Join(" AND ", parts.ToArray()));

            case ConditionsJoinType.OR:
                return(string.Join(" OR ", parts.ToArray()));

            default:
                throw new NotSupportedException();
            }
        }
Ejemplo n.º 3
0
        void InitServerByDatabase()
        {
            try
            {
                using (var dataReader = DataHelper.Instance.ExecuteProcedureReader("InitServer", DataHelper.CreateParam("@TYPE", System.Data.SqlDbType.Int, 1)))
                {
                    if (dataReader == null)
                    {
                        Environment.Exit(0);
                    }
                    //dataReader.Read();
                    dataReader.Read();
                    int count = dataReader.GetInt32(0);
                    _list    = new List <TagMetaData>(count);
                    _mapping = new Dictionary <string, ITag>(count);
                    dataReader.NextResult();
                    while (dataReader.Read())
                    {
                        _list.Add(new TagMetaData(dataReader.GetInt16(0), dataReader.GetInt16(1), dataReader.GetString(2), dataReader.GetString(3), (DataType)dataReader.GetByte(4),
                                                  (ushort)dataReader.GetInt16(5), dataReader.GetBoolean(6), dataReader.GetFloat(7), dataReader.GetFloat(8), dataReader.GetInt32(9)));
                        //_list[i].Description = dataReader.GetSqlString(6).Value;
                    }
                    _list.Sort();
                    if (reader != null && group == null)
                    {
                        group = reader.AddGroup("Group1", 1, 0, 0, true) as ClientGroup;
                        group.AddItems(_list);
                    }
                    dataReader.NextResult();
                    _conditions    = new List <ICondition>();
                    _conditionList = new ObservableCollection <ICondition>();
                    while (dataReader.Read())
                    {
                        int        id   = dataReader.GetInt32(0);
                        AlarmType  type = (AlarmType)dataReader.GetInt32(2);
                        ICondition cond;
                        string     source = dataReader.GetString(1);
                        if (_conditions.Count > 0)
                        {
                            cond = _conditions[_conditions.Count - 1];
                            if (cond.ID == id)
                            {
                                cond.AddSubCondition(new SubCondition((SubAlarmType)dataReader.GetInt32(9), dataReader.GetFloat(10),
                                                                      (Severity)dataReader.GetByte(11), dataReader.GetString(12), dataReader.GetBoolean(13)));
                                continue;
                            }
                        }
                        switch (type)
                        {
                        case AlarmType.Complex:
                            cond = new ComplexCondition(id, source, dataReader.GetString(6), dataReader.GetFloat(7), dataReader.GetInt32(8));
                            break;

                        case AlarmType.Level:
                            cond = new LevelAlarm(id, source, dataReader.GetString(6), dataReader.GetFloat(7), dataReader.GetInt32(8));
                            break;

                        case AlarmType.Dev:
                            cond = new DevAlarm(id, (ConditionType)dataReader.GetByte(4), source, dataReader.GetString(6),
                                                dataReader.GetFloat(5), dataReader.GetFloat(7), dataReader.GetInt32(8));
                            break;

                        case AlarmType.ROC:
                            cond = new ROCAlarm(id, source, dataReader.GetString(6), dataReader.GetFloat(7), dataReader.GetInt32(8));
                            break;

                        case AlarmType.Quality:
                            cond = new QualitiesAlarm(id, source, dataReader.GetString(6));
                            break;

                        default:
                            cond = new DigitAlarm(id, source, dataReader.GetString(6), dataReader.GetInt32(8));
                            break;
                        }
                        cond.AddSubCondition(new SubCondition((SubAlarmType)dataReader.GetInt32(9), dataReader.GetFloat(10),
                                                              (Severity)dataReader.GetByte(11), dataReader.GetString(12), dataReader.GetBoolean(13)));

                        cond.IsEnabled = dataReader.GetBoolean(3);
                        var simpcond = cond as SimpleCondition;
                        if (simpcond != null)
                        {
                            simpcond.Tag = this[source];
                        }
                        else
                        {
                            var complexcond = cond as ComplexCondition;
                            if (complexcond != null)
                            {
                                var action = complexcond.SetFunction(reval.Eval(source));
                                if (action != null)
                                {
                                    ValueChangedEventHandler handle = (s1, e1) => { action(); };
                                    foreach (ITag tag in reval.TagList)
                                    {
                                        tag.ValueChanged += handle;// tag.Refresh();
                                    }
                                }
                            }
                        }
                        cond.AlarmActive += new AlarmEventHandler(cond_SendAlarm);
                        cond.AlarmAck    += new EventHandler(cond_AckAlarm);
                        //_conditions.Add(cond);// UpdateCondition(cond);
                        _conditions.Add(cond);
                    }
                    dataReader.NextResult();
                    while (dataReader.Read())
                    {
                        _scales.Add(new Scaling(dataReader.GetInt16(0), (ScaleType)dataReader.GetByte(1),
                                                dataReader.GetFloat(2), dataReader.GetFloat(3), dataReader.GetFloat(4), dataReader.GetFloat(5)));
                    }
                }
                reval.Clear();
                _scales.Sort();
                _compare = new CompareCondBySource();
                _conditions.Sort(_compare);
            }
            catch (Exception e)
            {
                App.AddErrorLog(e);
                Environment.Exit(0);
            }
        }
Ejemplo n.º 4
0
        protected override GetMemberInfoRD ProcessRequest(DTO.Base.APIRequest <GetMemberInfoRP> pRequest)
        {
            GetMemberInfoRD rd = new GetMemberInfoRD();

            rd.MemberInfo = new MemberInfo();
            var vipLoginBLL = new VipBLL(base.CurrentUserInfo);

            //如果有一个查询标识非空,就用查询标识查,发现没有会员就报错
            if (!string.IsNullOrEmpty(pRequest.Parameters.SearchFlag))
            {
                List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                };
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "ClientID", Value = CurrentUserInfo.ClientID
                });
                var cond1 = new LikeCondition()
                {
                    FieldName = "VipName", Value = "%" + pRequest.Parameters.SearchFlag + "%"
                };
                var cond2 = new LikeCondition()
                {
                    FieldName = "VipRealName", Value = "%" + pRequest.Parameters.SearchFlag + "%"
                };
                var com1 = new ComplexCondition()
                {
                    Left = cond1, Right = cond2, Operator = LogicalOperators.Or
                };

                var cond3 = new EqualsCondition()
                {
                    FieldName = "Phone", Value = pRequest.Parameters.SearchFlag
                };
                var com2 = new ComplexCondition()
                {
                    Left = com1, Right = cond3, Operator = LogicalOperators.Or
                };
                complexCondition.Add(com2);
                complexCondition.Add(new DirectCondition("(WeiXinUserId!='' Or WeiXinUserId IS NOT NULL)"));
                var tempVipList = vipLoginBLL.Query(complexCondition.ToArray(), null);
                if (tempVipList != null && tempVipList.Length != 0)
                {
                    pRequest.UserID = pRequest.Parameters.MemberID = tempVipList[0].VIPID;
                }
            }

            string m_MemberID = "";

            if (!string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID))
            {
                m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID) ? pRequest.UserID : pRequest.Parameters.OwnerVipID;
            }
            else
            {
                m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.MemberID) ? pRequest.UserID : pRequest.Parameters.MemberID;
            }

            string UserID       = m_MemberID;
            var    VipLoginInfo = vipLoginBLL.GetByID(UserID);

            if (VipLoginInfo == null)
            {
                throw new APIException("用户不存在")
                      {
                          ErrorCode = 330
                      }
            }
            ;
            #region 20140909 kun.zou 发现状态为0,改为1
            if (VipLoginInfo.Status.HasValue && VipLoginInfo.Status == 0)
            {
                VipLoginInfo.Status = 1;
                vipLoginBLL.Update(VipLoginInfo, false);
                var log = new VipLogEntity()
                {
                    Action       = "更新",
                    ActionRemark = "vip状态为0的改为1.",
                    CreateBy     = UserID,
                    CreateTime   = DateTime.Now,
                    VipID        = VipLoginInfo.VIPID,
                    LogID        = Guid.NewGuid().ToString("N")
                };
                var logBll = new VipLogBLL(base.CurrentUserInfo);
                logBll.Create(log);
            }
            #endregion
            int couponCount = vipLoginBLL.GetVipCoupon(UserID);

            rd.MemberInfo.Mobile      = VipLoginInfo.Phone;      //手机号码
            rd.MemberInfo.Name        = VipLoginInfo.UserName;   //姓名
            rd.MemberInfo.VipID       = VipLoginInfo.VIPID;      //组标识
            rd.MemberInfo.VipName     = VipLoginInfo.VipName;    //会员名
            rd.MemberInfo.ImageUrl    = VipLoginInfo.HeadImgUrl; //会员头像  add by Henry 2014-12-5
            rd.MemberInfo.VipRealName = VipLoginInfo.VipRealName;
            rd.MemberInfo.VipNo       = VipLoginInfo.VipCode;
            rd.MemberInfo.IsDealer    = VipLoginInfo.Col48 != null?int.Parse(VipLoginInfo.Col48) : 0;

            //超级分销体系配置表 为判断是否存在分销体系使用
            var T_SuperRetailTraderConfigbll = new T_SuperRetailTraderConfigBLL(CurrentUserInfo);
            //获取分销体系信息
            var T_SuperRetailTraderConfigInfo = T_SuperRetailTraderConfigbll.QueryByEntity(new T_SuperRetailTraderConfigEntity()
            {
                IsDelete = 0, CustomerId = CurrentUserInfo.CurrentUser.customer_id
            }, null).FirstOrDefault();
            if (T_SuperRetailTraderConfigInfo != null)
            {
                rd.MemberInfo.CanBeSuperRetailTrader = 1;
            }
            else
            {
                rd.MemberInfo.CanBeSuperRetailTrader = 0;
            }
            rd.MemberInfo.SuperRetailTraderID = VipLoginInfo.Col26;
            //rd.MemberInfo.Integration = VipLoginInfo.Integration ?? 0;//会员积分

            #region 会员有效积分
            var vipIntegralBLL  = new VipIntegralBLL(CurrentUserInfo);
            var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity()
            {
                VipID = UserID, VipCardCode = VipLoginInfo.VipCode
            }, null).FirstOrDefault();
            if (vipIntegralInfo != null)
            {
                rd.MemberInfo.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0;
            }
            #endregion

            //会员等级
            //rd.MemberInfo.VipLevelName = string.IsNullOrEmpty(vipLoginBLL.GetVipLeave(UserID)) ? null : vipLoginBLL.GetVipLeave(UserID);
            #region 会员卡名称
            var                vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo);
            var                vipCardBLL           = new VipCardBLL(CurrentUserInfo);
            var                vipCardTypeBLL       = new SysVipCardTypeBLL(CurrentUserInfo);
            var                vipCardRuleBLL       = new VipCardRuleBLL(CurrentUserInfo);
            var                vipT_InoutBLL        = new T_InoutBLL(CurrentUserInfo);
            VipAmountBLL       vipAmountBLL         = new VipAmountBLL(CurrentUserInfo);
            ShoppingCartBLL    service     = new ShoppingCartBLL(CurrentUserInfo);
            ShoppingCartEntity queryEntity = new ShoppingCartEntity();
            queryEntity.VipId = UserID;
            int totalQty = service.GetListQty(queryEntity);
            rd.MemberInfo.ShopCartCount = totalQty;
            //定义当前自定义等级
            int?CurVipLevel        = 0;
            var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
            {
                VIPID = UserID, CustomerID = CurrentUserInfo.ClientID
            },
                                                                        new OrderBy[] { new OrderBy()
                                                                                        {
                                                                                            FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                                        } }).FirstOrDefault();
            if (vipCardMappingInfo != null)
            {
                var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                {
                    VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1
                }, null).FirstOrDefault();
                if (vipCardInfo != null)
                {
                    var vipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                    {
                        VipCardTypeID = vipCardInfo.VipCardTypeID
                    }, null).FirstOrDefault();
                    if (vipCardTypeInfo != null)
                    {
                        rd.MemberInfo.VipLevelName     = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : "";
                        rd.MemberInfo.CardTypeImageUrl = vipCardTypeInfo.PicUrl != null ? vipCardTypeInfo.PicUrl : "";
                        rd.MemberInfo.CardTypePrice    = vipCardTypeInfo.Prices != null ? vipCardTypeInfo.Prices.Value : 0;
                        rd.MemberInfo.IsExtraMoney     = vipCardTypeInfo.IsExtraMoney != null ? vipCardTypeInfo.IsExtraMoney : 0;
                        CurVipLevel             = vipCardTypeInfo.VipCardLevel;
                        rd.MemberInfo.IsPrepaid = vipCardTypeInfo.Isprepaid;
                        if (CurVipLevel > 1)
                        {
                            var VipCardTypeSysInfo = vipCardTypeBLL.GetBindVipCardTypeInfo(CurrentUserInfo.ClientID, VipLoginInfo.Phone, pRequest.UserID, CurVipLevel);
                            if (VipCardTypeSysInfo == null || VipCardTypeSysInfo.Tables[0].Rows.Count == 0)
                            {
                                rd.MemberInfo.IsNeedCard = 2;
                            }
                        }
                        else
                        {
                            rd.MemberInfo.IsNeedCard = 1;
                        }
                        //因为卡等级不能重复,知道当前等级后查找相应的下一级是否是自动升级(消费升级)
                        var NextVipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                        {
                            VipCardLevel = CurVipLevel + 1, CustomerID = CurrentUserInfo.ClientID
                        }, null).FirstOrDefault();
                        if (NextVipCardTypeInfo != null)
                        {
                            //获取当前会员的消费金额信息
                            decimal CurVipConsumptionAmount = 0;
                            decimal VipConsumptionInfo      = vipT_InoutBLL.GetVipSumAmount(UserID);
                            if (VipConsumptionInfo > 0)
                            {
                                CurVipConsumptionAmount = Convert.ToDecimal(Convert.ToDecimal(VipConsumptionInfo).ToString("0.00"));
                            }
                            //知道下一等级后要判断,升级条件是否是消费升级
                            //定义累积消费金额
                            decimal AccumulatedAmount      = 0;
                            var     vipCardTypeUpGradeInfo = vipCardTypeBLL.GetVipCardTypeUpGradeInfo(CurrentUserInfo.ClientID, CurVipLevel);
                            if (vipCardTypeUpGradeInfo != null && vipCardTypeUpGradeInfo.Tables[0].Rows.Count > 0)
                            {
                                //判断拉取的所有卡等级里的最近的一级满足条件即可返回提示所需的值
                                int flag = 0;
                                foreach (DataRow dr in vipCardTypeUpGradeInfo.Tables[0].Rows)
                                {
                                    AccumulatedAmount = Convert.ToDecimal(Convert.ToDecimal(dr["BuyAmount"].ToString()).ToString("0.00"));
                                    //获取消费升级还需多少钱
                                    if (AccumulatedAmount > CurVipConsumptionAmount && flag == 0)
                                    {
                                        flag = 1;
                                        rd.MemberInfo.UpGradeNeedMoney = AccumulatedAmount - CurVipConsumptionAmount;
                                        if (rd.MemberInfo.UpGradeNeedMoney > 0)
                                        {
                                            rd.MemberInfo.UpgradePrompt = "还需要消费" + rd.MemberInfo.UpGradeNeedMoney + "元可以升级啦,快点通知会员!";
                                        }
                                    }
                                }
                            }
                        }

                        var VipCardRuleInfo = vipCardRuleBLL.QueryByEntity(new VipCardRuleEntity()
                        {
                            CustomerID = CurrentUserInfo.ClientID, VipCardTypeID = vipCardTypeInfo.VipCardTypeID
                        }, null).FirstOrDefault();
                        if (VipCardRuleInfo != null)
                        {
                            rd.MemberInfo.CardDiscount = Convert.ToDecimal(Convert.ToDecimal((VipCardRuleInfo.CardDiscount / 10)).ToString("0.00"));
                        }
                    }
                }
            }
            else
            {
                //表示需要领卡,并展示等级为1的默认卡
                rd.MemberInfo.IsNeedCard = 0;
                var VipCardTypeData = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                {
                    VipCardLevel = 1, CustomerID = CurrentUserInfo.ClientID
                }, null).FirstOrDefault();
                if (VipCardTypeData != null)
                {
                    rd.MemberInfo.CardTypeImageUrl = VipCardTypeData.PicUrl != null ? VipCardTypeData.PicUrl : "";
                }
            }
            //获取红利/// decimal[0]=总收入(红利) decimal[2]=支出余额 decimal[1]=总提现金额
            decimal[] array = vipAmountBLL.GetVipSumAmountByCondition(UserID, CurrentUserInfo.ClientID, true);
            if (array[0] != null)
            {
                rd.MemberInfo.ProfitAmount = array[0];
            }
            //是否有付费的会员卡
            List <IWhereCondition> freeCardCon = new List <IWhereCondition> {
            };
            freeCardCon.Add(new EqualsCondition()
            {
                FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
            });
            freeCardCon.Add(new DirectCondition("Prices>0"));
            var freeCardTypeInfo = vipCardTypeBLL.Query(freeCardCon.ToArray(), null).FirstOrDefault();
            if (freeCardTypeInfo != null)
            {
                rd.MemberInfo.IsCostCardType = 1;
            }
            else
            {
                rd.MemberInfo.IsCostCardType = 0;
            }

            #endregion

            rd.MemberInfo.Status       = VipLoginInfo.Status.HasValue ? VipLoginInfo.Status.Value : 1;
            rd.MemberInfo.CouponsCount = couponCount;
            rd.MemberInfo.IsActivate   = (VipLoginInfo.IsActivate.HasValue && VipLoginInfo.IsActivate.Value == 1 ? true : false);
            var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo);
            rd.MemberInfo.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID);



            //获取标签信息
            TagsBLL TagsBLL = new TagsBLL(base.CurrentUserInfo);


            var dsIdentity = TagsBLL.GetVipTagsList("", UserID);//“车主标签”  传7
            if (dsIdentity != null && dsIdentity.Tables.Count > 0 && dsIdentity.Tables[0].Rows.Count > 0)
            {
                rd.IdentityTagsList = DataTableToObject.ConvertToList <TagsInfo>(dsIdentity.Tables[0]).ToArray(); //“年龄段”  传8
            }


            #region 获取注册表单的列明和值

            var vipEntity = vipLoginBLL.QueryByEntity(new VipEntity()
            {
                VIPID = UserID
            }, null);

            if (vipEntity == null || vipEntity.Length == 0)
            {
                return(rd);
            }
            else
            {
                var ds = vipLoginBLL.GetVipColumnInfo(CurrentUserInfo.ClientID, "online005");

                var vipDs = vipLoginBLL.GetVipInfo(UserID);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    var temp = ds.Tables[0].AsEnumerable().Select(t => new MemberControlInfo()
                    {
                        ColumnName  = t["ColumnName"].ToString(),
                        ControlType = Convert.ToInt32(t["ControlType"]),
                        ColumnValue = vipDs.Tables[0].Rows[0][t["ColumnName"].ToString()].ToString(),
                        ColumnDesc  = t["columnDesc"].ToString()
                    });

                    rd.MemberControlList = temp.ToArray();
                }
            }

            //var vipamountBll = new VipAmountBLL(this.CurrentUserInfo);

            //var vipAmountEntity = vipamountBll.GetByID(UserID);


            var unitBll = new UnitBLL(this.CurrentUserInfo);
            //Hashtable htPara = new Hashtable();
            //htPara["MemberID"] = UserID;
            //htPara["CustomerID"] = CurrentUserInfo.ClientID;
            //htPara["PageIndex"] = 1;
            //htPara["PageSize"] = 10;
            //DataSet dsMyAccount = unitBll.GetMyAccount(htPara);

            //if (dsMyAccount.Tables[0].Rows.Count > 0)
            //{
            //    //rd.AccountList = DataTableToObject.ConvertToList<AccountInfo>(dsMyAccount.Tables[0]);
            //    //rd.MemberInfo.Balance = Convert.ToDecimal(dsMyAccount.Tables[0].Rows[0]["Total"].ToString());
            //    //rd.TotalPageCount = int.Parse(dsMyAccount.Tables[0].Rows[0]["PageCount"].ToString());

            //}
            //else
            //    rd.MemberInfo.Balance = 0;

            //返现 add by Henry 2015-4-15
            var vipAmountBll = new VipAmountBLL(CurrentUserInfo);
            //var vipAmountInfo = vipAmountBll.GetByID(UserID);
            var vipAmountInfo = vipAmountBll.QueryByEntity(new VipAmountEntity()
            {
                VipId = UserID, VipCardCode = VipLoginInfo.VipCode
            }, null).FirstOrDefault();
            decimal returnAmount = 0;
            decimal amount       = 0;
            if (vipAmountInfo != null)
            {
                returnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value;
                amount       = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value;
            }
            rd.MemberInfo.ReturnAmount = returnAmount; //返现
            rd.MemberInfo.Balance      = amount;       //余额
            #endregion


            //获取订单的日期和订单的里的商品名称、商品单价、商品数量
            //先获取订单列表,再获取订单详细信息
            int?         pageSize     = 3; //rp.Parameters.PageSize;,只取三条记录
            int?         pageIndex    = 1; //rp.Parameters.PageIndex;
            string       OrderBy      = "";
            string       OrderType    = "";
            T_InoutBLL   T_InoutBLL   = new T_InoutBLL(CurrentUserInfo);
            InoutService InoutService = new InoutService(CurrentUserInfo);
            //只取状态为700的
            //根据订单列表取订单详情
            DataSet dsOrder = T_InoutBLL.GetOrdersByVipID(rd.MemberInfo.VipID, pageIndex ?? 1, pageSize ?? 15, OrderBy, OrderType);//获取会员信息
            if (dsOrder != null && dsOrder.Tables.Count != 0 && dsOrder.Tables[0].Rows.Count != 0)
            {
                List <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo> orderList = DataTableToObject.ConvertToList <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo>(dsOrder.Tables[1]);
                foreach (JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo oi in orderList)
                {
                    IList <InoutDetailInfo> detailList = InoutService.GetInoutDetailInfoByOrderId(oi.order_id);
                    oi.DetailList = detailList;
                }
                rd.OrderList = orderList;
            }

            MessageInfo message = new MessageInfo();


            InnerGroupNewsBLL InnerGroupNewsService = new InnerGroupNewsBLL(CurrentUserInfo);
            SetoffToolsBLL    setofftoolsService    = new SetoffToolsBLL(CurrentUserInfo);

            //1=微信用户 2=APP员工
            int UnReadInnerMessageCount = InnerGroupNewsService.GetVipInnerGroupNewsUnReadCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, null, Convert.ToDateTime(VipLoginInfo.CreateTime));
            var setofftoolsMessageCount = setofftoolsService.GetUnReadSetoffToolsCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, 1);
            message.InnerGroupNewsCount = UnReadInnerMessageCount;
            message.SetoffToolsCount    = setofftoolsMessageCount;
            var VipUpNewsInfo = InnerGroupNewsService.GetVipInnerNewsInfo(CurrentUserInfo.ClientID, 2, 1, 3, 0);
            if (VipUpNewsInfo != null && VipUpNewsInfo.Tables[0].Rows.Count > 0)
            {
                message.UpGradeSucess = VipUpNewsInfo.Tables[0].Rows[0]["Text"] != null ? VipUpNewsInfo.Tables[0].Rows[0]["Text"].ToString() : "";
                //获取通知信息 并更新已读状态 数据如果不是一条进行更新所有数据
                var newsUserMappingBLL = new NewsUserMappingBLL(CurrentUserInfo);
                if (VipUpNewsInfo.Tables[0].Rows.Count > 1)//数据如果不是一条进行更新所有数据
                {
                    foreach (DataRow VipNewsdr in VipUpNewsInfo.Tables[0].Rows)
                    {
                        var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity()
                        {
                            CustomerId = CurrentUserInfo.ClientID, MappingID = VipNewsdr["MappingID"].ToString()
                        }, null).FirstOrDefault();
                        if (vipNewsInfo != null)
                        {
                            vipNewsInfo.HasRead = 1;
                            newsUserMappingBLL.Update(vipNewsInfo);
                        }
                    }
                }
                else
                {
                    var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity()
                    {
                        CustomerId = CurrentUserInfo.ClientID, MappingID = VipUpNewsInfo.Tables[0].Rows[0]["MappingID"].ToString()
                    }, null).FirstOrDefault();
                    if (vipNewsInfo != null)
                    {
                        vipNewsInfo.HasRead = 1;
                        newsUserMappingBLL.Update(vipNewsInfo);
                    }
                }
            }
            else
            {
                message.UpGradeSucess = "";
            }
            rd.MessageInfo = message;
            return(rd);
        }
    }
Ejemplo n.º 5
0
        // GET api/values
        public IEnumerable <DynamicEntity> Get(string csvTable, string conditionType = null, string selectType = null)
        {
            // condtions
            var conditionClauses = (conditionType == null) || (conditionType.Equals("0")) ? conditionInput : conditionType.Equals("1") ? conditionInput1 : conditionType;

            string[] select = ((selectType == null) || (selectType.Equals("0")))? selectInput : selectType.Equals("1") ? selectInput1 : selectType.Split();

            // Creating dynamic rows of Dynamic Class Entity DynamicObject
            List <DynamicEntity> dynRows       = new List <DynamicEntity>();
            List <DynamicEntity> dynRowsReturn = new List <DynamicEntity>();
            // find the file in a folder location inside App_Data
            var path = HttpContext.Current.Server.MapPath(@"~\App_Data\" + csvTable + ".csv");

            if (!File.Exists(path))
            {
                return(dynRowsReturn);
            }

            // helping methods are written in helper class
            QueryHelper helper = new QueryHelper();

            string[] conditionClause;
            string[] complexCondition = conditionClauses.Split(new string[] { "AND", "OR" }, StringSplitOptions.RemoveEmptyEntries);
            //complex condition keeps list of simple conditions
            ComplexCondition complex = new ComplexCondition();

            //may have more than one and or at one level
            complex.AndOrOr = new List <AndOrOr>();
            int count = 0;

            foreach (string s in conditionClauses.Split())
            {
                if (s.Equals("AND"))
                {
                    complex.AndOrOr.Add(AndOrOr.AND);
                }
                else if (s.Equals("OR"))
                {
                    complex.AndOrOr.Add(AndOrOr.OR);
                }
            }
            complex.condtions = new List <SimpleCondition>();

            // filling conditions to complex conditions
            foreach (string condition in complexCondition)
            {
                conditionClause = condition.Replace('(', ' ').Replace(')', ' ').Trim().Split();
                SimpleCondition simpleConditions = new SimpleCondition()
                {
                    colName = conditionClause[0],
                    opera   = conditionClause[1],
                    value   = conditionClause[2]
                };
                complex.condtions.Add(simpleConditions);
            }

            //simple condition check one by one
            foreach (var condition in complex.condtions)
            {
                List <DynamicEntity> dynRowsPerCondition = new List <DynamicEntity>();

                using (TextFieldParser csvParser = new TextFieldParser(path))
                {
                    string[] fields = helper.csvParserDefaultSet(csvParser);

                    while (!csvParser.EndOfData)
                    {
                        string[] returnRow = csvParser.ReadFields();

                        List <int> selectList = new List <int>();
                        foreach (var s in select)
                        {
                            selectList.Add(Array.IndexOf(fields, s));
                        }
                        var entry = helper.rowFinder(returnRow, fields, selectList, condition);

                        if (entry != null)
                        {
                            dynRowsPerCondition.Add(entry);
                        }
                    }
                }

                // only one condition
                if (complex.condtions.Count == 1)
                {
                    return(dynRowsPerCondition);
                }
                // one level of complex queries all or / all and

                if (dynRows.Count == 0)
                {
                    dynRows.AddRange(dynRowsPerCondition);
                }
                else if (complex.AndOrOr[count] == AndOrOr.OR)
                {
                    //LEFT JOIN
                    foreach (var a in dynRowsPerCondition)
                    {
                        if (helper.LookUpAlt(dynRows, "id", helper.LookUp(a, "id")) == 0)
                        {
                            dynRows.Add(a);
                        }
                    }
                    dynRowsReturn = dynRows;
                    count++;
                }
                else if (complex.AndOrOr[count] == AndOrOr.AND)
                {
                    // INNER EQUE JOIN

                    foreach (var a in dynRowsPerCondition)
                    {
                        if (helper.LookUpAlt(dynRows, "id", helper.LookUp(a, "id")) == 1 &&
                            helper.LookUpAlt(dynRowsReturn, "id", helper.LookUp(a, "id")) == 0)
                        {
                            dynRowsReturn.Add(a);
                        }
                    }
                    dynRows = dynRowsReturn;
                    count++;
                }
            }
            return(dynRowsReturn);
        }
Ejemplo n.º 6
0
        private ICondition DigestCondition(XPathNavigator nav, IFactoryFarm factoryFarm)
        {
            ConditionTypes conditionType;

            if (!Enum.TryParse <ConditionTypes>(nav.Name, out conditionType))
            {
                throw new AccountingModuleException("Condition type is not supported. Condition type was: {0}", nav.Name);
            }

            switch (conditionType)
            {
            case ConditionTypes.and:
            case ConditionTypes.or:
            {
                ComplexCondition complexCondition = null;
                switch (conditionType)
                {
                case ConditionTypes.and: complexCondition = factoryFarm.ConditionFactory.CreateAndCondition(); break;

                case ConditionTypes.or: complexCondition = factoryFarm.ConditionFactory.CreateOrCondition(); break;
                }

                nav.MoveToFirstChild();

                do
                {
                    complexCondition.AddCondition(DigestCondition(nav.Clone(), factoryFarm));
                } while (nav.MoveToNext());

                return(complexCondition);
            }

            case ConditionTypes.isEqual:
            case ConditionTypes.isGreater:
            case ConditionTypes.isLess:
            case ConditionTypes.isNotEqual:
            case ConditionTypes.isGreaterOrEqual:
            case ConditionTypes.isLessOrEqual:
            {
                ICondition simpleCondition = null;

                nav.MoveToFirstChild();         // sourceField
                var sourceField = DigestField(nav.Clone(), factoryFarm);

                nav.MoveToNext();         // targetField
                var targetField = DigestField(nav.Clone(), factoryFarm);

                switch (conditionType)
                {
                case ConditionTypes.isEqual: simpleCondition = factoryFarm.ConditionFactory.CreateIsEqualCondition(sourceField, targetField); break;

                case ConditionTypes.isGreater: simpleCondition = factoryFarm.ConditionFactory.CreateIsGreaterCondition(sourceField, targetField); break;

                case ConditionTypes.isLess: simpleCondition = factoryFarm.ConditionFactory.CreateIsLessCondition(sourceField, targetField); break;

                case ConditionTypes.isNotEqual: simpleCondition = factoryFarm.ConditionFactory.CreateIsNotEqualCondition(sourceField, targetField); break;

                case ConditionTypes.isGreaterOrEqual: simpleCondition = factoryFarm.ConditionFactory.CreateIsGreaterOrEqualCondition(sourceField, targetField); break;

                case ConditionTypes.isLessOrEqual: simpleCondition = factoryFarm.ConditionFactory.CreateIsLessOrEqualCondition(sourceField, targetField); break;
                }

                return(simpleCondition);
            }

            default: throw new AccountingModuleException("Condition type is not supported. Condition type was: {0}", conditionType.ToString());
            }
        }
Ejemplo n.º 7
0
 public void addCondition(ComplexCondition condition)
 {
     conditions.Add(condition);
 }