public JsonResult Files([DataSourceRequest] DataSourceRequest request, string id) { Document document = db.Documents.FirstOrDefault(o => o.Id == new Guid(id)); var files = UploadHelper.GetFilesInfo(document.AttachPath.ToString(), false); return(Json(files.ToDataSourceResult(request), JsonRequestBehavior.AllowGet)); }
public ActionResult ChangeStatusPrice(Guid id) { Document baseDocument = db.Documents.Find(id); DocumentModel model = new DocumentModel(baseDocument); return(PartialView(model)); }
public ActionResult DocumentBuild(DocumentModel document) { if (document != null) { Document baseDocument = db.Documents.Include(o => o.Template).First(o => o.Id == document.Id); baseDocument = document.GetDocument(baseDocument); db.SaveChanges(); TemplateDocument templateDocument = new TemplateDocument(baseDocument); List <ReplaceItem> items = new List <ReplaceItem>(templateDocument.ItemsValue.Select(o => new ReplaceItem { Key = o.Key, Value = o.Value })); FileStream fileStream = System.IO.File.OpenRead(HttpContext.Server.MapPath("/Content/Projects/Project" + baseDocument.ProjectType + ".docx")); byte[] data = new byte[fileStream.Length]; fileStream.Read(data, 0, data.Length); if (document.RemarkId == 1) { items.FirstOrDefault(i => i.Key == "Comment1").Value = !string.IsNullOrEmpty(document.RemarkText1)?"1) " + document.RemarkText1:""; items.FirstOrDefault(i => i.Key == "Comment2").Value = !string.IsNullOrEmpty(document.RemarkText2) ? "2) " + document.RemarkText2 : ""; items.FirstOrDefault(i => i.Key == "Comment3").Value = !string.IsNullOrEmpty(document.RemarkText3) ? "3) " + document.RemarkText3 : ""; UploadHelper.UploadReplace(data, "Замечания.docx", baseDocument.AttachPath, items); } else if (document.RemarkId == 2) { fileStream = System.IO.File.OpenRead(HttpContext.Server.MapPath("/Content/Projects/Parley.docx")); data = new byte[fileStream.Length]; fileStream.Read(data, 0, data.Length); items.AddRange(new List <ReplaceItem> { new ReplaceItem { Key = "ParleyStartDate", Value = document.ParleyStartDate.ToString("d MMM yyyy", CultureInfo.CurrentCulture) }, new ReplaceItem { Key = "ParleyEndDate", Value = document.ParleyEndDate.ToString("d MMM yyyy", CultureInfo.CurrentCulture) } }); UploadHelper.UploadReplace(data, "Приглашение на переговоры.docx", baseDocument.AttachPath, items); } else { UploadHelper.UploadReplace(data, "Проект.docx", baseDocument.AttachPath, items); } fileStream.Close(); DocumentModel model = new DocumentModel(baseDocument); return(Content(JsonConvert.SerializeObject(new { State = true, document = model }, Formatting.Indented, new JsonSerializerSettings() { DateFormatString = "dd.MM.yyyy HH:mm" }))); return(Json(new { State = true, document = model }, JsonRequestBehavior.AllowGet)); } return(Content(bool.FalseString)); }
public ActionResult DocumentBuildWithParam(DocumentModel document, string type) { if (document != null) { Document baseDocument = db.Documents.Include(o => o.Template).First(o => o.Id == document.Id); baseDocument = document.GetDocument(baseDocument); db.SaveChanges(); TemplateDocument templateDocument = new TemplateDocument(baseDocument); List <ReplaceItem> items = new List <ReplaceItem>(templateDocument.ItemsValue.Select(o => new ReplaceItem { Key = o.Key, Value = o.Value })); FileStream fileStream = System.IO.File.OpenRead(HttpContext.Server.MapPath("/Content/Projects/templates/" + type + ".docx")); byte[] data = new byte[fileStream.Length]; fileStream.Read(data, 0, data.Length); UploadHelper.UploadReplace(data, "протокол.docx", baseDocument.AttachPath, items); fileStream.Close(); DocumentModel model = new DocumentModel(baseDocument); return(Content(JsonConvert.SerializeObject(new { State = true, document = model }, Formatting.Indented, new JsonSerializerSettings() { DateFormatString = "dd.MM.yyyy HH:mm" }))); return(Json(new { State = true, document = model }, JsonRequestBehavior.AllowGet)); } return(Content(bool.FalseString)); }
/// <summary> /// Конвертирование в исходящий /// </summary> /// <param name="objectContext"></param> /// <param name="project"></param> /// <param name="currentEmployee"></param> /// <param name="singInfo">Информация о подписывающем</param> public static void ConvertInOutgouingDocument(Document document, Document project, Employee currentEmployee, string singInfo) { ncelsEntities context = UserHelper.GetCn(); document.QrCode = GetQrCode(GetTextQRcode(singInfo, !string.IsNullOrEmpty(project.Digest))); document.MainTaskId = project.MainTaskId; document.MainDocumentId = project.MainDocumentId; document.SourceId = project.Id.ToString(); document.SourceValue = project.DisplayName; document.RegistratorValue = currentEmployee.DisplayName; document.RegistratorId = currentEmployee.Id.ToString(); document.DocumentType = 1; document.SortNumber = 99999; document.StateType = 0; document.TemplateId = null; document.Number = null; document.DocumentDate = document.CreatedDate = document.ModifiedDate = DateTime.Now; document.SortNumber = 0; document.SortingNumber = null; document.IsDeleted = false; document.IsAttachments = false; document.AttachPath = FileHelper.GetObjectPathRoot(); if (document.MainDocumentId != null) { Document doc = context.Documents.FirstOrDefault(o => o.Id == document.MainDocumentId.Value); if (doc != null) { document.OrganizationId = doc.OrganizationId; } } CopyFile(project.AttachPath.ToString(), document.AttachPath.ToString()); context.Documents.Add(document); context.SaveChanges(); }
public ActionResult DocumentUpdate(DocumentModel document) { if (document != null) { Document baseDocument = db.Documents.Find(document.Id); if (baseDocument == null) { baseDocument = new Document() { Id = document.Id, DocumentType = 3, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, DocumentDate = DateTime.Now, ProjectType = 6 }; db.Documents.Add(baseDocument); } baseDocument = document.GetDocument(baseDocument); db.SaveChanges(); return(Content(bool.TrueString)); } //IList<Document> teachers = new JavaScriptSerializer().Deserialize<IList<Document>>(models); return(Content(bool.FalseString)); }
public ActionResult DocumentUpdate(DocumentModel document) { if (document != null) { Document baseDocument = db.Documents.Find(document.Id); if (baseDocument == null) { baseDocument = new Document() { Id = document.Id, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, DocumentDate = DateTime.Now, ProjectType = document.ProjectType, DocumentType = 4, TemplateId = new Guid("C3292589-A25B-4CEF-8CB5-C7E64946C1D3") }; db.Documents.Add(baseDocument); } baseDocument = document.GetDocument(baseDocument); db.SaveChanges(); return(Content(bool.TrueString)); } //IList<Document> teachers = new JavaScriptSerializer().Deserialize<IList<Document>>(models); return(Content(bool.FalseString)); }
public ActionResult DocumentBpReview(Guid id) { Document baseDocument = db.Documents.Find(id); baseDocument.StateType = 4; Activity activity = db.Activities.FirstOrDefault(x => x.DocumentId == id && x.IsParrent && x.Branch == 0); if (activity != null) { activity.IsCurrent = true; } db.SaveChanges(); DocumentModel model = new DocumentModel(baseDocument); return(Content(JsonConvert.SerializeObject(new { State = true, document = model }, Formatting.Indented, new JsonSerializerSettings() { DateFormatString = "dd.MM.yyyy HH:mm" }))); return(Content(bool.FalseString)); }
public ActionResult DocumentRead(Guid id, Guid?repeatId) { Document document = db.Documents.Find(id); if (document == null) { document = new Document() { Id = id, DocumentType = 0, DocumentDate = DateTime.Now, MonitoringType = 1, AttachPath = FileHelper.GetObjectPathRoot() }; } if (repeatId.HasValue) { document = GetRepeatDocument(document, repeatId.Value); } DocumentModel model = new DocumentModel(document); return(Content(JsonConvert.SerializeObject(model, Formatting.Indented, new JsonSerializerSettings() { DateFormatString = "dd.MM.yyyy HH:mm" }))); }
public ActionResult SendRejectRequest(Guid id) { Document baseDocument = db.Documents.Find(id); DocumentModel model = new DocumentModel(baseDocument); return(PartialView(model)); }
public JsonResult FileTaskRead(string taskId) { Task task = db.Tasks.FirstOrDefault(o => o.Id == new Guid(taskId)); Document document = db.Documents.FirstOrDefault(o => o.Id == task.DocumentId); var files = UploadHelper.GetFilesInfo(document.AttachPath.ToString(), false); return(Json(files, JsonRequestBehavior.AllowGet)); }
/// <summary> /// Конвертирование во внутренний документ /// </summary> /// <param name="objectContext"></param> /// <param name="project"></param> /// <param name="currentEmployee"></param> /// <param name="singInfo">Информация о подписывающем</param> public static void ConvertInCorrespondentDocument(Document document, Document project, Employee currentEmployee, string singInfo) { ncelsEntities context = UserHelper.GetCn(); Template template = context.Templates.First(o => o.Id == project.TemplateId); document.QrCode = GetQrCode(GetTextQRcode(singInfo, !string.IsNullOrEmpty(project.Digest))); //Template convTemplate = context.Templates.First(o => o.Id == template.ConvertDictionaryTypeId); //document.DocumentDictionaryTypeId = convTemplate.DictionaryTypeId; //document.DocumentDictionaryTypeValue = convTemplate.DictionaryTypeValue; document.MainTaskId = project.MainTaskId; document.MainDocumentId = project.MainDocumentId; document.SourceId = project.Id.ToString(); document.SourceValue = project.DisplayName; document.RegistratorValue = currentEmployee.DisplayName; document.RegistratorId = currentEmployee.Id.ToString(); document.DocumentType = 5; document.TemplateId = context.Templates.First().Id; document.IsDeleted = false; document.DocumentDate = document.CreatedDate = document.ModifiedDate = DateTime.Now; document.ExecutionDate = document.ExecutionDate.HasValue ? document.ExecutionDate : DateTime.Now.AddDays(15); document.IsAttachments = false; document.AttachPath = FileHelper.GetObjectPathRoot(); if (document.ApplicantType == 0) { document.StateType = 2; Registrator.SetNumber(document); context.Activities.Add(GetNewActivity(document)); CopyFile(project.AttachPath.ToString(), document.AttachPath.ToString()); ReplaceText(document.AttachPath.ToString(), "Проект.docx", "DocumentNumber", document.Number); ReplaceText(document.AttachPath.ToString(), "Проект.docx", "DocumentDate", document.DocumentDate.Value.ToString("dd.MM.yyyy")); } else { var items = DictionaryHelper.GetItems(document.ExecutorsId, document.ExecutorsValue).Select(o => new Guid(o.Id)).ToList(); var employes = context.Employees.Where(o => items.Contains(o.Id)).ToList(); var orgId = new Guid("8F0B91F3-AF29-4D3C-96D6-019CBBDFC8BE"); if (employes.Select(o => o.OrganizationId).Contains(orgId)) { document.OrganizationId = orgId; } CopyFile(project.AttachPath.ToString(), document.AttachPath.ToString()); document.StateType = 0; document.Number = null; } project.DestinationId = document.Id.ToString(); project.DestinationValue = document.Number; context.Documents.Add(document); context.SaveChanges(); }
public ActionResult DocumentBpReject(Guid id) { Document baseDocument = db.Documents.Find(id); DocumentHelper.DeleteSignTask(db, baseDocument); baseDocument.StateType = 6; db.SaveChanges(); int branch = db.Activities.Where(d => d.DocumentId == baseDocument.Id).Max(o => o.Branch); var list = db.Activities.Where(d => d.DocumentId == baseDocument.Id && d.Branch == branch).Where(o => o.Type != 4); var listItem = list.FirstOrDefault(o => o.ParentId == null); if (listItem != null) { Guid?parentId = null; for (int i = 0; i < list.Count(); i++) { Activity activity = new Activity { Id = Guid.NewGuid(), // ParentTask = task.Id, DocumentId = id, AuthorId = UserHelper.GetCurrentEmployee().Id.ToString(), AuthorValue = UserHelper.GetCurrentEmployee().DisplayName, ExecutorsId = listItem.ExecutorsId, ExecutorsValue = listItem.ExecutorsValue, //ResponsibleId = DictionaryHelper.GetItemsId(taskAction.ResponsibleId), //ResponsibleValue = DictionaryHelper.GetItemsName(taskAction.ResponsibleId), Type = 3, IsParrent = !parentId.HasValue, CreatedDate = DateTime.Now, ParentId = !parentId.HasValue ? (Guid?)null : parentId.Value, ExecutionDate = baseDocument.ExecutionDate, Text = listItem.Text, IsNotActive = true, //IsMainLine = task.IsMainLine }; parentId = activity.Id; listItem = list.FirstOrDefault(o => o.ParentId == listItem.Id); db.Activities.Add(activity); } db.SaveChanges(); } DocumentModel model = new DocumentModel(baseDocument); return(Content(JsonConvert.SerializeObject(new { State = true, document = model }, Formatting.Indented, new JsonSerializerSettings() { DateFormatString = "dd.MM.yyyy HH:mm" }))); return(Json(new { State = true, document = model }, JsonRequestBehavior.AllowGet)); return(Content(bool.FalseString)); }
public ActionResult DocumentRegister(DocumentModel document) { if (document != null) { Document baseDocument = db.Documents.Find(document.Id); if (baseDocument == null) { baseDocument = new Document() { Id = document.Id, DocumentType = 4, ProjectType = document.ProjectType, CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, TemplateId = new Guid("C3292589-A25B-4CEF-8CB5-C7E64946C1D3") }; db.Documents.Add(baseDocument); } baseDocument = document.GetDocument(baseDocument); baseDocument.StateType = 1; baseDocument.DocumentDate = baseDocument.DocumentDate ?? DateTime.Now; //baseDocument.ExecutionDate = baseDocument.ExecutionDate ?? baseDocument.DocumentDate.Value.AddDays(15); baseDocument.RegistratorId = UserHelper.GetCurrentEmployee().Id.ToString(); baseDocument.RegistratorValue = UserHelper.GetCurrentEmployee().DisplayName; baseDocument.FirstExecutionDate = baseDocument.ExecutionDate; baseDocument.ModifiedDate = DateTime.Now; Registrator.SetNumber(baseDocument); if ((baseDocument.ProjectType == 5 || baseDocument.ProjectType == 2) && baseDocument.ApplicantType != 1) { if (UserHelper.CheckGuide(baseDocument.ExecutorsId)) { baseDocument.ApplicantType = 1; } } if (!document.RemarkId.HasValue) { LogHelper.Log.Error("Не указан тип замечания"); throw new Exception("Не указан тип замечания"); } var remarkType = db.RemarkTypes.First(x => x.Code == document.RemarkId.Value.ToString()); baseDocument.RemarkId = remarkType.Id; baseDocument.RemarkText1 = document.RemarkText1; baseDocument.RemarkText2 = document.RemarkText2; baseDocument.RemarkText3 = document.RemarkText3; db.SaveChanges(); GenerateActivity(baseDocument); DocumentModel model = new DocumentModel(baseDocument); return(Content(JsonConvert.SerializeObject(new { State = true, document = model }, Formatting.Indented, new JsonSerializerSettings() { DateFormatString = "dd.MM.yyyy HH:mm" }))); return(Json(new { State = true, document = model }, JsonRequestBehavior.AllowGet)); } return(Content(bool.FalseString)); }
public ActionResult DocumentRead(Guid id, Guid?documentId, string type) { Document document = db.Documents.Find(id); if (document == null) { document = new Document() { Id = id, DocumentType = 4, DocumentDate = DateTime.Now, CreatedUserId = UserHelper.GetCurrentEmployee().Id.ToString(), CreatedUserValue = UserHelper.GetCurrentEmployee().DisplayName, TemplateId = new Guid("C3292589-A25B-4CEF-8CB5-C7E64946C1D3"), MonitoringType = 1, AttachPath = FileHelper.GetObjectPathRoot(), ParleyStartDate = DateTime.Now, ParleyEndDate = DateTime.Now }; document.ProjectType = 1; Document documentmain = db.Documents.First(o => o.Id == documentId); document.CorrespondentsValue = documentmain.CorrespondentsValue; document.ApplicantEmail = documentmain.ApplicantEmail; document.AnswersId = documentmain.Id.ToString(); document.AnswersValue = documentmain.DisplayName; document.LanguageDictionaryId = documentmain.LanguageDictionaryId; document.LanguageDictionaryValue = documentmain.LanguageDictionaryValue; document.DocumentKindDictionaryId = documentmain.DocumentKindDictionaryId; document.DocumentKindDictionaryValue = documentmain.DocumentKindDictionaryValue; document.QuestionDesignDictionaryId = documentmain.QuestionDesignDictionaryId; document.QuestionDesignDictionaryValue = documentmain.QuestionDesignDictionaryValue; document.ExecutionDate = documentmain.ExecutionDate; document.CorrespondentsId = documentmain.CorrespondentsId; document.CorrespondentsValue = documentmain.CorrespondentsValue; document.CorrespondentsInfo = documentmain.RegistratorValue; document.ExecutorsValue = documentmain.RegistratorValue; document.ExecutorsId = documentmain.RegistratorId; document.RemarkId = documentmain.RemarkId ?? 0; document.RemarkText1 = documentmain.RemarkText1; document.RemarkText2 = documentmain.RemarkText2; document.RemarkText3 = documentmain.RemarkText3; document.OutgoingType = 1; } DocumentModel model = new DocumentModel(document); return(Content(JsonConvert.SerializeObject(model, Formatting.Indented, new JsonSerializerSettings() { DateFormatString = "dd.MM.yyyy HH:mm" }))); return(Json(model, JsonRequestBehavior.AllowGet)); }
private static void DeleteOldDocument(ncelsEntities objectContext, Document project) { if (!string.IsNullOrEmpty(project.DestinationId)) { Guid id = new Guid(project.DestinationId); Document document = objectContext.Documents.First(o => o.Id == id); document.IsDeleted = true; //objectContext.Documents.AttachAsModified(document); } }
public ActionResult ExtensionExecutionConfirm(ExtensionExecution execution) { Document document = db.Documents.Find(execution.DocumentId); document.ExecutionDate = execution.ExecutionDate; db.ExtensionExecutions.Add(execution); db.SaveChanges(); return(Content(bool.TrueString)); }
public ActionResult SendRejectRequestConfirm(Guid?id, Guid reason) { try { if (id != null) { Document d = db.Documents.FirstOrDefault(m => m.Id == id); if (d != null) { var reasonDic = db.Dictionaries.FirstOrDefault(x => x.Id == reason); var pp = db.PriceProjects.FirstOrDefault(x => x.Id == id); if (pp != null) { pp.Status = (int)PriceProjectStatus.Finished; if (reasonDic != null) { pp.RejectReasonId = reason; } db.SaveChanges(); var tasks = db.Tasks.Where(x => x.DocumentId == id).ToList(); while (tasks.Count > 0) { db.Tasks.Remove(tasks[0]); db.SaveChanges(); tasks = db.Tasks.Where(x => x.DocumentId == id).ToList(); } //if gobmp if (reasonDic != null && reasonDic.Code.Equals("gobmp")) { new NotificationManager().SendNotification( string.Format("Вам отказано в регистрации заявления №{0} по причине отсутствия его в рамках ГОБМП", d.OutgoingNumber), ObjectType.Letter, pp.Id, pp.OwnerId); } return(Json(bool.TrueString, JsonRequestBehavior.AllowGet)); } } else { LogHelper.Log.Error("document not found"); return(Json("document not found", JsonRequestBehavior.AllowGet)); } } LogHelper.Log.Error("id is null"); return(Json("id is null", JsonRequestBehavior.AllowGet)); } catch (Exception ex) { LogHelper.Log.Error("exception in SendRejectRequestConfirm", ex); return(Json("Error", JsonRequestBehavior.AllowGet)); } }
public JsonResult FileReadonly([DataSourceRequest] DataSourceRequest request, string docId) { Document document = db.Documents.FirstOrDefault(o => o.Id == new Guid(docId)); if (document != null) { var files = UploadHelper.GetFilesInfo(document.AttachPath, false); return(Json(files.ToDataSourceResult(request), JsonRequestBehavior.AllowGet)); } return(Json(JsonRequestBehavior.AllowGet)); }
public ActionResult ChangeStatus(Guid id) { Document baseDocument = db.Documents.Find(id); DocumentModel model = new DocumentModel(baseDocument); var setting = db.Settings.First(o => o.UniqueName == "Stage8"); var employe = db.Employees.First(o => o.Id == setting.UserId); model.CustomExecutorsId = DictionaryHelper.GetItems(employe.Id.ToString(), employe.DisplayName); return(PartialView(model)); }
public void GenerateActivity(Document document) { List <Item> items = new List <Item>(); if (document.MainTaskId.HasValue) { LogHelper.Log.DebugFormat("documentid {0} has maintaskId {1}", document.Id, document.MainTaskId); Task task = db.Tasks.Include(o => o.Activity).FirstOrDefault(x => x.Id == document.MainTaskId); if (task != null) { items.Add(new Item { Id = task.Activity.AuthorId, Name = task.Activity.AuthorValue }); LogHelper.Log.DebugFormat("add main activity AuthorId {0}, AuthorValue {1}", task.Activity.AuthorId, task.Activity.AuthorValue); RecycleActivity(task.Activity.ParentId, items); } foreach (var item in items) { LogHelper.Log.DebugFormat("add task AuthorId {0}, AuthorValue {1}", item.Id, item.Name); } Guid?parentId = null; foreach (var item in items) { Activity activity = new Activity { Id = Guid.NewGuid(), // ParentTask = task.Id, DocumentId = document.Id, AuthorId = UserHelper.GetCurrentEmployee().Id.ToString(), AuthorValue = UserHelper.GetCurrentEmployee().DisplayName, ExecutorsId = item.Id, ExecutorsValue = item.Name, //ResponsibleId = DictionaryHelper.GetItemsId(taskAction.ResponsibleId), //ResponsibleValue = DictionaryHelper.GetItemsName(taskAction.ResponsibleId), Type = 3, IsParrent = !parentId.HasValue, CreatedDate = DateTime.Now, ParentId = !parentId.HasValue ? (Guid?)null : parentId.Value, ExecutionDate = document.ExecutionDate, Text = "Согласовать", IsNotActive = true, //IsMainLine = task.IsMainLine }; parentId = activity.Id; db.Activities.Add(activity); } db.SaveChanges(); } else { LogHelper.Log.Debug("documentid not has main task"); GenerateDefaultActivity(document); } }
public ActionResult DocumentExcludeConfirm(Guid id, string text) { Document baseDocument = db.Documents.Find(id); baseDocument.StateType = 9; baseDocument.FactExecutionDate = DateTime.Now; baseDocument.Note = text; db.SaveChanges(); return(Content(bool.TrueString)); }
public static void CreateIncomingDocs(Document document) { ncelsEntities context = UserHelper.GetCn(); List <Item> items = DictionaryHelper.GetItems(document.CorrespondentsId, document.CorrespondentsValue); List <string> listEmail = new List <string>(); if (items.Count > 0) { foreach (var item in items) { Unit unit = context.Units.Find(new Guid(item.Id)); if (unit.Type == 0) { Document doc = context.Documents.FirstOrDefault(x => x.OrganizationId == unit.Id && x.SourceId == document.Id.ToString()); if (doc == null) { Document inDoc = new Document() { Id = Guid.NewGuid(), Summary = document.Summary, OutgoingDate = document.DocumentDate, OutgoingNumber = document.Number, DocumentDate = DateTime.Now, MonitoringType = document.MonitoringType, CorrespondentsId = UserHelper.GetCurrentEmployee().OrganizationId.ToString(), CorrespondentsValue = UserHelper.GetCurrentEmployee().Organization.Name, CorrespondentsInfo = document.SignerValue, ApplicantName = document.CreatedUserValue, ApplicantEmail = UserHelper.GetCurrentEmployee().Organization.Email, ExecutionDate = document.ExecutionDate, DocumentKindDictionaryId = document.DocumentKindDictionaryId, DocumentKindDictionaryValue = document.DocumentKindDictionaryValue, QuestionDesignDictionaryId = document.QuestionDesignDictionaryId, QuestionDesignDictionaryValue = document.QuestionDesignDictionaryValue, Counters = document.Counters, PageCount = document.PageCount, CopiesCount = document.CopiesCount, LanguageDictionaryId = document.LanguageDictionaryId, LanguageDictionaryValue = document.LanguageDictionaryValue, OrganizationId = unit.Id, SourceId = document.Id.ToString(), SourceValue = document.DisplayName, AttachPath = FileHelper.GetObjectPathRoot() }; context.Documents.Add(inDoc); CopyFile(document.AttachPath.ToString(), inDoc.AttachPath.ToString()); } } context.SaveChanges(); } } }
public ActionResult ExtensionExecution(Guid id) { Document document = db.Documents.Find(id); PW.Ncels.Database.DataModel.ExtensionExecution execution = new ExtensionExecution(); execution.Id = Guid.NewGuid(); execution.Date = document.DocumentDate.HasValue ? document.DocumentDate.Value : DateTime.Now; execution.Number = document.Number; execution.DocumentId = document.Id; execution.ExecutionDate = document.ExecutionDate.HasValue ? document.ExecutionDate.Value : DateTime.Now; return(PartialView(execution)); }
public ActionResult SendArchiveConfirm(Guid?id) { if (id != null) { Document d = db.Documents.FirstOrDefault(m => m.Id == id); if (d != null) { d.IsArchive = true; db.SaveChanges(); } } return(Json("Ok!", JsonRequestBehavior.AllowGet)); }
public ActionResult FormBpOut(Guid?id) { Guid guid = id.HasValue ? id.Value : Guid.NewGuid(); Document doc = db.Documents.FirstOrDefault(x => x.Id == guid); if (doc != null && !string.IsNullOrEmpty(doc.SourceId) && Guid.TryParse(doc.SourceId, out guid)) { return(PartialView("FormBpOut", guid)); } return(PartialView("FormBpOut", Guid.Empty)); }
// GET: /IncomingDoc/Edit/5 public ActionResult Edit(Guid?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Document document = db.Documents.Find(id); if (document == null) { return(HttpNotFound()); } return(PartialView("Card", new[] { id.Value })); }
private Document GetRepeatDocument(Document document, Guid repeatId) { Document parentDocument = db.Documents.FirstOrDefault(x => x.Id == repeatId); if (parentDocument != null) { if (parentDocument.RepeaterId != null) { parentDocument = db.Documents.FirstOrDefault(x => x.Id == parentDocument.RepeaterId); } if (parentDocument != null) { document.RepeaterId = parentDocument.Id; document.MonitoringType = parentDocument.MonitoringType; document.MonitoringNote = parentDocument.MonitoringNote; document.ReadersId = parentDocument.ReadersId; document.ReadersValue = parentDocument.ReadersValue; document.RegistratorId = parentDocument.RegistratorId; document.RegistratorValue = parentDocument.RegistratorValue; document.Summary = parentDocument.Summary; document.SignerId = parentDocument.SignerId; document.SignerValue = parentDocument.SignerValue; document.ResponsibleId = parentDocument.ResponsibleId; document.ResponsibleValue = parentDocument.ResponsibleValue; document.AgreementsId = parentDocument.AgreementsId; document.AgreementsValue = parentDocument.AgreementsValue; document.ExecutorsId = parentDocument.ExecutorsId; document.ExecutorsValue = parentDocument.ExecutorsValue; document.AdministrativeTypeDictionaryId = parentDocument.AdministrativeTypeDictionaryId; document.AdministrativeTypeDictionaryValue = parentDocument.AdministrativeTypeDictionaryValue; document.ProtocolDate = parentDocument.ProtocolDate; document.LanguageDictionaryId = parentDocument.LanguageDictionaryId; document.LanguageDictionaryValue = parentDocument.LanguageDictionaryValue; document.Counters = parentDocument.Counters; document.BlankNumber = parentDocument.BlankNumber; document.SigningFormDictionaryId = parentDocument.SigningFormDictionaryId; document.SigningFormDictionaryValue = parentDocument.SigningFormDictionaryValue; document.SourceId = parentDocument.SourceId; document.SourceValue = parentDocument.SourceValue; document.NomenclatureDictionaryId = parentDocument.NomenclatureDictionaryId; document.NomenclatureDictionaryValue = parentDocument.NomenclatureDictionaryValue; document.Deed = parentDocument.Deed; document.Book = parentDocument.Book; document.Akt = parentDocument.Akt; document.ProjectType = parentDocument.ProjectType; } } return(document); }
public ActionResult RegisterOutgoingNumber(Guid?documentId) { Document document = db.Documents.FirstOrDefault(x => x.Id == documentId); if (document == null) { LogHelper.Log.ErrorFormat("Не удалось найти документ по идентификатору {0}", documentId); throw new Exception("Не удалось найти документ"); } ViewBag.Data = new { document.OutgoingNumber }; return(PartialView(document.Id)); }
public static void ConvertInAdminDocument(Document document, Document project, Employee currentEmployee, string singInfo) { ncelsEntities context = UserHelper.GetCn(); Template template = context.Templates.First(o => o.Id == project.TemplateId); document.QrCode = GetQrCode(GetTextQRcode(singInfo, !string.IsNullOrEmpty(project.Digest))); //Template convTemplate = context.Templates.First(o => o.Id == template.ConvertDictionaryTypeId); //document.DocumentDictionaryTypeId = convTemplate.DictionaryTypeId; //document.DocumentDictionaryTypeValue = convTemplate.DictionaryTypeValue; document.MainTaskId = project.MainTaskId; document.MainDocumentId = project.MainDocumentId; document.SourceId = project.Id.ToString(); document.SourceValue = project.DisplayName; document.RegistratorValue = currentEmployee.DisplayName; document.RegistratorId = currentEmployee.Id.ToString(); document.DocumentType = 3; document.TemplateId = context.Templates.First().Id; document.IsDeleted = false; document.DocumentDate = document.CreatedDate = document.ModifiedDate = DateTime.Now; document.ExecutionDate = document.ExecutionDate.HasValue ? document.ExecutionDate : DateTime.Now.AddDays(15); document.IsAttachments = false; document.AttachPath = FileHelper.GetObjectPathRoot(); CopyFile(project.AttachPath.ToString(), document.AttachPath.ToString()); if (document.ProjectType == 4) { document.StateType = 2; Registrator.SetNumber(document); context.Activities.Add(GetNewActivity(document)); ReplaceText(document.AttachPath.ToString(), "Проект.docx", "DocumentNumber", document.Number); ReplaceText(document.AttachPath.ToString(), "Проект.docx", "DocumentDate", document.DocumentDate.Value.ToString("dd.MM.yyyy")); } if (document.ProjectType == 3) { document.Number = null; document.StateType = 0; } if (document.ProjectType == 6) { document.Number = null; document.StateType = 0; } context.Documents.Add(document); context.SaveChanges(); }