Пример #1
0
        private void btnSend_Click(object sender, EventArgs e)
        {
            StringBuilder sbmy = new StringBuilder();
            sbmy.Append("<div style='margin:2px;padding:0px 0px 0px 15px;" +
                    "font-family:" + this.txtContents.Font.FontFamily.Name + ";" +
                    "font-size:" +
                    this.txtContents.Font.Size + "pt;color:#" +
                    this.txtContents.ForeColor.R.ToString("X2") +
                    this.txtContents.ForeColor.G.ToString("X2") +
                    this.txtContents.ForeColor.B.ToString("X2"));
            sbmy.Append(";font-weight:");
            sbmy.Append(this.txtContents.Font.Bold ? "bold" : "");
            sbmy.Append(";font-style:");
            sbmy.Append(this.txtContents.Font.Italic ? "italic" : "");
            sbmy.Append(";'>");
            sbmy.Append(GetHtmlHref(this.txtContents.Text) + "</div>");

            DotNetService dotNetService = new DotNetService();
            // 发送信息
            dotNetService.MessageService.Broadcast(UserInfo, sbmy.ToString());
            if (dotNetService.MessageService is ICommunicationObject)
            {
                ((ICommunicationObject)dotNetService.MessageService).Close();
            }
            // 2010-12-15 发好信息了,还是关闭了比较好
            // this.txtContent.Clear();
            // this.txtContent.Focus();
            this.Close();
        }
Пример #2
0
 /// <summary>
 /// 批量删除
 /// </summary>
 public override int BatchDelete()
 {
     DotNetService dotNetService = new DotNetService();
     int returnValue = dotNetService.ExceptionService.BatchDelete(this.UserInfo, this.GetSelecteIds());
     if (dotNetService.ExceptionService is ICommunicationObject)
     {
         ((ICommunicationObject)dotNetService.ExceptionService).Close();
     }
     // 绑定数据
     this.GetList();
     return returnValue;
 }
Пример #3
0
 public override void FormOnLoad()
 {
     this.BindItemDetails();
     // 是否锁定系统
     DotNetService dotNetService = new DotNetService();
     string isLockSystem = dotNetService.ParameterService.GetParameter(UserInfo, "User", UserInfo.Id, "IsLockSystem");
     // 锁定等待时间
     string lockWaitMinute = dotNetService.ParameterService.GetParameter(UserInfo, "User", UserInfo.Id, "LockWaitMinute");
     if (dotNetService.ParameterService is ICommunicationObject)
     {
         ((ICommunicationObject)dotNetService.ParameterService).Close();
     }
     // 这里是需要保证,默认是选中的,只有被确认过不选,才是不选才对
     this.ckbIsLock.Checked = (isLockSystem == false.ToString() ? false : true);
     // 这里也要保证,屏幕上的默认值能保存,只有客户设置过参数才读取客户的参数
     if (!string.IsNullOrEmpty(lockWaitMinute))
     {
         this.cmbLockWaitMinute.SelectedValue = lockWaitMinute;
     }
     if (this.Owner != null)
     {
         this.Owner.Opacity = 0;
     }
 }
Пример #4
0
        /// <summary>
        /// 获得表格里的用户
        /// </summary>
        private void GetUserList(TreeNode selectedNode)
        {
            // 设置鼠标繁忙状态,并保留原先的状态
            // Cursor holdCursor = this.Cursor;
            // this.Cursor = Cursors.WaitCursor;

            // 当前是空节点
            if (selectedNode == null)
            {
                return;
            }
            // 当前节点是用户节点
            if (selectedNode.StateImageIndex > 2)
            {
                return;
            }
            // 是否已经加了用户节点
            if (selectedNode.Nodes.Count != 0)
            {
                // return;
            }
            // 检查是否已经加载了用户
            if (this.UserLoaded(selectedNode))
            {
                selectedNode.Nodes.Clear();
            }
            try
            {
                DotNetService dotNetService = new DotNetService();
                string id = ((BaseOrganizeEntity)selectedNode.Tag).Id.ToString();
                if (this.tcMessage.SelectedTab == this.tpOrganize)
                {
                    this.DTUser = dotNetService.MessageService.GetUserDTByOrganize(UserInfo, id);
                }
                else
                {
                    this.DTUser = dotNetService.MessageService.GetUserDTByRole(UserInfo, id);
                }
                if (dotNetService.MessageService is ICommunicationObject)
                {
                    ((ICommunicationObject)dotNetService.MessageService).Close();
                }
                // 过滤数据
                // BaseBusinessLogic.SetFilter(this.DTStaff, BaseStaffEntity.FieldEnabled, "1");
                // BaseBusinessLogic.SetFilter(this.DTStaff, BaseStaffEntity.FieldDeletionStateCode, "0");
                foreach (DataRow dataRow in this.DTUser.Rows)
                {
                    if (!String.IsNullOrEmpty(dataRow[BaseUserEntity.FieldId].ToString()))
                    {
                        TreeNode treeNode = new TreeNode();
                        treeNode.Tag = new BaseUserEntity(dataRow);
                        treeNode.Text = dataRow[BaseUserEntity.FieldRealName].ToString();
                        this.SetTreeNodeState(treeNode, dataRow[BaseUserEntity.FieldUserOnLine].ToString());
                        selectedNode.Nodes.Add(treeNode);
                    }
                }
            }
            catch (System.Exception ex)
            {
                this.WriteException(ex);
            }
            // 设置鼠标默认状态,原来的光标状态
            // this.Cursor = holdCursor;
        }
Пример #5
0
 /// <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.txtUser.Text;
         DotNetService dotNetService = new DotNetService();
         BaseUserInfo userInfo = dotNetService.LogOnService.UserLogOn(UserInfo, userName, this.txtPassword.Text, true, out statusCode, out statusMessage);
         if (dotNetService.LogOnService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.LogOnService).Close();
         }
         if (statusCode == StatusCode.OK.ToString())
         {
             // 检查身份
             if ((userInfo != null) && (userInfo.Id.Length > 0))
             {
                 // 用户登录,保存登录信息
                 BaseSystemInfo.UserInfo = userInfo;
                 // 保存登录信息
                 this.SaveLogOnInfo(userInfo);
                 // 这里表示已经登录系统了
                 BaseSystemInfo.UserIsLogOn = 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 (BaseSystemInfo.CheckPasswordStrength)
                 {
                     bool chanagePassword = false;
                     string message = string.Empty;
                     BaseUserEntity userEntity = dotNetService.UserService.GetEntity(userInfo, userInfo.Id);
                     if (dotNetService.UserService is ICommunicationObject)
                     {
                         ((ICommunicationObject)dotNetService.UserService).Close();
                     }
                     if (userEntity.ChangePasswordDate == null)
                     {
                         message = AppMessage.MSG0062;
                         chanagePassword = true;
                     }
                     else
                     {
                         TimeSpan ts = ((DateTime)userEntity.ChangePasswordDate).Subtract(DateTime.Now);
                         if (ts.TotalDays > 30)
                         {
                             message = AppMessage.MSG0063;
                             chanagePassword = true;
                         }
                     }
                     if (chanagePassword)
                     {
                         string assemblyName = "DotNet.WinForm.User";
                         string formName = "FrmUserChangePassword";
                         Type assemblyType = CacheManager.Instance.GetType(assemblyName, formName);
                         Form frmUserChangePassword = (Form)Activator.CreateInstance(assemblyType, message);
                         frmUserChangePassword.ShowDialog(this);
                     }
                 }
             }
             this.DialogResult = DialogResult.OK;
         }
         else
         {
             MessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.txtPassword.Focus();
             this.txtPassword.SelectAll();
             return false;
         }
     }
     catch (Exception ex)
     {
         this.ProcessException(ex);
     }
     finally
     {
         // 已经忙完了
         this.Cursor = holdCursor;
     }
     return true;
 }
Пример #6
0
 /// <summary>
 /// 从数据库中读取文件
 /// </summary>
 /// <param name="id">文件主键</param>
 /// <returns>文件</returns>
 public byte[] Download(string id)
 {
     DotNetService dotNetService = new DotNetService();
     byte[] returnValue = dotNetService.FileService.Download(UserInfo, id);
     if (dotNetService.FileService is ICommunicationObject)
     {
         ((ICommunicationObject)dotNetService.FileService).Close();
     }
     return returnValue;
     // OleDbHelper dbHelper = new SqlHelper();
     // dbHelper.Open();
     // byte[] fileContent = null;
     // string sqlQuery = " SELECT " + BaseFileEntity.FieldFileContent
     //                + "   FROM " + BaseFileEntity.TableName
     //                + "  WHERE " + BaseFileEntity.FieldId + " = '" + Id + "'";
     // OleDbDataReader dataReader = (OleDbDataReader)dbHelper.ExecuteReader(sqlQuery);
     // if (dataReader.Read())
     // {
     //    fileContent = (byte[])dataReader[BaseFileEntity.FieldFileContent];
     // }
     // dbHelper.Close();
     // return fileContent;
 }
Пример #7
0
 private void ProcessTable(DataTable dt)
 {
     DotNetService dotNetService = new DotNetService();
     DataTable dtColumns = dotNetService.TableColumnsService.GetDataTableByTable(UserInfo, this.TableName);
     if (dotNetService.TableColumnsService is ICommunicationObject)
     {
         ((ICommunicationObject)dotNetService.TableColumnsService).Close();
     }
     // 1:列的显示顺序
     // 2:列是否显示?
     // 3:列的中文名字?
     foreach (DataRow dataRow in dtColumns.Rows)
     {
         if (dataRow[BaseTableColumnsEntity.FieldEnabled].ToString().Equals("1"))
         {
             DataGridViewTextBoxColumn dgvtbc = new DataGridViewTextBoxColumn();
             dgvtbc.Name = dataRow[BaseTableColumnsEntity.FieldColumnCode].ToString();
             dgvtbc.HeaderText = dataRow[BaseTableColumnsEntity.FieldColumnName].ToString();
             dgvtbc.DataPropertyName = dataRow[BaseTableColumnsEntity.FieldColumnCode].ToString();
             this.grdTable.Columns.Add(dgvtbc);
         }
     }
 }
Пример #8
0
        /// <summary>
        /// 发送消息
        /// </summary>
        private void SendMessage()
        {
            this.btnSend.Enabled = false;
            StringBuilder sbmy = new StringBuilder();
            // 不是发给自己的消息
            if (!UserInfo.Id.Equals(this.ReceiverId))
            {
                // 设置信息样式 GGYY
                string 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:" + txtContent.Font.FontFamily.Name + ";" +
                    "font-size:" +
                    txtContent.Font.Size + "pt;color:#" +
                    txtContent.ForeColor.R.ToString("X2") +
                    txtContent.ForeColor.G.ToString("X2") +
                    txtContent.ForeColor.B.ToString("X2"));
                sbmy.Append(";font-weight:");
                sbmy.Append(txtContent.Font.Bold ? "bold" : "");
                sbmy.Append(";font-style:");
                sbmy.Append(txtContent.Font.Italic ? "italic" : "");
                sbmy.Append(";'>");
                sbmy.Append(GetHtmlHref(this.txtContent.Text) + "</div>");

                this.webMessage.DocumentText = this.webMessage.DocumentText.Insert(this.webMessage.DocumentText.Length, sendName + GetHtmlFace(sbmy.ToString()));
                //this.webBMsg.DocumentText = this.webBMsg.DocumentText.Insert(this.webBMsg.DocumentText.Length, strSendName + sbmy.ToString());
                //sb1.Insert(0, strSendName);
            }
            DotNetService dotNetService = new DotNetService();
            dotNetService.MessageService.Send(UserInfo, this.ReceiverId, sbmy.ToString());
            if (dotNetService.MessageService is ICommunicationObject)
            {
                ((ICommunicationObject)dotNetService.MessageService).Close();
            }
            this.txtContent.Clear();
            this.txtContent.Focus();
        }
Пример #9
0
 /// <summary>
 /// 设置控件状态
 /// </summary>
 public override void SetControlState()
 {
     if (!this.ReceiverId.Equals(this.UserInfo.Id))
     {
         this.btnSend.Enabled = (!string.IsNullOrEmpty(this.ReceiverId) && (this.txtContent.Text.Length > 0));
     }
     DotNetService dotNetService = new DotNetService();
     BaseUserEntity userEntity = dotNetService.UserService.GetEntity(this.UserInfo, this.ReceiverId);
     this.Text = userEntity.RealName + " (" + userEntity.DepartmentName + ")";
 }
Пример #10
0
        public virtual void Form_Load(object sender, EventArgs e)
        {
            if (!this.DesignMode)
            {
                // 设置鼠标繁忙状态,并保留原先的状态
                Cursor holdCursor = this.Cursor;
                this.Cursor = Cursors.WaitCursor;
                this.FormLoaded = false;
                try
                {
                    if (!this.DesignMode)
                    {
                        // 是否记录访问日志
                        if (BaseSystemInfo.RecordLog)
                        {
                            // 已经登录了系统了,才记录日志
                            if (BaseSystemInfo.UserIsLogOn)
                            {
                                // 调用服务事件
                                if (this.RecordFormLog)
                                {
                                    // 调用服务事件
                                    // this.LogId = DotNetService.Instance.LogService.WriteLog(UserInfo, this.Name, this.Text, "FormLoad");
                                    DotNetService dotNetService = new DotNetService();
                                    dotNetService.LogService.WriteLog(UserInfo, this.Name, AppMessage.GetMessage(this.Name), "FormLoad", AppMessage.LoadWindow);
                                    if (dotNetService.LogService is ICommunicationObject)
                                    {
                                        ((ICommunicationObject)dotNetService.LogService).Close();
                                    }
                                }
                            }
                        }
                    }

                    // 必须放在初始化组件之前
                    this.GetIcon();
                    // 获得页面的权限
                    this.GetPermission();
                    // 加载窗体
                    this.FormOnLoad();
                    // 设置按钮状态
                    this.SetControlState();
                    if (BaseSystemInfo.MultiLanguage)
                    {
                        // 多语言国际化加载
                        if (ResourceManagerWrapper.Instance.GetLanguages() != null)
                        {
                            this.Localization(this);
                        }
                    }
                    if (this.LoadUserParameters)
                    {
                        // 客户端页面配置加载
                        this.LoadUserParameter(this);
                    }
                    // 设置帮助
                    this.SetHelp();
                }
                catch (Exception ex)
                {
                    this.ProcessException(ex);
                }
                finally
                {
                    this.FormLoaded = true;
                    // 设置鼠标默认状态,原来的光标状态
                    this.Cursor = holdCursor;
                }
            }
        }
Пример #11
0
 /// <summary>
 /// 获取用户权限
 /// </summary>
 /// <param name="userInfo">当前用户</param>
 public void GetUserPermission(BaseUserInfo userInfo)
 {
     // 获取模块列表
     DotNetService dotNetService = new DotNetService();
     ClientCache.Instance.DTMoule = dotNetService.ModuleService.GetDataTable(userInfo);
     if (dotNetService.ModuleService is ICommunicationObject)
     {
         ((ICommunicationObject)dotNetService.ModuleService).Close();
     }
     // 获取用户模块访问权限范围
     ClientCache.Instance.DTUserMoule = dotNetService.PermissionService.GetModuleDTByUser(userInfo, userInfo.Id);
     if (dotNetService.PermissionService is ICommunicationObject)
     {
         ((ICommunicationObject)dotNetService.PermissionService).Close();
     }
     // 获取用户的操作权限
     ClientCache.Instance.DTPermission = null;
     ClientCache.Instance.GetPermission(userInfo);
 }
Пример #12
0
 /// <summary>
 /// 获得权限缓存数据
 /// </summary>
 /// <param name="userInfo">当前用户</param>
 /// <returns>数据表</returns>
 public DataTable GetPermission(BaseUserInfo userInfo)
 {
     if ((this.dtPermission == null) || (!BaseSystemInfo.ClientCache))
     {
         DotNetService dotNetService = new DotNetService();
         this.dtPermission = dotNetService.PermissionService.GetPermissionDT(userInfo);
         if (dotNetService.PermissionService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.PermissionService).Close();
         }
     }
     return this.dtPermission;
 }
Пример #13
0
 /// <summary>
 /// 获得部门缓存数据
 /// </summary>
 /// <param name="userInfo">当前用户</param>
 /// <returns>部门数据表</returns>
 public DataTable GetOrganizeDT(BaseUserInfo userInfo)
 {
     if ((this.dtOrganize == null) || (!BaseSystemInfo.ClientCache))
     {
         DotNetService dotNetService = new DotNetService();
         this.dtOrganize = dotNetService.OrganizeService.GetDataTable(userInfo);
         if (dotNetService.OrganizeService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.OrganizeService).Close();
         }
     }
     this.dtOrganize.DefaultView.Sort = BaseOrganizeEntity.FieldSortCode;
     return this.dtOrganize;
 }
Пример #14
0
 private void Search(string organizeId)
 {
     int recordCount = 0;
     DotNetService dotNetService = new DotNetService();
     // 获取数据
     this.DTStaff = dotNetService.StaffService.GetAddressDataTableByPage(UserInfo, organizeId, this.txtSearch.Text, pager.PageSize, pager.PageIndex, out recordCount);
     if (dotNetService.StaffService is ICommunicationObject)
     {
         ((ICommunicationObject)dotNetService.StaffService).Close();
     }
     pager.RecordCount = recordCount;
     pager.InitPageInfo();
     // 绑定屏幕数据
     this.BindData();
 }
Пример #15
0
        private void tmrTask_Tick(object sender, EventArgs e)
        {
            // 前提是用户已经登录系统了
            if (BaseSystemInfo.UserIsLogOn)
            {
                // 当退出程序时把当前用户的状态修改为离线状态
                if (BaseSystemInfo.CheckOnLine || (BaseSystemInfo.OnLineLimit > 0))
                {
                    try
                    {
                        // 每次都建立一个新的链接
                        DotNetService serviceManager = new DotNetService();
                        serviceManager.LogOnService.OnLine(this.UserInfo, 1);

                        // 每次都采用同一个连接,可能会有超时问题导致
                        // DotNetService.Instance.LogOnService.OnLine(this.UserInfo);
                    }
                    catch (System.Exception ex)
                    {
                        this.WriteException(ex);
                        System.Console.WriteLine(ex.InnerException);
                    }
                }
            }
        }
Пример #16
0
 /// <summary>
 /// 用户登录
 /// </summary>
 /// <returns>是否成功</returns>
 private bool LogOn(bool prompt)
 {
     // 设置鼠标繁忙状态,并保留原先的状态
     Cursor holdCursor = this.Cursor;
     this.Cursor = Cursors.WaitCursor;
     string statusCode = string.Empty;
     string statusMessage = string.Empty;
     try
     {
         string userName = BaseSystemInfo.CurrentUserName;
         DotNetService dotNetService = new DotNetService();
         BaseUserInfo userInfo = dotNetService.LogOnService.UserLogOn(UserInfo, userName, this.txtPassword.Text, false, out statusCode, out statusMessage);
         if (dotNetService.LogOnService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.LogOnService).Close();
         }
         if (statusCode == StatusCode.OK.ToString())
         {
             this.LogOned = true;
             BaseSystemInfo.UserInfo = userInfo;
             return true;
         }
         else
         {
             // 是否进行消息提示
             if (prompt)
             {
                 // MessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                 // "密码错误,请注意大小写。"
                 MessageBox.Show(AppMessage.MSG9967, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             this.txtPassword.Focus();
             this.txtPassword.SelectAll();
             return false;
         }
     }
     catch (Exception ex)
     {
         this.ProcessException(ex);
     }
     finally
     {
         // 已经忙完了
         this.Cursor = holdCursor;
     }
     return true;
 }
Пример #17
0
        /// <summary>
        /// 保存页面个性化配置情况
        /// </summary>
        private void SaveConfiguration()
        {
            DotNetService dotNetService = new DotNetService();
            dotNetService.ParameterService.SetParameter(UserInfo, "User", UserInfo.Id, "IsLockSystem", ckbIsLock.Checked.ToString());

            if(this.cmbLockWaitMinute.SelectedValue!=null)
            {
                dotNetService.ParameterService.SetParameter(UserInfo, "User", UserInfo.Id, "LockWaitMinute", this.cmbLockWaitMinute.SelectedValue.ToString());
            }
            if (dotNetService.ParameterService is ICommunicationObject)
            {
                ((ICommunicationObject)dotNetService.ParameterService).Close();
            }
        }
Пример #18
0
 /// <summary>
 /// 获取模块菜单限域数据
 /// </summary>
 public DataTable GetModuleScope(string permissionItemScopeCode)
 {
     DotNetService dotNetService = new DotNetService();
     // 获取部门数据
     if ((UserInfo.IsAdministrator) || (String.IsNullOrEmpty(permissionItemScopeCode)))
     {
         DataTable dtModule = dotNetService.ModuleService.GetDataTable(UserInfo);
         if (dotNetService.ModuleService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.ModuleService).Close();
         }
         // 这里需要只把有效的模块显示出来
         // BaseBusinessLogic.SetFilter(dtModule, BaseModuleEntity.FieldEnabled, "1");
         // 未被打上删除标标志的
         // BaseBusinessLogic.SetFilter(dtModule, BaseModuleEntity.FieldDeletionStateCode, "0");
         return dtModule;
     }
     else
     {
         DataTable dataTable = dotNetService.PermissionService.GetModuleDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode);
         if (dotNetService.PermissionService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.PermissionService).Close();
         }
         BaseInterfaceLogic.CheckTreeParentId(dataTable, BaseModuleEntity.FieldId, BaseModuleEntity.FieldParentId);
         return dataTable;
     }
 }
Пример #19
0
 /// <summary>
 /// 从数据库中读取文件
 /// </summary>
 /// <param name="id">文件主键</param>
 /// <returns>文件</returns>
 public byte[] Download(string id)
 {
     DotNetService dotNetService = new DotNetService();
     byte[] returnValue = dotNetService.FileService.Download(UserInfo, id);
     if (dotNetService.FileService is ICommunicationObject)
     {
         ((ICommunicationObject)dotNetService.FileService).Close();
     }
     return returnValue;
 }
Пример #20
0
 /// <summary>
 /// 获取组织机构权限域数据
 /// </summary>
 public DataTable GetOrganizeScope(string permissionItemScopeCode, bool isInnerOrganize)
 {
     // 获取部门数据,不启用权限域
     DataTable dataTable = new DataTable(BaseOrganizeEntity.TableName);
     if ((UserInfo.IsAdministrator) || (String.IsNullOrEmpty(permissionItemScopeCode) || (!BaseSystemInfo.UsePermissionScope)))
     {
         dataTable = ClientCache.Instance.GetOrganizeDT(UserInfo).Copy();
         if (isInnerOrganize)
         {
             BaseBusinessLogic.SetFilter(dataTable, BaseOrganizeEntity.FieldIsInnerOrganize, "1");
             BaseInterfaceLogic.CheckTreeParentId(dataTable, BaseOrganizeEntity.FieldId, BaseOrganizeEntity.FieldParentId);
         }
         dataTable.DefaultView.Sort = BaseOrganizeEntity.FieldSortCode;
     }
     else
     {
         DotNetService dotNetService = new DotNetService();
         dataTable = dotNetService.PermissionService.GetOrganizeDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode);
         if (dotNetService.PermissionService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.PermissionService).Close();
         }
         if (isInnerOrganize)
         {
             BaseBusinessLogic.SetFilter(dataTable, BaseOrganizeEntity.FieldIsInnerOrganize, "1");
             BaseInterfaceLogic.CheckTreeParentId(dataTable, BaseOrganizeEntity.FieldId, BaseOrganizeEntity.FieldParentId);
         }
         dataTable.DefaultView.Sort = BaseOrganizeEntity.FieldSortCode;
     }
     return dataTable;
 }
Пример #21
0
 private void FrmMessageRead_DragDrop(object sender, DragEventArgs e)
 {
     if (e.Data.GetDataPresent(DataFormats.FileDrop))
     {
         string[] file = (string[])e.Data.GetData(DataFormats.FileDrop);
         // 设置鼠标繁忙状态,并保留原先的状态
         Cursor holdCursor = this.Cursor;
         this.Cursor = Cursors.WaitCursor;
         try
         {
             DotNetService dotNetService = new DotNetService();
             for (int i = 0; i <= file.Length - 1; i++)
             {
                 if (System.IO.File.Exists(file[i]))
                 {
                     byte[] fileContents = FileUtil.GetFile(file[i]);
                     string fileName = System.IO.Path.GetFileName(file[i]);
                     dotNetService.FileService.Send(UserInfo, fileName, fileContents, this.ReceiverId);
                     // this.Text = this.webBMsg.DocumentText.Length.ToString();
                     string message = "发送文件 " + fileName + " 成功,等待对方接收。";
                     if (this.webMessage.DocumentText.Length > 216)
                     {
                         message = "<br>" + message;
                     }
                     this.webMessage.DocumentText = this.webMessage.DocumentText.Insert(this.webMessage.DocumentText.Length, message);
                 }
             }
             if (dotNetService.MessageService is ICommunicationObject)
             {
                 ((ICommunicationObject)dotNetService.MessageService).Close();
             }
         }
         catch (Exception ex)
         {
             this.ProcessException(ex);
         }
         finally
         {
             // 设置鼠标默认状态,原来的光标状态
             this.Cursor = holdCursor;
         }
     }
 }
Пример #22
0
        /// <summary>
        /// 获取授权范围数据 (按道理,应该是在某个数据区域上起作用)
        /// </summary>
        public DataTable GetPermissionItemScop(string permissionItemScopeCode)
        {
            // 获取部门数据
            DataTable dtPermissionItem = new DataTable(BasePermissionItemEntity.TableName);
            DotNetService dotNetService = new DotNetService();
            if (UserInfo.IsAdministrator)
            {
                dtPermissionItem = dotNetService.PermissionItemService.GetDataTable(UserInfo);
                if (dotNetService.PermissionItemService is ICommunicationObject)
                {
                    ((ICommunicationObject)dotNetService.PermissionItemService).Close();
                }
                // 这里需要只把有效的模块显示出来
                // BaseBusinessLogic.SetFilter(dtPermissionItem, BasePermissionItemEntity.FieldEnabled, "1");
                // 未被打上删除标标志的
                // BaseBusinessLogic.SetFilter(dtPermissionItem, BasePermissionItemEntity.FieldDeletionStateCode, "0");

            }
            else
            {
                dtPermissionItem = dotNetService.PermissionService.GetPermissionItemDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode);
                if (dotNetService.PermissionService is ICommunicationObject)
                {
                    ((ICommunicationObject)dotNetService.PermissionService).Close();
                }
                BaseInterfaceLogic.CheckTreeParentId(dtPermissionItem, BasePermissionItemEntity.FieldId, BasePermissionItemEntity.FieldParentId);
            }
            return dtPermissionItem;
        }
Пример #23
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <returns>是否成功</returns>
        private bool LogOn()
        {
            if (!BaseSystemInfo.UserIsLogOn && this.cmbLogOnTo.Enabled)
            {
                UserConfigHelper.LogOnTo = ((ListItem)this.cmbLogOnTo.SelectedItem).Id;
                // 读取配置文件
                UserConfigHelper.GetConfig();
            }

            string statusCode = string.Empty;
            string statusMessage = string.Empty;
            DotNetService dotNetService = new DotNetService();
            BaseUserInfo userInfo = dotNetService.LogOnService.UserLogOn(UserInfo, this.txtUserName.Text, this.txtPassword.Text, true, out statusCode, out statusMessage);
            if (dotNetService.LogOnService is ICommunicationObject)
            {
                ((ICommunicationObject)dotNetService.LogOnService).Close();
            }
            if (statusCode == StatusCode.OK.ToString())
            {
                // 检查身份
                if ((userInfo != null) && (userInfo.Id.Length > 0))
                {
                    BaseSystemInfo.UserInfo = userInfo;
                    if (BaseSystemInfo.RememberPassword)
                    {
                        this.SaveLogOnInfo();
                    }

                    // 这里是登录功能部分
                    if (this.Parent == null)
                    {
                        this.Hide();
                        if (!BaseSystemInfo.UserIsLogOn)
                        {
                            Form mainForm = CacheManager.Instance.GetForm(BaseSystemInfo.MainAssembly, BaseSystemInfo.MainForm);
                            ((IBaseMainForm)mainForm).InitService();
                            ((IBaseMainForm)mainForm).InitForm();
                            mainForm.Show();
                        }
                    }
                    // 这里表示已经登录系统了
                    BaseSystemInfo.UserIsLogOn = true;
                    // 登录次数归零,允许重新登录
                    this.LogOnCount = 0;

                    // 打开这个窗体的主窗口
                    if (this.Owner != null)
                    {
                        ((IBaseMainForm)this.Owner).InitService();
                        ((IBaseMainForm)this.Owner).InitForm();
                        ((IBaseMainForm)this.Owner).CheckMenu();
                        return true;
                    }
                    if (this.Parent != null)
                    {
                        // 重新获取登录状态信息
                        ((IBaseMainForm)this.Parent.Parent).InitService();
                        ((IBaseMainForm)this.Parent.Parent).InitForm();
                        ((IBaseMainForm)this.Parent.Parent).CheckMenu();
                        this.Close();
                    }
                }
            }
            else
            {
                MessageBox.Show(statusMessage, AppMessage.MSG0000, MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.txtPassword.Focus();
                this.txtPassword.SelectAll();
                return false;
            }
            return true;
        }
Пример #24
0
 /// <summary>
 /// 获取员工权限域数据
 /// </summary>
 public DataTable GetRoleScope(string permissionItemScopeCode)
 {
     // 获取部门数据
     DataTable returnValue = new DataTable(BaseOrganizeEntity.TableName);
     DotNetService dotNetService = new DotNetService();
     if ((UserInfo.IsAdministrator) || (String.IsNullOrEmpty(permissionItemScopeCode)))
     {
         returnValue = dotNetService.RoleService.GetDataTable(UserInfo);
         if (dotNetService.RoleService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.RoleService).Close();
         }
     }
     else
     {
         returnValue = dotNetService.PermissionService.GetRoleDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode);
         if (dotNetService.PermissionService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.PermissionService).Close();
         }
     }
     return returnValue;
 }
Пример #25
0
 /// <summary>
 /// 删除文件
 /// </summary>
 /// <param name="id">主键</param>
 /// <returns>影响的行数</returns>
 public int DeleteFile(string id)
 {
     int returnValue = 0;
     if (this.FromDatabase)
     {
         // 从数据库服务器删除文件
         DotNetService dotNetService = new DotNetService();
         returnValue = dotNetService.FileService.Delete(UserInfo, id);
         if (dotNetService.FileService is ICommunicationObject)
         {
             ((ICommunicationObject)dotNetService.FileService).Close();
         }
     }
     else
     {
         // 清除图片
         this.ClearPicture();
         // 删除文件
         System.IO.File.Delete(BaseSystemInfo.StartupPath + this.PictureId);
     }
     return returnValue;
 }
Пример #26
0
        /// <summary>
        /// 获取用户权限域数据
        /// </summary>
        public DataTable GetUserScope(string permissionItemScopeCode)
        {
            // 是否有用户管理权限,若有用户管理权限就有所有的用户类表,这个应该是内置的操作权限
            bool userAdmin = false;
            userAdmin = this.IsAuthorized("UserAdmin");
            DataTable returnValue = new DataTable(BaseUserEntity.TableName);
            // 获取用户数据
            DotNetService dotNetService = new DotNetService();
            if (userAdmin)
            {
                if (this.UserInfo.IsAdministrator||(String.IsNullOrEmpty(permissionItemScopeCode)))
                {
                    returnValue = dotNetService.UserService.GetDataTable(UserInfo);
                    if (dotNetService.UserService is ICommunicationObject)
                    {
                        ((ICommunicationObject)dotNetService.UserService).Close();
                    }
                }
                else
                {
                    returnValue = dotNetService.PermissionService.GetUserDTByPermissionScope(UserInfo, UserInfo.Id, permissionItemScopeCode);
                    if (dotNetService.PermissionService is ICommunicationObject)
                    {
                        ((ICommunicationObject)dotNetService.PermissionService).Close();
                    }
                }

            }
            return returnValue;
        }
Пример #27
0
 public string Upload(string folderId, string categoryId)
 {
     this.FolderId = folderId;
     string returnValue = string.Empty;
     if (!String.IsNullOrEmpty(this.pic.ImageLocation))
     {
         // 保存到数据库
         if (this.FromDatabase)
         {
             if (String.IsNullOrEmpty(this.PictureId))
             {
                 DotNetService dotNetService = new DotNetService();
                 returnValue = dotNetService.FileService.Upload(UserInfo, folderId, Path.GetFileName(this.pic.ImageLocation), FileUtil.GetFile(this.pic.ImageLocation), true);
                 if (dotNetService.FileService is ICommunicationObject)
                 {
                     ((ICommunicationObject)dotNetService.FileService).Close();
                 }
             }
             else
             {
                 string statusCode = string.Empty;
                 string statusMessage = string.Empty;
                 DotNetService dotNetService = new DotNetService();
                 dotNetService.FileService.UpdateFile(UserInfo, this.PictureId, Path.GetFileName(this.pic.ImageLocation), FileUtil.GetFile(this.pic.ImageLocation), out statusCode, out statusMessage);
                 if (dotNetService.FileService is ICommunicationObject)
                 {
                     ((ICommunicationObject)dotNetService.FileService).Close();
                 }
                 returnValue = this.PictureId;
             }
         }
         else
         {
             // 复制文件到指定的目录里
             if (!this.pic.ImageLocation.Equals(BaseSystemInfo.StartupPath + this.PictureId))
             {
                 string destDirectory = BaseSystemInfo.StartupPath + "\\UploadFiles" + "\\" + folderId + "\\" + categoryId;
                 System.IO.Directory.CreateDirectory(destDirectory);
                 string destFileName = destDirectory + "\\" + Path.GetFileName(this.pic.ImageLocation);
                 System.IO.File.Copy(this.pic.ImageLocation, destFileName);
                 returnValue = "\\UploadFiles" + "\\" + folderId + "\\" + categoryId + "\\" + Path.GetFileName(this.pic.ImageLocation);
             }
         }
         // OleDbHelper dbHelper = new SqlHelper();
         // dbHelper.Open();
         // string sequence = BaseSequenceManager.Instance.GetSequence(DbHelper, BaseFileEntity.TableName);
         // OleDbSQLBuilder sqlBuilder = new OleDbSQLBuilder();
         // sqlBuilder.BeginInsert(DbHelper, BaseFileEntity.TableName);
         // sqlBuilder.SetValue(BaseFileEntity.FieldId, sequence);
         // sqlBuilder.SetValue(BaseFileEntity.FieldFolderId, folderId);
         // sqlBuilder.SetValue(BaseFileEntity.FieldFileName, Path.GetFileName(this.pic.ImageLocation));
         // // byte[] File = this.ImageToByte(this.pic.Image);
         // byte[] File = this.GetFile(this.pic.ImageLocation);
         // sqlBuilder.SetValue(BaseFileEntity.FieldFileContent, File);
         // sqlBuilder.SetValue(BaseFileEntity.FieldFileSize, File.Length);
         // sqlBuilder.SetValue(BaseFileEntity.FieldCreateUserId, UserInfo.Id);
         // sqlBuilder.SetDBNow(BaseFileEntity.FieldCreateOn);
         // sqlBuilder.EndInsert();
         // dbHelper.Close();
         // returnValue = sequence;
     }
     return returnValue;
 }
Пример #28
0
        /// <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 (!BaseSystemInfo.UsePermissionItem)
            {
                return true;
            }

            /*
            // 这里是判断本地缓存里,操作权限是否为空?
            if (ClientCache.Instance.DTPermission == null)
            {
                // return false;
                // 重新读取本地缓存里的操作权限
                ClientCache.Instance.GetPermission(this.UserInfo);
            }
            // 直接判断是否有相应的操作权限
            returnValue = BaseBusinessLogic.IsAuthorized(ClientCache.Instance.DTPermission, permissionItemCode);
            if (returnValue))
            {
                return true;
            }
            returnValue = BaseBusinessLogic.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)
            {
                DotNetService dotNetService = new DotNetService();
                returnValue = dotNetService.PermissionService.IsAuthorizedByUser(this.UserInfo, this.UserInfo.Id, permissionItemCode, permissionItemName);
                if (dotNetService.PermissionService is ICommunicationObject)
                {
                    ((ICommunicationObject)dotNetService.PermissionService).Close();
                }
            }
            return returnValue;
        }
Пример #29
0
 public void DataBind()
 {
     this.FormLoaded = false;
     DotNetService dotNetService = new DotNetService();
     DataTable dataTable = dotNetService.ItemDetailsService.GetDataTable(this.UserInfo, this.TargetTableName);
     if (dotNetService.ItemDetailsService is ICommunicationObject)
     {
         ((ICommunicationObject)dotNetService.ItemDetailsService).Close();
     }
     // 绑定数据
     this.cmbItemDetail.DisplayMember = this.DisplayMember;
     this.cmbItemDetail.ValueMember = this.ValueMember;
     this.cmbItemDetail.DataSource = dataTable.DefaultView;
     if (this.AllowNull)
     {
         // 添加一个空记录
         DataRow dataRow = dataTable.NewRow();
         dataTable.Rows.InsertAt(dataRow, 0);
         this.cmbItemDetail.SelectedValue = dataRow;
     }
     this.SetSelectedValue(this.SelectedId);
     // this.AllowAdmin = UserInfo.IsAdministrator;
     // 默认绑定,没有进行选择时,也需要读取值,否则会不正确。
     this.GetSelectedValue();
     // 设置按钮状态
     this.SetControlState();
     this.FormLoaded = true;
 }
Пример #30
0
 /// <summary>
 /// 关闭窗体
 /// </summary>
 private void FormOnClosed()
 {
     if (!this.DesignMode)
     {
         // 是否记录访问日志,已经登录了系统了,才记录日志
         if (BaseSystemInfo.RecordLog && BaseSystemInfo.UserIsLogOn)
         {
             // 保存列宽
             BaseInterfaceLogic.SaveDataGridViewColumnWidth(this);
             // 调用服务事件
             if (this.RecordFormLog)
             {
                 DotNetService dotNetService = new DotNetService();
                 dotNetService.LogService.WriteExit(UserInfo, this.LogId);
                 if (dotNetService.LogService is ICommunicationObject)
                 {
                     ((ICommunicationObject)dotNetService.LogService).Close();
                 }
             }
         }
     }
 }