public int Update(PersonalFileModel model) { StringBuilder builder = new StringBuilder(); builder.Append("update F_PersonalFile set "); builder.Append("FileName=@FileName,"); builder.Append("FileNewName=@FileNewName,"); builder.Append("FileSize=@FileSize,"); builder.Append("FileOwner=@FileOwner,"); builder.Append("ParentId=@ParentId,"); builder.Append("FileType=@FileType,"); builder.Append("CreateTime=@CreateTime,"); builder.Append("ShareUsers=@ShareUsers"); builder.Append(" where Id=@Id "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Id", SqlDbType.NVarChar, 0x40), new SqlParameter("@FileName", SqlDbType.NVarChar), new SqlParameter("@FileNewName", SqlDbType.NVarChar), new SqlParameter("@FileSize", SqlDbType.NVarChar, 0x40), new SqlParameter("@FileOwner", SqlDbType.NVarChar, 0x40), new SqlParameter("@ParentId", SqlDbType.NVarChar, 0x40), new SqlParameter("@FileType", SqlDbType.NVarChar, 0x40), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@ShareUsers", SqlDbType.NVarChar) }; commandParameters[0].Value = model.Id; commandParameters[1].Value = model.FileName; commandParameters[2].Value = model.FileNewName; commandParameters[3].Value = model.FileSize; commandParameters[4].Value = model.FileOwner; commandParameters[5].Value = model.ParentId; commandParameters[6].Value = model.FileType; commandParameters[7].Value = model.CreateTime; commandParameters[8].Value = model.ShareUsers; return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); }
protected void btnReturn_Click(object sender, System.EventArgs e) { if (base.Request["id"] == null || base.Request["id"] == "0") { base.RegisterScript("alert('系统提示:\\n\\n 此目录为顶级目录')"); return; } PersonalFileModel model = this.personalFileBll.GetModel(base.Request.QueryString["id"]); base.RegisterScript("location='PersonalFileList.aspx?id=" + model.ParentId + "'"); }
protected void btnSave_Click(object sender, System.EventArgs e) { PersonalFileModel model = this.GetModel(); string text = this.hfldFolderName.Value; int count = this.personalFileBll.GetListArray(string.Concat(new string[] { " where FileName='", text, "' and FileType!=0 and ParentId='", model.ParentId, "'" })).Count; if (this.hdType.Value == "add") { if (count > 0) { base.RegisterLoadEvent("function(){alert('系统提示:\\n\\n 添加失败,此目录名称已存在!');}"); return; } this.personalFileBll.Add(model); } else { PersonalFileModel model2 = this.personalFileBll.GetModel(this.hfldPurchaseChecked.Value); if (count > 0 && this.txtFileInfo.Text.Trim() != model2.FileName) { base.RegisterLoadEvent("function(){alert('系统提示:\\n\\n 编辑失败,此目录名称已存在!');}"); return; } if (model2.FileType == "0") { string text2 = model2.FileName.Substring(model2.FileName.LastIndexOf('.')); if (text.LastIndexOf('.') != -1) { if (text.Substring(text.LastIndexOf('.')) != text2) { text += text2; } } else { text += text2; } model2.FileName = text; } else { model2.FileName = text; } this.personalFileBll.Update(model2); } base.RegisterScript("location.href='PersonalFileList.aspx?id=" + this.tvFile.SelectedValue + "'"); }
public void addModelByFistr() { if (this.personalFileBll.GetListArray(" where fileOwner='" + base.UserCode + "'").Count == 0) { string text = System.Guid.NewGuid().ToString(); PersonalFileModel model = this.GetModel(); model.FileName = "目录"; model.Id = text; model.ParentId = text; model.ShareUsers = ""; this.personalFileBll.Add(model); } }
public bool selectShare(string id) { PersonalFileModel model = this.personalFileBll.GetModel(id); string parentId = model.ParentId; if (parentId == id) { return(false); } PersonalFileModel model2 = this.personalFileBll.GetModel(parentId); string shareUsers = model2.ShareUsers; return(!model.ShareUsers.Contains(base.UserCode) || shareUsers.Contains(base.UserCode) || this.selectShare(parentId)); }
protected void Page_Load(object sender, EventArgs e) { this._ModuleID = Convert.ToInt32(base.Request.Params["mid"]); this._fid = base.Request.Params["fid"].ToString(); if (base.Request.Files.Count > 0) { string text = string.Empty; for (int i = 0; i < base.Request.Files.Count; i++) { HttpPostedFile httpPostedFile = base.Request.Files[i]; string fileName = httpPostedFile.FileName; if (this.fileInfoBll.GetListArray(" where fileName='" + httpPostedFile.FileName + "'").Count > 0) { fileName = new Random().Next(100).ToString() + httpPostedFile.FileName; } if (httpPostedFile != null && httpPostedFile.ContentLength > 0) { try { string fileNewName; if (this._ModuleID == 2) { PersonalFileModel personalModel = this.GetPersonalModel(httpPostedFile, fileName); fileNewName = personalModel.FileNewName; new PersonalFileBll().Add(personalModel); } else { FileInfoModel fileModel = this.GetFileModel(httpPostedFile, fileName); fileNewName = fileModel.FileNewName; this.fileInfoBll.Add(fileModel); } text = base.Server.MapPath("~/UploadFiles/FileInfo/"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } httpPostedFile.SaveAs(text + fileNewName); } catch (Exception) { throw; } } } } }
public void BindGv() { string selectedValue = this.ddlScope.SelectedValue; bool isGetAll = true; bool isShare = false; if (this.ViewState["search"].ToString() == "0") { selectedValue = this.tvFile.SelectedValue; isGetAll = false; } this.btnAdd.Disabled = false; this.FileUpload2.Visible = true; int recordCount; DataTable storageDataSource; if (selectedValue == "0") { this.btnAdd.Disabled = true; this.FileUpload2.Visible = false; string shareFolderIds = (this.ViewState["shareId"] == null) ? string.Empty : this.ViewState["shareId"].ToString(); recordCount = PersonalFileBll.GetShareFolersCount(shareFolderIds); storageDataSource = PersonalFileBll.GetShareFolders(shareFolderIds, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex); } else { PersonalFileModel model = this.personalFileBll.GetModel(selectedValue); if (model != null) { if (model.FileOwner != base.UserCode) { this.btnAdd.Disabled = true; this.FileUpload2.Visible = false; isShare = true; } if (this.tvFile.Nodes[0].Value == model.Id) { this.FileUpload2.Visible = false; } } recordCount = PersonalFileBll.GetAllFilesCount(selectedValue, this.txtStartTime.Text, this.txtEndTime.Text, this.txtFileName.Text, WebUtil.GetBSize(this.txtStartSize.Text), WebUtil.GetBSize(this.txtEndSize.Text), base.UserCode, isGetAll, isShare); storageDataSource = PersonalFileBll.GetAllFiles(selectedValue, this.txtStartTime.Text, this.txtEndTime.Text, this.txtFileName.Text, WebUtil.GetBSize(this.txtStartSize.Text), WebUtil.GetBSize(this.txtEndSize.Text), base.UserCode, isGetAll, isShare, this.AspNetPager1.PageSize, this.AspNetPager1.CurrentPageIndex); } this.AspNetPager1.RecordCount = recordCount; Common2.BindGvTable(storageDataSource, this.gvFile, true); }
public PersonalFileModel GetModel(string Id) { StringBuilder builder = new StringBuilder(); builder.Append("select Id,FileName,FileNewName,FileSize,FileOwner,ParentId,FileType,CreateTime,ShareUsers from F_PersonalFile "); builder.Append(" where Id=@Id "); PersonalFileModel model = null; using (IDataReader reader = SqlHelper.ExecuteReader(CommandType.Text, builder.ToString(), new SqlParameter[] { new SqlParameter("@id", Id) })) { if (reader.Read()) { model = this.ReaderBind(reader); } } return(model); }
public void DelFile(System.Collections.Generic.List <string> listId) { foreach (string current in listId) { if (!string.IsNullOrEmpty(current)) { PersonalFileModel model = this.personalFileBll.GetModel(current); if (model.FileType == "0") { string path = base.Server.MapPath("~/UploadFiles/FileInfo/" + model.FileNewName); if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } } } } }
protected void bindSelUser() { string a = base.Request["showType"]; System.Collections.Generic.List <string> list = new System.Collections.Generic.List <string>(); if (a == "1") { string id = base.Request["showId"]; FileInfoBll fileInfoBll = new FileInfoBll(); FileInfoModel model = fileInfoBll.GetModel(id); if (model != null) { list = this.getUserCodes(model.UserCodes); } } else { if (a == "2") { string id2 = base.Request["showId"]; PersonalFileBll personalFileBll = new PersonalFileBll(); PersonalFileModel model2 = personalFileBll.GetModel(id2); if (model2 != null) { list = this.getUserCodes(model2.ShareUsers); this.hfldNoSelCodes.Value = "00000000," + model2.FileOwner; } } else { if (a == "3") { string progressId = base.Request["progressId"]; list = cn.justwin.BLL.ProgressManagement.Privilege.GetUserCodes(progressId); } else { list = cn.justwin.BLL.Privilege.Privilege.GetUserCodes(base.Request["RelationsTable"], base.Request["RelationsKey"]); } } } this.hdId.Value = string.Join(",", list.ToArray()) + ","; this.AddUsers(list); }
public PersonalFileModel ReaderBind(IDataReader dataReader) { PersonalFileModel model = new PersonalFileModel { Id = dataReader["Id"].ToString(), FileName = dataReader["FileName"].ToString(), FileNewName = dataReader["FileNewName"].ToString(), FileSize = dataReader["FileSize"].ToString(), FileOwner = dataReader["FileOwner"].ToString(), ParentId = dataReader["ParentId"].ToString(), FileType = dataReader["FileType"].ToString(), ShareUsers = dataReader["ShareUsers"].ToString() }; object obj2 = dataReader["CreateTime"]; if ((obj2 != null) && (obj2 != DBNull.Value)) { model.CreateTime = new DateTime?((DateTime)obj2); } return(model); }
public int Add(PersonalFileModel model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into F_PersonalFile("); builder.Append("Id,FileName,FileNewName,FileSize,FileOwner,ParentId,FileType,CreateTime,ShareUsers)"); builder.Append(" values ("); builder.Append("@Id,@FileName,@FileNewName,@FileSize,@FileOwner,@ParentId,@FileType,@CreateTime,@ShareUsers)"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Id", SqlDbType.NVarChar, 0x40), new SqlParameter("@FileName", SqlDbType.NVarChar), new SqlParameter("@FileNewName", SqlDbType.NVarChar), new SqlParameter("@FileSize", SqlDbType.NVarChar, 0x40), new SqlParameter("@FileOwner", SqlDbType.NVarChar, 0x40), new SqlParameter("@ParentId", SqlDbType.NVarChar, 0x40), new SqlParameter("@FileType", SqlDbType.NVarChar, 0x40), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@ShareUsers", SqlDbType.NVarChar) }; commandParameters[0].Value = model.Id; commandParameters[1].Value = model.FileName; commandParameters[2].Value = model.FileNewName; commandParameters[3].Value = model.FileSize; commandParameters[4].Value = model.FileOwner; commandParameters[5].Value = model.ParentId; commandParameters[6].Value = model.FileType; commandParameters[7].Value = model.CreateTime; commandParameters[8].Value = model.ShareUsers; return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); }
public int Update(PersonalFileModel model) { return(this.personalFile.Update(model)); }
public int Add(PersonalFileModel model) { return(this.personalFile.Add(model)); }