/// <summary> /// /// </summary> /// <param name="user"></param> /// <param name="dtpData"></param> /// <returns></returns> private static DTPData SignBySecondUser(Upsilab.Data.Model.User user, DTPData dtpData) { //User infos dtpData = GetUserInfos(user, dtpData); if (string.IsNullOrEmpty(dtpData.TransactionId)) { //throw new Exception(SignatureExceptionCode.TransactionIdMissing.ToString()); throw new Exception("La transaction de cette signature est expirée."); } //#1 : Continue transaction DTPClient dtpClient = new DTPClient(dtpData.TransactionId); //Check if all users have signed the transaction if (dtpClient.IsTransactionSignedByAll()) //if (true) { dtpData.IHM_Url = dtpData.BackUrl.Replace("%3F", "?").Replace("%3D", "=").Replace("%7B", "{").Replace("%7D", "}").Replace("%26", "&") .Replace("{STATUS}", ALREADY_SIGNED).Replace("{LOGIN}", dtpData.Login).Replace("{OFFER}", dtpData.OfferId); //Exec back url; } else { //#2 : Create access user for second user dtpData.UserAccessId = dtpClient.CreateUserAccess(string.Empty, user.UserName, user.UserFirstName, user.UserMobilePhone, dtpData.BackUrl); //#3 : create user space dtpClient.CreateUserSpace(dtpData); //#4 : create user space content dtpClient.CreateUserSpaceContent(dtpData); //#4' : Send OTP by sms to user //dtpClient.SendOtp(accessId); TODO //#5 : IHM_url dtpData.IHM_Url = dtpClient.BuildUserInterfaceUrl(dtpData); } return dtpData; }
/// <summary> /// /// </summary> /// <param name="user"></param> /// <param name="dtpData"></param> /// <returns></returns> private static DTPData SignByFirstUser(Upsilab.Data.Model.User user, DTPData dtpData) { //User infos dtpData = GetUserInfos(user, dtpData); DTPClient dtpClient = new DTPClient(); //If idDictao has value, cancel this transaction and create a new one if (!string.IsNullOrEmpty(dtpData.TransactionId)) { dtpClient.TransactionId = dtpData.TransactionId; try { dtpClient.CancelTransaction(); } catch { } } //#1 : Init transaction dtpClient.InitTransaction(dtpData.BusinessId); //#2 : Provide document dtpClient.ProvideDocuments(dtpData.DocumentsToSign); //#3 : create access user //TODO : where to put ? //string termAndConditionsFileName = "termsAndConditions_fr.pdf"; //string termAndConditionsFileName = "convention_preuve.pdf"; //string termAndConditionsUrl = string.Format("{0}/Client/Documents/{1}", Upsilab.Business.Utility.UrlHelper.GetHost(), termAndConditionsFileName); dtpData.UserAccessId = dtpClient.CreateUserAccess(string.Empty, user.UserName, user.UserFirstName, user.UserMobilePhone, dtpData.BackUrl); //#4 : create user space dtpClient.CreateUserSpace(dtpData); //#5 : create user space content dtpClient.CreateUserSpaceContent(dtpData); //#5' : send OTP by sms to user //dtpClient.SendOtp(accessId); TODO //#6 : build urlIhm dtpData.IHM_Url = dtpClient.BuildUserInterfaceUrl(dtpData); dtpData.TransactionId = dtpClient.TransactionId; return dtpData; }