Ejemplo n.º 1
0
        /// <summary>
        /// 执行确认命令函数
        /// </summary>
        private void OnExecuteConfirmCommand()
        {
            if (ModuleManagerInfoList.Where(x => x.Name.Equals(ModuleManagerModel.Name)).ToList().Any())
            {
                Application.Current.Resources["UiMessage"] = $"操作失败,模块{ModuleManagerModel.Name}已经存在!";
                LogHelper.Info(Application.Current.Resources["UiMessage"].ToString());
                return;
            }

            ModuleManagerModel.ParentId       = Convert.ToInt32(ParentComboxInfo.ParentId);
            ModuleManagerModel.FunctionModels = LocalFunctionInfoList;


            var result = Utility.Http.HttpClientHelper.PostResponse <OperationResult>(GlobalData.ServerRootUri + "ModuleManager/Add",
                                                                                      Utility.JsonHelper.ToJson(ModuleManagerModel));

            if (!Equals(result, null) && result.Successed)
            {
                Application.Current.Resources["UiMessage"] = result?.Message;
                LogHelper.Info(Application.Current.Resources["UiMessage"].ToString());
                Messenger.Default.Send <ModuleManagerModel>(ModuleManagerModel, MessengerToken.DataChanged);
                Messenger.Default.Send <bool>(true, MessengerToken.ClosePopup);
            }
            else
            {
                //操作失败,显示错误信息
                //EnterpriseInfoList = new ObservableCollection<EnterpriseModel>();
                Application.Current.Resources["UiMessage"] = result?.Message ?? "操作失败,请联系管理员!";
                LogHelper.Info(Application.Current.Resources["UiMessage"].ToString());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 取得分页数据
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        private void getPageData(int pageIndex, int pageSize)
        {
#if DEBUG
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
#endif
            pageRepuestParams.SortOrder = "desc";

            pageRepuestParams.PageIndex = pageIndex;
            pageRepuestParams.PageSize  = pageSize;


            //_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
            //Console.WriteLine(await (await _httpClient.GetAsync("/api/service/EnterpriseInfo/Get?id='1'")).Content.ReadAsStringAsync());

            var result = Utility.Http.HttpClientHelper.PostResponse <OperationResult <PageResult <ModuleManagerModel> > >(GlobalData.ServerRootUri + "ModuleManager/PageData", Utility.JsonHelper.ToJson(pageRepuestParams));

#if DEBUG
            stopwatch.Stop();
            Utility.LogHelper.Info("获取模块信息用时(毫秒):" + stopwatch.ElapsedMilliseconds);
            Utility.LogHelper.Info("模块信息内容:" + Utility.JsonHelper.ToJson(result));
#endif

            if (!Equals(result, null) && result.Successed)
            {
                Application.Current.Resources["UiMessage"] = result?.Message;
                LogHelper.Info(Application.Current.Resources["UiMessage"].ToString());
                if (result.Data.Data.Any())
                {
                    //TotalCounts = result.Data.Total;
                    //Messenger.Default.Send(LoginUser, MessengerToken.LoginSuccess);
                    ObservableCollection <ModuleManagerModel> dataList = new ObservableCollection <ModuleManagerModel>(result.Data.Data);
                    //ModuleManagerInfoList = new ObservableCollection<ModuleManagerModel>();
                    ModuleManagerInfoList = GetModuleManagerModels(null, dataList, 10);
                    DataSource            = new ObservableCollection <ModuleManagerModel>();
                    foreach (var data in ModuleManagerInfoList)
                    {
                        if (data.ParentId.Equals(null))
                        {
                            data.PropertyChanged += OnPropertyChangedCommand;
                            DataSource.Add(data);
                        }
                    }
                    TotalCounts = result.Data.Total;
                }
                else
                {
                    ModuleManagerInfoList?.Clear();
                    TotalCounts = 0;
                    Application.Current.Resources["UiMessage"] = "未找到数据";
                }
            }
            else
            {
                //操作失败,显示错误信息
                ModuleManagerInfoList = new ObservableCollection <ModuleManagerModel>();
                Application.Current.Resources["UiMessage"] = result?.Message ?? "查询模块信息失败,请联系管理员!";
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 是否可以执行打印命令
 /// </summary>
 /// <returns></returns>
 private bool OnCanExecutePrintCommand()
 {
     if (Equals(ModuleManagerInfoList, null) || !ModuleManagerInfoList.Any())
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 模型数据改变
        /// </summary>
        /// <param name="obj"></param>
        private void dataChanged(ModuleManagerModel ModuleManagerModel)
        {
            getPageData(pageRepuestParams.PageIndex, pageRepuestParams.PageSize);
            var tmpModel = ModuleManagerInfoList.FirstOrDefault(a => a.Id == ModuleManagerModel.Id);

            this.ModuleManagerInfo = ModuleManagerInfoList.FirstOrDefault();
            ////新增、不存在的数据插入到第一行便于查看
            //if (Equals(tmpModel, null))
            //{
            //    this.EnterpriseInfoList.Insert(0, enterpriseModel);
            //    //this.EnterpriseInfoList.Insert(0, enterpriseModel);
            //    EnterpriseInfoList.RemoveAt(this.EnterpriseInfoList.Count - 1);
            //}
            //else
            //{
            //    //修改的更新后置于第一行,便于查看
            //    tmpModel = enterpriseModel;
            //    EnterpriseInfoList.Move(EnterpriseInfoList.IndexOf(tmpModel), 0);
            //    tmpModel = enterpriseModel;
            //}
        }