コード例 #1
0
ファイル: Document.cs プロジェクト: janstadt/esl.sdk.net
     public Document AddApproval(Approval value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("Argument cannot be null");
     }
     
     _approvals.Add(value);
     return this;
 }
コード例 #2
0
        public void ModifyApproval(PackageId packageId, string documentId, Approval approval)
        {
            string path = template.UrlFor(UrlTemplate.APPROVAL_ID_PATH)
                .Replace("{packageId}", packageId.Id)
                    .Replace("{documentId}", documentId)
                    .Replace("{approvalId}", approval.Id)
                    .Build();

            try {
                string json = JsonConvert.SerializeObject (approval, jsonSettings);
                restClient.Put(path, json);
            }
            catch (EslServerException e) {
                throw new EslServerException("Could not modify signature.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Could not modify signature.\t" + " Exception: " + e.Message, e);
            }
        }
コード例 #3
0
        public string AddApproval(PackageId packageId, string documentId, Approval approval)
        {
            string path = template.UrlFor(UrlTemplate.APPROVAL_PATH)
                          .Replace("{packageId}", packageId.Id)
                          .Replace("{documentId}", documentId)
                          .Build();

            try {
                string json     = JsonConvert.SerializeObject(approval, jsonSettings);
                string response = restClient.Post(path, json);
                Silanis.ESL.API.Approval apiApproval = JsonConvert.DeserializeObject <Silanis.ESL.API.Approval> (response, jsonSettings);
                return(apiApproval.Id);
            }
            catch (EslServerException e) {
                throw new EslServerException("Could not add signature.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Could not add signature.\t" + " Exception: " + e.Message, e);
            }
        }
コード例 #4
0
        public string AddApproval(PackageId packageId, string documentId, Approval approval)
        {
            string path = template.UrlFor(UrlTemplate.APPROVAL_PATH)
                .Replace("{packageId}", packageId.Id)
                    .Replace("{documentId}", documentId)
                    .Build();

            try {
                string json = JsonConvert.SerializeObject (approval, jsonSettings);
                string response = restClient.Post(path, json);
                Silanis.ESL.API.Approval apiApproval = JsonConvert.DeserializeObject<Silanis.ESL.API.Approval> (response, jsonSettings);
                return apiApproval.Id;
            }
            catch (EslServerException e) {
                throw new EslServerException("Could not add signature.\t" + " Exception: " + e.Message, e.ServerError, e);
            }
            catch (Exception e) {
                throw new EslException("Could not add signature.\t" + " Exception: " + e.Message, e);
            }
        }
コード例 #5
0
        internal static SignatureBuilder NewSignatureFromAPIApproval(Silanis.ESL.API.Approval apiApproval, Silanis.ESL.API.Package package)
        {
            SignatureBuilder signatureBuilder = null;

            Silanis.ESL.API.Signer apiSigner = null;
            foreach (Silanis.ESL.API.Role role in package.Roles)
            {
                if (role.Id.Equals(apiApproval.Role))
                {
                    if (!isPlaceHolder(role))
                    {
                        apiSigner = role.Signers [0];
                    }
                }
            }
            if (apiSigner != null)
            {
                if (apiSigner.Group == null)
                {
                    signatureBuilder = new SignatureBuilder(apiSigner.Email);
                }
                else
                {
                    signatureBuilder = new SignatureBuilder(new GroupId(apiSigner.Group.Id));
                }
            }
            else
            {
                signatureBuilder = new SignatureBuilder("");
            }
            signatureBuilder.WithName(apiApproval.Name);

            Silanis.ESL.API.Field apiSignatureField = null;
            foreach (Silanis.ESL.API.Field apiField in apiApproval.Fields)
            {
                if (apiField.Type == Silanis.ESL.API.FieldType.SIGNATURE)
                {
                    apiSignatureField = apiField;
                }
                else
                {
                    FieldBuilder fieldBuilder = FieldBuilder.NewFieldFromAPIField(apiField);
                    signatureBuilder.WithField(fieldBuilder);
                }
            }

            if (apiSignatureField == null)
            {
                signatureBuilder.WithStyle(SignatureStyle.ACCEPTANCE);
                signatureBuilder.WithSize(0, 0);
            }
            else
            {
                signatureBuilder.WithStyle(FromAPIFieldSubType(apiSignatureField.Subtype))
                .OnPage(apiSignatureField.Page)
                .AtPosition(apiSignatureField.Left, apiSignatureField.Top)
                .WithSize(apiSignatureField.Width, apiSignatureField.Height);

                if (apiSignatureField.Extract)
                {
                    signatureBuilder.EnableExtraction();
                }
            }

            return(signatureBuilder);
        }