Ejemplo n.º 1
0
        private void DoChgPwd()
        {
            if (!vmChgPwd.IsValid)
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Validate, vmChgPwd.Error);
                return;
            }
            string msg = "";

            if (!vmChgPwd.HandlyCheck(out msg))
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Validate, msg);
                return;
            }
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.ChangePwd), vmChgPwd.chgpwddata, ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.ChangePwd, rst.msg);
                return;
            }
            MessageWindow.ShowMsg(MessageType.Info, OperationDesc.ChangePwd, "密码修改成功");
            vmChgPwd.CanValidate = false;
            vmChgPwd.Reset();
            vmChgPwd.CanValidate = true;
            FocusManager.SetFocusedElement(this, txtOldPwd);
        }
Ejemplo n.º 2
0
        private void GetDbTablesAction(object parameter)
        {
            var rst = HttpUtils.GetResult(ApiUtils.GetApiUrl(ApiKeys.Cq_TableDbTables), ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Cq_GetDbTables, rst.msg);
                return;
            }
            if (rst.data != null && rst.data.rows != null)
            {
                var dbTables = JsonConvert.DeserializeObject <IEnumerable <DbTable> >(((JArray)rst.data.rows).ToString());
                if (dbTables.IsNotEmpty())
                {
                    base.Models = (dbTables
                                   .Select(dt => new TableViewModel {
                        tbname = dt.table_name, comment = dt.table_comment
                    })
                                   as IEnumerable <CheckableModel>)
                                  .ToList();
                }
                else
                {
                    base.Models = null;
                }
            }
        }
Ejemplo n.º 3
0
        void SaveAction(object parameter)
        {
            if (this._type == InfoOptType.View)
            {
                base.CloseCmd.Execute(null);
                return;
            }
            if (_type == InfoOptType.InsertOrUpdate)
            {
                _model.pic = new List <string>();
                var data = ctlImage.Base64Data;
                if (!string.IsNullOrEmpty(data))
                {
                    _model.pic.Add(data);
                }
            }
            //保存
            var url = ApiUtils.GetApiUrl(PartyBuildingApiKeys.AreaSave, PartyBuildingApiKeys.Key_ApiProvider_Party);
            var rst = HttpUtils.PostResult(url, _model);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Save, rst.msg);
                return;
            }
            this.DialogResult = true;
            base.CloseCmd.Execute(null);
        }
Ejemplo n.º 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.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);
            }
        }
Ejemplo n.º 5
0
        private void AssignAction(object param)
        {
            CheckableModel vm;

            if (base.GetSelectedOne(out vm, OperationDesc.Assign))
            {
                var usr = vm as UserDetailViewModel;
                TreeHelper.OpenAllPermsHelp((selNodes) =>
                {
                    if (selNodes == null || selNodes.Count < 1)
                    {
                        return;
                    }
                    var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.Assign),
                                                   new
                    {
                        userId    = usr.userdata.user_id,
                        perIds    = selNodes.Select(n => n.DataId),
                        assignAll = false
                    }, ClientContext.Token);
                    if (rst.code != ResultCode.Success)
                    {
                        MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Assign, rst.msg);
                        return;
                    }
                    MessageWindow.ShowMsg(MessageType.Info, OperationDesc.Assign, MsgConst.Msg_Succeed);
                });
            }
        }
Ejemplo n.º 6
0
        private void SaveAction(object obj)
        {
            var sels = base.GetSelectedModels();

            if (sels.IsEmpty())
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Save, "没有要保存的数据!");
                return;
            }
            //
            var askRst = MessageWindow.ShowMsg(MessageType.Ask, OperationDesc.Cq_InitFields, "初始化操作将清空当前查询字段,是否继续?");

            if (askRst != true)
            {
                return;
            }
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.Cq_FieldInit), sels, ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Cq_InitFields, rst.msg);
                return;
            }
            MessageWindow.ShowMsg(MessageType.Info, OperationDesc.Cq_InitFields, MsgConst.Msg_Succeed);
            if (Window != null)
            {
                Window.DialogResult = true;
                Window.CloseCmd.Execute(null);
            }
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
        public static IEnumerable <TableViewModel> GetTables(PageQuery page)
        {
            IEnumerable <TableViewModel> empty = new List <TableViewModel>();
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.Cq_TablePage),
                                           new
            {
                pageIndex  = page.pageIndex,
                pageSize   = page.pageSize,
                conditions = page.conditions
            },
                                           ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return(null);
            }
            if (rst.data != null && rst.data.total != null)
            {
                page.total = (int)rst.data.total;
                if (page.total == 0)
                {
                    page.pageTotal = 0;
                    page.pageIndex = 1;
                    return(empty);
                }
                page.pageTotal = Convert.ToInt32(Math.Ceiling(page.total * 1.0 / page.pageSize));
                var models = JsonConvert.DeserializeObject <IEnumerable <TableViewModel> >(((JArray)rst.data.rows).ToString());
                return(models);
            }
            return(empty);
        }
Ejemplo n.º 9
0
        private void InitMenutTree()
        {
            _menuTreeData        = new TreeViewData();
            menuTree.DataContext = _menuTreeData;

            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.GetPer), new { pk = ClientContext.CurrentUser.user_id }, ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Warning, "获取权限失败", rst.msg);
                return;
            }
            if (rst.data == null || rst.data.pers == null)
            {
                MessageWindow.ShowMsg(MessageType.Warning, "获取权限失败", "未能获得用户权限");
                return;
            }
            var pers = JsonConvert.DeserializeObject <IEnumerable <Permission> >(((JArray)rst.data.pers).ToString());

            ClientContext.Pers = pers;

            //功能菜单
            var funcs = pers.Where(p => p.per_type == PermType.Func.ToString());

            if (funcs != null && funcs.Count() > 0)
            {
                List <TreeViewData.NodeViewModel> datas = new List <TreeViewData.NodeViewModel>();
                datas.Add(new TreeViewData.NodeViewModel
                {
                    Id    = "main",
                    Label = "主页",
                    Order = "0",
                    Data  = new Permission {
                        per_uri = ClientContext.Conf.mainpage
                    },
                    IconUri = "/MyNet.Client;component/Resources/img/icon_home.png",
                    HAlign  = "Center"
                });
                foreach (var p in funcs)
                {
                    datas.Add(new TreeViewData.NodeViewModel
                    {
                        Id      = p.per_code,
                        Label   = p.per_name,
                        Parent  = p.per_parent,
                        Order   = p.per_sort,
                        Data    = p,
                        DataId  = p.per_id,
                        IconUri = p.per_icon,
                        HAlign  = p.per_halign
                    });
                }
                _menuTreeData.Bind(datas);
            }

            //选中第一个节点(主页)
            menuTree.Select();
        }
Ejemplo n.º 10
0
        private void Search(PagingArgs page)
        {
            base.Models = null;
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.GetPerByPage),
                                           new
            {
                pageIndex  = page.PageIndex,
                pageSize   = page.PageSize,
                conditions = new Dictionary <string, string>
                {
                    { "per_code", Filter_PerCode },
                    { "per_name", Filter_PerName },
                    { "per_type", Filter_PerType == null?"":Filter_PerType.Id },
                    { "per_parent", Filter_PerParent },
                    { "per_parent_name", Filter_PerParent_Name },
                }
            },
                                           ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return;
            }
            if (rst.data != null && rst.data.total != null)
            {
                page.RecordsCount = (int)rst.data.total;
                if (page.RecordsCount == 0)
                {
                    page.PageCount = 0;
                    page.PageIndex = 1;
                    return;
                }
                page.PageCount = Convert.ToInt32(Math.Ceiling(page.RecordsCount * 1.0 / page.PageSize));

                var datas = rst.data.rows as JArray;
                if (datas.IsNotEmpty())
                {
                    IEnumerable <PermDetailViewModel> perms = datas.Select(obj =>
                    {
                        PermDetailViewModel permVM = new PermDetailViewModel(needValidate: false);
                        var ins = JsonConvert.DeserializeObject(obj.ToString(), permVM.permdata.GetType());
                        (ins as IPermVM).CopyTo(permVM.permdata);
                        permVM.per_parent_name = obj["per_parent_name"].Value <string>();
                        permVM.per_type_name   = obj["per_type_name"].Value <string>();
                        return(permVM);
                    });

                    base.PageStart = page.Start;
                    base.Models    = (perms as IEnumerable <CheckableModel>).ToList();
                }
            }
        }
Ejemplo n.º 11
0
        private void Search(PagingArgs page)
        {
            base.Models = null;//没有使用ObservableCollection;这里不能用base.Models.Clear(),因为并不会触发base.RaisePropertyChanged
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.GetUsrByPage),
                                           new
            {
                pageIndex  = page.PageIndex,
                pageSize   = page.PageSize,
                conditions = new Dictionary <string, string>
                {
                    { "regioncode", Filter_RegionCode },
                    { "username", Filter_UserName },
                    { "truename", Filter_TrueName },
                    { "group", Filter_Group },
                    { "group_name", Filter_Group_Name },
                }
            },
                                           ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return;
            }

            if (rst.data != null && rst.data.total != null)
            {
                page.RecordsCount = (int)rst.data.total;
                if (page.RecordsCount == 0)
                {
                    page.PageCount = 0;
                    page.PageIndex = 1;
                    return;
                }
                page.PageCount = Convert.ToInt32(Math.Ceiling(page.RecordsCount * 1.0 / page.PageSize));

                var datas = rst.data.rows as JArray;
                if (datas.IsNotEmpty())
                {
                    IEnumerable <UserDetailViewModel> usrs = datas.Select(obj =>
                    {
                        UserDetailViewModel usrVM = new UserDetailViewModel(needValidate: false);//列表数据只读时,不需要进行验证;
                        var ins = JsonConvert.DeserializeObject(obj.ToString(), usrVM.userdata.GetType());
                        (ins as IUserVM).CopyTo(usrVM.userdata);
                        usrVM.user_group_name = obj["user_group_name"].Value <string>();
                        return(usrVM);
                    });

                    base.PageStart = page.Start;
                    base.Models    = (usrs as IEnumerable <CheckableModel>).ToList();
                }
            }
        }
Ejemplo n.º 12
0
        private void Search(bool all = true)
        {
            var rst = HttpUtils.GetResult(ApiUtils.GetApiUrl(PartyBuildingApiKeys.TaskGet, PartyBuildingApiKeys.Key_ApiProvider_Party));

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return;
            }
            dg.ItemsSource = null;
            if (rst.data != null && rst.data.tasks != null)
            {
                var tasks = JsonConvert.DeserializeObject <IEnumerable <TaskModel> >(((JArray)rst.data.tasks).ToString());
                if (tasks.IsEmpty())
                {
                    return;
                }
                tasks = tasks.Where(t => t.state != "编辑");
                if (all)
                {
                    dg.ItemsSource = tasks;
                }
                else
                {
                    if (txtTaskName.Text.IsNotEmpty())
                    {
                        tasks = tasks.Where(t => t.name.Contains(txtTaskName.Text));
                    }
                    if (cmbTaskPriority.SelectedItem != null)
                    {
                        tasks = tasks.Where(t => t.priority == (cmbTaskPriority.SelectedValue as CmbItem).Text);
                    }

                    if (cmbTaskCompleteState.SelectedItem != null)
                    {
                        tasks = tasks.Where(t => t.complete_state == (cmbTaskCompleteState.SelectedValue as CmbItem).Text);
                    }
                    var date = dtExpire_Begin.Text;
                    if (date.IsNotEmpty())
                    {
                        tasks = tasks.Where(t => !(string.Compare(t.expire_time, date) < 0));
                    }
                    date = dtExpire_End.Text;
                    if (date.IsNotEmpty())
                    {
                        tasks = tasks.Where(t => !(string.Compare(t.expire_time, date) > 0));
                    }

                    dg.ItemsSource = tasks;
                }
            }
        }
Ejemplo n.º 13
0
        private void ExecQAction(PagingArgs page)
        {
            ExecQModel.FilterBaseFieldsSrc();//这里是为了执行查询前,删除由于主表、关联表改变导致的垃圾数据
            Results.Clear();

            //1、转换QueryModel
            QueryModel qModel  = null;
            bool       success = ParseQueryModel(out qModel);

            if (success == false)
            {
                return;
            }

            //2、查询条件展示
            //3、过滤条件展示
            //4、查询结果DataGrid动态列
            BuildDataGridCols();
            //5、分页
            qModel.Page = new PageQuery {
                pageIndex = page.PageIndex, pageSize = page.PageSize
            };
            //6、执行查询,返回结果,绑定Results
            var url = ApiUtils.GetApiUrl(ApiKeys.Cq_ExecQuery);
            var rst = HttpUtils.PostResult(url, qModel, ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Cq_ExecQuery, rst.msg);
                return;
            }
            if (rst.data != null && rst.data.total != null)
            {
                page.RecordsCount = (int)rst.data.total;
                if (page.RecordsCount == 0)
                {
                    page.PageCount = 0;
                    page.PageIndex = 1;
                    return;
                }
                page.PageCount = Convert.ToInt32(Math.Ceiling(page.RecordsCount * 1.0 / page.PageSize));

                var rows = JsonConvert.DeserializeObject <IEnumerable <dynamic> >(((JArray)rst.data.rows).ToString());
                if (rows.IsNotEmpty())
                {
                    Results.AddRange(rows);
                }
                //设置行号
                DgResults.LoadingRow -= SetDgRowNumber;
                DgResults.LoadingRow += SetDgRowNumber;
            }
        }
Ejemplo n.º 14
0
        void SaveAction(object parameter)
        {
            _model.priority = cmbPriority.Text;
            var url = ApiUtils.GetApiUrl(PartyBuildingApiKeys.TaskSave, PartyBuildingApiKeys.Key_ApiProvider_Party);
            var rst = HttpUtils.PostResult(url, _model);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, this.IsNew ? OperationDesc.Add : OperationDesc.Edit, rst.msg);
                return;
            }
            this.DialogResult = true;
            base.CloseCmd.Execute(null);
        }
Ejemplo n.º 15
0
        void CompleteAction(object parameter)
        {
            string url = ApiUtils.GetApiUrl(PartyBuildingApiKeys.TaskComplete, PartyBuildingApiKeys.Key_ApiProvider_Party);
            var    rst = HttpUtils.PostResult(url, new { id = _model.id, progress = _model.progress });

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, "任务完成", rst.msg);
                return;
            }
            this.DialogResult = true;

            base.Close();
        }
Ejemplo n.º 16
0
        private void btnIssue_Click(object sender, RoutedEventArgs e)
        {
            var task = dg.SelectedItem as TaskModel;

            if (task == null)
            {
                return;
            }
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(PartyBuildingApiKeys.TaskRelease, PartyBuildingApiKeys.Key_ApiProvider_Party), new { id = task.id });

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, "任务发布", rst.msg);
                return;
            }
            GetTasks();
        }
Ejemplo n.º 17
0
        private void DoChg()
        {
            if (!vmUsr.IsValid)
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Validate, vmUsr.Error);
                return;
            }
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.EditUsr), vmUsr.userdata, ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Warning, OperationDesc.Edit, rst.msg);
                return;
            }
            MessageWindow.ShowMsg(MessageType.Info, OperationDesc.Edit, "修改成功");
            //更新用户缓存
            UpdateUsrCache();
        }
Ejemplo n.º 18
0
        void GetInfos()
        {
            var rst = HttpUtils.GetResult(ApiUtils.GetApiUrl(PartyBuildingApiKeys.InfoGet, PartyBuildingApiKeys.Key_ApiProvider_Party));

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return;
            }
            if (rst.data != null && rst.data.infos != null)
            {
                var infos = JsonConvert.DeserializeObject <IEnumerable <InfoModel> >(((JArray)rst.data.infos).ToString());
                if (infos != null && infos.Count() > 0)
                {
                    dgNotice.ItemsSource = infos.Where(i => i.state == "已发布");
                }
            }
        }
Ejemplo n.º 19
0
        private void btnReceive_Click(object sender, RoutedEventArgs e)
        {
            var task = dg.SelectedItem as TaskModel;

            if (task == null)
            {
                return;
            }
            string url = ApiUtils.GetApiUrl(PartyBuildingApiKeys.TaskTake, PartyBuildingApiKeys.Key_ApiProvider_Party);
            var    rst = HttpUtils.PostResult(url, new { id = task.id });

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return;
            }
            Search();
        }
Ejemplo n.º 20
0
        void Issue_SentAction(object parameter)
        {
            var info = dg_Sent.SelectedItem as InfoModel;

            if (info == null)
            {
                return;
            }
            var url = ApiUtils.GetApiUrl(PartyBuildingApiKeys.InfoRelease, PartyBuildingApiKeys.Key_ApiProvider_Party);
            var rst = HttpUtils.PostResult(url, new { id = info.id });

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Save, rst.msg);
                return;
            }
            GetInfos();
        }
Ejemplo n.º 21
0
        void GetTasks()
        {
            var rst = HttpUtils.GetResult(ApiUtils.GetApiUrl(PartyBuildingApiKeys.TaskGet, PartyBuildingApiKeys.Key_ApiProvider_Party));

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return;
            }
            if (rst.data != null && rst.data.tasks != null)
            {
                var tasks = JsonConvert.DeserializeObject <IEnumerable <TaskModel> >(((JArray)rst.data.tasks).ToString());
                if (tasks != null && tasks.Count() > 0)
                {
                    tasks = tasks.Where(t => t.complete_state == "未领" || t.complete_state == "已领未完成");
                }
                dgTasks.ItemsSource = tasks;
            }
        }
Ejemplo n.º 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();
        }
Ejemplo n.º 23
0
        private void GetDbFieldsAction(object parameter)
        {
            if (Tables.IsEmpty())
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Cq_GetDbFields, "未定义查询表!");
                return;
            }
            var url = ApiUtils.GetApiUrl(ApiKeys.Cq_FieldDbFields);
            var rst = HttpUtils.PostResult(url, Tables.Select(t => t.id), ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Cq_GetDbFields, rst.msg);
                return;
            }
            if (rst.data != null && rst.data.rows != null)
            {
                var fields = JsonConvert.DeserializeObject <IEnumerable <FieldViewModel> >(((JArray)rst.data.rows).ToString());
                base.Models = ((IEnumerable <CheckableModel>)fields).ToList();//
            }
        }
Ejemplo n.º 24
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            var rst = HttpUtils.GetResult(ApiUtils.GetApiUrl(PartyBuildingApiKeys.AreaGet, PartyBuildingApiKeys.Key_ApiProvider_Party));

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return;
            }
            if (rst.data != null && rst.data.infos != null)
            {
                allActPlaces = JsonConvert.DeserializeObject <IEnumerable <PartyActAreaModel> >(((JArray)rst.data.infos).ToString());
            }

            InitTotal();

            InitColChart();

            radioTown.Command.Execute("town");
            radioTown.IsChecked = true;
        }
Ejemplo n.º 25
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.AddUsr : ApiKeys.EditUsr);
            var rst = HttpUtils.PostResult(url, this.userdata, 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 (Window != null)
            {
                Window.DialogResult = true;
                Window.CloseCmd.Execute(null);
            }
        }
Ejemplo n.º 26
0
        protected override void DelAction(object param)
        {
            IEnumerable <CheckableModel> items = null;

            if (!base.BeforeDelete(out items))
            {
                return;
            }
            var ids = items.Select(m => ((TableViewModel)m).id);
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.Cq_TableDel),
                                           new
            {
                pks = ids.ToArray()
            }, ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Delete, rst.msg);
                return;
            }
            MessageWindow.ShowMsg(MessageType.Info, OperationDesc.Delete, MsgConst.Msg_Succeed);
            base.SearchCmd.Execute(null);
        }
Ejemplo n.º 27
0
        protected override void DelAction(object parameter)
        {
            IEnumerable <CheckableModel> items = null;

            if (!base.BeforeDelete(out items))
            {
                return;
            }
            var ids = items.Select(m => ((PermDetailViewModel)m).permdata.per_id);
            var rst = HttpUtils.PostResult(ApiUtils.GetApiUrl(ApiKeys.MultiDeletePer),
                                           new
            {
                pks = ids.ToArray()
            }, ClientContext.Token);

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Delete, rst.msg);
                return;
            }
            MessageWindow.ShowMsg(MessageType.Info, OperationDesc.Delete, MsgConst.Msg_Succeed);
            //清除垃圾缓存
            var funcCodes = items.Where(m => ((PermDetailViewModel)m).permdata.per_type == PermType.Func.ToString())
                            .Select(m => ((PermDetailViewModel)m).permdata.per_code);

            if (funcCodes != null && funcCodes.Count() > 0 && DataCacheUtils.AllFuncs.Count > 0)
            {
                foreach (var code in funcCodes)
                {
                    if (DataCacheUtils.AllFuncs.ContainsKey(code))
                    {
                        DataCacheUtils.AllFuncs.Remove(code);
                    }
                }
            }
            base.SearchCmd.Execute(null);
        }
Ejemplo n.º 28
0
        void GetAreas(bool all = true)
        {
            var rst = HttpUtils.GetResult(ApiUtils.GetApiUrl(PartyBuildingApiKeys.AreaGet, PartyBuildingApiKeys.Key_ApiProvider_Party));

            if (rst.code != ResultCode.Success)
            {
                MessageWindow.ShowMsg(MessageType.Error, OperationDesc.Search, rst.msg);
                return;
            }
            if (rst.data != null && rst.data.infos != null)
            {
                var areas = JsonConvert.DeserializeObject <IEnumerable <PartyActAreaModel> >(((JArray)rst.data.infos).ToString());
                //
                var node = gpTree.SelectedItem as TreeViewData.TreeNode;
                if (node != null)
                {
                    if (node.Level == 2)
                    {
                        areas = areas.Where(a => a.town == node.Label);
                    }
                    else if (node.Level == 3)
                    {
                        areas = areas.Where(a => a.village == node.Label);
                    }
                }
                if (all)
                {
                    dg.ItemsSource = areas;
                    return;
                }
                if (txtLevel.Text.IsNotEmpty())
                {
                    areas = areas.Where(a => a.levels == txtLevel.Text);
                }
                if (txtRooms.Text.IsNotEmpty())
                {
                    areas = areas.Where(a => a.rooms == txtRooms.Text);
                }
                //建筑面积
                string  max = "", min = "";
                CmbItem sel = cmbFloorArea.SelectedValue as CmbItem;
                if (sel != null)
                {
                    if (sel.Text.Contains("以上"))
                    {
                        min = sel.Text.Replace("以上", "");
                    }
                    else if (sel.Text.Contains("以下"))
                    {
                        max = sel.Text.Replace("以下", "");
                    }
                    else
                    {
                        var arr = sel.Text.Split('~');
                        max = arr[1];
                        min = arr[0];
                    }
                    if (max.IsNotEmpty())
                    {
                        areas = areas.Where(a => Convert.ToInt32(a.floor_area) < Convert.ToInt32(max));
                    }
                    if (min.IsNotEmpty())
                    {
                        areas = areas.Where(a => Convert.ToInt32(a.floor_area) >= Convert.ToInt32(min));
                    }
                }
                //院落面积
                sel = cmbCourtyardArea.SelectedValue as CmbItem;
                if (sel != null)
                {
                    if (sel.Text.Contains("以上"))
                    {
                        min = sel.Text.Replace("以上", "");
                    }
                    else if (sel.Text.Contains("以下"))
                    {
                        max = sel.Text.Replace("以下", "");
                    }
                    else
                    {
                        var arr = sel.Text.Split('~');
                        max = arr[1];
                        min = arr[0];
                    }
                    if (max.IsNotEmpty())
                    {
                        areas = areas.Where(a => Convert.ToInt32(a.courtyard_area) < Convert.ToInt32(max));
                    }
                    if (min.IsNotEmpty())
                    {
                        areas = areas.Where(a => Convert.ToInt32(a.courtyard_area) >= Convert.ToInt32(min));
                    }
                }

                dg.ItemsSource = areas;
            }
        }