public static void Create(ConvRTO convention) { using (var context = new UpsilabEntities()) { context.ConventionRTO.Attach(convention); context.ObjectStateManager.ChangeObjectState(convention, EntityState.Added); context.SaveChanges(); } }
/// <summary> /// Create a CRTO and update customerProspect idCRTO (from an existing LM/RM) /// </summary> /// <param name="missionDocument">LM ou RM having attached CRTO</param> /// <returns>Created CRTO</returns> public static ConvRTO CreateCRTOFromMissionDocument(MissionDocument missionDocument) { try { using (var context = new UpsilabEntities()) { if (missionDocument != null && missionDocument.AttachConventionRTO.HasValue && missionDocument.AttachConventionRTO.Value) { //Création d'un enregistrement dans la table ConventionRTO ConvRTO convention = new ConvRTO() { idConventionRTO = Guid.NewGuid(), IdCustomerProspect = missionDocument.idCustomerProspect, idDictao = missionDocument.idDictao, idDTPUserAccess = missionDocument.idDTPUserAccess, idSignatoryUser = missionDocument.idSignatoryUser, SignedByAdviser = missionDocument.SignedByAdviser, SignedByCustomer = missionDocument.SignedByCustomer, Status = missionDocument.Status, Archived = missionDocument.Archived, DateAdviserSignature = missionDocument.DateAdviserSignature, DateCreated = missionDocument.DateCreated, DateSignatureCustomer = missionDocument.DateCustomerSignature, DatesSendMailToCustomer = missionDocument.DatesSendMailToCustomer, DateUpdated = missionDocument.DateUpdated, }; Upsilab.Business.ConventionRTO.ConventionRTOBL.Create(convention); return convention; } } } catch (Exception ex) { Log.Log.AppendException(ex); } return null; }
/// <summary> /// /// </summary> /// <param name="idReport"></param> /// <returns>The url to access the signature page</returns> public static string SignCRTOByAdviser(Guid idCustomer, string docToSignPathFileName, Upsilab.Data.Model.User userAdviser) { using (UpsilabEntities context = new UpsilabEntities()) { var customer = context.CustomerProspect.FirstOrDefault(x => x.idCustomer == idCustomer); //Add new CRTO var crto = new Upsilab.Data.Model.ConventionRTO() { idConventionRTO = Upsilab.Business.Utility.GuidHelper.GenerateGuid(), IdCustomerProspect = idCustomer, Status = ReportBL.Status.InProgress.ToString(), SignedByCustomer = false, SignedByAdviser = false, Archived = false, DatesSendMailToCustomer = DateTime.Now.ToString("dd/MM/yyyy"), DateCreated = DateTime.Now, DateUpdated = DateTime.Now, }; context.ConventionRTO.Attach(crto); context.ObjectStateManager.ChangeObjectState(crto, System.Data.EntityState.Added); //Update idConvention customer customer.idConventionRTO = crto.idConventionRTO; // Data needed string businessId = string.Format("{0}-{1}", CONVENTION_RTO, idCustomer); string backUrl = string.Format("{0}/User/Signature/RetourSignatureCRTOParConseiller{1}", Upsilab.Business.Utility.UrlHelper.GetHost(), DTPClient.GET_Variables); List<SignatureParameter> signatureParameters = new List<SignatureParameter>(); SignatureParameter signatureParameter = new SignatureParameter() { SignatureFieldLabel = DTPClient.USER_ADVISER, SignaturePosition = new SignaturePosition() { Page = 4, //TODO X = 34, Y = 178, } }; signatureParameters.Add(signatureParameter); signatureParameter = new SignatureParameter() { SignatureFieldLabel = DTPClient.USER_CUSTOMER, SignaturePosition = new SignaturePosition() { Page = 4, //TODO X = 120, Y = 178, } }; signatureParameters.Add(signatureParameter); //Document to sign DocumentToSign doc = new DocumentToSign() { Label = LanguageContentBL.Translate("signature_crto_title"), Description = LanguageContentBL.Translate("signature_crto_title"), PathFilename = docToSignPathFileName, Type = DTPClient.DocumentTypes.CONTRACT.ToString(), SignatureParameters = signatureParameters }; List<DocumentToSign> documentsToSign = new List<DocumentToSign>() { doc }; //DTP Data DTPData dtpData = new DTPData() { TransactionId = crto.idDictao, UserAccessId = crto.idDTPUserAccess, BusinessId = businessId, BackUrl = backUrl, DocumentsToSign = documentsToSign, SignatureFieldLabels = new List<string> { DTPClient.USER_ADVISER }, UserSpaceTitle = LanguageContentBL.Translate("signature_crto_sign_title"), Language = SessionManager.GetCurrentLanguage().LanguageTypeName, }; //Sign document : adviser always sign first dtpData = SignatureDocumentBL.SignByFirstUser(userAdviser, dtpData); //Save transaction Id to table crto.idDictao = dtpData.TransactionId; crto.idDTPUserAccess = dtpData.UserAccessId; context.SaveChanges(); return dtpData.IHM_Url; } }