public void rptItemCommand(object sender, RepeaterCommandEventArgs e) { //Response.Write(e.CommandName); //Response.Write(e.CommandArgument); if (e.CommandName == "Download") { try { HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(Server.MapPath(e.CommandArgument.ToString()))); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.WriteFile(Server.MapPath(e.CommandArgument.ToString())); HttpContext.Current.Response.End(); } catch (Exception ex) { throw ex; } } if (e.CommandName == "Delete") { int WorkID = int.Parse(Request.QueryString["WorkID"].ToString()); OAttach objAttach = new OAttach(); BAttach BobjAttach = new BAttach(); BWork BobjWork = new BWork(); OWork objWork = BobjWork.GetWork(WorkID).First(); int IDUserCreate = int.Parse(objWork.IDUserCreate.ToString()); string listAttach = objWork.Attachs.ToString(); objAttach = BobjAttach.Get(int.Parse(e.CommandArgument.ToString())).First(); string AttachId = objAttach.AttachID.ToString(); try { FileInfo TheFile = new FileInfo(Server.MapPath(objAttach.Path)); if (TheFile.Exists) { File.Delete(Server.MapPath(objAttach.Path)); //Xóa file Attach BobjAttach.Delete(objAttach.AttachID); //Xóa file Attach trong CSDL string newListAttach = listAttach.Replace("," + AttachId + ",", ","); BobjWork.UpdateAttach(WorkID, newListAttach, IDUserCreate); Infomation_Load(); } else { throw new FileNotFoundException(); } } catch (Exception ex) { //throw new FileNotFoundException(); } } }
public void rptItemCommand(object sender, RepeaterCommandEventArgs e) { //Response.Write(e.CommandName); //Response.Write(e.CommandArgument); if (e.CommandName == "Download") { try { HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(e.CommandArgument.ToString())); HttpContext.Current.Response.Clear(); HttpContext.Current.Response.WriteFile(e.CommandArgument.ToString()); HttpContext.Current.Response.End(); } catch (Exception ex) { throw ex; } } if (e.CommandName == "Delete") { OAttach objAttach = new OAttach(); BAttach BobjAttach = new BAttach(); BDocument Bdocument = new BDocument(); ODocument obj = Bdocument.Get(DocumentId, int.Parse(EOFFICE.Common.DocumentType.DocumentSend.ToString("D"))).First(); //int IDUserCreate = int.Parse(objWork.IDUserCreate.ToString()); string listAttach = obj.Attachs.ToString(); objAttach = BobjAttach.Get(int.Parse(e.CommandArgument.ToString())).First(); string AttachId = objAttach.AttachID.ToString(); try { FileInfo TheFile = new FileInfo(Server.MapPath(objAttach.Path)); if (TheFile.Exists) { File.Delete(Server.MapPath(objAttach.Path)); //Xóa file Attach BobjAttach.Delete(objAttach.AttachID); //Xóa file Attach trong CSDL string newListAttach = listAttach.Replace("," + AttachId + ",", ","); obj.Attachs = newListAttach; Bdocument.Update(obj.DocumentID, "", obj.Name, obj.Excerpt, obj.Content, "", obj.PublishOffical, obj.Attachs, obj.IDDocumentKind, "", obj.UserProcess, "", obj.StartProcess.ToString("MM/dd/yyyy"), obj.EndProcess.ToString("MM/dd/yyyy"), DateTime.Now.ToString("MM/dd/yyyy"), "", obj.SendOfficals, obj.Priority, obj.Status); InitData(); } else { throw new FileNotFoundException(); } } catch (Exception ex) { //throw new FileNotFoundException(); } } }
/// <summary> /// Upload file /// </summary> /// <returns></returns> private string Upload() { string listFile = ","; try { if (fuDrap.PostedFile == null) { return(""); } if (!Directory.Exists(Server.MapPath("DocumentFiles"))) { Directory.CreateDirectory(Server.MapPath("DocumentFiles")); } if (!Directory.Exists(Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName))) { Directory.CreateDirectory(Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName)); } BAttach Bobj = new BAttach(); HttpFileCollection hfc = Request.Files; int n = hfc.Count; if (n > 0) { try { // Get the HttpFileCollection for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName) + "/" + hpf.FileName); OAttach objA = new OAttach(); objA.Name = System.IO.Path.GetFileName(hpf.FileName); objA.Path = Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName) + "/" + hpf.FileName; objA.Description = ""; Bobj.Add(objA); listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ","; } } } catch (Exception ex) { } } //FileUpload1.SaveAs(Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName + "/" + FileUpload1.FileName)); } catch (Exception ex) { } return(listFile); }
protected void btnCapNhat_Click(object sender, EventArgs e) { BWork BobjWork = new BWork(); //Lấy IDWWork int WorkID = int.Parse(Request.QueryString["WorkID"].ToString()); //Lấy IDUserCreate string IDUserCreate = Global.UserInfo.UserName;//Lấy lại sau //Lấy nội dung xử lý string Content = txtContent.Text; //Upload File DateTime CurrentTime = DateTime.Now; string day = CurrentTime.Day.ToString(); string month = CurrentTime.Month.ToString(); string year = CurrentTime.Year.ToString(); string hour = CurrentTime.Hour.ToString(); string minute = CurrentTime.Minute.ToString(); string millisecond = CurrentTime.Millisecond.ToString(); string str = "-" + day + "-" + month + "-" + year + "-" + "-" + hour + "-" + minute + "-" + millisecond; //Lấy danh sách file đính kèm BAttach Bobj = new BAttach(); HttpFileCollection hfc = Request.Files; int n = hfc.Count; string listFile = ","; if (n > 0) { try { // Get the HttpFileCollection for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("/MyFiles") + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName)); OAttach obj = new OAttach(); obj.Name = System.IO.Path.GetFileName(hpf.FileName); obj.Path = "~/MyFiles" + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName); obj.Description = ""; Bobj.Add(obj); listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ","; } } } catch (Exception ex) { } } //Lấy danh sách người chuyển tiếp string UserJoin = hdfUsers.Value; if (UserJoin == ",") { UserJoin = ""; } ////////////////////////////////////////////// //Tạo Comment mới BComment BobjComment = new BComment(); OComment objComment = new OComment(); objComment.CommentID = WorkID.ToString() + "" + CurrentTime.ToString(); objComment.Title = "Xử lý công việc: " + BobjWork.GetWork(WorkID).First().Name; objComment.Content = Content; objComment.IDUserCreate = IDUserCreate; objComment.IDDocument = ""; objComment.IDWork = WorkID; objComment.Attachs = listFile; objComment.CreateDate = CurrentTime; BobjComment.Add(objComment); //Thêm danh sách người chuyển tiếp nếu có chuyển tiếp if (UserJoin != "") { OWork objWork = new OWork(); objWork = BobjWork.GetWork(WorkID).First(); //Xử lý người chuyển tiếp trùng lặp string CurrentList = objWork.IDUserProcess; string[] divUser = UserJoin.Split(','); for (int i = 0; i < divUser.Count(); i++) { divUser[i] = "," + divUser[i] + ","; CurrentList = CurrentList.Replace(divUser[i], ","); } string newlistUserProcess = CurrentList + UserJoin; BobjWork.UpdateUserProcess(WorkID, newlistUserProcess, objWork.IDUserCreate); //Lấy IDUserCreate sau } Page.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); }
/// <summary> /// Gửi bản thảo /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void lnkSendDrap_Click(object sender, EventArgs e) { ODocument obj; BDocument ctl = new BDocument(); if (DocumentId != "") { try { obj = ctl.Get(DocumentId, int.Parse(EOFFICE.Common.DocumentType.DocumentReceived.ToString("D")))[0]; if (obj != null) { string listFile = ","; try { obj = ctl.Get(DocumentId, int.Parse(EOFFICE.Common.DocumentType.DocumentReceived.ToString("D")))[0]; try { if (FileUpload1.PostedFile == null) { return; } if (!Directory.Exists(Server.MapPath("DocumentFiles"))) { Directory.CreateDirectory(Server.MapPath("DocumentFiles")); } if (!Directory.Exists(Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName))) { Directory.CreateDirectory(Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName)); } BAttach Bobj = new BAttach(); HttpFileCollection hfc = Request.Files; int n = hfc.Count; if (n > 0) { try { // Get the HttpFileCollection for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName) + "/" + hpf.FileName); OAttach objA = new OAttach(); objA.Name = System.IO.Path.GetFileName(hpf.FileName); objA.Path = Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName) + "/" + hpf.FileName; objA.Description = ""; Bobj.Add(objA); listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ","; } } } catch (Exception ex) { } } //FileUpload1.SaveAs(Server.MapPath("DocumentFiles/" + Global.UserInfo.UserName + "/" + FileUpload1.FileName)); } catch (Exception ex) { } if (obj != null) { //Tạo Comment mới BComment BobjComment = new BComment(); OComment objComment = new OComment(); objComment.CommentID = DocumentId + DateTime.Now.ToString("dd_MM_yyyy_hh_mm_ss"); objComment.Title = "Xử lý Công văn đến: " + lblName.Text; objComment.Content = txtContent.Text; objComment.IDUserCreate = Global.UserInfo.UserName; objComment.IDDocument = DocumentId; objComment.IDWork = 0; objComment.Attachs = listFile; objComment.CreateDate = DateTime.Now; BobjComment.Add(objComment); ctl.Update(DocumentId, "", DateTime.Now.ToString(""), EOFFICE.Common.DocumentStatus.SendAgain.ToString("D")); } } catch (Exception ex) { } } } catch (Exception ex) { } } else { } Response.Redirect("/DocumentSend/DocumentProcess.aspx"); }
protected void btnForward_Click(object sender, EventArgs e) { int WorkID = int.Parse(Request.QueryString["WorkID"].ToString()); CultureInfo culture = new CultureInfo("fr-FR", true); //Upload File DateTime CurrentTime = DateTime.Now; string day = CurrentTime.Day.ToString(); string month = CurrentTime.Month.ToString(); string year = CurrentTime.Year.ToString(); string hour = CurrentTime.Hour.ToString(); string minute = CurrentTime.Minute.ToString(); string millisecond = CurrentTime.Millisecond.ToString(); string str = "-" + day + "-" + month + "-" + year + "-" + "-" + hour + "-" + minute + "-" + millisecond; //Lấy danh sách file Attach BAttach Bobj = new BAttach(); HttpFileCollection hfc = Request.Files; int n = hfc.Count; string listFile = ","; try { // Get the HttpFileCollection for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("/MyFiles") + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName)); OAttach obj = new OAttach(); obj.Name = System.IO.Path.GetFileName(hpf.FileName); obj.Path = "~/MyFiles" + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName); obj.Description = ""; Bobj.Add(obj); listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ","; } } } catch (Exception ex) { } //Lấy danh sách người thực hiện công việc string UserJoin = hdfUsers.Value; if (UserJoin == ",") { UserJoin = ""; } else { UserJoin = "," + UserJoin; } //Lấy mức độ ưu tiên string Priority = string.Empty; if (rdoPrior1.Checked == true) { Priority = "RAT_QUAN_TRONG"; } else if (rdoPrior2.Checked == true) { Priority = "QUAN_TRONG"; } else { Priority = "BINH_THUONG"; } // Cập nhật công việc OWork objWork = new OWork(); BWork _BWork = new BWork(); objWork = _BWork.GetWork(WorkID).First(); string Name = txtWorkName.Text; string Description = txtDescription.Text; string Content = txtContent.Text; string Attachs = objWork.Attachs; if (listFile != ",") { Attachs = Attachs.Remove(Attachs.Length - 1, 1) + listFile; } int IDUserCreate = objWork.IDUserCreate; string IDUserProcess = ""; //-- Kiểm tra quyền giao việc BUser ctl = new BUser(); if (ctl.HasPermission(Global.UserInfo.UserID, PermissionCode.WorkAssignment.ToString()) || Global.IsAdmin()) { IDUserProcess = UserJoin; } else { IDUserProcess = "," + Global.UserInfo.UserName + ","; } int IDWorkGroup = int.Parse(ddlWorkGroup.SelectedValue); DateTime CreateDate = objWork.CreateDate; string Status = "DANG_THUC_HIEN"; // Priority = Priority; DateTime StartProcess = DateTime.Parse(txtStartDate.Text, culture, DateTimeStyles.NoCurrentDateDefault); DateTime EndProcess = DateTime.Parse(txtEndDate.Text, culture, DateTimeStyles.NoCurrentDateDefault); BWork BobjWork = new BWork(); if (BobjWork.Update(WorkID, Name, Description, Content, Attachs, IDUserCreate, IDUserProcess, CreateDate, StartProcess, EndProcess, Status, Priority, IDWorkGroup)) { Response.Redirect("WorkAssignment.aspx"); } else { RegisterClientScriptBlock("NOTE", "<script>alert('Giao việc không thành công');</script>"); } }
protected void btnSave_Click(object sender, EventArgs e) { CultureInfo culture = new CultureInfo("fr-FR", true); //Upload File DateTime CurrentTime = DateTime.Now; string day = CurrentTime.Day.ToString(); string month = CurrentTime.Month.ToString(); string year = CurrentTime.Year.ToString(); string hour = CurrentTime.Hour.ToString(); string minute = CurrentTime.Minute.ToString(); string millisecond = CurrentTime.Millisecond.ToString(); string str = "-" + day + "-" + month + "-" + year + "-" + "-" + hour + "-" + minute + "-" + millisecond; //Lấy danh sách file Attach BAttach Bobj = new BAttach(); HttpFileCollection hfc = Request.Files; int n = hfc.Count; string listFile = ","; try { // Get the HttpFileCollection for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("/MyFiles") + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName)); OAttach obj = new OAttach(); obj.Name = System.IO.Path.GetFileName(hpf.FileName); obj.Path = "~/MyFiles" + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName); obj.Description = ""; Bobj.Add(obj); listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ","; } } } catch (Exception ex) { } //Lấy danh sách người thực hiện công việc string UserJoin = hdfUsers.Value; if (UserJoin == ",") { UserJoin = ""; } else { UserJoin = "," + UserJoin; } //Lấy mức độ ưu tiên string Priority = string.Empty; if (rdoPrior1.Checked == true) { Priority = "RAT_QUAN_TRONG"; } else if (rdoPrior2.Checked == true) { Priority = "QUAN_TRONG"; } else { Priority = "BINH_THUONG"; } //Lưu công việc mới OWork objWork = new OWork(); objWork.Name = txtWorkName.Text; objWork.Description = txtDescription.Text; objWork.Content = txtContent.Text; objWork.Attachs = listFile; objWork.IDUserCreate = Global.UserInfo.UserID; BUser ctl = new BUser(); //-- Kiểm tra quyền giao việc if (ctl.HasPermission(Global.UserInfo.UserID, PermissionCode.WorkAssignment.ToString()) || Global.IsAdmin()) { objWork.IDUserProcess = UserJoin; } else { objWork.IDUserProcess = "," + Global.UserInfo.UserName + ","; } objWork.IDWorkGroup = int.Parse(ddlWorkGroup.SelectedValue); objWork.CreateDate = CurrentTime; objWork.Status = "CHUA_GIAO"; objWork.Priority = Priority; objWork.StartProcess = DateTime.Parse(txtStartDate.Text, culture, DateTimeStyles.NoCurrentDateDefault); objWork.EndProcess = DateTime.Parse(txtEndDate.Text, culture, DateTimeStyles.NoCurrentDateDefault); BWork BobjWork = new BWork(); BobjWork.Add(objWork); Response.Redirect("WorkAssignment.aspx"); }
protected void btnForward_Click(object sender, EventArgs e) { //Gửi thông báo tới người thực hiện công việc //Upload File CultureInfo culture = new CultureInfo("fr-FR", true); //Upload File DateTime CurrentTime = DateTime.Now; string day = CurrentTime.Day.ToString(); string month = CurrentTime.Month.ToString(); string year = CurrentTime.Year.ToString(); string hour = CurrentTime.Hour.ToString(); string minute = CurrentTime.Minute.ToString(); string millisecond = CurrentTime.Millisecond.ToString(); string str = "-" + day + "-" + month + "-" + year + "-" + "-" + hour + "-" + minute + "-" + millisecond; //Lấy danh sách file Attach BAttach Bobj = new BAttach(); HttpFileCollection hfc = Request.Files; int n = hfc.Count; string listFile = ","; try { // Get the HttpFileCollection for (int i = 0; i < hfc.Count; i++) { HttpPostedFile hpf = hfc[i]; if (hpf.ContentLength > 0) { hpf.SaveAs(Server.MapPath("/MyFiles") + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName)); OAttach obj = new OAttach(); obj.Name = System.IO.Path.GetFileName(hpf.FileName); obj.Path = "~/MyFiles" + "/" + System.IO.Path.GetFileNameWithoutExtension(hpf.FileName).Replace(" ", "_") + str + System.IO.Path.GetExtension(hpf.FileName); obj.Description = ""; Bobj.Add(obj); listFile += Bobj.GetLast().FirstOrDefault().AttachID.ToString() + ","; } } } catch (Exception ex) { } //Lấy danh sách người thực hiện công việc string UserJoin = hdfUsers.Value; if (UserJoin == ",") { UserJoin = ""; } else { UserJoin = "," + UserJoin; } //Lấy mức độ ưu tiên string Priority = string.Empty; if (rdoPrior1.Checked == true) { Priority = "RAT_QUAN_TRONG"; } else if (rdoPrior2.Checked == true) { Priority = "QUAN_TRONG"; } else { Priority = "BINH_THUONG"; } //Lưu công việc mới OWork objWork = new OWork(); objWork.Name = txtWorkName.Text; objWork.Description = txtDescription.Text; objWork.Content = txtContent.Text; objWork.Attachs = listFile; objWork.IDUserCreate = Global.UserInfo.UserID; //--Lấy IDUserCreate sau objWork.IDUserProcess = UserJoin; objWork.IDWorkGroup = int.Parse(ddlWorkGroup.SelectedValue); objWork.CreateDate = CurrentTime; objWork.Status = "DANG_THUC_HIEN"; objWork.Priority = Priority; objWork.StartProcess = DateTime.Parse(txtStartDate.Text, culture, DateTimeStyles.NoCurrentDateDefault); objWork.EndProcess = DateTime.Parse(txtEndDate.Text, culture, DateTimeStyles.NoCurrentDateDefault); BWork BobjWork = new BWork(); BobjWork.Add(objWork); //Reset Field ResetField(); RegisterClientScriptBlock("NOTE", "<script>alert('Công việc đã được giao !');</script>"); }