protected override void OnActivated() { base.OnActivated(); if (setEmployeeDirected != null && !ObjectSpace.IsModified) //Lọc chuyển XL văn bản khi ở chế độ xem { FillItemWithLeaderEmployeeValues(setEmployeeDirected); } Employee emp = (Employee)SecuritySystem.CurrentUser; Document curDoc = View.CurrentObject as Document; if (emp != null && curDoc != null) { //1. Cập nhật ngày đọc văn bản nếu ở chế độ View if (!ObjectSpace.IsModified) { CriteriaOperator crit = CriteriaOperator.And(new BinaryOperator("LinkEmployee.Oid", emp.Oid), new BinaryOperator("LinkDocument", curDoc)); DocumentEmployees docEmp = curDoc.Session.FindObject <DocumentEmployees>(crit); if (docEmp != null && (docEmp.DateRead == null || docEmp.DateRead == DateTime.MinValue)) { docEmp.DateRead = DateTime.Now; docEmp.Save(); View.ObjectSpace.CommitChanges(); } } } }
private void actTheodoi_Execute(object sender, SimpleActionExecuteEventArgs e) { os = Application.CreateObjectSpace(); Document currentDoc = e.CurrentObject as Document; // View.CurrentObject as Document; Employee curUser = SecuritySystem.CurrentUser as Employee; //CriteriaOperator crit; DocumentEmployees objDEmp = null; foreach (DocumentEmployees docEmp in currentDoc.DocumentEmployees) { if (docEmp != null && docEmp.LinkEmployee != null && curUser != null && docEmp.LinkEmployee.Oid == curUser.Oid && docEmp.IsDirected && docEmp.IsCurrentDirected) { objDEmp = os.FindObject <DocumentEmployees>(new BinaryOperator("Oid", docEmp.Oid)); } } if (objDEmp != null) { objDEmp.IsFollow = true; objDEmp.Save(); os.CommitChanges(); //Hiển thị OK Application.ShowViewStrategy.ShowViewInPopupWindow(Application.CreateDashboardView(Application.CreateObjectSpace(), "ActionOkDashboard", true), null, null, "OK", ""); } else { //Hiển thị lỗi quyền truy cập Application.ShowViewStrategy.ShowViewInPopupWindow(Application.CreateDashboardView(Application.CreateObjectSpace(), "AccessDeniedMessage", true), null, null, "OK", ""); } }
private void actChuyenXuly_Execute(object sender, SingleChoiceActionExecuteEventArgs e) { if (e.SelectedChoiceActionItem != null) { Employee newEmp = e.SelectedChoiceActionItem.Data as Employee; Employee currentEmp = (Employee)SecuritySystem.CurrentUser; if (newEmp != null && currentEmp != null) { Document curDoc = View.CurrentObject as Document; if (curDoc != null) { //1. Bỏ chế độ isCurrentDirected int idx = curDoc.DocumentEmployees.FindIndex(x => x.LinkEmployee.Oid == currentEmp.Oid && x.IsCurrentDirected); if (idx > -1) { curDoc.DocumentEmployees[idx].IsCurrentDirected = false; curDoc.DocumentEmployees[idx].DirectedContent = string.Format("Đã chuyển \"{0}\" xử lý!", newEmp.Title); curDoc.DocumentEmployees[idx].DateDirected = DateTime.Now; int directOrder = curDoc.DocumentEmployees[idx].DirectedOrder; //2. Cập nhật người duyệt mới: add vao neu chua co idx = curDoc.DocumentEmployees.FindIndex(x => x.LinkEmployee == newEmp); if (idx > -1) //Cập nhật { curDoc.DocumentEmployees[idx].IsCurrentDirected = true; curDoc.DocumentEmployees[idx].IsDirected = true; } else //Thêm người vào danh sách { os = Application.CreateObjectSpace(); DocumentEmployees docEmp = os.CreateObject <DocumentEmployees>(); docEmp.LinkDocument = os.GetObject(curDoc); docEmp.LinkEmployee = os.GetObject(newEmp); docEmp.IsDirected = true; docEmp.IsCurrentDirected = true; docEmp.DirectedOrder = directOrder + 1; docEmp.Save(); os.CommitChanges(); //Hiển thị OK Application.ShowViewStrategy.ShowViewInPopupWindow(Application.CreateDashboardView(Application.CreateObjectSpace(), "ActionOkDashboard", true), null, null, "OK", ""); } curDoc.Save(); ObjectSpace.CommitChanges(); } } } } }
private void FeatureMarked(bool isFeature, SimpleActionExecuteEventArgs e) { Employee curEmp = SecuritySystem.CurrentUser as Employee; foreach (Document selectDoc in e.SelectedObjects) { CriteriaOperator crit = CriteriaOperator.And(new BinaryOperator("LinkEmployee.Oid", curEmp.Oid), new BinaryOperator("LinkDocument.Oid", selectDoc.Oid)); DocumentEmployees docEmp = View.ObjectSpace.FindObject <DocumentEmployees>(crit); if (docEmp != null) { //The Action's state is updated when objects in Views change their values. This work is done by the ActionsCriteriaViewController docEmp.IsFollow = isFeature; docEmp.Save(); docEmp.Session.CommitTransaction(); ASPxGridListEditor listEditor = ((ListView)View).Editor as ASPxGridListEditor; if (listEditor != null) { listEditor.UnselectAll(); } //View.SelectedObjects.Clear(); //View.Refresh(); } } }