private string GetabsolutePath(string parentUnid, string fileName) { string strRoot = FileUtils.GetAbsolutePathName(SimpleResourceHelper.GetString("ATM.DIRECTORY")); string path = strRoot + "\\" + parentUnid + "\\" + fileName; return(path); }
protected override User CreateEntity(TSLibStruts.ActionContext actionContext, HttpContext httpContext) { User user = new User(); DateTime now = DateTime.Now; user.ID = Constants.BLANK_INT_VALUE; user.UserStatus = UserStatuses.Disable; user.ValidityEndDate = now; user.ValidityStartDate = now; // 设置默认的职务 // 绑定职务列表 IList allJobTitle = this.jobTitleService.FindAll(); string defaultJobtitlecode = SimpleResourceHelper.GetString("USER.DEFAULT_JOBTITLE_CODE"); if (!string.IsNullOrEmpty(defaultJobtitlecode)) { JobTitle defaultJobTitle = this.jobTitleService.LoadByCode(defaultJobtitlecode); if (defaultJobTitle != null) { foreach (JobTitle item in allJobTitle) { if (item.Unid == defaultJobTitle.Unid) { user.JobTitleName = defaultJobTitle.Name; user.JobTitleUnid = defaultJobTitle.Unid; break; } } } } return(user); }
protected override OUInfo CreateEntity(ActionContext actionContext, HttpContext httpContext) { OUInfo ouInfo = new OUInfo(); ouInfo.Type = OUInfo.OT_DEPARTMENT; ouInfo.OUStatus = OUStatuses.Enable; ouInfo.IsTmpOU = Constants.YESNO_NO; ouInfo.Level = SimpleResourceHelper.GetString("OUINFO.DEPARTMENT.DEFAULT_LEVEL"); ouInfo.LevelName = SimpleResourceHelper.GetString("OUINFO.DEPARTMENT.DEFAULT_LEVEL_NAME"); return(ouInfo); }
private void BindDropDownList() { ArrayList whunitList = new ArrayList(); whunitList.Add(new WHUnit(Constants.BLANK_LONG_VALUE, SimpleResourceHelper.GetString("SELECT.EMPTY.LABEL"))); whunitList.AddRange(this.whUnitService.FindAll()); WHUnit_ID.DataSource = whunitList; WHUnit_ID.DataTextField = "Name"; WHUnit_ID.DataValueField = "ID"; WHUnit_ID.DataBind(); }
private void BindDropDownList() { ArrayList modelList = new ArrayList(); modelList.Add(new Model(Constants.BLANK_LONG_VALUE, SimpleResourceHelper.GetString("SELECT.EMPTY.LABEL"))); modelList.AddRange(this.modelService.FindAllWithExclude(this.Domain.ID)); ParentID.DataSource = modelList; ParentID.DataTextField = "Name"; ParentID.DataValueField = "ID"; ParentID.DataBind(); }
public void Move(string parentUnid, string oldFilePath, string newPath) { string strRoot = FileUtils.GetAbsolutePathName(SimpleResourceHelper.GetString("ATM.DIRECTORY")); string path = strRoot + "\\" + parentUnid; path = this.FormatePath(this.GetCurrentRunPath()) + path; if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } System.IO.File.Move(oldFilePath, newPath); }
public IList saveFiles() { IList atms = new ArrayList(); // 创建路径 string serverPath = FileUtils.GetAbsolutePathName(SimpleResourceHelper.GetString("ATTACHMENT.DIRECTORY")); serverPath = Path.Combine(serverPath, this.PUnid.Value); if (!Directory.Exists(serverPath)) { Directory.CreateDirectory(serverPath); } logger.Debug("begin2" + serverPath); HttpPostedFile file; for (int i = 0; i < Request.Files.Count; i++) { file = Request.Files[i]; if (string.IsNullOrEmpty(file.FileName)) { continue; } int index = file.FileName.LastIndexOf("."); if (index == -1) { throw new Exception("不允许上传不明扩展名的文件!"); } string extension = file.FileName.Substring(file.FileName.LastIndexOf(".") + 1); // 扩展名 string clientFileName = file.FileName.Substring(file.FileName.LastIndexOf(@"\") + 1); // 文件名+扩展名 // 上传文件 string serverFile = Path.Combine(serverPath, clientFileName); if (logger.IsInfoEnabled) { logger.Info("serverFile=" + serverFile); } // 保存物理文件 file.SaveAs(serverFile); // 创建附件信息 atms.Add(this.createAttachment(clientFileName, clientFileName, extension, file.ContentLength)); } this.atmService.Save(atms); return(atms); }
private void login(string pUser, string pPassword) { TSCommon.Core.Organize.Domain.User user = this.userService.Authorize(pUser, pPassword); user = this.userService.Load(user.ID); TSWEBContext context = TSWEBContext.Current; context.SetCurUser(user); context.SetCurUserGroupInfo(user.GroupLists); context.SetCurUserRoleInfo(this.roleService.FindByUser(user.Unid)); string loginSuccessPage = SimpleResourceHelper.GetString("LOGIN.SUCCESS.PAGE"); if (string.IsNullOrEmpty(loginSuccessPage)) { loginSuccessPage = "LoginSuccess.aspx"; } Response.Redirect(loginSuccessPage); }
protected void BindDropDownList() { // 绑定职务列表 IList list = this.jobTitleService.FindAll(); //添加空白选项 JobTitle jobTitle = new JobTitle(); jobTitle.ID = Constants.BLANK_INT_VALUE; jobTitle.Unid = ""; jobTitle.Name = SimpleResourceHelper.GetString("SELECT.EMPTY.LABEL.ANY"); list.Insert(0, jobTitle); this.JobTitleUnid.DataSource = list; this.JobTitleUnid.DataTextField = "Name"; this.JobTitleUnid.DataValueField = "Unid"; this.JobTitleUnid.DataBind(); }
protected TSCommon.Core.ATM.Domain.ATM createAttachment(string subject, string fileName, string fileFormat, int fileSize) { TSCommon.Core.ATM.Domain.ATM attachment = new TSCommon.Core.ATM.Domain.ATM(); attachment.ID = -1; attachment.Unid = Entry.NewUnid; attachment.Type = this.Type.Value; attachment.ParentUnid = this.PUnid.Value; attachment.Subject = subject; attachment.FileName = fileName; attachment.FileFormat = fileFormat; if (fileSize / 1024 > 1) { attachment.FileSize = (fileSize / 1024).ToString() + "KB"; } else { attachment.FileSize = fileSize.ToString() + "B"; } attachment.FileDate = DateTime.Now; attachment.Author = TSWEBContext.Current.CurUser; attachment.SavePath = SimpleResourceHelper.GetString("ATM.DIRECTORY"); return(attachment); }
/// <summary> /// 插入“== 任意 ==”的空白选项到指定列表的最前端 /// </summary> /// <param name="optionItems">源选项列表</param> public static void InsertAnyOptionItemToFirst(IList optionItems) { string emptyLabel = SimpleResourceHelper.GetString("SELECT.EMPTY.LABEL.ANY"); InsertOptionItemToFirst(optionItems, emptyLabel, ""); }
/// <summary> /// 呈现控件的内容 /// </summary> /// <param name="writer">要在客户端呈现 HTML 内容的输出流</param> protected override void Render(HtmlTextWriter writer) { // 获取附件列表 IList atms = this.atmService.GetATM(this.PUnid, this.Type); // 构建控件的html StringBuilder html = new StringBuilder(SimpleResourceHelper.GetString("ATM.WEB_CONTROL.TPL")); StringBuilder temp = new StringBuilder(); // 构建工具条:工具条的标题文字 if (!string.IsNullOrEmpty(this.Subject)) { temp.Append(SimpleResourceHelper.GetString("ATM.WEB_CONTROL.TPL.TB.SUBJECT")); temp.Replace("{SUBJECT}", this.Subject); } // 构建工具条:工具条按钮 if (this.readOnly) { temp.Append(SimpleResourceHelper.GetString("ATM.WEB_CONTROL.TPL.TB.BUTTON.DOWNLOAD")); // 下载 } else { temp.Append(SimpleResourceHelper.GetString("ATM.WEB_CONTROL.TPL.TB.BUTTON.UPLOAD")); // 上传 temp.Append(SimpleResourceHelper.GetString("ATM.WEB_CONTROL.TPL.TB.BUTTON.DOWNLOAD")); // 下载 temp.Append(SimpleResourceHelper.GetString("ATM.WEB_CONTROL.TPL.TB.BUTTON.DELETE")); // 删除 } html.Replace("{TB}", temp.ToString()); // 构建工具条:工具条的标题文字 temp.Remove(0, temp.Length); string dataTRTpl = SimpleResourceHelper.GetString("ATM.WEB_CONTROL.TPL.DATA_TR"); int i = 1; bool isJiShuRow; StringBuilder temp1 = new StringBuilder(); foreach (TSCommon.Core.ATM.Domain.ATM atm in atms) { isJiShuRow = (i % 2 == 0); temp1.Remove(0, temp1.Length); temp1.Append(dataTRTpl); temp1.Replace("{N}", isJiShuRow ? string.Empty : "1"); temp1.Replace("{UNID}", atm.Unid); temp1.Replace("{DATA_SUBJECT}", atm.Subject); temp1.Replace("{DATA_FILESIZE}", atm.FileSize); temp1.Replace("{DATA_FILEDATE}", atm.FileDate.ToString("yyyy-MM-dd")); temp1.Replace("{DATA_AUTHOR}", atm.Author.Name != null ? atm.Author.Name : string.Empty); temp.Append(temp1); i++; } html.Replace("{DATA_TRS}", temp.ToString()); // 全局替换 html.Replace("{MAIN_ID}", this.ID); html.Replace("{TYPE}", this.Type); html.Replace("{PUNID}", this.PUnid); html.Replace("{STYLE}", this.Style); html.Replace("{EMPTY}", @" "); // 输出控件内容 writer.Write(html.ToString()); if (logger.IsDebugEnabled) { logger.Debug("html=" + html.ToString()); } }
private void BindDropDownList() { // 绑定职务列表 IList list = this.jobTitleService.FindAll(); //添加空白选项 JobTitle jobTitle = new JobTitle(); jobTitle.ID = TSLibWeb.Constants.BLANK_INT_VALUE; jobTitle.Unid = ""; jobTitle.Name = SimpleResourceHelper.GetString("SELECT.EMPTY.LABEL"); list.Insert(0, jobTitle); // 处理职务被删除的特例情况 bool isIn = false; User user = this.Domain; log.Debug("userInfo.JobTitleName=" + user.JobTitleName); log.Debug("userInfo.JobTitleUnid=" + (user.JobTitleUnid != null ? user.JobTitleUnid : "null")); foreach (JobTitle item in list) { if (item.Unid == user.JobTitleUnid) { isIn = true; break; } } if (!isIn) { // 创建一个已丢失的选项 jobTitle = new JobTitle(); jobTitle.ID = TSLibWeb.Constants.BLANK_INT_VALUE; jobTitle.Unid = user.JobTitleUnid; jobTitle.Name = user.JobTitleName + "[已被删除的职务]"; list.Add(jobTitle); } this.JobTitleUnid.DataSource = list; this.JobTitleUnid.DataTextField = "Name"; this.JobTitleUnid.DataValueField = "Unid"; this.JobTitleUnid.DataBind(); // 绑定已拥有的岗位列表 this.GroupUnids.DataSource = user.GroupLists; this.GroupUnids.DataTextField = "Name"; this.GroupUnids.DataValueField = "Unid"; this.GroupUnids.DataBind(); // 绑定尚未拥有的岗位列表 if (!string.IsNullOrEmpty(user.OUUnid)) { list = this.groupService.FindByOU(user.OUUnid, true); if (null != list && list.Count > 0) { ArrayList allGroups = new ArrayList(); if (null == user.GroupLists || user.GroupLists.Count == 0) { allGroups.AddRange(list); } else { foreach (Group group in list) { bool isHas = false; foreach (Group groupTmp in user.GroupLists) { if (groupTmp.ID == group.ID) { isHas = true; break; } } if (!isHas) { allGroups.Add(group); } } } this.AllGroups.DataSource = allGroups; this.AllGroups.DataTextField = "Name"; this.AllGroups.DataValueField = "Unid"; this.AllGroups.DataBind(); } } }