/// <summary> /// 获取用户权限域数据 /// </summary> public DataTable GetUserScope(string permissionItemScopeCode) { //// 是否有用户管理权限,若有用户管理权限就有所有的用户类表,这个应该是内置的操作权限 bool userAdmin = false; userAdmin = this.IsAuthorized("UserAdmin"); DataTable returnValue = new DataTable(PiUserTable.TableName); // 获取用户数据 RDIFrameworkService platFormService = new RDIFrameworkService(); if (userAdmin) { if (this.UserInfo.IsAdministrator || (String.IsNullOrEmpty(permissionItemScopeCode) || (!SystemInfo.EnableUserAuthorizationScope))) { returnValue = platFormService.UserService.GetDT(UserInfo); if (platFormService.UserService is ICommunicationObject) { ((ICommunicationObject)platFormService.UserService).Close(); } } else { returnValue = platFormService.PermissionService.GetUserDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode); if (platFormService.PermissionService is ICommunicationObject) { ((ICommunicationObject)platFormService.PermissionService).Close(); } } } return(returnValue); }
private void FrmRDIFramework_FormClosing(object sender, FormClosingEventArgs e) { if (MessageBoxHelper.Show(RDIFrameworkMessage.MSG0204) == DialogResult.Yes) { this.ExitApplication = true; if (SystemInfo.LogOned) { if (AppStart.frmMsg != null) { AppStart.frmMsg.ExitApplication = true; AppStart.frmMsg.Close(); AppStart.frmMsg.Dispose(); } // 退出应用程序 var serviceInstance = new RDIFrameworkService(); serviceInstance.LogOnService.OnExit(UserInfo); this.CloseCommunicationObject(serviceInstance.LogOnService); } e.Cancel = false; //点击OK } else { e.Cancel = true; } }
/// <summary> /// 获取模块菜单限域数据 /// </summary> public DataTable GetModuleScope(string permissionItemScopeCode) { RDIFrameworkService platFormService = new RDIFrameworkService(); // 获取部门数据 if ((UserInfo.IsAdministrator) || (String.IsNullOrEmpty(permissionItemScopeCode) || (!SystemInfo.EnableUserAuthorizationScope))) { DataTable dtModule = platFormService.ModuleService.GetDT(UserInfo); if (platFormService.ModuleService is ICommunicationObject) { ((ICommunicationObject)platFormService.ModuleService).Close(); } // 这里需要只把有效的模块显示出来 // BusinessLogic.SetFilter(dtModule, PiModuleTable.FieldEnabled, "1"); // 未被打上删除标标志的 // BusinessLogic.SetFilter(dtModule, PiModuleTable.FieldDeleteMark, "0"); return(dtModule); } else { DataTable dataTable = platFormService.PermissionService.GetModuleDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode); if (platFormService.PermissionService is ICommunicationObject) { ((ICommunicationObject)platFormService.PermissionService).Close(); } BasePageLogic.CheckTreeParentId(dataTable, PiModuleTable.FieldId, PiModuleTable.FieldParentId); return(dataTable); } }
/// <summary> /// 置底 /// </summary> /// <returns>影响行数</returns> public int SetBottom() { RowCount = RowIndex; int returnValue = 0; string targetId = ""; targetId = dataTableFlag ? SortLogic.GetNextId(this.dataView, this.EntityId) : SortLogic.GetNextIdDyn(this.lstT, this.EntityId); if (targetId.Length > 0) { var rdiFrameworkService = new RDIFrameworkService(); string sequence = rdiFrameworkService.SequenceService.GetSequence(UserInfo, dataTableFlag ? this.dataView.Table.TableName : tabelName); if (rdiFrameworkService.SequenceService is ICommunicationObject) { ((ICommunicationObject)rdiFrameworkService.SequenceService).Close(); } if (dataTableFlag) { returnValue = BusinessLogic.SetProperty(this.dataView.Table, this.EntityId, BusinessLogic.FieldSortCode, sequence); } else { returnValue = BusinessLogic.SetPropertyDyn(this.lstT, this.EntityId, BusinessLogic.FieldSortCode, sequence); SetCRow(); } } else { if (SystemInfo.ShowInformation) { MessageBoxHelper.ShowInformationMsg(RDIFrameworkMessage.MSG0022); } } return(returnValue); }
/// <summary> /// 发送消息 /// </summary> private void SendMessage() { this.btnSend.Enabled = false; var sbmy = new StringBuilder(); // 不是发给自己的消息 if (!UserInfo.Id.Equals(this.ReceiverId)) { // 设置信息样式 var sendName = "<div style='color:#00f;font-size:12px;margin:2px;padding:0px'>" + UserInfo.RealName + "(" + UserInfo.DepartmentName + ") [" + DateTime.Now.ToLongTimeString() + "]:</div>"; //sbmy.Append("<div style='margin:2px;padding:0px 0px 0px 15px;" + // "font-family:" + txtMsgContent.Font.FontFamily.Name + ";" + // "font-size:" + // txtMsgContent.Font.Size + "pt;color:#" + // txtMsgContent.ForeColor.R.ToString("X2") + // txtMsgContent.ForeColor.G.ToString("X2") + // txtMsgContent.ForeColor.B.ToString("X2")); //sbmy.Append(";font-weight:"); //sbmy.Append(txtMsgContent.Font.Bold ? "bold" : ""); //sbmy.Append(";font-style:"); //sbmy.Append(txtMsgContent.Font.Italic ? "italic" : ""); //sbmy.Append(";'>"); //sbmy.Append(GetHtmlHref(this.txtMsgContent.Text) + "</div>"); sbmy.Append(GetHtmlHref(this.txtMsgContent.Text)); this.webMsg.DocumentText = this.webMsg.DocumentText.Insert(this.webMsg.DocumentText.Length, sendName + GetHtmlFace(sbmy.ToString())); } var serviceInstance = new RDIFrameworkService(); serviceInstance.MessageService.Send(UserInfo, this.ReceiverId, sbmy.ToString()); this.CloseCommunicationObject(serviceInstance.MessageService); this.txtMsgContent.Text = ""; this.txtMsgContent.Focus(); }
private void ProcessTable(DataTable dt) { RDIFrameworkService service = new RDIFrameworkService(); DataTable dtColumns = service.TableColumnsService.GetDTByTable(UserInfo, this.TableName); if (service.TableColumnsService is ICommunicationObject) { ((ICommunicationObject)service.TableColumnsService).Close(); } // 1:列的显示顺序 // 2:列是否显示? // 3:列的中文名字? foreach (DataRow dataRow in dtColumns.Rows) { if (!dataRow[CiTableColumnsTable.FieldEnabled].ToString().Equals("1")) { continue; } var dgvtbc = new DataGridViewTextBoxColumn { Name = dataRow[CiTableColumnsTable.FieldColumnCode].ToString(), HeaderText = dataRow[CiTableColumnsTable.FieldColumnName].ToString(), DataPropertyName = dataRow[CiTableColumnsTable.FieldColumnCode].ToString() }; this.dgvTable.Columns.Add(dgvtbc); } }
/// <summary> /// 获取组织机构权限域数据 /// </summary> public DataTable GetOrganizeScope(string permissionItemScopeCode = "Resource.ManagePermission", bool isInnerOrganize = true) { // 获取部门数据,不启用权限域 var dataTable = new DataTable(PiOrganizeTable.TableName); if ((UserInfo.IsAdministrator) || (String.IsNullOrEmpty(permissionItemScopeCode) || (!SystemInfo.EnableUserAuthorizationScope))) { dataTable = ClientCache.Instance.GetOrganizeDT(UserInfo).Copy(); if (isInnerOrganize) { BusinessLogic.SetFilter(dataTable, PiOrganizeTable.FieldIsInnerOrganize, "1"); BasePageLogic.CheckTreeParentId(dataTable, PiOrganizeTable.FieldId, PiOrganizeTable.FieldParentId); } dataTable.DefaultView.Sort = PiOrganizeTable.FieldSortCode; } else { var platFormService = new RDIFrameworkService(); dataTable = platFormService.PermissionService.GetOrganizeDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode); this.CloseCommunicationObject(platFormService.PermissionService); if (isInnerOrganize) { BusinessLogic.SetFilter(dataTable, PiOrganizeTable.FieldIsInnerOrganize, "1"); BasePageLogic.CheckTreeParentId(dataTable, PiOrganizeTable.FieldId, PiOrganizeTable.FieldParentId); } dataTable.DefaultView.Sort = PiOrganizeTable.FieldSortCode; } return(dataTable); }
/// <summary> /// 获取授权范围数据 (按道理,应该是在某个数据区域上起作用) /// </summary> public DataTable GetPermissionItemScop(string permissionItemScopeCode) { // 获取部门数据 DataTable dtPermissionItem = new DataTable(PiPermissionItemTable.TableName); RDIFrameworkService platFormService = new RDIFrameworkService(); if (UserInfo.IsAdministrator || (String.IsNullOrEmpty(permissionItemScopeCode) || (!SystemInfo.EnableUserAuthorizationScope))) { dtPermissionItem = platFormService.PermissionItemService.GetDT(UserInfo); if (platFormService.PermissionItemService is ICommunicationObject) { ((ICommunicationObject)platFormService.PermissionItemService).Close(); } // 这里需要只把有效的模块显示出来 // BusinessLogic.SetFilter(dtPermissionItem, BasePermissionItemEntity.FieldEnabled, "1"); // 未被打上删除标标志的 // BusinessLogic.SetFilter(dtPermissionItem, BasePermissionItemEntity.FieldDeleteMark, "0"); } else { dtPermissionItem = platFormService.PermissionService.GetPermissionItemDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode); if (platFormService.PermissionService is ICommunicationObject) { ((ICommunicationObject)platFormService.PermissionService).Close(); } BasePageLogic.CheckTreeParentId(dtPermissionItem, PiPermissionItemTable.FieldId, PiPermissionItemTable.FieldParentId); } return(dtPermissionItem); }
/// <summary> /// 从数据库中读取文件 /// </summary> /// <param name="id">文件主键</param> /// <returns>文件</returns> public byte[] Download(string id) { RDIFrameworkService serviceInstance = new RDIFrameworkService(); byte[] returnValue = serviceInstance.FileService.Download(UserInfo, id); if (serviceInstance.FileService is ICommunicationObject) { ((ICommunicationObject)serviceInstance.FileService).Close(); } return(returnValue); }
private void SendOnLineState() { //防止用户打开登录界面后一直不登录,此时系统会自动取其ID值为本机的IP地址,此时不应该记录登录状态,其用户主键为数据型的。 if (!MathHelper.IsInteger(UserInfo.Id)) { return; } var rdiFrameworkService = new RDIFrameworkService(); rdiFrameworkService.LogOnService.OnLine(UserInfo, 1); this.CloseCommunicationObject(rdiFrameworkService.LogOnService); }
/// <summary> /// 获得权限缓存数据 /// </summary> /// <param name="userInfo">当前用户</param> /// <returns>数据表</returns> public DataTable GetPermission(UserInfo userInfo) { if (this.dtPermission == null || (!SystemInfo.ClientCache)) { var service = new RDIFrameworkService(); this.dtPermission = service.PermissionService.GetPermissionDT(userInfo); if (service.PermissionService is ICommunicationObject) { ((ICommunicationObject)service.PermissionService).Close(); } } return(this.dtPermission); }
/// <summary> /// 获得部门缓存数据 /// </summary> /// <param name="userInfo">当前用户</param> /// <returns>部门数据表</returns> public DataTable GetOrganizeDT(UserInfo userInfo) { if ((this.dtOrganize == null) || (!SystemInfo.ClientCache)) { var service = new RDIFrameworkService(); this.dtOrganize = service.OrganizeService.GetDT(userInfo); if (service.OrganizeService is ICommunicationObject) { ((ICommunicationObject)service.OrganizeService).Close(); } } this.dtOrganize.DefaultView.Sort = PiOrganizeTable.FieldSortCode; return(this.dtOrganize); }
/// <summary> /// 获取角色权限域数据 /// </summary> public DataTable GetRoleScope(string permissionItemScopeCode) { // 获取角色数据 var dtTmpRole = new DataTable(PiRoleTable.TableName); var platFormService = new RDIFrameworkService(); if ((UserInfo.IsAdministrator) || (String.IsNullOrEmpty(permissionItemScopeCode) || (!SystemInfo.EnableUserAuthorizationScope))) { dtTmpRole = platFormService.RoleService.GetDT(UserInfo); this.CloseCommunicationObject(platFormService.RoleService); } else { dtTmpRole = platFormService.PermissionService.GetRoleDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode); this.CloseCommunicationObject(platFormService.PermissionService); } return(dtTmpRole); }
/// <summary> /// 是否有相应的权限 /// </summary> /// <param name="permissionItemCode">权限编号</param> /// <param name="permissionItemName">权限名称</param> /// <returns>有权限</returns> public bool IsAuthorized(string permissionItemCode, string permissionItemName = null) { var returnValue = false; // 加强安全验证防止未授权匿名调用 #if (!DEBUG) if (UserInfo.IsAdministrator) { return(true); } #endif // 若不使用操作权限项定义,那就所有操作权限都是不用生效了 if (!SystemInfo.EnablePermissionItem) { return(true); } /* * //法一:本地缓存权限判断法: * // 这里是判断本地缓存操作权限 * if (ClientCache.Instance.DTPermission == null) * { * // return false; * // 重新读取本地缓存里的操作权限 * ClientCache.Instance.GetPermission(this.UserInfo); * } * // 直接判断是否有相应的操作权限 * returnValue = BusinessLogic.IsAuthorized(ClientCache.Instance.DTPermission, permissionItemCode); * if (returnValue) * { * return true; * } */ //法二:直接服务上进行权限判断,也可法一与法二结合。 // 在服务器上进行权限判断(及时性高,但效率会低一些) if (!returnValue) { var platFormService = new RDIFrameworkService(); returnValue = platFormService.PermissionService.IsAuthorizedByUserId(this.UserInfo, this.UserInfo.Id, permissionItemCode, permissionItemName); this.CloseCommunicationObject(platFormService.PermissionService); } return(returnValue); }
/// <summary> /// 关闭窗体 /// </summary> private void FormOnClosed() { if (!this.DesignMode) { // 是否记录访问日志,已经登录了系统了,才记录日志 if (SystemInfo.EnableRecordLog && SystemInfo.LogOned) { // 保存列宽 BasePageLogic.SaveDataGridViewColumnWidth(this); // 调用服务事件 if (this.RecordFormLog) { var service = new RDIFrameworkService(); service.LogService.WriteExit(UserInfo, this.LogId); this.CloseCommunicationObject(service.LogService); } } } }
/// <summary> /// 绑定屏幕数据 /// </summary> private void GetList(string searchValue) { RDIFrameworkService Service = new RDIFrameworkService(); if (this.UserIds != null && this.UserIds.Length > 1) { this.DTUserList = Service.UserService.GetDTByIds(this.UserInfo, this.UserIds); } else { int recordCount = 0; this.DTUserList = Service.UserService.GetDTByPage(UserInfo, searchValue, this.OrganizeId, this.RoleId, out recordCount, ucPager.PageIndex, ucPager.PageSize, PiUserTable.TableName + "." + PiUserTable.FieldSortCode); ucPager.RecordCount = recordCount; ucPager.InitPageInfo(); } CloseCommunicationObject(Service.StaffService); this.DTUserList.PrimaryKey = new DataColumn[] { this.DTUserList.Columns[PiUserTable.FieldId] }; this.dgvUser.DataSource = this.DTUserList; }
/// <summary> /// 获取用户权限 /// </summary> /// <param name="userInfo">当前用户</param> public void GetUserPermission(UserInfo userInfo) { //获取模块列表 var service = new RDIFrameworkService(); ClientCache.Instance.DTMoule = service.ModuleService.GetDT(userInfo); if (service.ModuleService is ICommunicationObject) { ((ICommunicationObject)service.ModuleService).Close(); } // 获取用户模块访问权限范围 ClientCache.Instance.DTUserMoule = service.PermissionService.GetModuleDTByUserId(userInfo, userInfo.Id); if (service.PermissionService is ICommunicationObject) { ((ICommunicationObject)service.PermissionService).Close(); } // 获取用户的操作权限 ClientCache.Instance.DTPermission = null; ClientCache.Instance.GetPermission(userInfo); }
private void GetOnLineState() { if (!this.Visible) { return; } if (!this.FormLoaded || (this.Busyness)) { return; } if (this.tvOrganize.InvokeRequired) { SetGetOnLineState onLineState = this.GetOnLineState; this.Invoke(onLineState); } else { try { var serviceInstance = new RDIFrameworkService(); var dataTable = serviceInstance.MessageService.GetOnLineState(this.UserInfo); CloseCommunicationObject(serviceInstance.MessageService); if (this.tcMsg.SelectedTab == this.tpOrganize) { this.SetTreeViewOnLineState(dataTable, this.tvOrganize); } if (this.tcMsg.SelectedTab == this.tpRole) { this.SetTreeViewOnLineState(dataTable, this.tvRole); } } catch (System.Exception ex) { // 在本地记录异常 FileHelper.WriteException(UserInfo, ex); } } }
/// <summary> /// 加载业务角色 /// </summary> private void LoadApplicationRole() { var serviceInstance = new RDIFrameworkService(); this.DTRole = serviceInstance.RoleService.GetDT(this.UserInfo); CloseCommunicationObject(serviceInstance.RoleService); // 开始更新控件,屏幕不刷新,提高效率。 this.tvRole.BeginUpdate(); this.tvRole.Nodes.Clear(); foreach (DataRow dataRow in this.DTRole.Rows) { PiRoleEntity roleEntity = BaseEntity.Create <PiRoleEntity>(dataRow); // 当前节点的子节点, 加载根节点 var treeNode = new TreeNode { Text = roleEntity.RealName, Tag = roleEntity.Id }; treeNode.Tag = roleEntity; this.tvRole.Nodes.Add(treeNode); } this.tvRole.EndUpdate(); }
/// <summary> /// 获取用户权限域数据 /// </summary> public DataTable GetUserScope(string permissionItemScopeCode) { // 是否有用户管理权限,若有用户管理权限就有所有的用户类表,这个应该是内置的操作权限 var userAdmin = false; //userAdmin = this.IsAuthorized("UserAdmin"); //V2.8 版 暂时取消(用户可根据自己需要,只要登录用户可以访问用户表,就可以看到所有的用户,这儿就取消注释) //用户授权范围,不仅包含设置给用户的可管理用户范围,还包含用户可管理的组织机构范围下对应的用户。 var tmpUserDT = new DataTable(PiUserTable.TableName); // 获取用户数据 var platFormService = new RDIFrameworkService(); if (userAdmin || this.UserInfo.IsAdministrator || (String.IsNullOrEmpty(permissionItemScopeCode) || (!SystemInfo.EnableUserAuthorizationScope))) { tmpUserDT = platFormService.UserService.GetDT(UserInfo); this.CloseCommunicationObject(platFormService.UserService); } else { tmpUserDT = platFormService.PermissionService.GetUserDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode); this.CloseCommunicationObject(platFormService.PermissionService); } return(tmpUserDT); }
/// <summary> /// 获取员工权限域数据 /// </summary> public DataTable GetRoleScope(string permissionItemScopeCode) { // 获取部门数据 DataTable returnValue = new DataTable(PiOrganizeTable.TableName); RDIFrameworkService platFormService = new RDIFrameworkService(); if ((UserInfo.IsAdministrator) || (String.IsNullOrEmpty(permissionItemScopeCode) || (!SystemInfo.EnableUserAuthorizationScope))) { returnValue = platFormService.RoleService.GetDT(UserInfo); if (platFormService.RoleService is ICommunicationObject) { ((ICommunicationObject)platFormService.RoleService).Close(); } } else { returnValue = platFormService.PermissionService.GetRoleDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode); if (platFormService.PermissionService is ICommunicationObject) { ((ICommunicationObject)platFormService.PermissionService).Close(); } } return(returnValue); }
/// <summary> /// 得到新消息 /// </summary> private void GetNewMessage() { if (this.ExitApplication) { return; } if (!this.FormLoaded || (this.Busyness)) { return; } if (this.tvOrganize.InvokeRequired) { if (this.ExitApplication) { return; } SetGetNewMessage getNewMessage = this.GetNewMessage; this.Invoke(getNewMessage); } else { try { // 获取最新即时通讯消息 var serviceInstance = new RDIFrameworkService(); // 这里获取用户的登录凭证,看与本地的是否一致? var openId = string.Empty; var dataTable = serviceInstance.MessageService.GetDTNew(this.UserInfo, out openId); if ((dataTable != null) && (dataTable.Rows.Count > 0)) { var messageEntity = new CiMessageEntity(); for (var i = 0; i < dataTable.Rows.Count; i++) { messageEntity.GetFrom(dataTable.Rows[i]); if (messageEntity.FunctionCode.Equals("UserMessage")) { this.ShowMessage(messageEntity); } else { this.ShowRemind(messageEntity); } //TODO:系统推送的... // 将信息标记为已阅读 serviceInstance.MessageService.Read(UserInfo, messageEntity.Id); } if (serviceInstance.MessageService is ICommunicationObject) { ((ICommunicationObject)serviceInstance.MessageService).Close(); } } // 若检查在线状态,根本就无法登录了,所以加上这样的判断 if (SystemInfo.CheckOnLine && !UserInfo.OpenId.Equals(openId)) { if (AppStart.frmMsg != null) { AppStart.frmMsg.ExitApplication = true; AppStart.frmMsg.AbortThread(); AppStart.frmMsg.Close(); AppStart.frmMsg.Dispose(); } // 修改当前用户的登录状态 SystemInfo.LogOned = false; if (MessageBox.Show(RDIFrameworkMessage.MSG0300, RDIFrameworkMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Stop) == System.Windows.Forms.DialogResult.OK) { Application.Exit(); } } } catch (System.Exception ex) { // 在本地记录异常 FileHelper.WriteException(UserInfo, ex); } } }
/// <summary> /// 获得表格里的用户 /// </summary> private void GetUserList(TreeNode selectedNode) { // 当前是空节点 if (selectedNode == null) { return; } // 当前节点是用户节点 if (selectedNode.StateImageIndex >= 2) { return; } // 是否已经加了用户节点 if (selectedNode.Nodes.Count != 0) { // return; } // 检查是否已经加载了用户 if (this.UserLoaded(selectedNode)) { selectedNode.Nodes.Clear(); } try { this.Cursor = Cursors.WaitCursor; var id = string.Empty; if (selectedNode.Tag is PiOrganizeEntity) { id = ((PiOrganizeEntity)selectedNode.Tag).Id.ToString(); } else if (selectedNode.Tag is PiRoleEntity) { id = ((PiRoleEntity)selectedNode.Tag).Id.ToString(); } else { id = selectedNode.Tag.ToString(); } var serviceInstance = new RDIFrameworkService(); this.DTUser = this.tcMsg.SelectedTab == this.tpOrganize ? serviceInstance.MessageService.GetUserDTByOrganize(UserInfo, id) : serviceInstance.MessageService.GetUserDTByRole(UserInfo, id); CloseCommunicationObject(serviceInstance.MessageService); if (this.DTUser == null || this.DTUser.Rows.Count <= 0) { return; } var tmpCurNodeText = selectedNode.Text; selectedNode.Text = @"加载中..."; Application.DoEvents(); foreach (DataRow dataRow in this.DTUser.Rows) { if (!String.IsNullOrEmpty(dataRow[PiUserTable.FieldId].ToString())) { var treeNode = new TreeNode { Tag = BaseEntity.Create <PiUserEntity>(dataRow), Text = dataRow[PiUserTable.FieldRealName].ToString() }; this.SetTreeNodeState(treeNode, dataRow[PiUserLogOnTable.FieldUserOnLine].ToString()); selectedNode.Nodes.Add(treeNode); } } selectedNode.Text = tmpCurNodeText; Application.DoEvents(); selectedNode.Expand(); } catch (System.Exception ex) { this.WriteException(ex); } finally { this.Cursor = Cursors.Default; } }
/// <summary> /// 加载窗体 /// </summary> public override void FormOnLoad() { this.TopMost = true; this.Left = 600; //设置控件的角度 this.Region = new DrawUtil().SetControlRegion(this, 6); // 设置按钮状态 // this.SetControlState(); // 若是在忙碌状态,退出本程序 // if (!this.FormLoaded || this.Busyness) //{ // return; //} // 设置鼠标繁忙状态,并保留原先的状态 var holdCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; // 设置开关变量 this.Busyness = true; this.FormLoaded = false; // 设置窗体的显示位置 if (this.WindowState == FormWindowState.Normal) { var rectangle = System.Windows.Forms.SystemInformation.VirtualScreen; var width = rectangle.Width; var height = rectangle.Height; this.Left = width - this.Width; } try { var serviceInstance = new RDIFrameworkService(); this.DTOrganize = serviceInstance.MessageService.GetInnerOrganizeDT(this.UserInfo); //this.DTRole = serviceInstance.RoleService.GetDT(this.UserInfo); CloseCommunicationObject(serviceInstance.MessageService); // 过滤数据 // BusinessLogic.SetFilter(this.DTOrganize, PiOrganizeTable.FieldEnabled, "1"); // 只显示内部部门 // BUBusinessLogic.SetFilter(this.DTOrganize, PiOrganizeTable.FieldIsInnerOrganize, "1"); // this.DTOrganize.AcceptChanges(); // 绑定屏幕数据 this.BindData(true); if (this.tvOrganize.Nodes.Count > 0) { this.tvOrganize.Nodes[0].Expand(); } // 阅读消息 // this.timerMessage.Enabled = true; } catch (Exception ex) { this.ProcessException(ex); } finally { // 设置鼠标默认状态,原来的光标状态 this.Cursor = holdCursor; } if (SystemInfo.UseMessage) { this.MessageThread = new Thread(new ThreadStart(this.CheckNewMessage)); MessageThread.Start(); this.OnLineThread = new Thread(new ThreadStart(this.CheckOnLineState)); OnLineThread.Start(); } this.FormLoaded = true; this.Busyness = false; }
public virtual void Form_Load(object sender, EventArgs e) { if (!this.DesignMode) { // 设置鼠标繁忙状态,并保留原先的状态 var holdCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; this.FormLoaded = false; try { if (!this.DesignMode) { // 是否记录访问日志 if (SystemInfo.EnableRecordLog && (SystemInfo.LogOned && this.RecordFormLog)) { // 调用服务事件 //this.LogId = RDIFrameworkService.Instance.LogService.WriteLog(UserInfo, this.Name, this.Text, "FormLoad"); var platFormService = new RDIFrameworkService(); platFormService.LogService.WriteLog(UserInfo, this.Name, RDIFrameworkMessage.GetMessage(this.Name), "FormLoad", RDIFrameworkMessage.LoadWindow); this.CloseCommunicationObject(platFormService.LogService); } } // 必须放在初始化组件之前 this.GetIcon(); // 获得页面的权限 this.GetPermission(); // 加载窗体 this.FormOnLoad(); // 设置按钮状态 this.SetControlState(); if (SystemInfo.MultiLanguage) { try { // 多语言国际化加载 if (ResourceManagerWrapper.Instance.GetLanguages() != null) { this.Localization(this); } } catch (Exception ex) { MessageBoxHelper.ShowErrorMsg(ex.Message); } } if (this.LoadUserParameters) { // 客户端页面配置加载 this.LoadUserParameter(this); } // 设置帮助 this.SetHelp(); } catch (Exception ex) { this.ProcessException(ex); } finally { this.FormLoaded = true; // 设置鼠标默认状态,原来的光标状态 this.Cursor = holdCursor; } } }
/// <summary> /// 是否有相应的权限 /// </summary> /// <param name="permissionItemCode">权限编号</param> /// <param name="permissionItemName">权限名称</param> /// <returns>有权限</returns> public bool IsAuthorized(string permissionItemCode, string permissionItemName = null) { // 默认为了安全起见、设置为无权限比较好 bool returnValue = false; // 先判断用户是否超级管理员,若是超级管理员,就不用判断操作权限了(这个是有点儿C/S的特色) // 加强安全验证防止未授权匿名调用 #if (!DEBUG) if (UserInfo.IsAdministrator) { return(true); } #endif // 若不使用操作权限项定义,那就所有操作权限都是不用生效了 if (!SystemInfo.EnablePermissionItem) { return(true); } /* * // 这里是判断本地缓存里,操作权限是否为空? * if (ClientCache.Instance.DTPermission == null) * { * // return false; * // 重新读取本地缓存里的操作权限 * ClientCache.Instance.GetPermission(this.UserInfo); * } * // 直接判断是否有相应的操作权限 * returnValue = BusinessLogic.IsAuthorized(ClientCache.Instance.DTPermission, permissionItemCode); * if (returnValue)) * { * return true; * } * returnValue = BusinessLogic.IsAuthorized(ClientCache.Instance.DTPermission, permissionItemCode); * * // 查看看是否设置了操作权限映射关系表 * string fileName = Application.StartupPath + "\\" + "PermissionMapping.xml"; * if (System.IO.File.Exists(fileName)) * { * // 获得映射的操作权限编号 * string code = ConfigHelper.GetValue(fileName, permissionItemCode); * if (!String.IsNullOrEmpty(code)) * { * permissionItemCode = code; * } * } */ // 虽然这样读取权限效率低一些,但是会及时性高一些,例如这个时候正好权限被调整了 // 这里是在服务器上进行权限判断,远程进行权限判断(B/S的都用这个方法直接判断权限) if (!returnValue) { RDIFrameworkService platFormService = new RDIFrameworkService(); returnValue = platFormService.PermissionService.IsAuthorizedByUserId(this.UserInfo, this.UserInfo.Id, permissionItemCode, permissionItemName); if (platFormService.PermissionService is ICommunicationObject) { ((ICommunicationObject)platFormService.PermissionService).Close(); } } return(returnValue); }
/// <summary> /// 用户登录 /// </summary> /// <returns>是否成功</returns> private bool LogOn() { // 设置鼠标繁忙状态,并保留原先的状态 Cursor holdCursor = this.Cursor; this.Cursor = Cursors.WaitCursor; // 已经登录次数 ++ this.LogOnCount++; string statusCode = string.Empty; string statusMessage = string.Empty; try { string userName = this.txtUserName.Text; var rdiFrameworkService = new RDIFrameworkService(); var userInfo = rdiFrameworkService.LogOnService.UserLogOn(UserInfo, userName, this.txtPassword.Text, UserInfo.OpenId, true, out statusCode, out statusMessage); this.CloseCommunicationObject(rdiFrameworkService.LogOnService); if (statusCode == StatusCode.OK.ToString()) { // 检查身份 if ((userInfo != null) && (userInfo.Id.Length > 0)) { // 用户登录,保存登录信息 SystemInfo.UserInfo = userInfo; // 保存登录信息 this.SaveLogOnInfo(userInfo); // 这里表示已经登录系统了 SystemInfo.LogOned = true; // 这里是登录功能部分 if (this.Parent == null) { this.Hide(); Form mainForm = this.Owner; // 这里不允许重复初始化服务 //((IBaseMainForm)mainForm).InitService(); ((IBaseMainForm)mainForm).InitForm(); ((IBaseMainForm)mainForm).CheckMenu(); mainForm.Show(); } // 登录次数归零,允许重新登录 this.LogOnCount = 0; // 密码强度检查 // 周期性更换密码要求,一个月更换一次密码,30天 if (SystemInfo.EnableCheckPasswordStrength) { bool chanagePassword = false; string message = string.Empty; PiUserLogOnEntity userLogOnEntity = RDIFrameworkService.Instance.LogOnService.GetEntity(UserInfo, userInfo.Id); if (userLogOnEntity.ChangePasswordDate == null) { message = RDIFrameworkMessage.MSG0062; chanagePassword = true; } else { TimeSpan ts = DateTime.Now.Subtract((DateTime)userLogOnEntity.ChangePasswordDate); if (ts.TotalDays > 30) { message = RDIFrameworkMessage.MSG0063; chanagePassword = true; } } if (chanagePassword) { string assemblyName = "RDIFramework.WinModule"; string formName = "FrmChangePassword"; Type assemblyType = CacheManager.Instance.GetType(assemblyName, formName); var frmUserChangePassword = (Form)Activator.CreateInstance(assemblyType); frmUserChangePassword.ShowDialog(this); } } } this.DialogResult = DialogResult.OK; } else { System.Text.StringBuilder sbMessage = new System.Text.StringBuilder(); sbMessage.Append("用户验证过程中出现未知错误,请记录下面的异常信息,并通知您的\n系统管理员。\n"); sbMessage.Append("当前用户:“" + txtUserName.Text.Trim() + "”,信息:" + statusMessage); sbMessage.Append("\n提示:密码是区分大小写的,请确定你是否因为疏忽而按下了“Caps Lock”键,该\n"); sbMessage.Append("键将会使你键入的任何字母自动转换为大写形式,从而可能导致您的密码不正确。\n"); sbMessage.Append("如果忘记了密码,请通知您的系统管理员,请他(她)帮助您解决这个问题。"); MessageBoxHelper.ShowWarningMsg(sbMessage.ToString()); this.txtPassword.Focus(); this.txtPassword.SelectAll(); return(false); } } catch (Exception ex) { this.ProcessException(ex); Application.ExitThread(); } finally { // 已经忙完了 this.Cursor = holdCursor; } return(true); }