/// <summary>
        /// 获取参数坐标
        /// </summary>
        /// <param name="templateId">获取模板参数</param>
        /// <returns>模板参数列表</returns>
        private List <ExpressParamViewModel> GetExpressParams(string templateId)
        {
            var exParams = new List <ExpressParamViewModel>();

            if (cache.Contains(templateId))
            {
                exParams = cache.Get(templateId) as List <ExpressParamViewModel>;
            }
            else
            {
                var cc = new ConditionCollection();
                cc.Add(new Condition("template_id", templateId));
                var list = this.GetRepository <McpTemplateParamInfo>().ListModel(cc);
                if (list != null)
                {
                    foreach (var param in list)
                    {
                        exParams.Add(new ExpressParamViewModel()
                        {
                            param_code = TryConvertUtil.ToString(param.ParamCode),
                            loc_x      = TryConvertUtil.ToDecimal(param.LocX),
                            loc_y      = TryConvertUtil.ToDecimal(param.LocY),
                            param_type = param.ParamType,
                            is_need    = TryConvertUtil.ToBool(param.IsNeed)
                        });
                    }
                }

                cache.Add(templateId, exParams, DateTimeOffset.Now.AddHours(24));
            }

            return(exParams);
        }
        /// <summary>
        /// 获取设备列表【授权或开通WiFi】
        /// </summary>
        /// <returns></returns>
        public object GetDevices(PageViewModel pageModel, out int pageCount)
        {
            var list       = GetDeviceList(pageModel);
            int totalCount = this.GetRepository <McpEquipmentInfo>().Count();
            int pageSize   = pageModel.PageSize > 0 ? pageModel.PageSize : 10;

            pageCount = (int)Math.Ceiling(TryConvertUtil.ToDecimal(totalCount) / pageSize);

            return(from o in list
                   select new
            {
                EquId = o.EquipmentId,
                EquCode = o.EquipmentCode,
                SnCode = o.CheckCode,
                DeviceId = o.DeviceId,
                IsAuth = o.IsAuth,
                IsOpenWifi = o.IsOpenWifi
            });
        }
Пример #3
0
        /// <summary>
        /// 发送短信
        /// </summary>
        /// <param name="appSign"></param>
        /// <param name="mobile"></param>
        /// <param name="content"></param>
        /// <param name="smsType"></param>
        /// <returns></returns>
        public void SendSmsMessage(string appSign, string mobile, Dictionary <string, object> parms, string content, SMSType smsType, SmsFuncType tempType)
        {
            // 参数检查
            if (string.IsNullOrWhiteSpace(appSign))
            {
                throw new MessageException("应用标识不能为空!");
            }
            if (string.IsNullOrWhiteSpace(mobile))
            {
                throw new MessageException("手机号码不能为空!");
            }
            if (parms.Count <= 0)
            {
                throw new MessageException("短信内容参数不能为空!");
            }
            if (string.IsNullOrWhiteSpace(content))
            {
                throw new MessageException("短信内容不能为空!");
            }
            if (!RegexUtil.IsMobile(mobile))
            {
                throw new MessageException(string.Format("手机号码:{0},格式不正确。" + mobile));
            }

            var smsId = CreateSmsRecord(appSign, mobile, content, smsType);

            switch (smsType)
            {
            case SMSType.Bind:
            case SMSType.UnBind:
            case SMSType.GetPwd:
            case SMSType.ValidateCode:
                SmsUtil.SendValidCode(mobile, parms["code"].ToString(), TryConvertUtil.ToDecimal(parms["code_expire"], 2), tempType);
                break;

            default:
                break;
            }
        }