/// <summary> /// 记录用户操作日志 /// </summary> /// <param name="projectId"></param> /// <param name="projectName"></param> /// <param name="clientPath"></param> /// <param name="action"></param> public static void ActionLog(Model.FileVersion fileVerModel, Model.FileModel fileModel, string remark, string actionCode, ActionType action) { // 用户信息 Model.UserModel UserInfo = SystemBll.UserInfo; BLL.FileLogBll logBll = new FileLogBll(); Model.FileLogModel logModel = new FileLogModel(); logModel.AddTime = DateTime.Now; logModel.UserID = UserInfo.ID; logModel.UserName = UserInfo.UserName; logModel.UserRealName = UserInfo.RealName; //logModel.Ip = SystemBll.GetIP(); logModel.Ip = SystemBll.GetComputerName(); logModel.ProjectID = 0; logModel.ProjectName = string.Empty; logModel.ClientPath = fileVerModel.ClientPath; logModel.ActionType = action.ToString(); logModel.ActionName = GetActionName(action); logModel.FileID = fileVerModel.File_Id > 0 ? fileVerModel.File_Id : fileModel.ID; logModel.FileName = fileModel.File_Name; logModel.FileType = 0; logModel.FileVer = fileVerModel.Ver; logModel.FileVerID = fileVerModel.ID; logModel.ParentForderId = fileModel.File_DirId; logModel.Remark = remark; logModel.ActionCode = actionCode; logBll.Add(logModel); }
public static void FileLog(Model.FileVersion fileVerModel, Model.FileModel fileModel, string actionCode, ActionType logType) { if (fileVerModel == null && fileModel == null) { return; } string remark = string.Empty; Model.UserModel UserInfo = SystemBll.UserInfo; if (logType == ActionType.RENAME) { remark = string.Format("{0}({1})重命名文件:{2}为==>:", UserInfo.UserName, UserInfo.RealName, fileModel.File_Name); fileModel = new BLL.FileBll().GetModel(fileModel.ID); remark = remark + fileModel.File_Name; } if (logType == ActionType.ONEDELFILE) { remark = string.Format("{0}({1})删除文件:{2}:", UserInfo.UserName, UserInfo.RealName, fileModel.File_Name); } if (fileModel == null && fileVerModel != null) { fileModel = new BLL.FileBll().GetModel(fileVerModel.File_Id); } if (fileModel != null && fileVerModel == null) { FileBll fileBll = new FileBll(); fileVerModel = fileBll.GetFileLastVer(fileModel.ID); } ActionLogAsyn(fileVerModel, fileModel, remark, actionCode, logType); }
public static bool CheckProject(string softwareName) { Model.UserProjectModel curProject = null; Model.UserModel user = Bll.SystemBll.UserInfo; if (user == null || user.Projects == null || user.Projects.Count == 0) { MessageBox.Show("账号信息不正确,请联系管理员处理!"); return(false); } foreach (var item in user.Projects) { if (item.MonitoringSoftwareName == softwareName) { curProject = item; break; } } if (curProject == null) { //MessageBox.Show("工程信息绑定不正确,请联系管理员处理!"); return(false); } return(true); }
/// <summary> /// 异步记录用户操作日志 /// </summary> /// <param name="projectId"></param> /// <param name="projectName"></param> /// <param name="clientPath"></param> /// <param name="action"></param> public static void ActionLogAsyn(Model.FileVersion fileVerModel, Model.FileModel fileModel, string remark, string actionCode, ActionType action) { ActionLogHandler handler = new ActionLogHandler(ActionLog); Model.UserModel user = Bll.SystemBll.UserInfo; handler.BeginInvoke(fileVerModel, fileModel, remark, actionCode, action, IAsyncMenthod, null); }
/// <summary> /// 修改属性 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { try { string addTimeStr = this.skinTextBox_addTime.SkinTxt.Text.Trim(); string modifyTimeStr = this.skinTextBox_modifyTime.SkinTxt.Text.Trim(); string name = this.skinTextBox_name.SkinTxt.Text.Trim(); ListItem selectItem = (ListItem)this.skinComboBox_createUser.SelectedItem; Model.UserModel createUser = (Model.UserModel)selectItem.Value; DateTime addTime = DateTime.Now; DateTime modifyTime = DateTime.Now; if (createUser == null || string.IsNullOrEmpty(createUser.UserName)) { MessageBoxEx.Show("所选用户信息不正确!"); return; } if (string.IsNullOrEmpty(name)) { MessageBoxEx.Show("名称不能为空!"); return; } if (string.IsNullOrEmpty(addTimeStr) || !DateTime.TryParse(addTimeStr, out addTime)) { MessageBoxEx.Show("添加时间不正确!"); return; } if (string.IsNullOrEmpty(modifyTimeStr) || !DateTime.TryParse(modifyTimeStr, out modifyTime)) { MessageBoxEx.Show("修改时间不正确!"); return; } this.file.Add_Time = addTime; this.file.File_Modify_Time = modifyTime.Ticks; this.file.File_Name = name; this.file.UserId = createUser.ID; this.file.UserName = createUser.UserName; BLL.FileBll bll = new BLL.FileBll(); //string updateValue = string.Format(" name = {0},modifyTime = {1} ,createUser = {2} , addTime={3}"); //bll.UpdateField(this.file.ID, updateValue); bool ret = bll.Update(file); this.DialogResult = System.Windows.Forms.DialogResult.OK; MessageBoxEx.Show("修改成功!"); } catch (Exception ee) { this.DialogResult = System.Windows.Forms.DialogResult.None; MessageBoxEx.Show("修改失败!" + ee.Message); } }
/// <summary> /// 数据初始化 /// </summary> private void InitData() { BLL.FileLogBll fLogBll = new BLL.FileLogBll(); DataSet ds = fLogBll.GetAllInfoList(1000, " fl.IsDeleted = 0 and fl.actionCode = '" + code + "'", " fl.AddTime desc, fl.id asc"); if (ds != null && ds.Tables.Count > 0) { DataTable orgdt = ds.Tables[0]; DataTable dt = new DataTable(); dt.Columns.Add("id"); dt.Columns.Add("FileName"); dt.Columns.Add("file_user_name"); dt.Columns.Add("file_user_realname"); dt.Columns.Add("file_version"); dt.Columns.Add("ActionName"); dt.Columns.Add("file_modifyTime"); dt.Columns.Add("file_userName"); dt.Columns.Add("ComputerName"); dt.Columns.Add("file_userIp"); dt.Columns.Add("file_size"); dt.Columns.Add("downLink"); dt.Columns.Add("saveas"); dt.Columns.Add("File_ID"); dt.Columns.Add("ClientPath"); dt.Columns.Add("remark"); if (orgdt != null && orgdt.Rows.Count > 0) { Model.UserModel user = Bll.SystemBll.UserInfo; for (int i = 0; i < orgdt.Rows.Count; i++) { DataRow row = dt.NewRow(); row[0] = orgdt.Rows[i]["FileVerID"].ToString(); row[1] = orgdt.Rows[i]["FileName"].ToString(); string userName = orgdt.Rows[i]["file_user_name"].ToString(); string userRealName = orgdt.Rows[i]["file_user_realname"].ToString(); if (string.IsNullOrEmpty(userName)) { row[2] = user.UserName; row[3] = user.RealName; } else { row[2] = userName; row[3] = userRealName; } row[4] = orgdt.Rows[i]["FileVer"].ToString(); row[5] = orgdt.Rows[i]["ActionName"].ToString(); row[6] = orgdt.Rows[i]["AddTime"].ToString(); row[7] = orgdt.Rows[i]["UserName"].ToString(); row[8] = string.Empty; row[9] = orgdt.Rows[i]["Ip"].ToString(); row[10] = string.Empty; row[11] = "下载到本地"; row[12] = "另存为"; row[13] = orgdt.Rows[i]["FileID"]; row[14] = orgdt.Rows[i]["ClientPath"]; row[15] = orgdt.Rows[i]["remark"]; dt.Rows.Add(row); } } this.skinDataGridView_history.DataSource = dt; } }
public static void FileLogForderRename(Model.FileVersion fileVerModel, Model.FileModel fileModel, string remark, string actionCode, ActionType logType) { Model.UserModel UserInfo = SystemBll.UserInfo; ActionLogAsyn(fileVerModel, fileModel, remark, actionCode, logType); }
/// <summary> /// 初始化界面展示 /// </summary> private void InitUiData() { if (userId <= 0) { this.skinTextBox_addTime.SkinTxt.Text = DateTime.Now.ToString(); return; } if (userId > 0) { BLL.ManagerBll managerBll = new BLL.ManagerBll(); Model.UserModel userModel = managerBll.GetModel(userId); if (userModel == null) { this.skinTextBox_addTime.SkinTxt.Text = DateTime.Now.ToString(); return; } if (userModel != null) { this.skinTextBox_userName.SkinTxt.Text = userModel.UserName; this.skinTextBox_realName.SkinTxt.Text = userModel.RealName; this.skinTextBox_addTime.SkinTxt.Text = userModel.AddTime.ToString(); this.skinRadioButton_lock.Checked = userModel.IsLock == 1; this.skinRadioButton_unLock.Checked = userModel.IsLock == 0; this.skinComboBox_role.SelectedIndex = userModel.RoleType; //工程初始化 if (userModel.Projects != null && userModel.Projects.Count > 0) { foreach (var item in userModel.Projects) { int index = this.skinDataGridView_projects.Rows.Add(1); DataGridViewRow gridRow = this.skinDataGridView_projects.Rows[index]; gridRow.Cells[0].Value = item.ID; gridRow.Cells[1].Value = item.ProjectName; gridRow.Cells[2].Value = item.MonitoringSoftwareName; gridRow.Cells[3].Value = item.MonitoringPath; //gridRow.Cells[4].Value = item.UserName; //gridRow.Cells[5].Value = item.IsLock; //gridRow.Cells[6].Value = item.ClientIp; //gridRow.Cells[7].Value = item.AddTime; gridRow.Tag = item; } #region 暂时删除 //DataTable dt = new DataTable(); //dt.Columns.Add("ID"); //dt.Columns.Add("ProjectName"); //dt.Columns.Add("MonitoringSoftwareName"); //dt.Columns.Add("MonitoringPath"); //dt.Columns.Add("UserName"); //dt.Columns.Add("IsLock"); //dt.Columns.Add("ClientIp"); //dt.Columns.Add("AddTime"); //foreach (var item in userModel.Projects) //{ // DataRow row = dt.NewRow(); // row[0] = item.ID; // row[1] = item.ProjectName; // row[2] = item.MonitoringSoftwareName; // row[3] = item.MonitoringPath; // row[4] = item.UserName; // row[5] = item.IsLock; // row[6] = item.ClientIp; // row[7] = item.AddTime; // dt.Rows.Add(row); // int index = this.skinDataGridView_projects.Rows.Add(1); // DataGridViewRow gridRow = this.skinDataGridView_projects.Rows[index]; // gridRow.Cells[0].Value = item.ID; // gridRow.Cells[1].Value = item.ProjectName; // gridRow.Cells[2].Value = item.MonitoringSoftwareName; // gridRow.Cells[3].Value = item.MonitoringPath; // gridRow.Cells[4].Value = item.UserName; // gridRow.Cells[5].Value = item.IsLock; // gridRow.Cells[6].Value = item.ClientIp; // gridRow.Cells[7].Value = item.AddTime; // gridRow.Tag = item; //} //this.skinDataGridView_projects.DataSource = dt; //this.skinDataGridView_projects.DataSource = userModel.Projects; #endregion } } } }
/// <summary> /// 确定 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btn_ok_Click(object sender, EventArgs e) { Model.UserModel user = new Model.UserModel(); BLL.ManagerBll managerBll = new BLL.ManagerBll(); try { #region 信息校验 //校验 int isLock = this.skinRadioButton_lock.Checked ? 1 : 0;; string userName = this.skinTextBox_userName.SkinTxt.Text; string realName = this.skinTextBox_realName.SkinTxt.Text; int roleType = this.skinComboBox_role.SelectedIndex; string addTimeStr = this.skinTextBox_addTime.SkinTxt.Text.Trim(); DateTime addTime = DateTime.Now; if (string.IsNullOrEmpty(userName)) { MessageBoxEx.Show("账号不能为空!"); return; } if (string.IsNullOrEmpty(realName)) { MessageBoxEx.Show("姓名不能为空!"); return; } if (roleType != 0 && roleType != 1) { MessageBoxEx.Show("请联系管理员,用户角色有异常!"); return; } if (string.IsNullOrEmpty(addTimeStr) || !DateTime.TryParse(addTimeStr, out addTime)) { MessageBoxEx.Show("添加时间不正确!"); return; } //新增用户校验用户是否存在 if (userId <= 0) { bool isExidted = managerBll.Exists(userName); if (isExidted) { MessageBoxEx.Show(string.Format("账号: {0}已经存在!", userName)); return; } //开始修改值 } //修改用户 if (userId > 0) { user = managerBll.GetModel(userId); //开始修改值 } #endregion #region 构建信息 user.IsLock = isLock; user.UserName = userName; user.RealName = realName; user.RoleType = roleType; user.RoleName = this.skinComboBox_role.SelectedItem.ToString();; user.AddTime = addTime; //工程信息构建 user.Projects = new List <Model.UserProjectModel>(); foreach (DataGridViewRow item in this.skinDataGridView_projects.Rows) { Model.UserProjectModel projectModel = (Model.UserProjectModel)item.Tag; if (projectModel == null) { continue; } user.Projects.Add(projectModel); } #endregion #region 添加域账号判断 // 域账号验证 if (!AuthDomin(realName, userName)) { return; } #endregion //修改用户 if (userId > 0) { if (managerBll.Update(user)) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBoxEx.Show("更新用户信息异常!"); } } else { if (managerBll.Add(user) > 0) { this.DialogResult = System.Windows.Forms.DialogResult.OK; } else { MessageBoxEx.Show("新增用户信息异常!"); } } } catch (Exception ex) { MessageBoxEx.Show("更新用户信息异常!" + ex.Message); } }
private void buttonLogin_Click(object sender, EventArgs e) { this.skinLabel_errorMsg.Visible = false; this.skinLabel_errorMsg.Text = string.Empty; string account = this.skinTextBox_account.SkinTxt.Text.Trim(); string pwd = this.skinTextBox_pwd.SkinTxt.Text.Trim(); if (string.IsNullOrEmpty(account)) { MessageBoxEx.Show("�˺���Ϣ����Ϊ�գ�"); return; } if (string.IsNullOrEmpty(pwd)) { MessageBoxEx.Show("������Ϣ����Ϊ�գ�"); return; } // ���˺ŵ�¼��֤ try { this.skinLabel_errorMsg.Text = string.Format("���˺ţ�{0}�����ڵ�¼��,��Ⱥ�...", account); Application.DoEvents(); UserLoginForDomainBll bll = new UserLoginForDomainBll(); // ��ȡ������Ϣ var config = BLL.SystemConfigBll.GetConfig(); if (this.errorLoginCount > 4) { MessageBoxEx.Show(string.Format("���˺ţ�{0}�������������5��,�ѱ�����,����ϵ����Ա��", account)); this.skinLabel_errorMsg.Text = string.Format("���˺ţ�{0}�������������5��,�ѱ�����,����ϵ����Ա��", account); this.skinLabel_errorMsg.Visible = true; // �����˺� return; } //if (!bll.ImpersonateValidUser(account, config.Domin, pwd)) if (!bll.ImpersonateValidUser2(account, config.Domin, pwd)) //if (!bll.AuthDomainUserByAdHelper(account, config.Domin, pwd)) { this.errorLoginCount += 1; MessageBoxEx.Show(string.Format("���˺ţ�{0}����¼��ʧ�� ���˺Ż����������", account)); this.skinLabel_errorMsg.Text = string.Format("���˺ţ�{0}����¼��ʧ�ܣ��˺Ż����������", account); this.skinLabel_errorMsg.Visible = true; return; } try { //new UserLoginForDomainBll().AuthDomainUserAuth(); } catch { } } catch (Exception ex) { MessageBoxEx.Show(string.Format("���˺ţ�{0}����¼��ʧ�� ������ϵ����Ա����", account)); this.skinLabel_errorMsg.Text = string.Format("���˺ţ�{0}����¼��ʧ�ܣ�", account); this.skinLabel_errorMsg.Visible = true; return; } //��ȡϵͳ�˺� Model.UserModel user = Bll.SystemBll.GetUserInfo(account); if (user == null || string.IsNullOrEmpty(user.UserName) || string.IsNullOrEmpty(user.RealName)) { MessageBoxEx.Show(string.Format("���˺ţ�{0}�������ڻ��������������ϵ����Ա����", account) + Bll.SystemBll.ManagerLinkInfo); this.skinLabel_errorMsg.Text = string.Format("���˺ţ�{0}�������ڻ����������", account); this.skinLabel_errorMsg.Visible = true; return; } if (user.IsLock == 1) { MessageBoxEx.Show(string.Format("���˺ţ�{0}���Ѿ������� ������ϵ����Ա����", account) + Bll.SystemBll.ManagerLinkInfo); this.skinLabel_errorMsg.Text = string.Format("���˺ţ�{0}��û��Ȩ�ޣ�", account); this.skinLabel_errorMsg.Visible = true; return; } Bll.SystemBll.UserInfo = user; // �첽��־ SystemBll.ActionLogAsyn(0, string.Empty, string.Empty, Model.ActionType.USERLOGIN); this.DialogResult = System.Windows.Forms.DialogResult.OK; }
private void btnOk_Click(object sender, EventArgs e) { try { Model.UserProjectModel curProject = null; Model.UserModel user = Bll.SystemBll.UserInfo; if (user == null || user.Projects == null || user.Projects.Count == 0) { MessageBox.Show("账号信息不正确,请联系管理员处理!"); return; } foreach (var item in user.Projects) { if (item.MonitoringSoftwareName == softwareName) { curProject = item; break; } } if (curProject == null) { MessageBox.Show("工程信息绑定不正确,请联系管理员处理!"); return; //curProject = user.Projects[0]; } if (curProject == null || string.IsNullOrEmpty(curProject.MonitoringPath)) { MessageBox.Show("服务器配置路径不正确,请联系管理员处理!"); return; } //监控绑定路径 string dirPath = curProject.MonitoringPath; if (!Directory.Exists(dirPath)) { MessageBox.Show("服务器配置路径不正确,请联系管理员处理!"); return; } //此处查询出所有文件内容 DirectoryInfo rootDirInfo = new DirectoryInfo(dirPath); FileWinexploer upload = new FileWinexploer(); //上传之前开启文件受影响检查 user.CurProject = curProject; this.curProject = curProject; #region 20151104修改上传动画效果&初次上传大量文件卡死现象--删除 //upload.CheckFolderUploadToDb(dirPath, user); //if (FileWinexploer.NeedAddOrMordifyFiles == null || FileWinexploer.NeedAddOrMordifyFiles.Count == 0) //{ // MessageBox.Show("没有可更新文件,不需要操作!"); // return; //} //else //{ // if (MessageBox.Show( // string.Format("此次上传文件数量为:{0},是否继续上传!", FileWinexploer.NeedAddOrMordifyFiles.Count), // "一键上传文件", // MessageBoxButtons.OKCancel) == DialogResult.OK) // { // //检查通过开始异步上传 // FolderUploadHandler handler = new FolderUploadHandler(upload.FolderUploadToDb); // handler.BeginInvoke(dirPath, user, IAsyncMenthod, null); // ///异步日志 // ActionLog(string.Empty, ActionType.ALLUPLOAD); // this.DialogResult = System.Windows.Forms.DialogResult.OK; // return; // //动态上传进度 // FrmFileTransferNew frmTransfer = new FrmFileTransferNew(0); // frmTransfer.Show(); // } //} #endregion #region 20151104修改上传动画效果&初次上传大量文件卡死现象--修改 // 提示是否上传|取消|上传差异 string tip = FileWinexploer.ConstructUploadTip(); FrmMessageBox messageBox = new FrmMessageBox(tip, 0); var result = messageBox.ShowDialog(); if (result == System.Windows.Forms.DialogResult.Cancel) { return; } // 替换检查界面[8.5wjh] FrmWait frmCheckFile = new FrmWait(dirPath, user, 0); DialogResult frmCheckFileResult = frmCheckFile.ShowDialog(); if (frmCheckFileResult != System.Windows.Forms.DialogResult.OK) { return; } if (FileWinexploer.NeedAddOrMordifyFiles == null || FileWinexploer.NeedAddOrMordifyFiles.Count == 0) { MessageBox.Show("上传完成!"); return; } else { if (result == System.Windows.Forms.DialogResult.OK) { FileWinexploer.SetUploadCache(); } // 0909 上传王君海修改 //FrmFileProgressBar frmTransfer = new FrmFileProgressBar(0); //检查通过开始异步上传 FolderUploadHandler handler = new FolderUploadHandler(upload.FolderUploadToDb); handler.BeginInvoke(dirPath, user, IAsyncMenthod, null); ///异步日志 ActionLog(string.Empty, ActionType.ALLUPLOAD); //frmTransfer.Activate(); //frmTransfer.Show(); } #endregion this.DialogResult = System.Windows.Forms.DialogResult.OK; } catch (Exception ex) { MessageBox.Show(ex.Message); return; } }