public static void RemoveDocument(DocumentDB doc) { using (var db = new UpsilabEntities()) { db.Document.DeleteObject(doc); db.ObjectStateManager.ChangeObjectState(doc, System.Data.EntityState.Deleted); db.SaveChanges(); } }
public static DocumentDB AddDocument(DocumentDB doc) { using (var db = new UpsilabEntities()) { db.Document.AddObject(doc); db.SaveChanges(); return doc; } }
public static void AddDocuments(Guid idSignatureTransaction, List<int> listDocumentCategories, bool generatedFromModel= false) { using (var db = new UpsilabEntities()) { foreach (var docCategory in listDocumentCategories) { var doc = new DocumentDB() { idDocument = Guid.NewGuid(), IdDocumentCategory = docCategory, idSignatureTransaction = idSignatureTransaction, Status = Status.Created.ToString(), PageCount = 0, DocumentType = Upsilab.Business.Document.ElectronicSafeDocumentBL.DocumentType.DOC.ToString(), DateCreated = DateTime.Now }; db.AddToDocument(doc); } db.SaveChanges(); } }
public static DocumentDB UpdateDocument(DocumentDB doc) { using (var db = new UpsilabEntities()) { db.Document.Attach(doc); db.ObjectStateManager.ChangeObjectState(doc, System.Data.EntityState.Modified); db.SaveChanges(); return doc; } }
public static DocumentDB AddOrUpdateDocument(DocumentDB doc) { using (var db = new UpsilabEntities()) { var dc = db.Document.FirstOrDefault( x => x.idSignatureTransaction == doc.idSignatureTransaction && x.DocumentType == doc.DocumentType); if (dc == null) { db.Document.AddObject(doc); db.SaveChanges(); } else { dc.Name = doc.Name; dc.Location = doc.Location; dc.PageCount = doc.PageCount; dc.Comment = doc.Comment; dc.IdDocumentCategory = doc.IdDocumentCategory; dc.GeneratedFromModel = doc.GeneratedFromModel; dc.DateExpiration = doc.DateExpiration; } db.SaveChanges(); return doc; } }
public static void AddDocuments(Guid idSignatureTransaction, List<string> listDocumentTypes, UpsilabEntities context, bool generatedFromModel = true) { //Get documentModel var firmSDG = Upsilab.Business.Sdg.DocumentModelBL.GetFirmSDG(); List<DocumentModel> documentModels = Upsilab.Business.Sdg.DocumentModelBL.GetDocumentModelsByTypes(firmSDG.idFirmInstitution, listDocumentTypes); foreach (var docType in listDocumentTypes) { var doc = new DocumentDB() { idDocument = Guid.NewGuid(), IdDocumentModel = documentModels.FirstOrDefault(x => x.DocumentType.ToLower() == docType.ToLower()).IdDocumentModel, DocumentType = docType, GeneratedFromModel = generatedFromModel, idSignatureTransaction = idSignatureTransaction, Status = Status.Created.ToString(), PageCount = 0, DateCreated = DateTime.Now, Name = string.Empty, Location = string.Empty, }; context.AddToDocument(doc); } context.SaveChanges(); }
public ActionResult DocFileUpload(Document pDoc, HttpPostedFileBase uploadFile) { var error = string.Empty; try { Upload(pDoc.idDocument, uploadFile); //var currentCGP = GetFirmCGP(); //Document objDoc = DocumentBL.GetDocumentById(pDoc.idDocument); //objDoc.DateExpiration = pDoc.DateExpiration; //if (uploadFile!=null && uploadFile.ContentLength > 0) //{ // var relativePath = string.Empty; // var fullPath = ElectronicSafeDocumentBL.BuildSignatureDocumentPath(currentCGP.FirmInstitutionName, currentCGP.idFirmInstitution, ElectronicSafeDocumentBL.DocumentType.DOC, true, out relativePath); // var fileName = ElectronicSafeDocumentBL.BuildDocumentName(objDoc.Label, objDoc.idSignatureTransaction, uploadFile.FileName); // var filePath = Path.Combine(fullPath, fileName); // // 1- Sauvegarde dans le repertoire // uploadFile.SaveAs(filePath); // // 2- Mise à jour du document en base // objDoc.Location = relativePath; // objDoc.Name = fileName; //} //DocumentBL.UpdateDocument(objDoc); } catch (Exception ex) { Business.Log.Log.AppendException(ex); error = ex.Message; } var controllername = (TempData["CONTROLLER"] != null) ? TempData["CONTROLLER"].ToString() : string.Empty; if (controllername.Equals("SignConvention")) { TempData.Remove("CONTROLLER"); return RedirectToAction("Documents", "SignConvention", new { type = "DOC" }); } return Redirect("Index"); }
public static Guid InsererDocument(Guid idTransaction, ElectronicSafeDocumentBL.DocumentType documentType, string name, string location, string designation, int pageCount = 0, DocumentBL.Status status = DocumentBL.Status.Created) { Guid id = Guid.NewGuid(); var doc = new Upsilab.Data.Model.Document { idDocument = id, DateCreated = DateTime.Now, DocumentType = documentType.ToString().ToUpper().Trim(), Name = name, Location = location, Designation = designation, idSignatureTransaction = idTransaction, PageCount = pageCount, Status = status.ToString() }; if (documentType == ElectronicSafeDocumentBL.DocumentType.AVENANT) { doc.Status = DocumentBL.Status.InProgress.ToString(); } DocumentBL.AddDocument(doc); return id; }
public ActionResult SaveDossier(Guid produitId) { var productModel = ProductBL.GetProductById(produitId); var sfViewModel = new Upsilab.Web.ExtranetUser.Models.Provider.SubscriptionFileViewModel(); sfViewModel.IdProduct = produitId; sfViewModel.IdUserCreator = SessionManager.GetUserSession().idUser; try { var transactionId = Guid.NewGuid(); #region "Création transaction" var transactionModel = new SignatureTransactionModel() { IdSignatureTransaction = transactionId, IdUser = SessionManager.GetUserSession().idUser, DateCreated = DateTime.Now, Status = SignatureTransactionBL.Status.InProgress.ToString(), DateSignatureObjetList = new List<DateSignatureObjet>() { new DateSignatureObjet(){ Role = SignatoryBL.Roles.CGP.ToString()} } }; SignatureTransactionBL.InsertSignatureTransaction(transactionModel.ToEntity()); #endregion #region "Création subcriptionFile" sfViewModel.IdTransactionSignatory = transactionId; int subscriptionFileId = FrDossierBL.AddSubscriptionFile(sfViewModel.ToEntity()); #endregion #region "Création document" if (subscriptionFileId > 0) { sfViewModel.DossierNumber = subscriptionFileId.ToString(); } var docId = Guid.NewGuid(); var doc = new Document() { idDocument = docId, idSignatureTransaction = transactionId, IdDocumentModel = productModel.IdDocumentModel, DocumentType = Upsilab.Business.Document.ElectronicSafeDocumentBL.DocumentType.SF.ToString(), Name = string.Format("Bulletin de souscription pour le dossier n°{0}", sfViewModel.DossierNumber), DateCreated = DateTime.Now, Status = DocumentBL.Status.InProgress.ToString(), }; DocumentBL.AddDocument(doc); #endregion #region "Ajouter dans la session" if (subscriptionFileId > 0) { var dossierViewModel = new DossierViewModel() { IdSubscriptionFile = subscriptionFileId, IdDocument = docId, IdProduit = produitId }; SessionManager.Set(KEY_DOSSIER, dossierViewModel); } #endregion return RedirectToAction("Open"); } catch (Exception ex) { Log.AppendException(ex); } return RedirectToAction("Index"); }
public string UploadRecueilFileAssociated() { try { HttpPostedFileBase uploadedFile = Request.Files[0]; int idSubsription = 0; int.TryParse(Request.Form[0].ToString(), out idSubsription); if (idSubsription > 0) { /* Recherche id Transaction */ SignatureTransaction st = FrDossierBL.GetSignatureTransaction(idSubsription); if (st != null && uploadedFile!=null && uploadedFile.ContentLength > 0) { /* save file */ var documentRelativePath = string.Empty; var ext = Path.GetExtension(uploadedFile.FileName); var documentFullPath = ElectronicSafeDocumentBL.BuildSubscriptionFileDocumentsPath(idSubsription, true, out documentRelativePath); var filename = ElectronicSafeDocumentBL.BuildDocumentNameWithExtension(ElectronicSafeDocumentBL.DocumentType.RC.ToString(), idSubsription.ToString("D8"),ext); // 1- Sauvegarde dans le repertoire string filePath = System.IO.Path.Combine(documentFullPath, filename); uploadedFile.SaveAs(filePath); /* save doc */ var doc = new Upsilab.Data.Model.Document() { idDocument = Guid.NewGuid(), idSignatureTransaction = st.idSignatureTransaction, DocumentType = ElectronicSafeDocumentBL.DocumentType.RC.ToString(), Name = filename, Location = documentRelativePath, PageCount = 0, DateCreated = DateTime.Now, Status = DocumentBL.Status.Created.ToString(), Comment = null, IdDocumentCategory = null, GeneratedFromModel = false, DateExpiration = null }; // Update doc if subsfile id exist DocumentBL.AddOrUpdateDocument(doc); } return "OK"; } } catch (Exception ex) { Log.AppendException(ex); } return "KO"; }
public ActionResult UploadDocumentFile(SignatureTransaction _signatureTrans, HttpPostedFileBase uploadFile) { var LanguageData = PageLanguageHelper.GetLanguageContent("User", "PDFSignature"); DocumentType docType = DocumentTypeBL.GetDocumentTypeByCode(ElectronicSafeDocumentBL.DocumentType.SIGN.ToString()); string error = string.Empty; Upsilab.Data.Model.User currentUser = SessionManager.GetUserSession(); try { if (uploadFile != null) { if (uploadFile.ContentLength > 0 && FileManager.IsPDF(uploadFile.ContentType)) { string documentPath = string.Empty; documentPath = ElectronicSafeDocumentBL.BuildUserDocumentPath(docType.DocumentNamePrefix, currentUser); if (!Directory.Exists(Server.MapPath("~/uploads"))) Directory.CreateDirectory(Server.MapPath("~/uploads")); string documentFullPath = Path.Combine(Server.MapPath("~/uploads"), documentPath); if (!Directory.Exists(documentFullPath)) Directory.CreateDirectory(documentFullPath); string filename = ElectronicSafeDocumentBL.BuildDocumentName(docType.DocumentNamePrefix, currentUser.idUser, uploadFile.FileName); // 1- Sauvegarde dans le repertoire string filePath = System.IO.Path.Combine(documentFullPath, filename); uploadFile.SaveAs(filePath); // 2 - Sauvegarde dans la table Document PdfReader pdfReader = new PdfReader(filePath); int numberOfPages = pdfReader.NumberOfPages; Document newDoc = new Document(); newDoc.idDocument = GuidHelper.GenerateGuid(); newDoc.DocumentType = docType.ToString().ToUpper(); newDoc.idSignatureTransaction = _signatureTrans.idSignatureTransaction; newDoc.Name = filename; newDoc.Location = documentPath; newDoc.PageCount = numberOfPages; newDoc.DateCreated = DateTime.Now; SignatureTransactionBL.InsertDocument(newDoc); } else { ViewBag.DocumentError = ViewBag.DocumentError + LanguageData.GetContent("fichier_pdf_requis"); } } else { ViewBag.DocumentError = ViewBag.DocumentError + LanguageData.GetContent("please_add_file"); } } catch (Exception ex) { Business.Log.Log.AppendException(ex); ViewBag.DocumentError = ViewBag.DocumentError + ex.Message; } return RedirectToAction("Transaction"); }