public ActionResult ActiveNOnActiveSeal(int?id) { if (id == null) { return(RedirectToAction("BadRequestError", "ErrorController")); } DocumentDepartment documentDepartment = db.DocumentDepartments.Include(a => a.document).Include(a => a.Department).SingleOrDefault(a => a.Id == id); if (documentDepartment == null) { return(RedirectToAction("HttpNotFoundError", "ErrorController")); } if (ManagedAes.CipherData) { documentDepartment.document.Subject = ManagedAes.DecryptText(documentDepartment.document.Subject); } return(View(documentDepartment)); }
public ActionResult Create(int DocumentIdValue, List <int> Departments) { ViewBag.Current = "Document"; List <string> UsersId = new List <string>(); string NotificationTime = string.Empty; string UserId = User.Identity.GetUserId(); Document doc = db.Documents.Find(DocumentIdValue); if (Departments == null) { return(RedirectToAction("Index", new { @id = DocumentIdValue, @msg = "CreateError" })); } if (ModelState.IsValid) { DocumentDepartment documentDepartment = null; foreach (int i in Departments) { documentDepartment = new DocumentDepartment() { DepartmentId = i, DocumentId = DocumentIdValue, EnableEdit = true, EnableRelate = true, EnableSeal = true, EnableReplay = true, CreatedAt = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"), CreatedById = this.User.Identity.GetUserId() }; db.DocumentDepartments.Add(documentDepartment); NotificationTime = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"); UsersId = db.Users.Where(a => a.DepartmentId == i).Select(a => a.Id).ToList(); Notification notification = null; List <ApplicationUser> Users = db.Users.Where(a => UsersId.Contains(a.Id)).ToList(); foreach (ApplicationUser user in Users) { notification = new Notification() { CreatedAt = NotificationTime, Active = false, UserId = user.Id, Message = "تم إضافة وثيقة جديدة للقسم الحالي، رقم الوثيقة :" + doc.DocumentNumber + " موضوع الوثيقة :" + doc.Subject + " ،عنوان الوثيقة :" + doc.Address + "،وصف الوثيقة :" + doc.Description , NotificationOwnerId = UserId }; db.Notifications.Add(notification); } } db.SaveChanges(); return(RedirectToAction("Index", new { @id = DocumentIdValue, @msg = "CreateSuccess" })); } return(RedirectToAction("Index", new { @id = DocumentIdValue })); }
public ActionResult ActiveNOnActiveConfirmSeal(int id) { string ActiveMode = string.Empty; List <string> UsersId = new List <string>(); string NotificationTime = string.Empty; string UserId = User.Identity.GetUserId(); Document doc = db.DocumentDepartments.Include(a => a.document).SingleOrDefault(a => a.Id == id).document; DocumentDepartment documentDepartment = db.DocumentDepartments.Find(id); if (documentDepartment.EnableSeal == true) { documentDepartment.EnableSeal = false; ActiveMode = "الغاء إمكانية التسديد"; } else { documentDepartment.EnableSeal = true; ActiveMode = "تفعيل إمكانية التسديد"; } documentDepartment.UpdatedAt = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"); db.Entry(documentDepartment).State = EntityState.Modified; int Form_id = documentDepartment.DocumentId; db.SaveChanges(); UsersId = db.Users.Where(a => a.DepartmentId == documentDepartment.DepartmentId).Select(a => a.Id).ToList(); Notification notification = null; NotificationTime = DateTime.Now.ToString("dd/MM/yyyy-HH:mm:ss"); List <ApplicationUser> Users = db.Users.Where(a => UsersId.Contains(a.Id)).ToList(); foreach (ApplicationUser user in Users) { notification = new Notification() { CreatedAt = NotificationTime, Active = false, UserId = user.Id, Message = "تمت عملية " + ActiveMode + " في القسم الحالي ، رقم الوثيقة" + "" + (ManagedAes.CipherData ? ManagedAes.DecryptText(doc.DocumentNumber) : doc.DocumentNumber) + " موضوع الوثيقة :" + (ManagedAes.CipherData ? ManagedAes.DecryptText(doc.Subject) : doc.Subject) + " ،عنوان الوثيقة :" + (ManagedAes.CipherData ? ManagedAes.DecryptText(doc.Address) : doc.Address) + "،وصف الوثيقة :" + (ManagedAes.CipherData ? ManagedAes.DecryptText(doc.Description) : doc.Description) , NotificationOwnerId = UserId }; db.Notifications.Add(notification); } db.SaveChanges(); return(RedirectToAction("Index", new { @id = Form_id, @msg = "EditSuccess" })); }
/// <summary> /// Поиск всех пользователей в системе Lotus Notes /// </summary> /// <returns></returns> public ModelComparableUser FindAllUsersAndAttribute() { var modelComparableUsers = new ModelComparableUser(); try { var modelList = new List <FullModelUserAllSystem>(); Db.LotusConnectedDataBaseServer(Config.LotusServer, Config.LotusImns); DocumentCollectionDepartment = Db.Db.Search(String.Format("Select(Form= \"Department\")"), null, 0); DocumentDepartment = DocumentCollectionDepartment.GetFirstDocument(); while (DocumentDepartment != null) { string repDep = DocumentDepartment.GetItemValue("Abbreviation")[0]; DocumentCollectionUsers = Db.Db.Search(String.Format("Select (Abbreviation= \"" + repDep + "\"&Form= \"Department\"| @AllChildren)"), null, 0); DocumentUsers = DocumentCollectionUsers.GetFirstDocument(); while (DocumentUsers != null) { string nameNull = DocumentUsers.GetItemValue("Abbreviation")[0]; if (DocumentUsers.GetItemValue("Discharged")[0] != "1" && nameNull.Length == 0) { var modelUsers = new FullModelUserAllSystem(); modelUsers.SystemDataBase = "Lotus Notes"; modelUsers.Surname = DocumentUsers.GetItemValue("LastName")[0]; modelUsers.Name = DocumentUsers.GetItemValue("FirstName")[0]; modelUsers.Patronymic = DocumentUsers.GetItemValue("Person_MiddleName")[0]; modelUsers.FullName = DocumentUsers.GetItemValue("Person_Name")[0]; modelUsers.Department = DocumentDepartment.GetItemValue("Dep_Name")[0]; modelUsers.JobTitle = DocumentUsers.GetItemValue("Person_Post")[0]; modelUsers.Ranks = DocumentUsers.GetItemValue("Person_Title")[0]; modelUsers.Room = null; modelUsers.Telephon = DocumentUsers.GetItemValue("Comm_Phone")[0]; modelUsers.NameMail = DocumentUsers.GetItemValue("MailAddress")[0]; modelList.Add(modelUsers); } DocumentUsers = DocumentCollectionUsers.GetNextDocument(DocumentUsers); } DocumentDepartment = DocumentCollectionDepartment.GetNextDocument(DocumentDepartment); } modelComparableUsers.FullModelUserAllSystem = modelList.ToArray(); } catch (Exception ex) { Loggers.Log4NetLogger.Error(ex); throw; } finally { if (DocumentDepartment != null) { Marshal.ReleaseComObject(DocumentDepartment); } DocumentDepartment = null; if (DocumentUsers != null) { Marshal.ReleaseComObject(DocumentUsers); } DocumentUsers = null; if (DocumentCollectionDepartment != null) { Marshal.ReleaseComObject(DocumentCollectionDepartment); } DocumentCollectionDepartment = null; if (DocumentCollectionUsers != null) { Marshal.ReleaseComObject(DocumentCollectionUsers); } DocumentCollectionUsers = null; Loggers.Log4NetLogger.Info(new Exception("Сбор данных по справочнику ИМНС Завершен!!!")); } return(modelComparableUsers); }