Beispiel #1
0
        public void Bind(IList <NodeViewModel> data)
        {
            RootNodes.Clear();
            if (data == null || data.Count < 1)
            {
                return;
            }
            //构造节点树
            var rootsData = data.Where(p => string.IsNullOrEmpty(p.Parent))
                            .OrderBy(p => p.Order);
            TreeNode rootNode = null;

            foreach (var rData in rootsData)
            {
                rootNode       = OOMapper.Map <NodeViewModel, TreeNode>(rData);//Label、Id、Parent、Data
                rootNode.Level = 1;
                //递归构造子节点
                if (data.Where(p => p.Parent == rootNode.Id).Count() > 0)
                {
                    BindSubNodes(rootNode, data);
                }

                RootNodes.Add(rootNode);
            }
        }
Beispiel #2
0
        public OptResult Refund(RefundViewModel vmRefund)
        {
            OptResult rst = null;

            if (vmRefund == null)
            {
                rst = OptResult.Build(ResultCode.ParamError, "参数不能为空");
                return(rst);
            }
            if (ModelState.IsValid == false)
            {
                rst = OptResult.Build(ResultCode.ParamError, ModelState.Parse());
                return(rst);
            }

            var token = base.ParseToken(ActionContext);

            if (string.IsNullOrEmpty(vmRefund.opt))
            {
                vmRefund.opt = token.iss;
            }

            var refundEntity = OOMapper.Map <RefundViewModel, RefundEntity>(vmRefund);

            rst = _cardMoneySrv.Refound(refundEntity);

            return(rst);
        }
Beispiel #3
0
        private void SaveAction(object parameter)
        {
            if (!this.IsValid)
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Validate, this.Error);
                return;
            }
            var url = ApiUtils.GetApiUrl(this.IsNew ? ApiKeys.AddPer : ApiKeys.EditPer);
            var rst = HttpUtils.PostResult(url, permdata, ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, this.IsNew ? OperationDesc.Add : OperationDesc.Edit, rst.msg);
                return;
            }
            MessageWindow.ShowMsg(MessageType.Info, this.IsNew ? OperationDesc.Add : OperationDesc.Edit, MsgConst.Msg_Succeed);
            //如果保存的是功能权限,则添加或更新缓存
            if (permdata.per_type == PermType.Func.ToString())
            {
                var funcPermDto = OOMapper.Map <IPermVM, PermissionCacheDto>(permdata);
                if (DataCacheUtils.AllFuncs.ContainsKey(permdata.per_code))
                {
                    DataCacheUtils.AllFuncs[permdata.per_code] = funcPermDto;
                }
                else
                {
                    DataCacheUtils.AllFuncs.Add(permdata.per_code, funcPermDto);
                }
            }
            if (Window != null)
            {
                Window.DialogResult = true;
                Window.CloseCmd.Execute(null);
            }
        }
Beispiel #4
0
        private void SaveAction(object parameter)
        {
            if (!this.IsValid)
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Validate, this.Error);
                return;
            }
            var url = ApiUtils.GetApiUrl(this.IsNew ? ApiKeys.AddGroup : ApiKeys.EditGroup);
            var rst = HttpUtils.PostResult(url, groupdata, ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, this.IsNew ? OperationDesc.Add : OperationDesc.Edit, rst.msg);
                return;
            }
            MessageWindow.ShowMsg(MessageType.Info, this.IsNew ? OperationDesc.Add : OperationDesc.Edit, MsgConst.Msg_Succeed);
            //如果保存成功,则添加或更新缓存
            var group = OOMapper.Map <IGroupVM, Group>(groupdata);

            if (DataCacheUtils.AllGroups.ContainsKey(groupdata.gp_code))
            {
                DataCacheUtils.AllGroups[groupdata.gp_code] = group;
            }
            else
            {
                DataCacheUtils.AllGroups.Add(groupdata.gp_code, group);
            }
            if (Window != null)
            {
                Window.DialogResult = true;
                Window.CloseCmd.Execute(null);
            }
        }
Beispiel #5
0
        public OptResult Pay(PayViewModel vmPay)
        {
            OptResult rst = null;

            if (vmPay == null)
            {
                rst = OptResult.Build(ResultCode.ParamError, "参数不能为空");
                return(rst);
            }
            if (ModelState.IsValid == false)
            {
                rst = OptResult.Build(ResultCode.ParamError, ModelState.Parse());
                return(rst);
            }

            var token = base.ParseToken(ActionContext);

            if (string.IsNullOrEmpty(vmPay.opt))
            {
                vmPay.opt = token.iss;
            }

            var payEntity = OOMapper.Map <PayViewModel, PayEntity>(vmPay);

            rst = _cardMoneySrv.Pay(payEntity);

            return(rst);
        }
Beispiel #6
0
        public OptResult Add(AddDictViewModel vmAddDict)
        {
            OptResult rst = null;

            var dict = OOMapper.Map <AddDictViewModel, Dict>(vmAddDict);

            rst = _dictSrv.Add(dict);

            return(rst);
        }
Beispiel #7
0
        public OptResult Add(AddDictTypeViewModel vmAddDictType)
        {
            OptResult rst = null;

            var dictType = OOMapper.Map <AddDictTypeViewModel, DictType>(vmAddDictType);

            rst = _dictTypeSrv.Add(dictType);

            return(rst);
        }
Beispiel #8
0
        public OptResult Add(TableVM vmAddTable)
        {
            OptResult rst = null;
            //
            var token = base.ParseToken(ActionContext);
            var table = OOMapper.Map <TableVM, Table>(vmAddTable);

            rst = _tableSrv.Add(table);

            return(rst);
        }
Beispiel #9
0
        public OptResult Add(FieldVM vmAddField)
        {
            OptResult rst = null;
            //
            var token = base.ParseToken(ActionContext);
            var field = OOMapper.Map <FieldVM, Field>(vmAddField);

            rst = _fieldSrv.Add(field);

            return(rst);
        }
Beispiel #10
0
        public OptResult Update(UserVM vmUsr)
        {
            OptResult rst = null;

            var token = base.ParseToken(ActionContext);
            var usr   = OOMapper.Map <UserVM, User>(vmUsr);

            rst = _usrSrv.Update(usr);

            return(rst);
        }
Beispiel #11
0
        public OptResult Update(GroupVM vmEditGroup)
        {
            OptResult rst = null;

            //
            var token = base.ParseToken(ActionContext);

            var group = OOMapper.Map <GroupVM, Group>(vmEditGroup);

            rst = _groupSrv.Update(group);

            return(rst);
        }
Beispiel #12
0
        public OptResult Add(UserVM vmUsr)
        {
            OptResult rst = null;

            //
            var token = base.ParseToken(ActionContext);

            var usr = OOMapper.Map <UserVM, User>(vmUsr);

            usr.user_creator = token.iss;
            rst = _usrSrv.Add(usr);
            return(rst);
        }
Beispiel #13
0
        public OptResult Update(PermVM vmEditPer)
        {
            OptResult rst = null;

            //
            var token = base.ParseToken(ActionContext);

            var per = OOMapper.Map <PermVM, Permission>(vmEditPer);

            rst = _perSrv.Update(per);

            return(rst);
        }
Beispiel #14
0
        public OptResult Add(GroupVM vmAddGroup)
        {
            OptResult rst  = null;
            Type      type = typeof(GroupVM);

            //
            var token = base.ParseToken(ActionContext);
            var group = OOMapper.Map <GroupVM, Group>(vmAddGroup);

            rst = _groupSrv.Add(group);

            return(rst);
        }
        public JsonResult Save(UserDetailsViewModel usrDetailsVM)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { code = OperationResultType.ParamError, message = base.ParseModelStateErrorMessage(ModelState) }));
            }
            var usrDetails = OOMapper.Map <UserDetailsViewModel, UserDetails>(usrDetailsVM);
            var rst        = _usrDetailSrv.Save(usrDetails);

            if (rst.ResultType != OperationResultType.Success)
            {
                return(Json(new { code = rst.ResultType, message = rst.Message }));
            }
            return(Json(new { code = OperationResultType.Success, message = "保存成功" }));
        }
Beispiel #16
0
        public OptResult Add(PermVM vmAddPer)
        {
            OptResult rst = null;

            if (vmAddPer == null)
            {
                rst = OptResult.Build(ResultCode.ParamError, "参数不能为空");
                return(rst);
            }

            //
            var token = base.ParseToken(ActionContext);
            var per   = OOMapper.Map <PermVM, Permission>(vmAddPer);

            rst = _perSrv.Add(per);

            return(rst);
        }
Beispiel #17
0
        public static FieldViewModel Parse(DbField dbField)
        {
            if (dbField == null)
            {
                return(null);
            }
            FieldViewModel fvm = OOMapper.Map <DbField, FieldViewModel>(dbField,
                                                                        new DefaultMapConfig()
                                                                        .ConvertUsing <DbField, FieldViewModel>(f => new FieldViewModel
            {
                fieldname   = f.column_name,
                displayname = f.column_comment,
                fieldtype   = f.field_type,
                tbname      = f.table_name
            }));

            return(fvm);
        }
Beispiel #18
0
        public JsonResult Edit(ModuleViewModel vmModule)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { code = OperationResultType.ParamError, message = base.ParseModelStateErrorMessage(ModelState) }));
            }
            var module = OOMapper.Map <ModuleViewModel, Module>(vmModule);

            module.LastModifier   = HttpContext.Session.GetUserId();
            module.LastModifyTime = DateTime.Now;

            OperationResult result = _moduleSrv.UpdateDetail(module);

            if (result.ResultType != OperationResultType.Success)
            {
                return(Json(new { code = result.ResultType, message = result.Message }));
            }
            return(Json(new { code = OperationResultType.Success, message = "修改成功" }));
        }
Beispiel #19
0
        public JsonResult Add(RoleViewModel roleVM)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { code = OperationResultType.ParamError, message = base.ParseModelStateErrorMessage(ModelState) }));
            }

            var role = OOMapper.Map <RoleViewModel, Role>(roleVM);

            role.Creator    = HttpContext.Session.GetUserId();
            role.CreateTime = DateTime.Now;

            OperationResult result = _roleSrv.Add(role);

            if (result.ResultType != OperationResultType.Success)
            {
                return(Json(new { code = result.ResultType, message = result.Message }));
            }
            return(Json(new { code = OperationResultType.Success, message = "添加成功" }));
        }
Beispiel #20
0
        public JsonResult Edit(RoleViewModel roleVM)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { code = OperationResultType.ParamError, messgae = base.ParseModelStateErrorMessage(ModelState) }));
            }

            var role = OOMapper.Map <RoleViewModel, Role>(roleVM);

            role.LastModifier   = HttpContext.Session.GetUserId();
            role.LastModifyTime = DateTime.Now;

            var rst = _roleSrv.UpdateDetail(role);

            if (rst.ResultType != OperationResultType.Success)
            {
                return(Json(new { code = rst.ResultType, message = rst.Message }));
            }
            return(Json(new { code = OperationResultType.Success, message = "修改成功" }));
        }
Beispiel #21
0
        public JsonResult Edit(UserViewModel usrVM)
        {
            if (!ModelState.IsValid)
            {
                return(Json(new { code = OperationResultType.ParamError, message = base.ParseModelStateErrorMessage(ModelState) }));
            }

            var usr = OOMapper.Map <UserViewModel, User>(usrVM);

            usr.LastModifier   = HttpContext.Session.GetUserId();
            usr.LastModifyTime = DateTime.Now;

            OperationResult result = _userSrv.UpdateDetail(usr);

            if (result.ResultType != OperationResultType.Success)
            {
                return(Json(new { code = result.ResultType, message = result.Message }));
            }
            return(Json(new { code = OperationResultType.Success, message = "修改成功" }));
        }
Beispiel #22
0
        private void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            e.Handled = true;
            if (!vmLogin.IsValid)
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Validate, vmLogin.Error);
                return;
            }
            if (!vmLogin.CheckVerifyCode())
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Validate, "验证码错误");
                return;
            }
            //登录
            var url = ApiUtils.GetApiUrl(ApiKeys.Login);
            var rst = HttpUtils.PostResult(url, new { username = vmLogin.logindata.username, pwd = vmLogin.logindata.pwd });

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Login, rst.msg);
                return;
            }
            //登录成功,记录token
            ClientContext.Token = rst.data.token;
            //获取用户信息
            rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.GetUsr), new { pk = rst.data.usrid }, ClientContext.Token);
            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.GetUsr, rst.msg);
                return;
            }
            var user = JsonConvert.DeserializeObject <User>(((JObject)rst.data).ToString());

            ClientContext.CurrentUser = new UserVM();
            OOMapper.Map(typeof(User), typeof(UserVM), user, ClientContext.CurrentUser);
            //记住我?
            RememberMe();

            new MainWindow().Show();
            this.Close();
        }
Beispiel #23
0
        private void BindSubNodes(TreeNode pNode, IList <NodeViewModel> data)
        {
            var subDatas = data.Where(p => p.Parent == pNode.Id)
                           .OrderBy(p => p.Order);

            if (subDatas == null || subDatas.Count() < 1)
            {
                return;
            }
            TreeNode subNode = null;

            foreach (var sub in subDatas)
            {
                subNode            = OOMapper.Map <NodeViewModel, TreeNode>(sub);
                subNode.Level      = pNode.Level + 1;
                subNode.ParentNode = pNode;
                if (data.Where(p => p.Parent == subNode.Id).Count() > 0)
                {
                    BindSubNodes(subNode, data);
                }

                pNode.SubNodes.Add(subNode);
            }
        }