Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/257.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在基于模板的文档签名信封上添加签名者_C#_Docusignapi - Fatal编程技术网

C# 在基于模板的文档签名信封上添加签名者

C# 在基于模板的文档签名信封上添加签名者,c#,docusignapi,C#,Docusignapi,我已经创建了一个模板,并添加了两个角色签名者1和签名者2。我正在使用此模板动态创建信封和添加签名者。工作正常。在某些情况下,管理员用户不知道第二个签名者,只添加第一个签名者,并且使用单个签名者创建信封。创建信封后,现在我想在信封上添加第二个签名人。我正在使用C#docusign客户端,我尝试了 { var templateInfo = await envelopesApi.ListTemplatesAsync(await AccountAsync(

我已经创建了一个模板,并添加了两个角色签名者1和签名者2。我正在使用此模板动态创建信封和添加签名者。工作正常。在某些情况下,管理员用户不知道第二个签名者,只添加第一个签名者,并且使用单个签名者创建信封。创建信封后,现在我想在信封上添加第二个签名人。我正在使用C#docusign客户端,我尝试了

  {                 
     var templateInfo = await envelopesApi.ListTemplatesAsync(await AccountAsync(), envelopeId, new EnvelopesApi.ListTemplatesOptions { include = "applied" }); //fetching template id
                foreach (var template in templateInfo.Templates)
                {
                    var templateRecipients = await templatesApi.ListRecipientsAsync(await AccountAsync(), template.TemplateId, new ListRecipientsOptions { includeTabs = "true" }); //fetching tabs assigned to roles in templatea
                Var signer=  templateRecipients.Signers.FirstOrDefault(w => w.RoleName.ToLower() == signer.SigningRole.ToLower())
                    Recipients.Signers = signers.Aggregate(new List<Signer>(), (newSigners, signer) =>
                    {
                        string recipeintId = Guid.NewGuid().ToString();
                        Tabs tabs = templateSigner.Tabs;
                        Tabs newTabs = new Tabs();
                        var newSigner = new Signer
                        {
                            Email = signer.Email,
                            Name = signer.FullName,
                            RoleName = signer.SigningRole,
                            //ClientUserId = signer.Email,
                            RecipientId = recipeintId, //Int or Guid expected
                            Tabs =BuildRecipientTabs(recipeintId,signer?.Tabs) ; //copying tabs
                        };
                        newSigners.Add(newSigner);
                        return newSigners;
                    });


    var something = await envelopesApi.UpdateRecipientsAsync( AccountId, envelopeId, recipients);
}
//
         private Tabs BuildRecipientTabs(string recipientId, Tabs tabs)
        {
            Tabs newTab = new Tabs();
            if (tabs.ApproveTabs != null)
            {
                tabs.ApproveTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.CheckboxTabs != null)
            {
                tabs.CheckboxTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.DateTabs != null)
            {
                tabs.DateTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.DateSignedTabs != null)
            {
                tabs.DateSignedTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.DeclineTabs != null)
            {
                tabs.DeclineTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.EmailAddressTabs != null)
            {
                tabs.EmailAddressTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.EmailTabs != null)
            {
                tabs.EmailTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.EnvelopeIdTabs != null)
            {
                tabs.EnvelopeIdTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.FullNameTabs != null)
            {
                tabs.FullNameTabs.ForEach(w => { if (w!=null) { w.RecipientId = recipientId;}});             
            }
            if (tabs.FirstNameTabs != null)
            {
                tabs.FirstNameTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.FormulaTabs != null)
            {
                tabs.FormulaTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.InitialHereTabs != null)
            {
                tabs.InitialHereTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }           
            if (tabs.LastNameTabs != null)
            {
                tabs.LastNameTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.ListTabs != null)
            {
                tabs.ListTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.NotarizeTabs != null)
            {
                tabs.NotarizeTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.NoteTabs != null)
            {
                tabs.NoteTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.NumberTabs != null)
            {
                tabs.NumberTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.PolyLineOverlayTabs != null)
            {
                tabs.PolyLineOverlayTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }           
            if (tabs.RadioGroupTabs != null)
            {
                tabs.RadioGroupTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.SignerAttachmentTabs != null)
            {
                tabs.SignerAttachmentTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.SignHereTabs != null)
            {
                tabs.SignHereTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; w.TabId = null; } });
            }
            if (tabs.SmartSectionTabs != null)
            {
                tabs.SmartSectionTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.SsnTabs != null)
            {
                tabs.SsnTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.TitleTabs != null)
            {
                tabs.TitleTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.TextTabs != null)
            {
                tabs.TextTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId;  w.TabId=null; } });

            }
            if (tabs.TabGroups != null)
            {
                tabs.TabGroups.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }          
            if (tabs.ViewTabs != null)
            {
                tabs.ViewTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            if (tabs.ZipTabs != null)
            {
                tabs.ZipTabs.ForEach(w => { if (w != null) { w.RecipientId = recipientId; } });
            }
            return tabs;
        }
{
var templateInfo=await envelopesApi.ListTemplatesAsync(await AccountAsync(),envelopeId,new envelopesApi.ListTemplatesOptions{include=“applicated”});//获取模板id
foreach(templateInfo.Templates中的var模板)
{
var templateRecipients=await templatesApi.ListRecipientsAsync(await AccountAsync(),template.TemplateId,new ListRecipientsOptions{includeTabs=“true”});//获取分配给templatea中角色的选项卡
Var signer=templateRecipients.Signers.FirstOrDefault(w=>w.RoleName.ToLower()==signer.SigningRole.ToLower())
Recipients.Signers=Signers.Aggregate(new List(),(newSigners,signer)=>
{
字符串recipeintId=Guid.NewGuid().ToString();
Tabs=templateSigner.Tabs;
Tabs newTabs=新选项卡();
var newSigner=新签名者
{
Email=signer.Email,
Name=signer.FullName,
RoleName=signer.SigningRole,
//ClientUserId=signer.Email,
RecipientId=RecipientId,//应为Int或Guid
Tabs=BuildRecipientTabs(RecipientId,signer?.Tabs);//复制选项卡
};
newSigner.Add(newSigner);
返回新闻签名者;
});
var something=await envelopesApi.UpdateRecipientsAsync(AccountId、envelopeId、recipients);
}
//
私有选项卡BuildRecipientTabs(字符串recipientId,选项卡)
{
Tabs newTab=新选项卡();
如果(tabs.ApproveTabs!=null)
{
tabs.ApproveTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.CheckboxTabs!=null)
{
tabs.CheckboxTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.DateTabs!=null)
{
tabs.DateTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}}});
}
如果(tabs.DateSignedTabs!=null)
{
tabs.DateSignedTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.DeclineTabs!=null)
{
tabs.DeclineTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.EmailAddressTabs!=null)
{
tabs.EmailAddressTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}}});
}
如果(tabs.EmailTabs!=null)
{
tabs.EmailTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.EnvelopeIdTabs!=null)
{
ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}}});
}
如果(tabs.fullnametab!=null)
{
tabs.fullnametab.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.firstnametab!=null)
{
tabs.firstnametab.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}}});
}
如果(tabs.FormulaTabs!=null)
{
tabs.FormulaTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}}});
}
如果(tabs.InitialHereTabs!=null)
{
tabs.InitialHereTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}           
如果(tabs.lastnametab!=null)
{
tabs.lastname tabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.ListTabs!=null)
{
ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.abs!=null)
{
ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}}});
}
如果(tabs.notetab!=null)
{
ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.NumberTabs!=null)
{
tabs.NumberTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}}});
}
如果(tabs.PolyLineOverlayTabs!=null)
{
tabs.PolyLineOverlayTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}}});
}           
如果(tabs.radiogroup tabs!=null)
{
tabs.radiogroup tabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}});
}
如果(tabs.SignerAttachmentTabs!=null)
{
tabs.SignerAttachmentTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;}}});
}
如果(tabs.SignHereTabs!=null)
{
tabs.SignHereTabs.ForEach(w=>{if(w!=null){w.RecipientId=RecipientId;w.TabId=null;}});
}
如果(tabs.SmartSectionTabs!=null)
{
tabs.SmartSectionTabs.ForEach(w=>
 //build recipients
                recipients.Signers = signers.Aggregate(new List<Signer>(), (newSigners, signer) =>
                {
                    string recipeintId = Guid.NewGuid().ToString();
                    var newSigner = new Signer
                    {
                        Email = signer.Email,
                        Name = signer.FullName,
                        RoleName = signer.SigningRole,
                        ClientUserId = signer.Email,
                        RecipientId = recipeintId //Int or Guid expected                      
                    };
                    newSigners.Add(newSigner);
                    return newSigners;
                });
                var addedRecipient = await envelopesApi.CreateRecipientAsync(await AccountAsync(), envelopeId, recipients); //adding recipients
                var templateInfo = await envelopesApi.ListTemplatesAsync(await AccountAsync(), envelopeId, new EnvelopesApi.ListTemplatesOptions { include = "applied" });

                //envelope is created using one template only
                    var templateRecipients = await templatesApi.ListRecipientsAsync(await AccountAsync(), templateInfo.Templates.FirstOrDefault().TemplateId, new ListRecipientsOptions { includeTabs = "true" });
                    foreach (var signer in recipients.Signers)
                    {
                        Signer templateSigner = templateRecipients.Signers.FirstOrDefault(w => w.RoleName.ToLower() == signer.RoleName.ToLower());
                        Tabs tabs =BuildRecipientTabs(signer.RecipientId, templateSigner.Tabs);
                        var t=  await envelopesApi.CreateTabsAsync(await AccountAsync(), envelopeId, signer.RecipientId, tabs);
                    }