public ActionResult EnvoyerEngagementAuClient(string id) { string error = string.Empty; bool isCustomer = true; try { // Id Customer = id in parameter if (string.IsNullOrEmpty(id)) { error = _languageData.GetContent("client_identité_non_reconnue"); } else { using (UpsilabEntities context = new UpsilabEntities()) { Guid idCustomer = Guid.Parse(id); Upsilab.Data.Model.CustomerProspect customer = (from cust in context.CustomerProspect.Include("ConfidentialityAgreement").Include("ConfidentialityAgreement.User").Include("User").Include("User1").Include("FirmInstitution") where cust.idCustomer == idCustomer select cust).FirstOrDefault(); if (customer == null) { error = _languageData.GetContent("client_identité_non_reconnue"); } else { isCustomer = customer.IsCustomer; //TODO : Create pdf to sign string docType = ElectronicSafeDocumentBL.DocumentType.EC.ToString(); string userPath = ElectronicSafeDocumentBL.BuildClientDocumentPath(docType, customer, true); string destFullPath = ElectronicSafeDocumentBL.BuildClientUploadDocumentPath(docType, customer); string filename = ElectronicSafeDocumentBL.BuildDocumentName(docType, customer.idCustomer, false); string filePath = System.IO.Path.Combine(destFullPath, filename); if (!System.IO.File.Exists(filePath)) { EngagementPdfGenerationBL.GeneratePDF(customer, customer.FirmInstitution, filePath, false); } if (System.IO.File.Exists(filePath)) { SignatureDocumentBL.SendAgreementMailToClient(customer, true); //Update date send email (invite client to sign EC) Upsilab.Data.Model.ConfidentialityAgreement confident = customer.ConfidentialityAgreement; if (confident == null) { confident = new ConfidentialityAgreement() { idConfidentialityAgreement = Upsilab.Business.Utility.GuidHelper.GenerateGuid(), Status = Upsilab.Business.Report.ReportBL.Status.InProgress.ToString(), DateCreated = DateTime.Now, SignedByCustomer = false, SignedByAdviser = false, Archived = false }; context.ConfidentialityAgreement.Attach(confident); context.ObjectStateManager.ChangeObjectState(confident, System.Data.EntityState.Added); customer.idConfidentialityAgreement = confident.idConfidentialityAgreement; } //Dates in DB are separeted by ";" List<string> lstDates = new List<string>(); if (!string.IsNullOrEmpty(confident.DatesSendMailToCustomer)) { lstDates = confident.DatesSendMailToCustomer.Split(new char[] {';'}).ToList(); } lstDates.Insert(0, DateTime.Now.ToString("dd/MM/yyyy")); string remindDates = string.Join(";", lstDates.ToArray()); confident.DatesSendMailToCustomer = remindDates; //Save context.SaveChanges(); } else { error = _languageData.GetContent("fic_engagement_de_conf_n_existe_pas"); } } }//End using } } catch (Exception ex) { //Log error = ex.Message; Upsilab.Business.Log.Log.AppendException(ex); } //TODO : popup ok string message = (!string.IsNullOrEmpty(error)) ? error : _languageData.GetContent("email_invitant_a_signer_engagement_conf_envoyé"); SessionManager.Set<string>("EC_RETOUR_ENVOI_ENGAGEMENT", message); //Clear session in engagement - index return RedirectToAction("Index", "EngagementConfidentialite", new { _isCustomer = isCustomer }); }
public bool EnvoyerEngagementAuClient(Guid id) { string error = string.Empty; using (UpsilabEntities context = new UpsilabEntities()) { Guid idCustomer = id; Upsilab.Data.Model.CustomerProspect customer = (from cust in context.CustomerProspect.Include("ConfidentialityAgreement").Include("ConfidentialityAgreement.User").Include("User").Include("User1").Include("FirmInstitution") where cust.idCustomer == idCustomer select cust).FirstOrDefault(); if (customer == null) { return false; } else { string docType = ElectronicSafeDocumentBL.DocumentType.EC.ToString(); string userPath = ElectronicSafeDocumentBL.BuildClientDocumentPath(docType, customer, true); string destFullPath = ElectronicSafeDocumentBL.BuildClientUploadDocumentPath(docType, customer); string filename = ElectronicSafeDocumentBL.BuildDocumentName(docType, customer.idCustomer, false); string filePath = System.IO.Path.Combine(destFullPath, filename); if (!System.IO.File.Exists(filePath)) { EngagementPdfGenerationBL.GeneratePDF(customer, customer.FirmInstitution, filePath, false); } if (System.IO.File.Exists(filePath)) { SignatureDocumentBL.SendAgreementMailToClient(customer, true); //Update date send email (invite client to sign EC) Upsilab.Data.Model.ConfidentialityAgreement confident = customer.ConfidentialityAgreement; if (confident == null) { confident = new ConfidentialityAgreement() { idConfidentialityAgreement = Upsilab.Business.Utility.GuidHelper.GenerateGuid(), Status = Upsilab.Business.Report.ReportBL.Status.InProgress.ToString(), DateCreated = DateTime.Now, SignedByCustomer = false, SignedByAdviser = false, Archived = false }; context.ConfidentialityAgreement.Attach(confident); context.ObjectStateManager.ChangeObjectState(confident, System.Data.EntityState.Added); customer.idConfidentialityAgreement = confident.idConfidentialityAgreement; } //Dates in DB are separeted by ";" List<string> lstDates = new List<string>(); if (!string.IsNullOrEmpty(confident.DatesSendMailToCustomer)) { lstDates = confident.DatesSendMailToCustomer.Split(new char[] { ';' }).ToList(); } lstDates.Insert(0, DateTime.Now.ToString("dd/MM/yyyy")); string remindDates = string.Join(";", lstDates.ToArray()); confident.DatesSendMailToCustomer = remindDates; //Save context.SaveChanges(); } else { return false; } } return true; } }
//---------------------------POPULATE RELANCE DATE---------------------------------- public string PopulateDateEC() { string error = string.Empty; try { using (UpsilabEntities context = new UpsilabEntities()) { Guid idCustomer; Guid idUser; //Get IDCustomer from EmailLog var lstEmailLogEC = (from el in context.EmailLog where el.EmailType == "SendAgreementMailToClient" select el).ToList(); foreach (var eLog in lstEmailLogEC) { idUser = eLog.IDRecipient.Value; Upsilab.Data.Model.CustomerProspect customer = (from cust in context.CustomerProspect.Include("ConfidentialityAgreement").Include("User").Include("User1").Include("FirmInstitution") where cust.User.idUser == idUser select cust).FirstOrDefault(); if (customer == null) { error += LanguageData.GetContent("client_identité_non_reconnue"); } else { idCustomer = customer.idCustomer; //Update date send email (invite client to sign EC) Upsilab.Data.Model.ConfidentialityAgreement confident = customer.ConfidentialityAgreement; if (confident == null) { confident = new ConfidentialityAgreement() { idConfidentialityAgreement = Upsilab.Business.Utility.GuidHelper.GenerateGuid(), Status = Upsilab.Business.Report.ReportBL.Status.InProgress.ToString(), DateCreated = DateTime.Now, SignedByCustomer = false, SignedByAdviser = false, Archived = false }; context.ConfidentialityAgreement.Attach(confident); context.ObjectStateManager.ChangeObjectState(confident, System.Data.EntityState.Added); customer.idConfidentialityAgreement = confident.idConfidentialityAgreement; } if (string.IsNullOrEmpty(confident.DatesSendMailToCustomer)) { confident.DatesSendMailToCustomer = eLog.DateCreated.ToString("dd/MM/yyyy"); } //Save context.SaveChanges(); } } }//End using } catch (Exception ex) { //Log error = ex.Message; Upsilab.Business.Log.Log.AppendException(ex); } if (!string.IsNullOrEmpty(error)) { return error; } else { return "OK"; } }
public ActionResult DocFileUpload(ElectronicSafeDocument objESDoc, HttpPostedFileBase uploadFile) { DocumentType objDoctype = DocumentTypeBL.GetDocumentTypeById(objESDoc.idDocumentType); string error = string.Empty; bool isCustomer = true; try { if (objESDoc.idCustomer.HasValue) { CustomerProspect customer = CustomerProspectBL.GetCustomerProspectById(objESDoc.idCustomer.Value); isCustomer = customer.IsCustomer; if (uploadFile.ContentLength > 0) { string documentPath = ElectronicSafeDocumentBL.BuildClientDocumentPath(ElectronicSafeDocumentBL.DocumentType.EC.ToString(), customer); string documentFullPath = System.IO.Path.Combine(ConfigurationManager.CoffreFortRootPath, documentPath); string sFilename = ElectronicSafeDocumentBL.BuildDocumentName(objDoctype.DocumentNamePrefix, customer.idCustomer, uploadFile.FileName); // 1- Sauvegarde dans le repertoire string filePath = System.IO.Path.Combine(documentFullPath, sFilename); uploadFile.SaveAs(filePath); // 2- Upload file to DICTAO server D3SClient clientD3S = new D3SClient(); string dictaoId = ElectronicSafeDocumentBL.SendToDictaoCoffreFort(documentFullPath, sFilename, clientD3S); // 3- Gestion Crédit : soustraire des points au creditCount de la firme pour avoir fait une operation ayant le creditCode "MISE_AU_COFFRE_MANUELLE_ENGAGEMENT_CONFIDENTIALITE" if (!string.IsNullOrEmpty(dictaoId)) { //var firmInstitution = SessionManager.GetFirmInstitutionSession(); //Guid idFirmInstitution = (firmInstitution != null) ? firmInstitution.idFirmInstitution : customer.idFirmInstitution; CreditOperationBL.SubstractCredit(customer.idFirmInstitution, CreditOperationBL.OperationType.MISE_AU_COFFRE_MANUELLE_ENGAGEMENT_CONFIDENTIALITE.ToString(), customer.idUserCreated, customer.idCustomer); // 4- Sauvegarde dans la base (table ElectronicSafeDocument) ElectronicSafeDocumentBL.SaveDocumentToDB(sFilename, ElectronicSafeDocumentBL.DocumentType.EC.ToString(), objESDoc.DocumentLabel, documentPath, customer.idCustomer, dictaoId, clientD3S); // 5- Sauvegarde dans la base (table ConfidentialityAgreement) string dateSignatureConseiller = Request.Form["DateSignatureConseiller"]; string dateSignatureClient = Request.Form["DateSignatureClient"]; DateTime dDateSignatureConseiller = new DateTime(); DateTime dDateSignatureClient = new DateTime(); if (!string.IsNullOrEmpty(dateSignatureConseiller)) DateTime.TryParse(dateSignatureConseiller, out dDateSignatureConseiller); if (!string.IsNullOrEmpty(dateSignatureClient)) DateTime.TryParse(dateSignatureClient, out dDateSignatureClient); ConfidentialityAgreement objConfAgr = new ConfidentialityAgreement() { idConfidentialityAgreement = GuidHelper.GenerateGuid(), Status = Upsilab.Business.Report.ReportBL.Status.Completed.ToString(), DateCreated = DateTime.Now, //DateUpdated = , idDictao = dictaoId, SignedByCustomer = true, DateCustomerSignature = dDateSignatureClient, SignedByAdviser = true, DateAdviserSignature = dDateSignatureConseiller, Archived = true, }; db.ConfidentialityAgreement.Attach(objConfAgr); db.ObjectStateManager.ChangeObjectState(objConfAgr, System.Data.EntityState.Added); db.SaveChanges(); customer.idConfidentialityAgreement = objConfAgr.idConfidentialityAgreement; CustomerProspectBL.Update(customer); } else { error = LanguageData.GetContent("EngagementConfid_doc_impossible_a_envoyer_au_cfe"); } } } } catch (Exception ex) { Log.AppendException(ex); error = ex.Message; } //---- if (!string.IsNullOrEmpty(error)) { SessionManager.Set<string>(ERROR_UPLOAD_SESSION, error); // Remove session value in "index" } return RedirectToAction("Index", "EngagementConfidentialite", new { _isCustomer = isCustomer }); //---- }