コード例 #1
0
ファイル: SubSystemModelService.cs プロジェクト: wpmyj/LC
 public SubSystemEditModel GetSubSystemByCode(string code)
 {
     try
     {
         SubSystemEditModel        subSystemEditModel = new SubSystemEditModel();
         Repository <SysSubSystem> sysSubSystemDal    = this._unitOfWork.GetRepository <SysSubSystem>();
         SysSubSystem sysSubSystem = sysSubSystemDal.GetObjectByKey(code).Entity;
         if (sysSubSystem != null)
         {
             subSystemEditModel.InitEditModel(sysSubSystem);
         }
         return(subSystemEditModel);
     }
     catch (RepositoryException rex)
     {
         string msg    = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg    = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
 }
コード例 #2
0
        private async void menuBindToRight(string rightCode)
        {
            string strErrorMsg = string.Empty;

            try
            {
                List <MenuEditModel> rightSelectedList          = new List <MenuEditModel>();
                IAsyncProxy <ISubSystemModelService> asyncProxy = await Task.Run(() => ServiceHelper.GetSubSystemService());

                SubSystemEditModel rightEditModel = await asyncProxy.CallAsync(d => d.GetSubSystemByCode(rightCode));

                if (rightEditModel != null)
                {
                    if (rightEditModel.SysMenus != null && rightEditModel.SysMenus.Count != 0)
                    {
                        foreach (var item in rightEditModel.SysMenus)
                        {
                            rightSelectedList.Add(item);
                        }
                    }
                }

                this.ShowChecked((RadTreeViewItem)this.rightmenuTree.Items[0], rightSelectedList);
            }
            catch (TimeoutException timeProblem)
            {
                strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message;
            }
            catch (FaultException <LCFault> af)
            {
                strErrorMsg = af.Detail.Message;
            }
            catch (FaultException unknownFault)
            {
                strErrorMsg = UIResources.UnKnowFault + unknownFault.Message;
            }
            catch (CommunicationException commProblem)
            {
                strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace;
            }
            catch (Exception ex)
            {
                strErrorMsg = ex.Message;
                //AisinoMessageBox.Show(ex.Message, UIResources.MsgInfo, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
            if (strErrorMsg != string.Empty)
            {
                await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgError, "菜单树失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null);

                //AisinoMessageBox.Show(strErrorMsg);
            }
        }
コード例 #3
0
 private void BaseWindow_Loaded(object sender, RoutedEventArgs e)
 {
     this.cmbMetroType.ItemsSource = Enum.GetValues(typeof(MetroTypes));
     if (this.OM == OperationMode.AddMode)
     {
         _sysSubSystem           = new SubSystemEditModel();
         this.gdMenu.DataContext = this._sysSubSystem;
     }
     if (this.OM == OperationMode.EditMode)
     {
         this.GetSysSubSystem(this._subSystemDisplayModel);
     }
 }
コード例 #4
0
ファイル: SubSystemModelService.cs プロジェクト: wpmyj/LC
        public SubSystemEditModel SetSubSystemMenu(SubSystemEditModel newSubSystem, List <string> menuCodes)
        {
            try
            {
                Repository <SysSubSystem> sysSubSystemDal = this._unitOfWork.GetRepository <SysSubSystem>();
                SysSubSystem sysSubSystem = sysSubSystemDal.GetObjectByKey(newSubSystem.SubSystemCode).Entity;
                if (sysSubSystem != null)
                {
                    sysSubSystem.Remark         = newSubSystem.Remark;
                    sysSubSystem.MetroType      = newSubSystem.MetroType;
                    sysSubSystem.MetroBackColor = newSubSystem.MetroBackColor;
                    sysSubSystem.MetroForeColor = newSubSystem.MetroForeColor;
                    sysSubSystem.IconString     = newSubSystem.IconString;
                    if (sysSubSystem.SysMenus != null && sysSubSystem.SysMenus.Count > 0)
                    {
                        sysSubSystem.SysMenus.Clear();
                    }

                    if (menuCodes != null && menuCodes.Count > 0)
                    {
                        List <SysMenu>       sysMenuListTemp = new List <SysMenu>();
                        Repository <SysMenu> sysMenuDal      = _unitOfWork.GetRepository <SysMenu>();
                        foreach (string menuCode in menuCodes)
                        {
                            SysMenu sysMenu = sysMenuDal.GetObjectByKey(menuCode).Entity;
                            sysMenuListTemp.Add(sysMenu);
                        }
                        sysSubSystem.SysMenus = sysMenuListTemp;
                    }
                }
                _unitOfWork.AddAction(sysSubSystem, DataActions.Update);
                _unitOfWork.Save();
                return(newSubSystem);
            }
            catch (RepositoryException rex)
            {
                string msg    = rex.Message;
                string reason = rex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
            catch (Exception ex)
            {
                string msg    = ex.Message;
                string reason = ex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
        }
コード例 #5
0
        private async void SaveMenu_Click(object sender, RoutedEventArgs e)
        {
            string strErrorMsg = string.Empty;

            try
            {
                List <String> IsCheckedList = new List <string>();
                this.ISChecked((RadTreeViewItem)this.rightmenuTree.Items[0], IsCheckedList);
                IAsyncProxy <ISubSystemModelService> asyncProxy = await Task.Run(() => ServiceHelper.GetSubSystemService());

                SubSystemEditModel rightEditModel = await asyncProxy.CallAsync(d => d.GetSubSystemByCode(this.mySelectedElement.SubSystemCode));

                await asyncProxy.CallAsync(d => d.SetSubSystemMenu(rightEditModel, IsCheckedList));

                //AisinoMessageBox.Show("修改权限菜单成功!", "提示", MessageBoxButton.OK, MessageBoxImage.None, MessageBoxResult.OK);
                MessageDialogResult result = await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgInfo, "修改权限菜单成功!", MessageDialogStyle.Affirmative, null);
            }
            catch (TimeoutException timeProblem)
            {
                strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message;
            }
            catch (FaultException <LCFault> af)
            {
                strErrorMsg = af.Detail.Message;
            }
            catch (FaultException unknownFault)
            {
                strErrorMsg = UIResources.UnKnowFault + unknownFault.Message;
            }
            catch (CommunicationException commProblem)
            {
                strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace;
            }
            catch (Exception ex)
            {
                strErrorMsg = ex.Message;
                //AisinoMessageBox.Show(ex.Message, UIResources.MsgInfo, MessageBoxButton.OK, MessageBoxImage.Error, MessageBoxResult.OK);
            }
            if (strErrorMsg != string.Empty)
            {
                await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgError, "修改权限菜单失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null);

                //AisinoMessageBox.Show(strErrorMsg);
            }
        }
コード例 #6
0
        private async void GetSysSubSystem(SubSystemDisplayModel subsys)
        {
            string strErrorMsg = string.Empty;

            try
            {
                this._SubSystemAyncProxy = await Task.Run(() => ServiceHelper.GetSubSystemService());

                SubSystemEditModel subSystemEditModel = await this._SubSystemAyncProxy.CallAsync(c => c.GetSubSystemByCode(subsys.SubSystemCode));

                if (subSystemEditModel != null)
                {
                    this._sysSubSystem = subSystemEditModel;
                }
                this.gdMenu.DataContext = this._sysSubSystem;
                this.gdMenu.DataContext = subSystemEditModel;
            }
            catch (TimeoutException timeProblem)
            {
                strErrorMsg = timeProblem.Message + UIResources.TimeOut + timeProblem.Message;
            }
            catch (FaultException <LCFault> af)
            {
                strErrorMsg = af.Detail.Message;
            }
            catch (FaultException unknownFault)
            {
                strErrorMsg = UIResources.UnKnowFault + unknownFault.Message;
            }
            catch (CommunicationException commProblem)
            {
                strErrorMsg = UIResources.ConProblem + commProblem.Message + commProblem.StackTrace;
            }
            catch (Exception ex)
            {
                strErrorMsg = ex.Message;
            }
            if (strErrorMsg != string.Empty)
            {
                await DialogManager.ShowMessageAsync(this.GetMainWindow(), UIResources.MsgError, "修改模式绑定失败!原因:" + strErrorMsg, MessageDialogStyle.Affirmative, null);
            }
        }
コード例 #7
0
ファイル: SubSystemModelService.cs プロジェクト: wpmyj/LC
        public SubSystemEditModel Add(SubSystemEditModel newSubSystem)
        {
            try
            {
                if (CheckCodeExists(newSubSystem.SubSystemCode))
                {
                    throw new FaultException <LCFault>(new LCFault("子菜单添加失败"), "该子菜单编号已存在,不能重复添加");
                }
                if (CheckNameExists(newSubSystem.SubSystemName))
                {
                    throw new FaultException <LCFault>(new LCFault("子菜单添加失败"), "该子菜单编号已存在,不能重复添加");
                }

                SysSubSystem sysSubSystem = new SysSubSystem();
                sysSubSystem.IconString     = newSubSystem.IconString;
                sysSubSystem.MetroBackColor = newSubSystem.MetroBackColor;
                sysSubSystem.MetroForeColor = newSubSystem.MetroForeColor;
                sysSubSystem.MetroType      = newSubSystem.MetroType;
                sysSubSystem.Remark         = newSubSystem.Remark;
                sysSubSystem.SubSystemCode  = newSubSystem.SubSystemCode;
                sysSubSystem.SubSystemName  = newSubSystem.SubSystemName;

                this._unitOfWork.AddAction(sysSubSystem, DataActions.Add);
                this._unitOfWork.Save();
                return(newSubSystem);
            }
            catch (RepositoryException rex)
            {
                string msg    = rex.Message;
                string reason = rex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
            catch (Exception ex)
            {
                string msg    = ex.Message;
                string reason = ex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
        }
コード例 #8
0
ファイル: SubSystemModelService.cs プロジェクト: wpmyj/LC
 public SubSystemEditModel Update(SubSystemEditModel newSubSystem)
 {
     try
     {
         if (newSubSystem == null)
         {
             return(null);
         }
         Repository <SysSubSystem> sysSubSystemDal = this._unitOfWork.GetRepository <SysSubSystem>();
         SysSubSystem sysSubSystem = sysSubSystemDal.GetObjectByKey(newSubSystem.SubSystemCode).Entity;
         if (sysSubSystem != null)
         {
             sysSubSystem.SubSystemCode  = newSubSystem.SubSystemCode;
             sysSubSystem.SubSystemName  = newSubSystem.SubSystemName;
             sysSubSystem.Remark         = newSubSystem.Remark;
             sysSubSystem.MetroBackColor = newSubSystem.MetroBackColor;
             sysSubSystem.MetroForeColor = newSubSystem.MetroForeColor;
             sysSubSystem.MetroType      = newSubSystem.MetroType;
             sysSubSystem.IconString     = newSubSystem.IconString;
         }
         this._unitOfWork.AddAction(sysSubSystem, DataActions.Update);
         this._unitOfWork.Save();
         return(newSubSystem);
     }
     catch (RepositoryException rex)
     {
         string msg    = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg    = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
 }