private void InitData() { if (DocumentId != "") { BDocument ctl = new BDocument(); if (ctl.Get(DocumentId, int.Parse(EOFFICE.Common.DocumentType.DocumentDrap.ToString("D"))) != null) { ODocument obj = ctl.Get(DocumentId, int.Parse(EOFFICE.Common.DocumentType.DocumentDrap.ToString("D")))[0]; if (obj != null) { lblName.Text = obj.Name; lblSubContent.Text = obj.Excerpt; lblUserDrap.Text = obj.IDUserCreate.ToString(); try { lblUserDrap.Text = (new BUser()).Get(obj.IDUserCreate).First().UserName; } catch (Exception ex) { } lblAttach.Text = obj.Attachs; BComment BobjComment = new BComment(); rptComment.DataSource = BobjComment.Get("", DocumentId, 0); rptComment.DataBind(); List <OAttach> listAttach = new List <OAttach>(); foreach (OComment objI in BobjComment.Get("", DocumentId, 0)) { listAttach = listAttach.Union(BobjComment.GetAttachs(objI.CommentID)).ToList(); } rptFileAttachs.DataSource = listAttach; rptFileAttachs.DataBind(); } } } }
protected string BindTime(string CommentID) { BComment Bcomment = new BComment(); string CreateDate = Bcomment.Get(CommentID).First().CreateDate.ToString("dd/MM/yyyy hh:mm:ss"); return(CreateDate); }
public BComment GetForText(string text) { BComment author = AutoMapper <Comments, BComment> .Map(Database.Comments.Find(i => i.Text == text).FirstOrDefault()); if (author != null) { return(author); } return(new BComment()); }
public void Create(BComment comment) { Comments commentt = new Comments() { BooksId = comment.BooksId, Text = comment.Text }; Database.Comments.Create(commentt); Database.Save(); }
private void InitData() { //BUser ctlUP = new BUser(); ////-- Kiểm tra quyền dự thảo //if (ctlUP.HasPermission(Global.UserInfo.UserID, Common.PermissionCode.DocumentSendDrap.ToString())) // Response.Redirect("/"); BUser ctlUP = new BUser(); //-- Kiểm tra quyền dự thảo if (!ctlUP.HasPermission(Global.UserInfo.UserID, Common.PermissionCode.DocumentSendDrap.ToString()) && !Global.IsAdmin()) { Response.Redirect("/permission-fail.aspx"); } if (DocumentId != "") { BDocument ctl = new BDocument(); if (ctl.Get(DocumentId, int.Parse(EOFFICE.Common.DocumentType.DocumentSend.ToString("D"))) != null) { ODocument obj = ctl.Get(DocumentId, int.Parse(EOFFICE.Common.DocumentType.DocumentSend.ToString("D")))[0]; if (obj != null) { lblName.Text = obj.Name; lblSubContent.Text = obj.Excerpt; lblUserDrap.Text = obj.IDUserCreate.ToString(); try { lblUserDrap.Text = (new BUser()).Get(obj.IDUserCreate).First().UserName; } catch (Exception ex) { } //lblAttach.Text = obj.Attachs; BComment BobjComment = new BComment(); rptComment.DataSource = BobjComment.Get("", DocumentId, 0); rptComment.DataBind(); List <OAttach> listAttach = new List <OAttach>(); foreach (OComment objI in BobjComment.Get("", DocumentId, 0)) { listAttach = listAttach.Union(BobjComment.GetAttachs(objI.CommentID)).ToList(); } rptFileAttachs.DataSource = listAttach; rptFileAttachs.DataBind(); rptFiles.DataSource = (new BAttach()).GetAttachs(obj.Attachs); rptFiles.DataBind(); } } } }
public ActionResult EditAndCreate(CommentModel comment) { BComment oldComment = AutoMapper <CommentModel, BComment> .Map(comment); List <UserModel> users = AutoMapper <IEnumerable <BUsers>, List <UserModel> > .Map(userService.GetUsers); users.Where(x => x.Login == Request.Cookies["auth_cookie"].Value); var user = userService.GetUserByLogin(HttpContext.Request.Cookies["authCookie"].Value); oldComment.UserId = user.Id; commentService.Create(oldComment); BookModel book = AutoMapper <BBook, BookModel> .Map(bookService.GetBook(oldComment.BooksId)); book.Respect += 2; return(View("Index", AutoMapper <IEnumerable <BComment>, List <CommentModel> > .Map(commentService.GetComments))); }
protected void rptListUser_ItemCommand(object source, RepeaterCommandEventArgs e) { int WorkID = int.Parse(Request.QueryString["WorkID"].ToString()); if (e.CommandName == "trigger") { LinkButton btn = e.CommandSource as LinkButton; if (btn != null) { RepeaterItem ri = e.Item; HiddenField hdfID = (HiddenField)ri.FindControl("hdfID"); BComment BobjComment = new BComment(); OComment objComment = new OComment(); if (BobjComment.GetCreate(hdfID.Value, WorkID).Count == 0) { lblMessage.Text = "Chưa có nội dung xử lý!"; rptComment.Visible = false; rptFileAttachs.Visible = false; } else { rptComment.Visible = true; rptFileAttachs.Visible = true; lblMessage.Text = ""; objComment = BobjComment.GetCreate(hdfID.Value, WorkID).First(); rptComment.DataSource = BobjComment.GetCreate(hdfID.Value, WorkID); rptComment.DataBind(); List <OAttach> listAttach = new List <OAttach>(); foreach (OComment obj in BobjComment.GetCreate(hdfID.Value, WorkID)) { listAttach = listAttach.Union(BobjComment.GetAttachs(obj.CommentID)).ToList(); } rptFileAttachs.DataSource = listAttach; rptFileAttachs.DataBind(); } } } }
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"); }